Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
BdtBeamParticleIdTool.h
Go to the documentation of this file.
1
8#ifndef LAR_BDT_BEAM_PARTICLE_ID_TOOL_H
9#define LAR_BDT_BEAM_PARTICLE_ID_TOOL_H 1
10
12
14
16
17namespace lar_content
18{
19
24{
25public:
30
37
44
49
50 void SelectOutputPfos(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &beamSliceHypotheses,
51 const SliceHypotheses &crSliceHypotheses, pandora::PfoList &selectedPfos);
52
53private:
81
82 typedef std::vector<Plane> PlaneVector;
83
88 {
89 public:
94
105 void Initialize(const float larTPCMinX, const float larTPCMaxX, const float larTPCMinY, const float larTPCMaxY,
106 const float larTPCMinZ, const float larTPCMaxZ);
107
113 void SetBeamLArTPCIntersection(const pandora::CartesianVector &beamLArTPCIntersection);
114
120 void SetBeamDirection(const pandora::CartesianVector &beamDirection);
121
127 void SetSelectedFraction(const float selectedFraction);
128
134 void SetNSelectedHits(const unsigned int nSelectedHits);
135
141 void SetContainmentLimit(const float containmentLimit);
142
146 float GetLArTPCMinX() const;
147
151 float GetLArTPCMaxX() const;
152
156 float GetLArTPCMinY() const;
157
161 float GetLArTPCMaxY() const;
162
166 float GetLArTPCMinZ() const;
167
171 float GetLArTPCMaxZ() const;
172
176 const PlaneVector &GetPlanes() const;
177
182
187
191 float GetSelectedFraction() const;
192
196 unsigned int GetNSelectedHits() const;
197
201 float GetContainmentLimit() const;
202
203 private:
214 unsigned int m_nSelectedHits;
216 };
217
222 {
223 public:
231 SliceFeatures(const pandora::PfoList &nuPfos, const pandora::PfoList &crPfos, const SliceFeatureParameters &sliceFeatureParameters);
232
238 SliceFeatures(const SliceFeatures &) = default;
239
243 ~SliceFeatures() = default;
244
250 bool IsFeatureVectorAvailable() const;
251
257 void FillFeatureVector(LArMvaHelper::MvaFeatureVector &featureVector) const;
258
266 float GetAdaBoostDecisionTreeScore(const AdaBoostDecisionTree &adaBoostDecisionTree) const;
267
268 private:
277 const pandora::CaloHitList &inputCaloHitList, pandora::CaloHitList &outputCaloHitList, double &closestHitToFaceDistance) const;
278
288 pandora::CartesianVector &interceptOne, pandora::CartesianVector &interceptTwo) const;
289
295 bool IsContained(const pandora::CartesianVector &spacePoint, const float limit) const;
296
300 };
301
302 typedef std::vector<SliceFeatures> SliceFeaturesVector;
303 typedef std::pair<unsigned int, float> UintFloatPair;
304 typedef std::unordered_map<const pandora::MCParticle *, int> MCParticleToIntMap;
305
307
315 void GetSliceFeatures(
316 const SliceHypotheses &nuSliceHypotheses, const SliceHypotheses &crSliceHypotheses, SliceFeaturesVector &sliceFeaturesVector) const;
317
325 void SelectAllPfos(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &hypotheses, pandora::PfoList &selectedPfos) const;
326
333 void SelectPfos(const pandora::PfoList &pfos, pandora::PfoList &selectedPfos) const;
334
343 void GetBestMCSliceIndices(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &nuSliceHypotheses,
344 const SliceHypotheses &crSliceHypotheses, pandora::IntVector &bestSliceIndices) const;
345
352 void PopulateMCParticleToHitsMap(MCParticleToIntMap &mcParticleToIntMap, const pandora::CaloHitList &caloHitList) const;
353
361 void Collect2DHits(const pandora::PfoList &pfos, pandora::CaloHitList &caloHitList, const pandora::CaloHitSet &reconstructableCaloHitSet) const;
362
371 bool PassesQualityCuts(const float purity, const float completeness) const;
372
382 void SelectPfosByAdaBDTScore(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &nuSliceHypotheses,
383 const SliceHypotheses &crSliceHypotheses, const SliceFeaturesVector &sliceFeaturesVector, pandora::PfoList &selectedPfos) const;
384
386
387 // Training
390 std::string m_caloHitListName;
394
395 // Classification
398 unsigned int m_maxNeutrinos;
401};
402
403//------------------------------------------------------------------------------------------------------------------------------------------
404
406{
407 m_beamLArTPCIntersection = beamLArTPCIntersection;
408}
409
410//------------------------------------------------------------------------------------------------------------------------------------------
411
413{
414 m_beamDirection = beamDirection;
415}
416
417//------------------------------------------------------------------------------------------------------------------------------------------
418
420{
421 m_selectedFraction = selectedFraction;
422}
423
424//------------------------------------------------------------------------------------------------------------------------------------------
425
426inline void BdtBeamParticleIdTool::SliceFeatureParameters::SetNSelectedHits(const unsigned int nSelectedHits)
427{
428 m_nSelectedHits = nSelectedHits;
429}
430
431//------------------------------------------------------------------------------------------------------------------------------------------
432
434{
435 m_containmentLimit = containmentLimit;
436}
437
438//------------------------------------------------------------------------------------------------------------------------------------------
439
441{
442 return m_larTPCMinX;
443}
444
445//------------------------------------------------------------------------------------------------------------------------------------------
446
448{
449 return m_larTPCMaxX;
450}
451
452//------------------------------------------------------------------------------------------------------------------------------------------
453
455{
456 return m_larTPCMinY;
457}
458
459//------------------------------------------------------------------------------------------------------------------------------------------
460
462{
463 return m_larTPCMaxY;
464}
465
466//------------------------------------------------------------------------------------------------------------------------------------------
467
469{
470 return m_larTPCMinZ;
471}
472
473//------------------------------------------------------------------------------------------------------------------------------------------
474
476{
477 return m_larTPCMaxZ;
478}
479
480//------------------------------------------------------------------------------------------------------------------------------------------
481
486
487//------------------------------------------------------------------------------------------------------------------------------------------
488
490{
491 return m_beamLArTPCIntersection;
492}
493
494//------------------------------------------------------------------------------------------------------------------------------------------
495
497{
498 return m_beamDirection;
499}
500
501//------------------------------------------------------------------------------------------------------------------------------------------
502
504{
505 return m_selectedFraction;
506}
507
508//------------------------------------------------------------------------------------------------------------------------------------------
509
511{
512 return m_nSelectedHits;
513}
514
515//------------------------------------------------------------------------------------------------------------------------------------------
516
518{
519 return m_containmentLimit;
520}
521
522//------------------------------------------------------------------------------------------------------------------------------------------
523
525{
526 return m_isAvailable;
527}
528
529} // namespace lar_content
530
531#endif // #ifndef LAR_BDT_BEAM_PARTICLE_ID_TOOL_H
Header file for the lar adaptive boosted decision tree class.
Header file for the master algorithm class.
pandora::CartesianVector m_unitNormal
Unit normal to plane.
double m_d
Parameter defining a plane.
pandora::CartesianVector m_point
A point on the plane.
pandora::CartesianVector GetLineIntersection(const pandora::CartesianVector &point, const pandora::CartesianVector &direction) const
Return the intersection between the plane and a line.
void SetBeamDirection(const pandora::CartesianVector &beamDirection)
Set m_beamDirection.
float m_larTPCMinX
Global LArTPC volume minimum x extent.
float m_containmentLimit
Limit applied in is contained definition.
void SetBeamLArTPCIntersection(const pandora::CartesianVector &beamLArTPCIntersection)
Set m_beamLArTPCIntersection.
float m_larTPCMaxX
Global LArTPC volume maximum x extent.
const pandora::CartesianVector & GetBeamDirection() const
Get the beam direction.
unsigned int m_nSelectedHits
Minimum number of hits to use in 3D cluster fits.
pandora::CartesianVector m_beamLArTPCIntersection
Intersection of beam and global LArTPC volume.
const pandora::CartesianVector & GetBeamLArTPCIntersection() const
Get the beam LArTPC intersection.
float m_larTPCMaxY
Global LArTPC volume maximum y extent.
const PlaneVector & GetPlanes() const
Get vector of planes.
float m_larTPCMinZ
Global LArTPC volume minimum z extent.
void SetNSelectedHits(const unsigned int nSelectedHits)
Set m_nSelectedHits.
float m_larTPCMaxZ
Global LArTPC volume maximum z extent.
void SetContainmentLimit(const float containmentLimit)
Set m_containmentLimit.
PlaneVector m_larTPCPlanes
Vector of all planes making up global LArTPC volume.
float m_selectedFraction
Fraction of hits to use in 3D cluster fits.
void SetSelectedFraction(const float selectedFraction)
Set m_selectedFraction.
float m_larTPCMinY
Global LArTPC volume minimum y extent.
void GetLeadingCaloHits(const pandora::CaloHitList &inputCaloHitList, pandora::CaloHitList &outputCaloHitList, double &closestHitToFaceDistance) const
Select a given fraction of a slice's calo hits that are closest to the beam spot.
SliceFeatures(const SliceFeatures &)=default
Copy constructor.
const SliceFeatureParameters m_sliceFeatureParameters
Geometry information block.
bool m_isAvailable
Is the feature vector available.
bool IsFeatureVectorAvailable() const
Check if all features were calculable.
float GetAdaBoostDecisionTreeScore(const AdaBoostDecisionTree &adaBoostDecisionTree) const
Get the probability that this slice contains a beam particle.
bool IsContained(const pandora::CartesianVector &spacePoint, const float limit) const
Check if a given 3D spacepoint is inside the global LArTPC volume.
void FillFeatureVector(LArMvaHelper::MvaFeatureVector &featureVector) const
Get the feature vector for the SVM.
void GetLArTPCIntercepts(const pandora::CartesianVector &a0, const pandora::CartesianVector &majorAxis, pandora::CartesianVector &interceptOne, pandora::CartesianVector &interceptTwo) const
Find the intercepts of a line with the protoDUNE detector.
LArMvaHelper::MvaFeatureVector m_featureVector
The MVA feature vector.
bool m_useTrainingMode
Should use training mode. If true, training examples will be written to the output file.
void SelectPfos(const pandora::PfoList &pfos, pandora::PfoList &selectedPfos) const
Add the given pfos to the selected Pfo list.
AdaBoostDecisionTree m_adaBoostDecisionTree
The adaptive boost decision tree.
pandora::StatusCode Initialize()
Perform any operations that must occur after reading settings, but before running the process.
void Collect2DHits(const pandora::PfoList &pfos, pandora::CaloHitList &caloHitList, const pandora::CaloHitSet &reconstructableCaloHitSet) const
Collect all 2D hits in a supplied list of Pfos and push them on to an existing hit list,...
void SelectPfosByAdaBDTScore(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &nuSliceHypotheses, const SliceHypotheses &crSliceHypotheses, const SliceFeaturesVector &sliceFeaturesVector, pandora::PfoList &selectedPfos) const
Select pfos based on the AdaBDT score that the slice contains a beam particle interaction.
SliceFeatureParameters m_sliceFeatureParameters
Geometry information block.
void SelectAllPfos(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &hypotheses, pandora::PfoList &selectedPfos) const
Select all pfos under the same hypothesis.
float m_minPurity
Minimum purity of the best slice to use event for training.
std::string m_mcParticleListName
Name of input MC particle list.
void GetSliceFeatures(const SliceHypotheses &nuSliceHypotheses, const SliceHypotheses &crSliceHypotheses, SliceFeaturesVector &sliceFeaturesVector) const
Get the features of each slice.
BdtBeamParticleIdTool(const BdtBeamParticleIdTool &)=default
Copy constructor.
unsigned int m_maxNeutrinos
The maximum number of neutrinos to select in any one event.
std::string m_caloHitListName
Name of input calo hit list.
bool PassesQualityCuts(const float purity, const float completeness) const
Determine if the event passes the selection cuts for training.
~BdtBeamParticleIdTool()=default
Destructor.
std::unordered_map< const pandora::MCParticle *, int > MCParticleToIntMap
float m_minAdaBDTScore
Minimum score required to classify a slice as a beam particle.
void GetBestMCSliceIndices(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &nuSliceHypotheses, const SliceHypotheses &crSliceHypotheses, pandora::IntVector &bestSliceIndices) const
Get the slice with the most neutrino induced hits using Monte-Carlo information.
std::string m_trainingOutputFile
Output file name for training examples.
std::pair< unsigned int, float > UintFloatPair
void PopulateMCParticleToHitsMap(MCParticleToIntMap &mcParticleToIntMap, const pandora::CaloHitList &caloHitList) const
Fill mc particle to nHits map from calo hit list.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
std::string m_filePathEnvironmentVariable
The environment variable providing a list of paths to bdt files.
void SelectOutputPfos(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &beamSliceHypotheses, const SliceHypotheses &crSliceHypotheses, pandora::PfoList &selectedPfos)
Select which reconstruction hypotheses to use; neutrino outcomes or cosmic-ray muon outcomes for each...
std::vector< SliceFeatures > SliceFeaturesVector
float m_minCompleteness
Minimum completeness of the best slice to use event for training.
BdtBeamParticleIdTool & operator=(const BdtBeamParticleIdTool &)=default
Assignment operator.
MvaTypes::MvaFeatureVector MvaFeatureVector
SliceIdBaseTool class.
Algorithm class. Algorithm addresses are held only by the algorithm manager. They have a fully define...
Definition Algorithm.h:21
CartesianVector class.
std::vector< pandora::PfoList > SliceHypotheses
std::vector< int > IntVector
std::unordered_set< const CaloHit * > CaloHitSet
MANAGED_CONTAINER< const CaloHit * > CaloHitList
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList