All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NeutrinoHierarchyAlgorithm.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArThreeDReco/LArEventBuilding/NeutrinoHierarchyAlgorithm.h
3  *
4  * @brief Header file for the neutrino hierarchy algorithm class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_NEUTRINO_HIERARCHY_ALGORITHM_H
9 #define LAR_NEUTRINO_HIERARCHY_ALGORITHM_H 1
10 
11 #include "Pandora/Algorithm.h"
12 
14 
15 #include <unordered_map>
16 
17 namespace lar_content
18 {
19 
20 class PfoRelationTool;
21 
22 //------------------------------------------------------------------------------------------------------------------------------------------
23 
24 /**
25  * @brief NeutrinoHierarchyAlgorithm class
26  */
27 class NeutrinoHierarchyAlgorithm : public pandora::Algorithm
28 {
29 public:
30  /**
31  * @brief Default constructor
32  */
34 
35  /**
36  * @brief PfoInfo class
37  */
38  class PfoInfo
39  {
40  public:
41  /**
42  * @brief Constructor
43  *
44  * @param pPfo the address of the pfo
45  * @param halfWindowLayers the number of layers to use for half-window of sliding fit
46  * @param layerPitch the sliding fit z pitch, units cm
47  */
48  PfoInfo(const pandora::ParticleFlowObject *const pPfo, const unsigned int halfWindowLayers, const float layerPitch);
49 
50  /**
51  * @brief Copy constructor
52  *
53  * @param rhs the pfo info to copy
54  */
55  PfoInfo(const PfoInfo &rhs);
56 
57  /**
58  * @brief Assignment operator
59  *
60  * @param rhs the pfo info to assign
61  */
62  PfoInfo &operator=(const PfoInfo &rhs);
63 
64  /**
65  * @brief Destructor
66  */
67  ~PfoInfo();
68 
69  /**
70  * @brief Get the address of the pfo
71  *
72  * @return the address of the pfo
73  */
74  const pandora::ParticleFlowObject *GetThisPfo() const;
75 
76  /**
77  * @brief Get the address of the three dimensional cluster
78  *
79  * @return the address of the three dimensional cluster
80  */
81  const pandora::Cluster *GetCluster3D() const;
82 
83  /**
84  * @brief Get the address of the three dimensional sliding fit result
85  *
86  * @return the address of the three dimensional sliding fit result
87  */
89 
90  /**
91  * @brief Whether the pfo is associated with the neutrino vertex
92  *
93  * @return boolean
94  */
95  bool IsNeutrinoVertexAssociated() const;
96 
97  /**
98  * @brief If associated, whether association to parent (vtx or pfo) is at sliding fit inner layer
99  *
100  * @return boolean
101  */
102  bool IsInnerLayerAssociated() const;
103 
104  /**
105  * @brief Get the address of the parent pfo
106  *
107  * @return the address of the parent pfo
108  */
109  const pandora::ParticleFlowObject *GetParentPfo() const;
110 
111  /**
112  * @brief Get the daughter pfo list
113  *
114  * @return the daughter pfo list
115  */
116  const pandora::PfoList &GetDaughterPfoList() const;
117 
118  /**
119  * @brief Set the neutrino vertex association flag
120  *
121  * @param isNeutrinoVertexAssociated the neutrino vertex association flag
122  */
123  void SetNeutrinoVertexAssociation(const bool isNeutrinoVertexAssociated);
124 
125  /**
126  * @brief Set the inner layer association flag
127  *
128  * @param isInnerLayerAssociated the inner layer association flag
129  */
130  void SetInnerLayerAssociation(const bool isInnerLayerAssociated);
131 
132  /**
133  * @brief Set the parent pfo
134  *
135  * @param pParentPfo the address of the parent pfo
136  */
137  void SetParentPfo(const pandora::ParticleFlowObject *const pParentPfo);
138 
139  /**
140  * @brief Remove the parent pfo
141  */
142  void RemoveParentPfo();
143 
144  /**
145  * @brief Add a daughter pfo
146  *
147  * @param pDaughterPfo the address of the daughter pfo to add
148  */
149  void AddDaughterPfo(const pandora::ParticleFlowObject *const pDaughterPfo);
150 
151  /**
152  * @brief Remove a daughter pfo
153  *
154  * @param pDaughterPfo the address of the daughter pfo to remove
155  */
156  void RemoveDaughterPfo(const pandora::ParticleFlowObject *const pDaughterPfo);
157 
158  private:
159  const pandora::ParticleFlowObject *m_pThisPfo; ///< The address of the pfo
160  const pandora::Cluster *m_pCluster3D; ///< The address of the three dimensional cluster
161  const pandora::Vertex *m_pVertex3D; ///< The address of the three dimensional vertex
162  ThreeDSlidingFitResult *m_pSlidingFitResult3D; ///< The three dimensional sliding fit result
163 
164  bool m_isNeutrinoVertexAssociated; ///< Whether the pfo is associated with the neutrino vertex
165  bool m_isInnerLayerAssociated; ///< If associated, whether association to parent (vtx or pfo) is at sliding fit inner layer
166  const pandora::ParticleFlowObject *m_pParentPfo; ///< The address of the parent pfo
167  pandora::PfoList m_daughterPfoList; ///< The daughter pfo list
168  };
169 
170  typedef std::unordered_map<const pandora::ParticleFlowObject *, PfoInfo *> PfoInfoMap;
171 
172  /**
173  * @brief Query the pfo info map and separate/extract pfos currently either acting as parents or associated with the neutrino vertex
174  *
175  * @param pfoInfoMap the pfo info map
176  * @param assignedPfos to receive the sorted vector of assigned pfos
177  * @param unassignedPfos to receive the sorted vector of unassigned pfos
178  */
179  void SeparatePfos(const NeutrinoHierarchyAlgorithm::PfoInfoMap &pfoInfoMap, pandora::PfoVector &assignedPfos, pandora::PfoVector &unassignedPfos) const;
180 
181 private:
182  pandora::StatusCode Run();
183 
184  /**
185  * @brief Get the address of the input neutrino pfo - enforces only one pfo present in input list; can return NULL if no neutrino exists
186  *
187  * @param to receive the address of the input neutrino pfo
188  */
189  void GetNeutrinoPfo(const pandora::ParticleFlowObject *&pNeutrinoPfo) const;
190 
191  /**
192  * @brief Get the list of candidate daughter pfos
193  *
194  * @param candidateDaughterPfoList to receive the candidate daughter pfo list
195  */
196  void GetCandidateDaughterPfoList(pandora::PfoList &candidateDaughterPfoList) const;
197 
198  /**
199  * @brief Process a provided pfo list and populate an initial pfo info map
200  *
201  * @param pfoList the provided pfo list
202  * @param pfoInfoMap to receive the initial pfo info map
203  */
204  void GetInitialPfoInfoMap(const pandora::PfoList &pfoList, PfoInfoMap &pfoInfoMap) const;
205 
206  /**
207  * @brief Process the information in a pfo info map, creating pfo parent/daughter links
208  *
209  * @param pNeutrinoPfo the address of the (original) parent neutrino pfo
210  * @param candidateDaughterPfoList the list of candidate daughter pfos
211  * @param pfoInfoMap the pfo info map
212  * @param callDepth depth of callstack for this function, tracking recursive use
213  */
214  void ProcessPfoInfoMap(const pandora::ParticleFlowObject *const pNeutrinoPfo, const pandora::PfoList &candidateDaughterPfoList,
215  PfoInfoMap &pfoInfoMap, const unsigned int callDepth = 0) const;
216 
217  /**
218  * @brief Adjust neutrino vertex to ensure agreement with at least one pfo (first in sorted input list)
219  *
220  * @param pNeutrinoPfo the address of the (original) parent neutrino pfo
221  * @param candidateDaughterPfoList the list of candidate daughter pfos
222  * @param pfoInfoMap the pfo info map
223  */
224  void AdjustVertexAndPfoInfo(const pandora::ParticleFlowObject *const pNeutrinoPfo, const pandora::PfoList &candidateDaughterPfoList,
225  PfoInfoMap &pfoInfoMap) const;
226 
227  /**
228  * @brief Display the information in a pfo info map, visualising pfo parent/daughter links
229  *
230  * @param pNeutrinoPfo the address of the (original) parent neutrino pfo
231  * @param pfoInfoMap the pfo info map
232  */
233  void DisplayPfoInfoMap(const pandora::ParticleFlowObject *const pNeutrinoPfo, const PfoInfoMap &pfoInfoMap) const;
234 
235  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
236 
237  typedef std::vector<PfoRelationTool *> PfoRelationToolVector;
238  PfoRelationToolVector m_algorithmToolVector; ///< The algorithm tool vector
239 
240  std::string m_neutrinoPfoListName; ///< The neutrino pfo list name
241  pandora::StringVector m_daughterPfoListNames; ///< The list of daughter pfo list names
242 
243  std::string m_neutrinoVertexListName; ///< The neutrino vertex list name - if not specified will assume current list
244 
245  unsigned int m_halfWindowLayers; ///< The number of layers to use for half-window of sliding fit
246  bool m_displayPfoInfoMap; ///< Whether to display the pfo info map (if monitoring is enabled)
247 };
248 
249 //------------------------------------------------------------------------------------------------------------------------------------------
250 
251 /**
252  * @brief PfoRelationTool class
253  */
254 class PfoRelationTool : public pandora::AlgorithmTool
255 {
256 public:
257  /**
258  * @brief Run the algorithm tool
259  *
260  * @param pAlgorithm address of the calling algorithm
261  * @param pNeutrinoVertex the address of the three dimensional neutrino interaction vertex
262  * @param pfoInfoMap mapping from pfos to three dimensional clusters, sliding fits, vertices, etc.
263  */
264  virtual void Run(const NeutrinoHierarchyAlgorithm *const pAlgorithm, const pandora::Vertex *const pNeutrinoVertex,
266 };
267 
268 //------------------------------------------------------------------------------------------------------------------------------------------
269 
270 inline const pandora::ParticleFlowObject *NeutrinoHierarchyAlgorithm::PfoInfo::GetThisPfo() const
271 {
272  return m_pThisPfo;
273 }
274 
275 //------------------------------------------------------------------------------------------------------------------------------------------
276 
277 inline const pandora::Cluster *NeutrinoHierarchyAlgorithm::PfoInfo::GetCluster3D() const
278 {
279  return m_pCluster3D;
280 }
281 
282 //------------------------------------------------------------------------------------------------------------------------------------------
283 
285 {
286  return m_pSlidingFitResult3D;
287 }
288 
289 //------------------------------------------------------------------------------------------------------------------------------------------
290 
292 {
293  return m_isNeutrinoVertexAssociated;
294 }
295 
296 //------------------------------------------------------------------------------------------------------------------------------------------
297 
299 {
300  return m_isInnerLayerAssociated;
301 }
302 
303 //------------------------------------------------------------------------------------------------------------------------------------------
304 
305 inline const pandora::ParticleFlowObject *NeutrinoHierarchyAlgorithm::PfoInfo::GetParentPfo() const
306 {
307  return m_pParentPfo;
308 }
309 
310 //------------------------------------------------------------------------------------------------------------------------------------------
311 
312 inline const pandora::PfoList &NeutrinoHierarchyAlgorithm::PfoInfo::GetDaughterPfoList() const
313 {
314  return m_daughterPfoList;
315 }
316 
317 } // namespace lar_content
318 
319 #endif // #ifndef LAR_NEUTRINO_HIERARCHY_ALGORITHM_H
void SetInnerLayerAssociation(const bool isInnerLayerAssociated)
Set the inner layer association flag.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
const pandora::ParticleFlowObject * GetThisPfo() const
Get the address of the pfo.
const pandora::Cluster * m_pCluster3D
The address of the three dimensional cluster.
PfoInfo & operator=(const PfoInfo &rhs)
Assignment operator.
void ProcessPfoInfoMap(const pandora::ParticleFlowObject *const pNeutrinoPfo, const pandora::PfoList &candidateDaughterPfoList, PfoInfoMap &pfoInfoMap, const unsigned int callDepth=0) const
Process the information in a pfo info map, creating pfo parent/daughter links.
const ThreeDSlidingFitResult * GetSlidingFitResult3D() const
Get the address of the three dimensional sliding fit result.
bool m_isNeutrinoVertexAssociated
Whether the pfo is associated with the neutrino vertex.
const pandora::Cluster * GetCluster3D() const
Get the address of the three dimensional cluster.
PfoRelationToolVector m_algorithmToolVector
The algorithm tool vector.
const pandora::ParticleFlowObject * m_pThisPfo
The address of the pfo.
bool m_displayPfoInfoMap
Whether to display the pfo info map (if monitoring is enabled)
void DisplayPfoInfoMap(const pandora::ParticleFlowObject *const pNeutrinoPfo, const PfoInfoMap &pfoInfoMap) const
Display the information in a pfo info map, visualising pfo parent/daughter links. ...
void SeparatePfos(const NeutrinoHierarchyAlgorithm::PfoInfoMap &pfoInfoMap, pandora::PfoVector &assignedPfos, pandora::PfoVector &unassignedPfos) const
Query the pfo info map and separate/extract pfos currently either acting as parents or associated wit...
unsigned int m_halfWindowLayers
The number of layers to use for half-window of sliding fit.
std::string m_neutrinoVertexListName
The neutrino vertex list name - if not specified will assume current list.
bool m_isInnerLayerAssociated
If associated, whether association to parent (vtx or pfo) is at sliding fit inner layer...
bool IsInnerLayerAssociated() const
If associated, whether association to parent (vtx or pfo) is at sliding fit inner layer...
void RemoveDaughterPfo(const pandora::ParticleFlowObject *const pDaughterPfo)
Remove a daughter pfo.
void AdjustVertexAndPfoInfo(const pandora::ParticleFlowObject *const pNeutrinoPfo, const pandora::PfoList &candidateDaughterPfoList, PfoInfoMap &pfoInfoMap) const
Adjust neutrino vertex to ensure agreement with at least one pfo (first in sorted input list) ...
const pandora::ParticleFlowObject * GetParentPfo() const
Get the address of the parent pfo.
ThreeDSlidingFitResult * m_pSlidingFitResult3D
The three dimensional sliding fit result.
virtual void Run(const NeutrinoHierarchyAlgorithm *const pAlgorithm, const pandora::Vertex *const pNeutrinoVertex, NeutrinoHierarchyAlgorithm::PfoInfoMap &pfoInfoMap)=0
Run the algorithm tool.
pandora::PfoList m_daughterPfoList
The daughter pfo list.
const pandora::PfoList & GetDaughterPfoList() const
Get the daughter pfo list.
bool IsNeutrinoVertexAssociated() const
Whether the pfo is associated with the neutrino vertex.
void SetParentPfo(const pandora::ParticleFlowObject *const pParentPfo)
Set the parent pfo.
std::unordered_map< const pandora::ParticleFlowObject *, PfoInfo * > PfoInfoMap
void GetNeutrinoPfo(const pandora::ParticleFlowObject *&pNeutrinoPfo) const
Get the address of the input neutrino pfo - enforces only one pfo present in input list; can return N...
PfoInfo(const pandora::ParticleFlowObject *const pPfo, const unsigned int halfWindowLayers, const float layerPitch)
Constructor.
std::vector< PfoRelationTool * > PfoRelationToolVector
Header file for the lar three dimensional sliding fit result class.
std::string m_neutrinoPfoListName
The neutrino pfo list name.
const pandora::Vertex * m_pVertex3D
The address of the three dimensional vertex.
pandora::StringVector m_daughterPfoListNames
The list of daughter pfo list names.
void SetNeutrinoVertexAssociation(const bool isNeutrinoVertexAssociated)
Set the neutrino vertex association flag.
void AddDaughterPfo(const pandora::ParticleFlowObject *const pDaughterPfo)
Add a daughter pfo.
const pandora::ParticleFlowObject * m_pParentPfo
The address of the parent pfo.
void GetCandidateDaughterPfoList(pandora::PfoList &candidateDaughterPfoList) const
Get the list of candidate daughter pfos.
void GetInitialPfoInfoMap(const pandora::PfoList &pfoList, PfoInfoMap &pfoInfoMap) const
Process a provided pfo list and populate an initial pfo info map.