LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
NeutrinoIdTool.h
Go to the documentation of this file.
1 
8 #ifndef LAR_NEUTRINO_ID_TOOL_H
9 #define LAR_NEUTRINO_ID_TOOL_H 1
10 
13 
16 
17 #include <functional>
18 
19 namespace lar_content
20 {
21 
32 template <typename T>
34 {
35 public:
40 
41  void SelectOutputPfos(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &nuSliceHypotheses,
42  const SliceHypotheses &crSliceHypotheses, pandora::PfoList &selectedPfos);
43 
44 private:
49  {
50  public:
58  SliceFeatures(const pandora::PfoList &nuPfos, const pandora::PfoList &crPfos, const NeutrinoIdTool *const pTool);
59 
65  bool IsFeatureVectorAvailable() const;
66 
72  void GetFeatureVector(LArMvaHelper::MvaFeatureVector &featureVector) const;
73 
79  void GetFeatureMap(LArMvaHelper::DoubleMap &featureMap) const;
80 
88  float GetNeutrinoProbability(const T &t, const float defaultProbability) const;
89 
90  private:
96  const pandora::ParticleFlowObject *GetNeutrino(const pandora::PfoList &nuPfos) const;
97 
104  void GetSpacePoints(const pandora::ParticleFlowObject *const pPfo, pandora::CartesianPointVector &spacePoints) const;
105 
114  pandora::CartesianVector GetDirection(const pandora::CartesianPointVector &spacePoints,
115  std::function<bool(const pandora::CartesianVector &pointA, const pandora::CartesianVector &pointB)> fShouldChooseA) const;
116 
125  pandora::CartesianVector GetDirectionFromVertex(const pandora::CartesianPointVector &spacePoints, const pandora::CartesianVector &vertex) const;
126 
134  pandora::CartesianVector GetUpperDirection(const pandora::CartesianPointVector &spacePoints) const;
135 
143  pandora::CartesianVector GetLowerDirection(const pandora::CartesianPointVector &spacePoints) const;
144 
153  void GetPointsInSphere(const pandora::CartesianPointVector &spacePoints, const pandora::CartesianVector &vertex, const float radius,
154  pandora::CartesianPointVector &spacePointsInSphere) const;
155 
159  const NeutrinoIdTool *const m_pTool;
160  };
161 
162  typedef std::pair<unsigned int, float> UintFloatPair;
163  typedef std::vector<SliceFeatures> SliceFeaturesVector;
164 
173  void GetSliceFeatures(const NeutrinoIdTool *const pTool, const SliceHypotheses &nuSliceHypotheses,
174  const SliceHypotheses &crSliceHypotheses, SliceFeaturesVector &sliceFeaturesVector) const;
175 
186  bool GetBestMCSliceIndex(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &nuSliceHypotheses,
187  const SliceHypotheses &crSliceHypotheses, unsigned int &bestSliceIndex) const;
188 
198  bool PassesQualityCuts(const pandora::Algorithm *const pAlgorithm, const float purity, const float completeness) const;
199 
207  void Collect2DHits(const pandora::PfoList &pfos, pandora::CaloHitList &reconstructedCaloHitList,
208  const pandora::CaloHitSet &reconstructableCaloHitSet) const;
209 
217  unsigned int CountNeutrinoInducedHits(const pandora::CaloHitList &caloHitList) const;
218 
226  int GetNuanceCode(const pandora::Algorithm *const pAlgorithm) const;
227 
235  void SelectAllPfos(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &hypotheses, pandora::PfoList &selectedPfos) const;
236 
246  void SelectPfosByProbability(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &nuSliceHypotheses,
247  const SliceHypotheses &crSliceHypotheses, const SliceFeaturesVector &sliceFeaturesVector, pandora::PfoList &selectedPfos) const;
248 
255  void SelectPfos(const pandora::PfoList &pfos, pandora::PfoList &selectedPfos) const;
256 
257  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
258 
259  // Training
261  std::string m_trainingOutputFile;
263  int m_nuance;
264  float m_minPurity;
266 
267  // Classification
270  unsigned int m_maxNeutrinos;
271 
273 
274  T m_mva;
276 };
277 
280 
281 } // namespace lar_content
282 
283 #endif // #ifndef LAR_NEUTRINO_ID_TOOL_H
float m_defaultProbability
Default probability set if score could not be calculated.
bool PassesQualityCuts(const pandora::Algorithm *const pAlgorithm, const float purity, const float completeness) const
Determine if the event passes the selection cuts for training and has the required NUANCE code...
std::vector< pandora::PfoList > SliceHypotheses
MvaTypes::MvaFeatureVector MvaFeatureVector
Definition: LArMvaHelper.h:75
bool GetBestMCSliceIndex(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &nuSliceHypotheses, const SliceHypotheses &crSliceHypotheses, unsigned int &bestSliceIndex) const
Get the slice with the most neutrino induced hits using Monte-Carlo information.
SliceFeatures(const pandora::PfoList &nuPfos, const pandora::PfoList &crPfos, const NeutrinoIdTool *const pTool)
Constructor.
void GetFeatureMap(LArMvaHelper::DoubleMap &featureMap) const
Get the feature map for the MVA.
bool IsFeatureVectorAvailable() const
Check if all features were calculable.
NeutrinoIdTool()
Default constructor.
float m_minProbability
Minimum probability required to classify a slice as the neutrino.
int GetNuanceCode(const pandora::Algorithm *const pAlgorithm) const
Use the current MCParticle list to get the nuance code of the neutrino in the event.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
const NeutrinoIdTool *const m_pTool
The tool that owns this.
void SelectOutputPfos(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &nuSliceHypotheses, const SliceHypotheses &crSliceHypotheses, pandora::PfoList &selectedPfos)
Select which reconstruction hypotheses to use; neutrino outcomes or cosmic-ray muon outcomes for each...
void SelectAllPfos(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &hypotheses, pandora::PfoList &selectedPfos) const
Select all pfos under the same hypothesis.
LArMvaHelper::DoubleMap m_featureMap
A map between MVA features and their names.
float m_minCompleteness
Minimum completeness of the best slice to use event for training.
std::string m_filePathEnvironmentVariable
The environment variable providing a list of paths to mva files.
void Collect2DHits(const pandora::PfoList &pfos, pandora::CaloHitList &reconstructedCaloHitList, const pandora::CaloHitSet &reconstructableCaloHitSet) const
Collect all 2D hits in a supplied list of Pfos and push them on to an existing hit list...
bool m_selectNuanceCode
Should select training events by nuance code.
unsigned int m_maxNeutrinos
The maximum number of neutrinos to select in any one event.
unsigned int CountNeutrinoInducedHits(const pandora::CaloHitList &caloHitList) const
Count the number of neutrino induced hits in a given list using MC information.
std::pair< unsigned int, float > UintFloatPair
void GetFeatureVector(LArMvaHelper::MvaFeatureVector &featureVector) const
Get the feature vector for the MVA.
pandora::CartesianVector GetLowerDirection(const pandora::CartesianPointVector &spacePoints) const
Use a sliding fit to get the lower direction of a collection of spacepoints.
void GetSliceFeatures(const NeutrinoIdTool *const pTool, const SliceHypotheses &nuSliceHypotheses, const SliceHypotheses &crSliceHypotheses, SliceFeaturesVector &sliceFeaturesVector) const
Get the features of each slice.
Header file for the master algorithm class.
Header file for the lar adaptive boosted decision tree class.
std::map< std::string, double > DoubleMap
Definition: LArMvaHelper.h:76
int m_nuance
Nuance code to select for training.
bool m_isAvailable
Is the feature vector available.
Header file for the lar support vector machine class.
void SelectPfos(const pandora::PfoList &pfos, pandora::PfoList &selectedPfos) const
Add the given pfos to the selected Pfo list.
bool m_useTrainingMode
Should use training mode. If true, training examples will be written to the output file...
Float_t radius
Definition: plot.C:23
float m_minPurity
Minimum purity of the best slice to use event for training.
LArMvaHelper::MvaFeatureVector m_featureVector
The MVA feature vector.
const pandora::ParticleFlowObject * GetNeutrino(const pandora::PfoList &nuPfos) const
Get the recontructed neutrino the input list of neutrino Pfos.
float GetNeutrinoProbability(const T &t, const float defaultProbability) const
Get the probability that this slice contains a neutrino interaction.
void SelectPfosByProbability(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &nuSliceHypotheses, const SliceHypotheses &crSliceHypotheses, const SliceFeaturesVector &sliceFeaturesVector, pandora::PfoList &selectedPfos) const
Select pfos based on the probability that their slice contains a neutrino interaction.
std::vector< SliceFeatures > SliceFeaturesVector
bool m_persistFeatures
If true, the mva features will be persisted in the metadata.
NeutrinoIdTool class.
SliceIdBaseTool class.
pandora::CartesianVector GetDirectionFromVertex(const pandora::CartesianPointVector &spacePoints, const pandora::CartesianVector &vertex) const
Use a sliding fit to get the direction of a collection of spacepoint near a vertex position...
pandora::CartesianVector GetUpperDirection(const pandora::CartesianPointVector &spacePoints) const
Use a sliding fit to get the upper direction of a collection of spacepoints.
pandora::CartesianVector GetDirection(const pandora::CartesianPointVector &spacePoints, std::function< bool(const pandora::CartesianVector &pointA, const pandora::CartesianVector &pointB)> fShouldChooseA) const
Use a sliding fit to get the direction of a collection of spacepoints.
Header file for the stitching tool base class.
void GetPointsInSphere(const pandora::CartesianPointVector &spacePoints, const pandora::CartesianVector &vertex, const float radius, pandora::CartesianPointVector &spacePointsInSphere) const
Get a vector of spacepoints within a given radius of a vertex point.
void GetSpacePoints(const pandora::ParticleFlowObject *const pPfo, pandora::CartesianPointVector &spacePoints) const
Get the 3D space points in a given pfo.
std::string m_trainingOutputFile
Output file name for training examples.
NeutrinoIdTool< AdaBoostDecisionTree > BdtNeutrinoIdTool
NeutrinoIdTool< SupportVectorMachine > SvmNeutrinoIdTool
vertex reconstruction