LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::TestBeamEventValidationAlgorithm Class Reference

TestBeamEventValidationAlgorithm class. More...

#include "TestBeamEventValidationAlgorithm.h"

Inheritance diagram for lar_content::TestBeamEventValidationAlgorithm:
lar_content::EventValidationBaseAlgorithm

Public Member Functions

 TestBeamEventValidationAlgorithm ()
 Default constructor. More...
 
 ~TestBeamEventValidationAlgorithm ()
 Destructor. More...
 

Protected Member Functions

void InterpretMatching (const ValidationInfo &validationInfo, LArMCParticleHelper::MCParticleToPfoHitSharingMap &interpretedMCToPfoHitSharingMap) const
 Apply an interpretative matching procedure to the comprehensive matches in the provided validation info object. More...
 
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. More...
 
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. More...
 
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. More...
 

Protected Attributes

LArMCParticleHelper::PrimaryParameters m_primaryParameters
 The mc particle primary selection parameters. More...
 
int m_fileIdentifier
 The input file identifier. More...
 
int m_eventNumber
 The event number. More...
 
std::string m_treeName
 Name of output tree. More...
 

Private Types

typedef std::unordered_map< const pandora::ParticleFlowObject *, unsigned int > PfoToIdMap
 
typedef std::vector< pandora::HitType > HitTypeVector
 

Private Member Functions

void FillValidationInfo (const pandora::MCParticleList *const pMCParticleList, const pandora::CaloHitList *const pCaloHitList, const pandora::PfoList *const pPfoList, ValidationInfo &validationInfo) const
 Fill the validation info containers. More...
 
void ProcessOutput (const ValidationInfo &validationInfo, const bool useInterpretedMatching, const bool printToScreen, const bool fillTree) const
 Print matching information in a provided validation info object, and write information to tree if configured to do so. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Detailed Description

Member Typedef Documentation

typedef std::vector<pandora::HitType> lar_content::TestBeamEventValidationAlgorithm::HitTypeVector
private

Definition at line 68 of file TestBeamEventValidationAlgorithm.h.

typedef std::unordered_map<const pandora::ParticleFlowObject *, unsigned int> lar_content::TestBeamEventValidationAlgorithm::PfoToIdMap
private

Definition at line 54 of file TestBeamEventValidationAlgorithm.h.

Constructor & Destructor Documentation

lar_content::TestBeamEventValidationAlgorithm::TestBeamEventValidationAlgorithm ( )

Default constructor.

Definition at line 24 of file TestBeamEventValidationAlgorithm.cc.

25 {
26 }
lar_content::TestBeamEventValidationAlgorithm::~TestBeamEventValidationAlgorithm ( )

Destructor.

Definition at line 30 of file TestBeamEventValidationAlgorithm.cc.

31 {
32 }

Member Function Documentation

void lar_content::TestBeamEventValidationAlgorithm::FillValidationInfo ( const pandora::MCParticleList *const  pMCParticleList,
const pandora::CaloHitList *const  pCaloHitList,
const pandora::PfoList *const  pPfoList,
ValidationInfo validationInfo 
) const
privatevirtual

Fill the validation info containers.

Parameters
pMCParticleListthe address of the mc particle list
pCaloHitListthe address of the calo hit list
pPfoListthe address of the pfo list
validationInfoto receive the validation info

Implements lar_content::EventValidationBaseAlgorithm.

Definition at line 36 of file TestBeamEventValidationAlgorithm.cc.

References lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetAllMCParticleToHitsMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetPfoToHitsMap(), lar_content::LArMCParticleHelper::PrimaryParameters::m_minHitsForGoodView, lar_content::LArMCParticleHelper::PrimaryParameters::m_minHitSharingFraction, lar_content::LArMCParticleHelper::PrimaryParameters::m_minPrimaryGoodHits, lar_content::EventValidationBaseAlgorithm::ValidationInfo::SetAllMCParticleToHitsMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::SetInterpretedMCToPfoHitSharingMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::SetMCToPfoHitSharingMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::SetPfoToHitsMap(), and lar_content::EventValidationBaseAlgorithm::ValidationInfo::SetTargetMCParticleToHitsMap().

