Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
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
12
15
16#include <functional>
17
18namespace lar_content
19{
20
31template <typename T>
33{
34public:
39
40 void SelectOutputPfos(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &nuSliceHypotheses,
41 const SliceHypotheses &crSliceHypotheses, pandora::PfoList &selectedPfos);
42
43private:
48 {
49 public:
57 SliceFeatures(const pandora::PfoList &nuPfos, const pandora::PfoList &crPfos, const NeutrinoIdTool *const pTool);
58
64 bool IsFeatureVectorAvailable() const;
65
71 void GetFeatureVector(LArMvaHelper::MvaFeatureVector &featureVector) const;
72
78 void GetFeatureMap(LArMvaHelper::DoubleMap &featureMap) const;
79
87 float GetNeutrinoProbability(const T &t, const float defaultProbability) const;
88
89 private:
96
103 void GetSpacePoints(const pandora::ParticleFlowObject *const pPfo, pandora::CartesianPointVector &spacePoints) const;
104
114 std::function<bool(const pandora::CartesianVector &pointA, const pandora::CartesianVector &pointB)> fShouldChooseA) const;
115
125
134
143
152 void GetPointsInSphere(const pandora::CartesianPointVector &spacePoints, const pandora::CartesianVector &vertex, const float radius,
153 pandora::CartesianPointVector &spacePointsInSphere) const;
154
158 const NeutrinoIdTool *const m_pTool;
159 };
160
161 typedef std::pair<unsigned int, float> UintFloatPair;
162 typedef std::vector<SliceFeatures> SliceFeaturesVector;
163
172 void GetSliceFeatures(const NeutrinoIdTool *const pTool, const SliceHypotheses &nuSliceHypotheses,
173 const SliceHypotheses &crSliceHypotheses, SliceFeaturesVector &sliceFeaturesVector) const;
174
185 bool GetBestMCSliceIndex(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &nuSliceHypotheses,
186 const SliceHypotheses &crSliceHypotheses, unsigned int &bestSliceIndex) const;
187
197 bool PassesQualityCuts(const pandora::Algorithm *const pAlgorithm, const float purity, const float completeness) const;
198
206 void Collect2DHits(const pandora::PfoList &pfos, pandora::CaloHitList &reconstructedCaloHitList,
207 const pandora::CaloHitSet &reconstructableCaloHitSet) const;
208
216 unsigned int CountNeutrinoInducedHits(const pandora::CaloHitList &caloHitList) const;
217
225 int GetNuanceCode(const pandora::Algorithm *const pAlgorithm) const;
226
234 void SelectAllPfos(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &hypotheses, pandora::PfoList &selectedPfos) const;
235
245 void SelectPfosByProbability(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &nuSliceHypotheses,
246 const SliceHypotheses &crSliceHypotheses, const SliceFeaturesVector &sliceFeaturesVector, pandora::PfoList &selectedPfos) const;
247
254 void SelectPfos(const pandora::PfoList &pfos, pandora::PfoList &selectedPfos) const;
255
257
258 // Training
265
266 // Classification
269 unsigned int m_maxNeutrinos;
270
272
275};
276
279
280} // namespace lar_content
281
282#endif // #ifndef LAR_NEUTRINO_ID_TOOL_H
Header file for the lar adaptive boosted decision tree class.
Header file for the lar support vector machine class.
Header file for the master algorithm class.
MvaTypes::MvaFeatureVector MvaFeatureVector
std::map< std::string, double > DoubleMap
LArMvaHelper::DoubleMap m_featureMap
A map between MVA features and their names.
void GetSpacePoints(const pandora::ParticleFlowObject *const pPfo, pandora::CartesianPointVector &spacePoints) const
Get the 3D space points in a given pfo.
bool IsFeatureVectorAvailable() const
Check if all features were calculable.
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.
float GetNeutrinoProbability(const T &t, const float defaultProbability) const
Get the probability that this slice contains a neutrino interaction.
void GetFeatureMap(LArMvaHelper::DoubleMap &featureMap) const
Get the feature map for the MVA.
const pandora::ParticleFlowObject * GetNeutrino(const pandora::PfoList &nuPfos) const
Get the recontructed neutrino the input list of neutrino Pfos.
pandora::CartesianVector GetUpperDirection(const pandora::CartesianPointVector &spacePoints) const
Use a sliding fit to get the upper direction of a collection of spacepoints.
LArMvaHelper::MvaFeatureVector m_featureVector
The MVA feature vector.
const NeutrinoIdTool *const m_pTool
The tool that owns this.
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 GetFeatureVector(LArMvaHelper::MvaFeatureVector &featureVector) const
Get the feature vector for the MVA.
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.
bool m_isAvailable
Is the feature vector available.
pandora::CartesianVector GetLowerDirection(const pandora::CartesianPointVector &spacePoints) const
Use a sliding fit to get the lower direction of a collection of spacepoints.
NeutrinoIdTool class.
void SelectAllPfos(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &hypotheses, pandora::PfoList &selectedPfos) const
Select all pfos under the same hypothesis.
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.
std::pair< unsigned int, float > UintFloatPair
bool m_useTrainingMode
Should use training mode. If true, training examples will be written to the output file.
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.
bool m_selectNuanceCode
Should select training events by nuance code.
float m_minPurity
Minimum purity of the best slice to use event for training.
NeutrinoIdTool()
Default constructor.
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,...
void GetSliceFeatures(const NeutrinoIdTool *const pTool, const SliceHypotheses &nuSliceHypotheses, const SliceHypotheses &crSliceHypotheses, SliceFeaturesVector &sliceFeaturesVector) const
Get the features of each slice.
std::string m_filePathEnvironmentVariable
The environment variable providing a list of paths to mva files.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
float m_minProbability
Minimum probability required to classify a slice as the neutrino.
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.
bool m_persistFeatures
If true, the mva features will be persisted in the metadata.
void SelectPfos(const pandora::PfoList &pfos, pandora::PfoList &selectedPfos) const
Add the given pfos to the selected Pfo list.
int m_nuance
Nuance code to select for training.
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...
unsigned int m_maxNeutrinos
The maximum number of neutrinos to select in any one event.
float m_minCompleteness
Minimum completeness of the best slice to use event for training.
std::vector< SliceFeatures > SliceFeaturesVector
float m_defaultProbability
Default probability set if score could not be calculated.
unsigned int CountNeutrinoInducedHits(const pandora::CaloHitList &caloHitList) const
Count the number of neutrino induced hits in a given list using MC information.
int GetNuanceCode(const pandora::Algorithm *const pAlgorithm) const
Use the current MCParticle list to get the nuance code of the neutrino in the event.
std::string m_trainingOutputFile
Output file name for training examples.
SliceIdBaseTool class.
Algorithm class. Algorithm addresses are held only by the algorithm manager. They have a fully define...
Definition Algorithm.h:21
CartesianVector class.
ParticleFlowObject class.
std::vector< pandora::PfoList > SliceHypotheses
NeutrinoIdTool< SupportVectorMachine > SvmNeutrinoIdTool
NeutrinoIdTool< AdaBoostDecisionTree > BdtNeutrinoIdTool
std::vector< CartesianVector > CartesianPointVector
std::unordered_set< const CaloHit * > CaloHitSet
MANAGED_CONTAINER< const CaloHit * > CaloHitList
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList