LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
EventValidationBaseAlgorithm.h
Go to the documentation of this file.
1 
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 
27 class EventValidationBaseAlgorithm : public pandora::Algorithm
28 {
29 protected:
34 
39 
40 protected:
45  {
46  public:
53 
60 
67 
74 
81 
87  void SetAllMCParticleToHitsMap(const LArMCParticleHelper::MCContributionMap &allMCParticleToHitsMap);
88 
94  void SetTargetMCParticleToHitsMap(const LArMCParticleHelper::MCContributionMap &targetMCParticleToHitsMap);
95 
102 
109 
116 
117  private:
123  };
124 
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 
144  virtual void ProcessOutput(
145  const ValidationInfo &validationInfo, const bool useInterpretedMatching, const bool printToScreen, const bool fillTree) const = 0;
146 
153  void InterpretMatching(const ValidationInfo &validationInfo, LArMCParticleHelper::MCParticleToPfoHitSharingMap &interpretedMCToPfoHitSharingMap) const;
154 
165  bool GetStrongestPfoMatch(const ValidationInfo &validationInfo, const pandora::MCParticleVector &mcPrimaryVector,
166  pandora::PfoSet &usedPfos, LArMCParticleHelper::MCParticleToPfoHitSharingMap &interpretedMCToPfoHitSharingMap) const;
167 
176  void GetRemainingPfoMatches(const ValidationInfo &validationInfo, const pandora::MCParticleVector &mcPrimaryVector,
177  const pandora::PfoSet &usedPfos, LArMCParticleHelper::MCParticleToPfoHitSharingMap &interpretedMCToPfoHitSharingMap) const;
178 
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 
195 
196  std::string m_treeName;
197 
198 private:
199  pandora::StatusCode Run();
200 
206  void PrintAllMatches(const ValidationInfo &validationInfo) const;
207 
213  void PrintInterpretedMatches(const ValidationInfo &validationInfo) const;
214 
220  void WriteInterpretedMatches(const ValidationInfo &validationInfo) const;
221 
222  std::string m_caloHitListName;
223  std::string m_mcParticleListName;
224  std::string m_pfoListName;
225 
229 
231  unsigned int m_matchingMinSharedHits;
234 
235  std::string m_fileName;
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.
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.
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.
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
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.