38 {
39  if (pMCParticleList && pCaloHitList)
40  {
41  LArMCParticleHelper::MCContributionMap targetMCParticleToHitsMap;
43  pMCParticleList, pCaloHitList, m_primaryParameters, LArMCParticleHelper::IsBeamParticle, targetMCParticleToHitsMap);
45  pMCParticleList, pCaloHitList, m_primaryParameters, LArMCParticleHelper::IsCosmicRay, targetMCParticleToHitsMap);
46 
47  LArMCParticleHelper::PrimaryParameters parameters(m_primaryParameters);
48  parameters.m_minPrimaryGoodHits = 0;
49  parameters.m_minHitsForGoodView = 0;
50  parameters.m_minHitSharingFraction = 0.f;
51  LArMCParticleHelper::MCContributionMap allMCParticleToHitsMap;
53  pMCParticleList, pCaloHitList, parameters, LArMCParticleHelper::IsBeamParticle, allMCParticleToHitsMap);
55  pMCParticleList, pCaloHitList, parameters, LArMCParticleHelper::IsCosmicRay, allMCParticleToHitsMap);
56 
57  validationInfo.SetTargetMCParticleToHitsMap(targetMCParticleToHitsMap);
58  validationInfo.SetAllMCParticleToHitsMap(allMCParticleToHitsMap);
59  }
60 
61  if (pPfoList)
62  {
63  PfoList allConnectedPfos;
64  LArPfoHelper::GetAllConnectedPfos(*pPfoList, allConnectedPfos);
65 
66  PfoList finalStatePfos;
67  for (const ParticleFlowObject *const pPfo : allConnectedPfos)
68  {
69  if (pPfo->GetParentPfoList().empty())
70  finalStatePfos.push_back(pPfo);
71  }
72 
75  finalStatePfos, validationInfo.GetAllMCParticleToHitsMap(), pfoToHitsMap, m_primaryParameters.m_foldBackHierarchy);
76 
77  validationInfo.SetPfoToHitsMap(pfoToHitsMap);
78  }
79 
83  validationInfo.GetPfoToHitsMap(), {validationInfo.GetAllMCParticleToHitsMap()}, pfoToMCHitSharingMap, mcToPfoHitSharingMap);
84  validationInfo.SetMCToPfoHitSharingMap(mcToPfoHitSharingMap);
85 
86  LArMCParticleHelper::MCParticleToPfoHitSharingMap interpretedMCToPfoHitSharingMap;
87  this->InterpretMatching(validationInfo, interpretedMCToPfoHitSharingMap);
88  validationInfo.SetInterpretedMCToPfoHitSharingMap(interpretedMCToPfoHitSharingMap);
89 }
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCContributionMap
void InterpretMatching(const ValidationInfo &validationInfo, LArMCParticleHelper::MCParticleToPfoHitSharingMap &interpretedMCToPfoHitSharingMap) const
Apply an interpretative matching procedure to the comprehensive matches in the provided validation in...
static void GetPfoToReconstructable2DHitsMap(const pandora::PfoList &pfoList, const MCContributionMap &selectedMCParticleToHitsMap, PfoContributionMap &pfoToReconstructable2DHitsMap, const bool foldBackHierarchy)
Get mapping from Pfo to reconstructable 2D hits (=good hits belonging to a selected reconstructable M...
static void GetPfoMCParticleHitSharingMaps(const PfoContributionMap &pfoToReconstructable2DHitsMap, const MCContributionMapVector &selectedMCParticleToHitsMaps, PfoToMCParticleHitSharingMap &pfoToMCParticleHitSharingMap, MCParticleToPfoHitSharingMap &mcParticleToPfoHitSharingMap)
Get the mappings from Pfo -> pair (reconstructable MCparticles, number of reconstructable 2D hits sha...
std::map< const pandora::MCParticle *, PfoToSharedHitsVector > MCParticleToPfoHitSharingMap
bool m_foldBackHierarchy
whether to fold the hierarchy back to the primary (neutrino) or leading particles (test beam) ...
static bool IsCosmicRay(const pandora::MCParticle *const pMCParticle)
Return true if passed a primary cosmic ray MCParticle.
static void SelectReconstructableMCParticles(const pandora::MCParticleList *pMCParticleList, const pandora::CaloHitList *pCaloHitList, const PrimaryParameters &parameters, std::function< bool(const pandora::MCParticle *const)> fCriteria, MCContributionMap &selectedMCParticlesToHitsMap)
Select target, reconstructable mc particles that match given criteria.
LArMCParticleHelper::PrimaryParameters m_primaryParameters
The mc particle primary selection parameters.
static bool IsBeamParticle(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary beam MCParticle.
std::unordered_map< const pandora::ParticleFlowObject *, pandora::CaloHitList > PfoContributionMap
static void GetAllConnectedPfos(const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList)
Get a flat list of all pfos, recursively including all daughters and parents associated with those pf...
std::map< const pandora::ParticleFlowObject *, MCParticleToSharedHitsVector > PfoToMCParticleHitSharingMap
void lar_content::EventValidationBaseAlgorithm::GetRemainingPfoMatches ( const ValidationInfo validationInfo,
const pandora::MCParticleVector &  mcPrimaryVector,
const pandora::PfoSet &  usedPfos,
LArMCParticleHelper::MCParticleToPfoHitSharingMap interpretedMCToPfoHitSharingMap 
) const
protectedinherited

Get the best matches for any pfos left-over after the strong matching procedure.

Parameters
validationInfothe validation info
mcPrimaryVectorthe mc primary vector
usedPfosthe set of previously used pfos
interpretedMCToPfoHitSharingMapthe output, interpreted mc particle to pfo hit sharing map

Definition at line 155 of file EventValidationBaseAlgorithm.cc.

References lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetMCToPfoHitSharingMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetTargetMCParticleToHitsMap(), and lar_content::EventValidationBaseAlgorithm::m_useSmallPrimaries.

Referenced by lar_content::EventValidationBaseAlgorithm::InterpretMatching().

157 {
158  LArMCParticleHelper::PfoToMCParticleHitSharingMap pfoToMCParticleHitSharingMap;
159 
160  for (const MCParticle *const pMCPrimary : mcPrimaryVector)
161  {
162  if (!m_useSmallPrimaries && !validationInfo.GetTargetMCParticleToHitsMap().count(pMCPrimary))
163  continue;
164 
165  if (!validationInfo.GetMCToPfoHitSharingMap().count(pMCPrimary))
166  continue;
167 
168  for (const LArMCParticleHelper::PfoCaloHitListPair &pfoToSharedHits : validationInfo.GetMCToPfoHitSharingMap().at(pMCPrimary))
169  {
170  if (usedPfos.count(pfoToSharedHits.first))
171  continue;
172 
173  const LArMCParticleHelper::MCParticleCaloHitListPair mcParticleToHits(pMCPrimary, pfoToSharedHits.second);
174  LArMCParticleHelper::PfoToMCParticleHitSharingMap::iterator iter(pfoToMCParticleHitSharingMap.find(pfoToSharedHits.first));
175 
176  if (pfoToMCParticleHitSharingMap.end() == iter)
177  {
178  pfoToMCParticleHitSharingMap[pfoToSharedHits.first].push_back(mcParticleToHits);
179  }
180  else
181  {
182  if (1 != iter->second.size())
183  throw StatusCodeException(STATUS_CODE_FAILURE);
184 
185  LArMCParticleHelper::MCParticleCaloHitListPair &originalMCParticleToHits(iter->second.at(0));
186 
187  if (mcParticleToHits.second.size() > originalMCParticleToHits.second.size())
188  originalMCParticleToHits = mcParticleToHits;
189  }
190  }
191  }
192 
193  for (const auto &mapEntry : pfoToMCParticleHitSharingMap)
194  {
195  const LArMCParticleHelper::MCParticleCaloHitListPair &mcParticleToHits(mapEntry.second.at(0));
196  interpretedMCToPfoHitSharingMap[mcParticleToHits.first].push_back(
197  LArMCParticleHelper::PfoCaloHitListPair(mapEntry.first, mcParticleToHits.second));
198  }
199 }
intermediate_table::iterator iterator
std::pair< const pandora::MCParticle *, pandora::CaloHitList > MCParticleCaloHitListPair
bool m_useSmallPrimaries
Whether to consider matches to mc primaries with fewer than m_matchingMinPrimaryHits.
std::pair< const pandora::ParticleFlowObject *, pandora::CaloHitList > PfoCaloHitListPair
std::map< const pandora::ParticleFlowObject *, MCParticleToSharedHitsVector > PfoToMCParticleHitSharingMap
bool lar_content::EventValidationBaseAlgorithm::GetStrongestPfoMatch ( const ValidationInfo validationInfo,
const pandora::MCParticleVector &  mcPrimaryVector,
pandora::PfoSet &  usedPfos,
LArMCParticleHelper::MCParticleToPfoHitSharingMap interpretedMCToPfoHitSharingMap 
) const
protectedinherited

Get the strongest pfo match (most matched hits) between an available mc primary and an available pfo.

Parameters
validationInfothe validation info
mcPrimaryVectorthe mc primary vector
usedPfosthe set of previously used pfos
interpretedMCToPfoHitSharingMapthe output, interpreted mc particle to pfo hit sharing map
Returns
whether a strong match was identified

Definition at line 111 of file EventValidationBaseAlgorithm.cc.

References lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetAllMCParticleToHitsMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetMCToPfoHitSharingMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetPfoToHitsMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetTargetMCParticleToHitsMap(), lar_content::EventValidationBaseAlgorithm::IsGoodMatch(), and lar_content::EventValidationBaseAlgorithm::m_useSmallPrimaries.

Referenced by lar_content::EventValidationBaseAlgorithm::InterpretMatching().

113 {
114  const MCParticle *pBestMCParticle(nullptr);
115  LArMCParticleHelper::PfoCaloHitListPair bestPfoHitPair(nullptr, CaloHitList());
116 
117  for (const MCParticle *const pMCPrimary : mcPrimaryVector)
118  {
119  if (interpretedMCToPfoHitSharingMap.count(pMCPrimary))
120  continue;
121 
122  if (!m_useSmallPrimaries && !validationInfo.GetTargetMCParticleToHitsMap().count(pMCPrimary))
123  continue;
124 
125  if (!validationInfo.GetMCToPfoHitSharingMap().count(pMCPrimary))
126  continue;
127 
128  for (const LArMCParticleHelper::PfoCaloHitListPair &pfoToSharedHits : validationInfo.GetMCToPfoHitSharingMap().at(pMCPrimary))
129  {
130  if (usedPfos.count(pfoToSharedHits.first))
131  continue;
132 
133  if (!this->IsGoodMatch(validationInfo.GetAllMCParticleToHitsMap().at(pMCPrimary),
134  validationInfo.GetPfoToHitsMap().at(pfoToSharedHits.first), pfoToSharedHits.second))
135  continue;
136 
137  if (pfoToSharedHits.second.size() > bestPfoHitPair.second.size())
138  {
139  pBestMCParticle = pMCPrimary;
140  bestPfoHitPair = pfoToSharedHits;
141  }
142  }
143  }
144 
145  if (!pBestMCParticle || !bestPfoHitPair.first)
146  return false;
147 
148  interpretedMCToPfoHitSharingMap[pBestMCParticle].push_back(bestPfoHitPair);
149  usedPfos.insert(bestPfoHitPair.first);
150  return true;
151 }
bool m_useSmallPrimaries
Whether to consider matches to mc primaries with fewer than m_matchingMinPrimaryHits.
std::pair< const pandora::ParticleFlowObject *, pandora::CaloHitList > PfoCaloHitListPair
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.
void lar_content::EventValidationBaseAlgorithm::InterpretMatching ( const ValidationInfo validationInfo,
LArMCParticleHelper::MCParticleToPfoHitSharingMap interpretedMCToPfoHitSharingMap 
) const
protectedinherited

Apply an interpretative matching procedure to the comprehensive matches in the provided validation info object.

Parameters
validationInfothe validation info
interpretedMCToPfoHitSharingMapthe output, interpreted mc particle to pfo hit sharing map

Definition at line 86 of file EventValidationBaseAlgorithm.cc.

References lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetAllMCParticleToHitsMap(), lar_content::LArMonitoringHelper::GetOrderedMCParticleVector(), lar_content::EventValidationBaseAlgorithm::GetRemainingPfoMatches(), lar_content::EventValidationBaseAlgorithm::GetStrongestPfoMatch(), and lar_content::LArPfoHelper::SortByNHits().

Referenced by lar_content::NeutrinoEventValidationAlgorithm::FillValidationInfo(), and lar_content::MuonLeadingEventValidationAlgorithm::PerformUnfoldedMatching().

88 {
89  MCParticleVector mcPrimaryVector;
90  LArMonitoringHelper::GetOrderedMCParticleVector({validationInfo.GetAllMCParticleToHitsMap()}, mcPrimaryVector);
91 
92  PfoSet usedPfos;
93  while (this->GetStrongestPfoMatch(validationInfo, mcPrimaryVector, usedPfos, interpretedMCToPfoHitSharingMap))
94  {
95  }
96  this->GetRemainingPfoMatches(validationInfo, mcPrimaryVector, usedPfos, interpretedMCToPfoHitSharingMap);
97 
98  // Ensure all primaries have an entry, and sorting is as desired
99  for (const MCParticle *const pMCPrimary : mcPrimaryVector)
100  {
101  LArMCParticleHelper::PfoToSharedHitsVector &pfoHitPairs(interpretedMCToPfoHitSharingMap[pMCPrimary]);
102  std::sort(pfoHitPairs.begin(), pfoHitPairs.end(),
104  return ((a.second.size() != b.second.size()) ? a.second.size() > b.second.size() : LArPfoHelper::SortByNHits(a.first, b.first));
105  });
106  }
107 }
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
std::vector< PfoCaloHitListPair > PfoToSharedHitsVector
static void GetOrderedMCParticleVector(const LArMCParticleHelper::MCContributionMapVector &selectedMCParticleToGoodHitsMaps, pandora::MCParticleVector &orderedMCParticleVector)
Order input MCParticles by their number of hits.
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
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...
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.
std::pair< const pandora::ParticleFlowObject *, pandora::CaloHitList > PfoCaloHitListPair
bool lar_content::EventValidationBaseAlgorithm::IsGoodMatch ( const pandora::CaloHitList &  trueHits,
const pandora::CaloHitList &  recoHits,
const pandora::CaloHitList &  sharedHits 
) const
protectedinherited

Whether a provided mc primary and pfo are deemed to be a good match.

Parameters
trueHitsthe list of true hits
recoHitsthe list of reco hits
sharedHitsthe list of shared hits
Returns
boolean

Definition at line 203 of file EventValidationBaseAlgorithm.cc.

References f, lar_content::EventValidationBaseAlgorithm::m_matchingMinCompleteness, lar_content::EventValidationBaseAlgorithm::m_matchingMinPurity, and lar_content::EventValidationBaseAlgorithm::m_matchingMinSharedHits.

Referenced by lar_content::MuonLeadingEventValidationAlgorithm::DetermineIncorrectlyReconstructedCosmicRays(), lar_content::EventValidationBaseAlgorithm::GetStrongestPfoMatch(), lar_content::NeutrinoEventValidationAlgorithm::ProcessOutput(), and lar_content::MuonLeadingEventValidationAlgorithm::ProcessOutput().

204 {
205  const float purity((recoHits.size() > 0) ? static_cast<float>(sharedHits.size()) / static_cast<float>(recoHits.size()) : 0.f);
206  const float completeness((trueHits.size() > 0) ? static_cast<float>(sharedHits.size()) / static_cast<float>(trueHits.size()) : 0.f);
207 
208  return ((sharedHits.size() >= m_matchingMinSharedHits) && (purity >= m_matchingMinPurity) && (completeness >= m_matchingMinCompleteness));
209 }
float m_matchingMinPurity
The minimum particle purity to declare a match.
TFile f
Definition: plotHisto.C:6
unsigned int m_matchingMinSharedHits
The minimum number of shared hits used in matching scheme.
float m_matchingMinCompleteness
The minimum particle completeness to declare a match.
void lar_content::TestBeamEventValidationAlgorithm::ProcessOutput ( const ValidationInfo validationInfo,
const bool  useInterpretedMatching,
const bool  printToScreen,
const bool  fillTree 
) const
privatevirtual

Print matching information in a provided validation info object, and write information to tree if configured to do so.

Parameters
validationInfothe validation info
useInterpretedMatchingwhether to use the interpreted (rather than raw) matching information
printToScreenwhether to print the information to screen
fillTreewhether to write the information to tree

Implements lar_content::EventValidationBaseAlgorithm.

Definition at line 93 of file TestBeamEventValidationAlgorithm.cc.

References lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetAllMCParticleToHitsMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetInterpretedMCToPfoHitSharingMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetMCToPfoHitSharingMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetPfoToHitsMap(), and lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetTargetMCParticleToHitsMap().

95 {
96  static int eventNumber{-1};
97  ++eventNumber;
98  if (printToScreen && useInterpretedMatching)
99  std::cout << "---EVENT-" << eventNumber << "-INTERPRETED-MATCHING-OUTPUT----------------------------------------------------------"
100  << std::endl;
101  else if (printToScreen)
102  std::cout << "---EVENT-" << eventNumber << "-RAW-MATCHING-OUTPUT------------------------------------------------------------------"
103  << std::endl;
104 
105  const LArMCParticleHelper::MCParticleToPfoHitSharingMap &mcToPfoHitSharingMap(
106  useInterpretedMatching ? validationInfo.GetInterpretedMCToPfoHitSharingMap() : validationInfo.GetMCToPfoHitSharingMap());
107 
108  MCParticleVector mcPrimaryVector;
109  LArMonitoringHelper::GetOrderedMCParticleVector({validationInfo.GetTargetMCParticleToHitsMap()}, mcPrimaryVector);
110 
111  // Test Beam Validation Bookkeeping
112  PfoVector primaryPfoVector;
113  LArMonitoringHelper::GetOrderedPfoVector(validationInfo.GetPfoToHitsMap(), primaryPfoVector);
114 
115  int pfoIndex(0), testBeamPfoIndex(0);
116  PfoToIdMap pfoToIdMap, testBeamPfoToIdMap;
117 
118  for (const Pfo *const pPrimaryPfo : primaryPfoVector)
119  {
120  pfoToIdMap.insert(PfoToIdMap::value_type(pPrimaryPfo, ++pfoIndex));
121  const Pfo *const pRecoTestBeam(LArPfoHelper::IsTestBeamFinalState(pPrimaryPfo) ? LArPfoHelper::GetParentPfo(pPrimaryPfo) : nullptr);
122 
123  if (pRecoTestBeam && !testBeamPfoToIdMap.count(pRecoTestBeam))
124  testBeamPfoToIdMap.insert(PfoToIdMap::value_type(pRecoTestBeam, ++testBeamPfoIndex));
125  }
126 
127  LArMCParticleHelper::MCParticleIntMap triggeredToLeading, triggeredToLeadingCounter;
128 
129  MCParticleList associatedMCPrimaries;
130 
131  int nCorrectTB(0), nTotalTB(0), nCorrectCR(0), nTotalCR(0), nFakeTB(0), nFakeCR(0), nSplitTB(0), nSplitCR(0), nLost(0);
132  int mcPrimaryIndex(0), nTargetMatches(0), nTargetTBMatches(0), nTargetCRMatches(0);
133  IntVector mcPrimaryId, mcPrimaryPdg, nMCHitsTotal, nMCHitsU, nMCHitsV, nMCHitsW;
134  FloatVector mcPrimaryE, mcPrimaryPX, mcPrimaryPY, mcPrimaryPZ;
135  FloatVector mcPrimaryVtxX, mcPrimaryVtxY, mcPrimaryVtxZ, mcPrimaryEndX, mcPrimaryEndY, mcPrimaryEndZ;
136  IntVector nPrimaryMatchedPfos, nPrimaryMatchedTBPfos, nPrimaryMatchedCRPfos;
137  IntVector bestMatchPfoId, bestMatchPfoPdg, bestMatchPfoIsTB;
138  IntVector bestMatchPfoNHitsTotal, bestMatchPfoNHitsU, bestMatchPfoNHitsV, bestMatchPfoNHitsW;
139  IntVector bestMatchPfoNSharedHitsTotal, bestMatchPfoNSharedHitsU, bestMatchPfoNSharedHitsV, bestMatchPfoNSharedHitsW;
140  FloatVector bestMatchPfoX0;
141 
142  std::stringstream targetSS;
143 
144  for (const MCParticle *const pMCPrimary : mcPrimaryVector)
145  {
146  const bool hasMatch(mcToPfoHitSharingMap.count(pMCPrimary) && !mcToPfoHitSharingMap.at(pMCPrimary).empty());
147  const bool isTargetPrimary(validationInfo.GetTargetMCParticleToHitsMap().count(pMCPrimary));
148 
149  if (!isTargetPrimary && !hasMatch)
150  continue;
151 
152  associatedMCPrimaries.push_back(pMCPrimary);
153  ++mcPrimaryIndex;
154  const CaloHitList &mcPrimaryHitList(validationInfo.GetAllMCParticleToHitsMap().at(pMCPrimary));
155 
157  const int isBeamParticle(LArMCParticleHelper::IsBeamParticle(pMCPrimary));
158  const int isCosmicRay(LArMCParticleHelper::IsCosmicRay(pMCPrimary));
159 #ifdef MONITORING
160  const int nTargetPrimaries(associatedMCPrimaries.size());
161  const CartesianVector &targetVertex(LArMCParticleHelper::GetParentMCParticle(pMCPrimary)->GetVertex());
162  const float targetVertexX(targetVertex.GetX()), targetVertexY(targetVertex.GetY()), targetVertexZ(targetVertex.GetZ());
163 #endif
164 
165  targetSS << (!isTargetPrimary ? "(Non target) " : "") << "PrimaryId " << mcPrimaryIndex << ", TB " << isBeamParticle << ", CR "
166  << isCosmicRay << ", MCPDG " << pMCPrimary->GetParticleId() << ", Energy " << pMCPrimary->GetEnergy() << ", Dist. "
167  << (pMCPrimary->GetEndpoint() - pMCPrimary->GetVertex()).GetMagnitude() << ", nMCHits " << mcPrimaryHitList.size() << " ("
168  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, mcPrimaryHitList) << ", "
169  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, mcPrimaryHitList) << ", "
170  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, mcPrimaryHitList) << ")" << std::endl;
171 
172  mcPrimaryId.push_back(mcPrimaryIndex);
173  mcPrimaryPdg.push_back(pMCPrimary->GetParticleId());
174  mcPrimaryE.push_back(pMCPrimary->GetEnergy());
175  mcPrimaryPX.push_back(pMCPrimary->GetMomentum().GetX());
176  mcPrimaryPY.push_back(pMCPrimary->GetMomentum().GetY());
177  mcPrimaryPZ.push_back(pMCPrimary->GetMomentum().GetZ());
178  mcPrimaryVtxX.push_back(pMCPrimary->GetVertex().GetX());
179  mcPrimaryVtxY.push_back(pMCPrimary->GetVertex().GetY());
180  mcPrimaryVtxZ.push_back(pMCPrimary->GetVertex().GetZ());
181  mcPrimaryEndX.push_back(pMCPrimary->GetEndpoint().GetX());
182  mcPrimaryEndY.push_back(pMCPrimary->GetEndpoint().GetY());
183  mcPrimaryEndZ.push_back(pMCPrimary->GetEndpoint().GetZ());
184  nMCHitsTotal.push_back(mcPrimaryHitList.size());
185  nMCHitsU.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, mcPrimaryHitList));
186  nMCHitsV.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, mcPrimaryHitList));
187  nMCHitsW.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, mcPrimaryHitList));
188 
189  int matchIndex(0), nPrimaryMatches(0), nPrimaryTBMatches(0), nPrimaryCRMatches(0);
190 #ifdef MONITORING
191  float recoVertexX(std::numeric_limits<float>::max()), recoVertexY(std::numeric_limits<float>::max()),
192  recoVertexZ(std::numeric_limits<float>::max());
193 #endif
194  for (const LArMCParticleHelper::PfoCaloHitListPair &pfoToSharedHits : mcToPfoHitSharingMap.at(pMCPrimary))
195  {
196  const CaloHitList &sharedHitList(pfoToSharedHits.second);
197  const CaloHitList &pfoHitList(validationInfo.GetPfoToHitsMap().at(pfoToSharedHits.first));
198 
199  const bool isRecoTestBeam(LArPfoHelper::IsTestBeam(pfoToSharedHits.first));
200  const bool isGoodMatch(this->IsGoodMatch(mcPrimaryHitList, pfoHitList, sharedHitList));
201 
202  const int pfoId(pfoToIdMap.at(pfoToSharedHits.first));
203 
204  if (0 == matchIndex++)
205  {
206  bestMatchPfoId.push_back(pfoId);
207  bestMatchPfoPdg.push_back(pfoToSharedHits.first->GetParticleId());
208  bestMatchPfoIsTB.push_back(isRecoTestBeam ? 1 : 0);
209  bestMatchPfoNHitsTotal.push_back(pfoHitList.size());
210  bestMatchPfoNHitsU.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, pfoHitList));
211  bestMatchPfoNHitsV.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, pfoHitList));
212  bestMatchPfoNHitsW.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, pfoHitList));
213  bestMatchPfoNSharedHitsTotal.push_back(sharedHitList.size());
214  bestMatchPfoNSharedHitsU.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, sharedHitList));
215  bestMatchPfoNSharedHitsV.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, sharedHitList));
216  bestMatchPfoNSharedHitsW.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, sharedHitList));
217  bestMatchPfoX0.push_back(pfoToSharedHits.first->GetPropertiesMap().count("X0") ? pfoToSharedHits.first->GetPropertiesMap().at("X0")
218  : std::numeric_limits<float>::max());
219 #ifdef MONITORING
220  try
221  {
222  const Vertex *const pRecoVertex(isRecoTestBeam ? LArPfoHelper::GetTestBeamInteractionVertex(pfoToSharedHits.first)
223  : LArPfoHelper::GetVertex(pfoToSharedHits.first));
224  recoVertexX = pRecoVertex->GetPosition().GetX();
225  recoVertexY = pRecoVertex->GetPosition().GetY();
226  recoVertexZ = pRecoVertex->GetPosition().GetZ();
227  }
228  catch (const StatusCodeException &)
229  {
230  }
231 #endif
232  }
233 
234  if (isGoodMatch)
235  ++nPrimaryMatches;
236 
237  if (isRecoTestBeam && isGoodMatch)
238  ++nPrimaryTBMatches;
239  if (!isRecoTestBeam && isGoodMatch)
240  ++nPrimaryCRMatches;
241 
242  targetSS << "-" << (!isGoodMatch ? "(Below threshold) " : "") << "MatchedPfoId " << pfoId << ", TB " << isRecoTestBeam
243  << ", CR " << (!isRecoTestBeam) << ", PDG " << pfoToSharedHits.first->GetParticleId() << ", nMatchedHits "
244  << sharedHitList.size() << " (" << LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, sharedHitList) << ", "
245  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, sharedHitList) << ", "
246  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, sharedHitList) << ")"
247  << ", nPfoHits " << pfoHitList.size() << " (" << LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, pfoHitList) << ", "
248  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, pfoHitList) << ", "
249  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, pfoHitList) << ")" << std::endl;
250  }
251 
252  if (mcToPfoHitSharingMap.at(pMCPrimary).empty())
253  {
254  targetSS << "-No matched Pfo" << std::endl;
255  bestMatchPfoId.push_back(-1);
256  bestMatchPfoPdg.push_back(0);
257  bestMatchPfoIsTB.push_back(0);
258  bestMatchPfoNHitsTotal.push_back(0);
259  bestMatchPfoNHitsU.push_back(0);
260  bestMatchPfoNHitsV.push_back(0);
261  bestMatchPfoNHitsW.push_back(0);
262  bestMatchPfoNSharedHitsTotal.push_back(0);
263  bestMatchPfoNSharedHitsU.push_back(0);
264  bestMatchPfoNSharedHitsV.push_back(0);
265  bestMatchPfoNSharedHitsW.push_back(0);
266  bestMatchPfoX0.push_back(std::numeric_limits<float>::max());
267  }
268 
269  nPrimaryMatchedPfos.push_back(nPrimaryMatches);
270  nPrimaryMatchedTBPfos.push_back(nPrimaryTBMatches);
271  nPrimaryMatchedCRPfos.push_back(nPrimaryCRMatches);
272  nTargetMatches += nPrimaryMatches;
273  nTargetTBMatches += nPrimaryTBMatches;
274  nTargetCRMatches += nPrimaryCRMatches;
275 
276  if (fillTree)
277  {
278  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "fileIdentifier", m_fileIdentifier));
279  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "eventNumber", eventNumber));
280  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcNuanceCode", mcNuanceCode));
281  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "isBeamParticle", isBeamParticle));
282  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "isCosmicRay", isCosmicRay));
283  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "nTargetPrimaries", nTargetPrimaries));
284  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "targetVertexX", targetVertexX));
285  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "targetVertexY", targetVertexY));
286  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "targetVertexZ", targetVertexZ));
287  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "recoVertexX", recoVertexX));
288  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "recoVertexY", recoVertexY));
289  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "recoVertexZ", recoVertexZ));
290  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPrimaryId", &mcPrimaryId));
291  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPrimaryPdg", &mcPrimaryPdg));
292  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPrimaryE", &mcPrimaryE));
293  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPrimaryPX", &mcPrimaryPX));
294  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPrimaryPY", &mcPrimaryPY));
295  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPrimaryPZ", &mcPrimaryPZ));
296  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPrimaryVtxX", &mcPrimaryVtxX));
297  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPrimaryVtxY", &mcPrimaryVtxY));
298  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPrimaryVtxZ", &mcPrimaryVtxZ));
299  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPrimaryEndX", &mcPrimaryEndX));
300  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPrimaryEndY", &mcPrimaryEndY));
301  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPrimaryEndZ", &mcPrimaryEndZ));
302  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPrimaryNHitsTotal", &nMCHitsTotal));
303  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPrimaryNHitsU", &nMCHitsU));
304  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPrimaryNHitsV", &nMCHitsV));
305  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPrimaryNHitsW", &nMCHitsW));
306  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "nPrimaryMatchedPfos", &nPrimaryMatchedPfos));
307  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "nPrimaryMatchedTBPfos", &nPrimaryMatchedTBPfos));
308  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "nPrimaryMatchedCRPfos", &nPrimaryMatchedCRPfos));
309  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchPfoId", &bestMatchPfoId));
310  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchPfoPdg", &bestMatchPfoPdg));
311  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchPfoNHitsTotal", &bestMatchPfoNHitsTotal));
312  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchPfoNHitsU", &bestMatchPfoNHitsU));
313  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchPfoNHitsV", &bestMatchPfoNHitsV));
314  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchPfoNHitsW", &bestMatchPfoNHitsW));
315  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchPfoNSharedHitsTotal", &bestMatchPfoNSharedHitsTotal));
316  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchPfoNSharedHitsU", &bestMatchPfoNSharedHitsU));
317  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchPfoNSharedHitsV", &bestMatchPfoNSharedHitsV));
318  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchPfoNSharedHitsW", &bestMatchPfoNSharedHitsW));
319  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchPfoX0", &bestMatchPfoX0));
320  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "nTargetMatches", nTargetMatches));
321  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "nTargetTBMatches", nTargetTBMatches));
322  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "nTargetCRMatches", nTargetCRMatches));
323  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchPfoIsTB", &bestMatchPfoIsTB));
324  }
325 
326  if (isBeamParticle || isCosmicRay)
327  {
329 #ifdef MONITORING
330  const int interactionTypeInt(static_cast<int>(interactionType));
331 #endif
332  // ATTN Some redundancy introduced to contributing variables
333  const int isCorrectTB(isBeamParticle && (nTargetTBMatches == 1) && (nTargetCRMatches == 0));
334  const int isCorrectCR(isCosmicRay && (nTargetTBMatches == 0) && (nTargetCRMatches == 1));
335  const int isFakeTB(isCosmicRay && (nTargetTBMatches > 0));
336  const int isFakeCR(!isCosmicRay && (nTargetCRMatches > 0));
337  const int isSplitTB(!isCosmicRay && (nTargetTBMatches > 1));
338  const int isSplitCR(isCosmicRay && (nTargetCRMatches > 1));
339  const int isLost(nTargetMatches == 0);
340 
341  std::stringstream outcomeSS;
342  outcomeSS << LArInteractionTypeHelper::ToString(interactionType) << " (Nuance " << mcNuanceCode << ", TB " << isBeamParticle
343  << ", CR " << isCosmicRay << ")" << std::endl;
344 
345  if (isBeamParticle)
346  ++nTotalTB;
347  if (isCosmicRay)
348  ++nTotalCR;
349  if (isCorrectTB)
350  ++nCorrectTB;
351  if (isCorrectCR)
352  ++nCorrectCR;
353  if (isFakeTB)
354  ++nFakeTB;
355  if (isFakeCR)
356  ++nFakeCR;
357  if (isSplitTB)
358  ++nSplitTB;
359  if (isSplitCR)
360  ++nSplitCR;
361  if (isLost)
362  ++nLost;
363 
364  if (isCorrectTB)
365  outcomeSS << "IsCorrectTB ";
366  if (isCorrectCR)
367  outcomeSS << "IsCorrectCR ";
368  if (isFakeTB)
369  outcomeSS << "IsFakeTB ";
370  if (isFakeCR)
371  outcomeSS << "IsFakeCR ";
372  if (isSplitTB)
373  outcomeSS << "isSplitTB ";
374  if (isSplitCR)
375  outcomeSS << "IsSplitCR ";
376  if (isLost)
377  outcomeSS << "IsLost ";
378  if (nTargetTBMatches > 0)
379  outcomeSS << "(NTBMatches: " << nTargetTBMatches << ") ";
380  if (nTargetCRMatches > 0)
381  outcomeSS << "(NCRMatches: " << nTargetCRMatches << ") ";
382  if (printToScreen)
383  std::cout << outcomeSS.str() << std::endl << targetSS.str() << std::endl;
384 
385  if (fillTree)
386  {
387  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "interactionType", interactionTypeInt));
388  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "isCorrectTB", isCorrectTB));
389  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "isCorrectCR", isCorrectCR));
390  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "isFakeTB", isFakeTB));
391  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "isFakeCR", isFakeCR));
392  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "isSplitTB", isSplitTB));
393  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "isSplitCR", isSplitCR));
394  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "isLost", isLost));
395  PANDORA_MONITORING_API(FillTree(this->GetPandora(), m_treeName.c_str()));
396  }
397 
398  targetSS.str(std::string());
399  targetSS.clear();
400  associatedMCPrimaries.clear();
401  nTargetMatches = 0;
402  nTargetTBMatches = 0;
403  nTargetCRMatches = 0;
404  mcPrimaryId.clear();
405  mcPrimaryPdg.clear();
406  nMCHitsTotal.clear();
407  nMCHitsU.clear();
408  nMCHitsV.clear();
409  nMCHitsW.clear();
410  mcPrimaryE.clear();
411  mcPrimaryPX.clear();
412  mcPrimaryPY.clear();
413  mcPrimaryPZ.clear();
414  mcPrimaryVtxX.clear();
415  mcPrimaryVtxY.clear();
416  mcPrimaryVtxZ.clear();
417  mcPrimaryEndX.clear();
418  mcPrimaryEndY.clear();
419  mcPrimaryEndZ.clear();
420  nPrimaryMatchedPfos.clear();
421  nPrimaryMatchedTBPfos.clear();
422  nPrimaryMatchedCRPfos.clear();
423  bestMatchPfoId.clear();
424  bestMatchPfoPdg.clear();
425  bestMatchPfoIsTB.clear();
426  bestMatchPfoNHitsTotal.clear();
427  bestMatchPfoNHitsU.clear();
428  bestMatchPfoNHitsV.clear();
429  bestMatchPfoNHitsW.clear();
430  bestMatchPfoNSharedHitsTotal.clear();
431  bestMatchPfoNSharedHitsU.clear();
432  bestMatchPfoNSharedHitsV.clear();
433  bestMatchPfoNSharedHitsW.clear();
434  bestMatchPfoX0.clear();
435  }
436  }
437 
438  if (useInterpretedMatching)
439  {
440  std::stringstream summarySS;
441  summarySS << "---SUMMARY--------------------------------------------------------------------------------------" << std::endl;
442  if (nTotalTB > 0)
443  summarySS << "#CorrectTB: " << nCorrectTB << "/" << nTotalTB
444  << ", Fraction: " << (nTotalTB > 0 ? static_cast<float>(nCorrectTB) / static_cast<float>(nTotalTB) : 0.f) << std::endl;
445  if (nTotalCR > 0)
446  summarySS << "#CorrectCR: " << nCorrectCR << "/" << nTotalCR
447  << ", Fraction: " << (nTotalCR > 0 ? static_cast<float>(nCorrectCR) / static_cast<float>(nTotalCR) : 0.f) << std::endl;
448  if (nFakeTB > 0)
449  summarySS << "#FakeTB: " << nFakeTB << " ";
450  if (nFakeCR > 0)
451  summarySS << "#FakeCR: " << nFakeCR << " ";
452  if (nSplitTB > 0)
453  summarySS << "#SplitTB: " << nSplitTB << " ";
454  if (nSplitCR > 0)
455  summarySS << "#SplitCR: " << nSplitCR << " ";
456  if (nLost > 0)
457  summarySS << "#Lost: " << nLost << " ";
458  if (nFakeTB || nFakeCR || nSplitTB || nSplitCR || nLost)
459  summarySS << std::endl;
460  if (printToScreen)
461  std::cout << summarySS.str();
462  }
463 
464  if (printToScreen)
465  std::cout << "------------------------------------------------------------------------------------------------" << std::endl
466  << std::endl;
467 }
std::unordered_map< const pandora::ParticleFlowObject *, unsigned int > PfoToIdMap
static const pandora::Vertex * GetVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo vertex.
static const pandora::Vertex * GetTestBeamInteractionVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo test beam interaction vertex.
STL namespace.
std::map< const pandora::MCParticle *, PfoToSharedHitsVector > MCParticleToPfoHitSharingMap
std::vector< int > IntVector
static unsigned int GetNuanceCode(const pandora::MCParticle *const pMCParticle)
Get the nuance code of an MCParticle.
static InteractionType GetInteractionType(const pandora::MCParticleList &mcPrimaryList)
Get the interaction type of an event.
TFile f
Definition: plotHisto.C:6
static void GetOrderedMCParticleVector(const LArMCParticleHelper::MCContributionMapVector &selectedMCParticleToGoodHitsMaps, pandora::MCParticleVector &orderedMCParticleVector)
Order input MCParticles by their number of hits.
static bool IsCosmicRay(const pandora::MCParticle *const pMCParticle)
Return true if passed a primary cosmic ray MCParticle.
static bool IsTestBeam(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a test beam particle.
std::unordered_map< const pandora::MCParticle *, int > MCParticleIntMap
static const pandora::ParticleFlowObject * GetParentPfo(const pandora::ParticleFlowObject *const pPfo)
Get the primary parent pfo.
static std::string ToString(const InteractionType interactionType)
Get a string representation of an interaction type.
static bool IsBeamParticle(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary beam MCParticle.
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
static const pandora::MCParticle * GetParentMCParticle(const pandora::MCParticle *const pMCParticle)
Get the parent mc particle.
static void GetOrderedPfoVector(const LArMCParticleHelper::PfoContributionMap &pfoToReconstructable2DHitsMap, pandora::PfoVector &orderedPfoVector)
Order input Pfos by their number of hits.
std::pair< const pandora::ParticleFlowObject *, pandora::CaloHitList > PfoCaloHitListPair
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
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.
static unsigned int CountHitsByType(const pandora::HitType hitType, const pandora::CaloHitList &caloHitList)
Count the number of calo hits, in a provided list, of a specified type.
static bool IsTestBeamFinalState(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a final-state particle from a test beam particle interaction.
StatusCode lar_content::TestBeamEventValidationAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 471 of file TestBeamEventValidationAlgorithm.cc.

472 {
474 }
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)

Member Data Documentation

int lar_content::EventValidationBaseAlgorithm::m_eventNumber
protectedinherited
int lar_content::EventValidationBaseAlgorithm::m_fileIdentifier
protectedinherited
LArMCParticleHelper::PrimaryParameters lar_content::EventValidationBaseAlgorithm::m_primaryParameters
protectedinherited

The documentation for this class was generated from the following files: