EventValidationBaseAlgorithm.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArMonitoring/EventValidationBaseAlgorithm.h
3  *
4  * @brief Header file for the event validation algorithm.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_EVENT_VALIDATION_BASE_ALGORITHM_H
9 #define LAR_EVENT_VALIDATION_BASE_ALGORITHM_H 1
10 
11 #include "Pandora/Algorithm.h"
12 
14 
15 #ifdef MONITORING
16 #include "PandoraMonitoringApi.h"
17 #endif
18 
19 #include <map>
20 
21 namespace lar_content
22 {
23 
24 /**
25  * @brief EventValidationBaseAlgorithm class
26  */
27 class EventValidationBaseAlgorithm : public pandora::Algorithm
28 {
29 protected:
30  /**
31  * @brief Default constructor
32  */
34 
35  /**
36  * @brief Destructor
37  */
39 
40 protected:
41  /**
42  * @brief ValidationInfo class
43  */
45  {
46  public:
47  /**
48  * @brief Get the all mc particle to hits map
49  *
50  * @return the all mc particle to hits map
51  */
53 
54  /**
55  * @brief Get the target mc particle to hits map
56  *
57  * @return the target mc particle to hits map
58  */
60 
61  /**
62  * @brief Get the pfo to hits map
63  *
64  * @return the pfo to hits map
65  */
67 
68  /**
69  * @brief Get the mc to pfo hit sharing map
70  *
71  * @return the mc to pfo hit sharing map
72  */
74 
75  /**
76  * @brief Get the interpreted mc to pfo hit sharing map
77  *
78  * @return the interpreted mc to pfo hit sharing map
79  */
81 
82  /**
83  * @brief Set the all mc particle to hits map
84  *
85  * @param allMCParticleToHitsMap the all mc particle to hits map
86  */
87  void SetAllMCParticleToHitsMap(const LArMCParticleHelper::MCContributionMap &allMCParticleToHitsMap);
88 
89  /**
90  * @brief Set the target mc particle to hits map
91  *
92  * @param targetMCParticleToHitsMap the target mc particle to hits map
93  */
94  void SetTargetMCParticleToHitsMap(const LArMCParticleHelper::MCContributionMap &targetMCParticleToHitsMap);
95 
96  /**
97  * @brief Set the pfo to hits map
98  *
99  * @param pfoToHitsMap the pfo to hits map
100  */
102 
103  /**
104  * @brief Set the mc to pfo hit sharing map
105  *
106  * @param mcToPfoHitSharingMap the mc to pfo hit sharing map
107  */
109 
110  /**
111  * @brief Set the interpreted mc to pfo hit sharing map
112  *
113  * @param interpretedMCToPfoHitSharingMap the interpreted mc to pfo hit sharing map
114  */
116 
117  private:
123  };
124 
125  /**
126  * @brief Fill the validation info containers
127  *
128  * @param pMCParticleList the address of the mc particle list
129  * @param pCaloHitList the address of the calo hit list
130  * @param pPfoList the address of the pfo list
131  * @param validationInfo to receive the validation info
132  */
133  virtual void FillValidationInfo(const pandora::MCParticleList *const pMCParticleList, const pandora::CaloHitList *const pCaloHitList,
134  const pandora::PfoList *const pPfoList, ValidationInfo &validationInfo) const = 0;
135 
136  /**
137  * @brief Print matching information in a provided validation info object, and write information to tree if configured to do so
138  *
139  * @param validationInfo the validation info
140  * @param useInterpretedMatching whether to use the interpreted (rather than raw) matching information
141  * @param printToScreen whether to print the information to screen
142  * @param fillTree whether to write the information to tree
143  */
144  virtual void ProcessOutput(
145  const ValidationInfo &validationInfo, const bool useInterpretedMatching, const bool printToScreen, const bool fillTree) const = 0;
146 
147  /**
148  * @brief Apply an interpretative matching procedure to the comprehensive matches in the provided validation info object
149  *
150  * @param validationInfo the validation info
151  * @param interpretedMCToPfoHitSharingMap the output, interpreted mc particle to pfo hit sharing map
152  */
153  void InterpretMatching(const ValidationInfo &validationInfo, LArMCParticleHelper::MCParticleToPfoHitSharingMap &interpretedMCToPfoHitSharingMap) const;
154 
155  /**
156  * @brief Get the strongest pfo match (most matched hits) between an available mc primary and an available pfo
157  *
158  * @param validationInfo the validation info
159  * @param mcPrimaryVector the mc primary vector
160  * @param usedPfos the set of previously used pfos
161  * @param interpretedMCToPfoHitSharingMap the output, interpreted mc particle to pfo hit sharing map
162  *
163  * @return whether a strong match was identified
164  */
165  bool GetStrongestPfoMatch(const ValidationInfo &validationInfo, const pandora::MCParticleVector &mcPrimaryVector,
166  pandora::PfoSet &usedPfos, LArMCParticleHelper::MCParticleToPfoHitSharingMap &interpretedMCToPfoHitSharingMap) const;
167 
168  /**
169  * @brief Get the best matches for any pfos left-over after the strong matching procedure
170  *
171  * @param validationInfo the validation info
172  * @param mcPrimaryVector the mc primary vector
173  * @param usedPfos the set of previously used pfos
174  * @param interpretedMCToPfoHitSharingMap the output, interpreted mc particle to pfo hit sharing map
175  */
176  void GetRemainingPfoMatches(const ValidationInfo &validationInfo, const pandora::MCParticleVector &mcPrimaryVector,
177  const pandora::PfoSet &usedPfos, LArMCParticleHelper::MCParticleToPfoHitSharingMap &interpretedMCToPfoHitSharingMap) const;
178 
179  /**
180  * @brief Whether a provided mc primary and pfo are deemed to be a good match
181  *
182  * @param trueHits the list of true hits
183  * @param recoHits the list of reco hits
184  * @param sharedHits the list of shared hits
185  *
186  * @return boolean
187  */
188  bool IsGoodMatch(const pandora::CaloHitList &trueHits, const pandora::CaloHitList &recoHits, const pandora::CaloHitList &sharedHits) const;
189 
190  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
191 
192  LArMCParticleHelper::PrimaryParameters m_primaryParameters; ///< The mc particle primary selection parameters
193  int m_fileIdentifier; ///< The input file identifier
194  int m_eventNumber; ///< The event number
195 
196  std::string m_treeName; ///< Name of output tree
197 
198 private:
199  pandora::StatusCode Run();
200 
201  /**
202  * @brief Print all/raw matching information to screen
203  *
204  * @param validationInfo the validation info
205  */
206  void PrintAllMatches(const ValidationInfo &validationInfo) const;
207 
208  /**
209  * @brief Print interpreted matching information to screen
210  *
211  * @param validationInfo the validation info
212  */
213  void PrintInterpretedMatches(const ValidationInfo &validationInfo) const;
214 
215  /**
216  * @brief Write interpreted matching information to tree
217  *
218  * @param validationInfo the validation info
219  */
220  void WriteInterpretedMatches(const ValidationInfo &validationInfo) const;
221 
222  std::string m_caloHitListName; ///< Name of input calo hit list
223  std::string m_mcParticleListName; ///< Name of input MC particle list
224  std::string m_pfoListName; ///< Name of input Pfo list
225 
226  bool m_printAllToScreen; ///< Whether to print all/raw matching details to screen
227  bool m_printMatchingToScreen; ///< Whether to print matching output to screen
228  bool m_writeToTree; ///< Whether to write all/raw matching details to tree
229 
230  bool m_useSmallPrimaries; ///< Whether to consider matches to mc primaries with fewer than m_matchingMinPrimaryHits
231  unsigned int m_matchingMinSharedHits; ///< The minimum number of shared hits used in matching scheme
232  float m_matchingMinCompleteness; ///< The minimum particle completeness to declare a match
233  float m_matchingMinPurity; ///< The minimum particle purity to declare a match
234 
235  std::string m_fileName; ///< Name of output file
236 };
237 
238 //------------------------------------------------------------------------------------------------------------------------------------------
239 //------------------------------------------------------------------------------------------------------------------------------------------
240 
242 {
244 }
245 
246 //------------------------------------------------------------------------------------------------------------------------------------------
247 
249 {
251 }
252 
253 //------------------------------------------------------------------------------------------------------------------------------------------
254 
256 {
257  return m_pfoToHitsMap;
258 }
259 
260 //------------------------------------------------------------------------------------------------------------------------------------------
261 
263 {
264  return m_mcToPfoHitSharingMap;
265 }
266 
267 //------------------------------------------------------------------------------------------------------------------------------------------
268 
270 {
272 }
273 
274 //------------------------------------------------------------------------------------------------------------------------------------------
275 
277 {
278  m_allMCParticleToHitsMap = allMCParticleToHitsMap;
279 }
280 
281 //------------------------------------------------------------------------------------------------------------------------------------------
282 
284 {
285  m_targetMCParticleToHitsMap = targetMCParticleToHitsMap;
286 }
287 
288 //------------------------------------------------------------------------------------------------------------------------------------------
289 
291 {
292  m_pfoToHitsMap = pfoToHitsMap;
293 }
294 
295 //------------------------------------------------------------------------------------------------------------------------------------------
296 
298 {
299  m_mcToPfoHitSharingMap = mcToPfoHitSharingMap;
300 }
301 
302 //------------------------------------------------------------------------------------------------------------------------------------------
303 
305  const LArMCParticleHelper::MCParticleToPfoHitSharingMap &interpretedMCToPfoHitSharingMap)
306 {
307  m_interpretedMCToPfoHitSharingMap = interpretedMCToPfoHitSharingMap;
308 }
309 
310 //------------------------------------------------------------------------------------------------------------------------------------------
311 //------------------------------------------------------------------------------------------------------------------------------------------
312 
313 inline void EventValidationBaseAlgorithm::PrintAllMatches(const ValidationInfo &validationInfo) const
314 {
315  return this->ProcessOutput(validationInfo, false, true, false);
316 }
317 
318 //------------------------------------------------------------------------------------------------------------------------------------------
319 
321 {
322  return this->ProcessOutput(validationInfo, true, true, false);
323 }
324 
325 //------------------------------------------------------------------------------------------------------------------------------------------
326 
328 {
329  return this->ProcessOutput(validationInfo, true, false, true);
330 }
331 
332 } // namespace lar_content
333 
334 #endif // LAR_EVENT_VALIDATION_BASE_ALGORITHM_H
const LArMCParticleHelper::PfoContributionMap & GetPfoToHitsMap() const
Get the pfo to hits map.
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCContributionMap
const LArMCParticleHelper::MCContributionMap & GetTargetMCParticleToHitsMap() const
Get the target mc particle to hits map.
std::string string
Definition: nybbler.cc:12
void InterpretMatching(const ValidationInfo &validationInfo, LArMCParticleHelper::MCParticleToPfoHitSharingMap &interpretedMCToPfoHitSharingMap) const
Apply an interpretative matching procedure to the comprehensive matches in the provided validation in...
void PrintAllMatches(const ValidationInfo &validationInfo) const
Print all/raw matching information to screen.
LArMCParticleHelper::MCParticleToPfoHitSharingMap m_mcToPfoHitSharingMap
The mc to pfo hit sharing map.
LArMCParticleHelper::PfoContributionMap m_pfoToHitsMap
The pfo to hits map.
const LArMCParticleHelper::MCContributionMap & GetAllMCParticleToHitsMap() const
Get the all mc particle to hits map.
float m_matchingMinPurity
The minimum particle purity to declare a match.
std::map< const pandora::MCParticle *, PfoToSharedHitsVector > MCParticleToPfoHitSharingMap
const LArMCParticleHelper::MCParticleToPfoHitSharingMap & GetMCToPfoHitSharingMap() const
Get the mc to pfo hit sharing map.
void SetInterpretedMCToPfoHitSharingMap(const LArMCParticleHelper::MCParticleToPfoHitSharingMap &interpretedMCToPfoHitSharingMap)
Set the interpreted mc to pfo hit sharing map.
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
void SetMCToPfoHitSharingMap(const LArMCParticleHelper::MCParticleToPfoHitSharingMap &mcToPfoHitSharingMap)
Set the mc to pfo hit sharing map.
bool m_printAllToScreen
Whether to print all/raw matching details to screen.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
void WriteInterpretedMatches(const ValidationInfo &validationInfo) const
Write interpreted matching information to tree.
std::string m_pfoListName
Name of input Pfo list.
void PrintInterpretedMatches(const ValidationInfo &validationInfo) const
Print interpreted matching information to screen.
void SetTargetMCParticleToHitsMap(const LArMCParticleHelper::MCContributionMap &targetMCParticleToHitsMap)
Set the target mc particle to hits map.
LArMCParticleHelper::MCContributionMap m_allMCParticleToHitsMap
The all mc particle to hits map.
Header file for the lar monte carlo particle helper helper class.
LArMCParticleHelper::PrimaryParameters m_primaryParameters
The mc particle primary selection parameters.
const LArMCParticleHelper::MCParticleToPfoHitSharingMap & GetInterpretedMCToPfoHitSharingMap() const
Get the interpreted mc to pfo hit sharing map.
std::string m_mcParticleListName
Name of input MC particle list.
bool m_writeToTree
Whether to write all/raw matching details to tree.
unsigned int m_matchingMinSharedHits
The minimum number of shared hits used in matching scheme.
LArMCParticleHelper::MCContributionMap m_targetMCParticleToHitsMap
The target mc particle to hits map.
virtual void ProcessOutput(const ValidationInfo &validationInfo, const bool useInterpretedMatching, const bool printToScreen, const bool fillTree) const =0
Print matching information in a provided validation info object, and write information to tree if con...
bool GetStrongestPfoMatch(const ValidationInfo &validationInfo, const pandora::MCParticleVector &mcPrimaryVector, pandora::PfoSet &usedPfos, LArMCParticleHelper::MCParticleToPfoHitSharingMap &interpretedMCToPfoHitSharingMap) const
Get the strongest pfo match (most matched hits) between an available mc primary and an available pfo...
bool m_useSmallPrimaries
Whether to consider matches to mc primaries with fewer than m_matchingMinPrimaryHits.
void SetAllMCParticleToHitsMap(const LArMCParticleHelper::MCContributionMap &allMCParticleToHitsMap)
Set the all mc particle to hits map.
void GetRemainingPfoMatches(const ValidationInfo &validationInfo, const pandora::MCParticleVector &mcPrimaryVector, const pandora::PfoSet &usedPfos, LArMCParticleHelper::MCParticleToPfoHitSharingMap &interpretedMCToPfoHitSharingMap) const
Get the best matches for any pfos left-over after the strong matching procedure.
bool m_printMatchingToScreen
Whether to print matching output to screen.
void SetPfoToHitsMap(const LArMCParticleHelper::PfoContributionMap &pfoToHitsMap)
Set the pfo to hits map.
LArMCParticleHelper::MCParticleToPfoHitSharingMap m_interpretedMCToPfoHitSharingMap
The interpreted mc to pfo hit sharing map.
float m_matchingMinCompleteness
The minimum particle completeness to declare a match.
bool IsGoodMatch(const pandora::CaloHitList &trueHits, const pandora::CaloHitList &recoHits, const pandora::CaloHitList &sharedHits) const
Whether a provided mc primary and pfo are deemed to be a good match.
std::unordered_map< const pandora::ParticleFlowObject *, pandora::CaloHitList > PfoContributionMap
virtual void FillValidationInfo(const pandora::MCParticleList *const pMCParticleList, const pandora::CaloHitList *const pCaloHitList, const pandora::PfoList *const pPfoList, ValidationInfo &validationInfo) const =0
Fill the validation info containers.
std::string m_caloHitListName
Name of input calo hit list.