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

MuonLeadingEventValidationAlgorithm class. More...

#include "MuonLeadingEventValidationAlgorithm.h"

Inheritance diagram for lar_content::MuonLeadingEventValidationAlgorithm:
lar_content::EventValidationBaseAlgorithm

Public Member Functions

 MuonLeadingEventValidationAlgorithm ()
 Default constructor. More...
 
virtual ~MuonLeadingEventValidationAlgorithm ()
 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 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 GetRecoCosmicRayHits (const pandora::MCParticleList *const pMCParticleList, const pandora::CaloHitList *const pCaloHitList, const pandora::PfoList *const pPfoList, pandora::CaloHitList &recoCosmicRayHitList) const
 Determine all reconstructable hits in cosmic ray pfos. More...
 
void PerformUnfoldedMatching (const pandora::MCParticleList *const pMCParticleList, const pandora::CaloHitList *const pCaloHitList, const pandora::PfoList *const pPfoList, const pandora::CaloHitList &recoCosmicRayHitList, const float minHitSharingFraction, ValidationInfo &validationInfo) const
 Perform the main matching procedure. More...
 
void RemoveIncorrectlyReconstructedCosmicRays (const pandora::MCParticleList *const pMCParticleList, const pandora::CaloHitList *const pCaloHitList, const pandora::PfoList *const pPfoList, ValidationInfo &validationInfo) const
 Remove incorrectly reconstructed cosmic rays from main matching maps. More...
 
void DetermineIncorrectlyReconstructedCosmicRays (const pandora::MCParticleList *const pMCParticleList, const pandora::CaloHitList *const pCaloHitList, const pandora::PfoList *const pPfoList, pandora::MCParticleList &incorrectlyReconstructedCosmicRays) const
 Perform the cosmic ray matching procedure and identify incorrectly reconstructed cosmic rays. 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...
 
void PrintHits (const pandora::CaloHitList totalCaloHitList, const pandora::CaloHitList leadingCaloHitList, const std::string &stringTag) const
 Print leading MCParticle hits. More...
 
void FillContaminationHitsDistance (const pandora::CaloHitList &contaminationHits, const pandora::CaloHitList &leadingMCHits, pandora::FloatVector &bestMatchContaminationHitsDistance) const
 Fill an input contamination hit distance vector with the closest distance of each contaminant hit to the true leading particle hits. More...
 
void GetHitsOfType (const pandora::CaloHitList &inputList, const pandora::HitType hitType, pandora::CaloHitList &outputList) const
 To filter out the hits of a given type from an input list. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

LArMuonLeadingHelper::ValidationParameters m_validationParameters
 The definition of a reconstructable MCParticle. More...
 
bool m_removeRecoCosmicRayHits
 Whether to remove the reconstructed cosmic ray hits from leading particle metrics. More...
 
bool m_deltaRayMode
 Whether to run in delta ray mode. More...
 
bool m_michelMode
 Whether to run in michel mode. More...
 
int m_cosmicRaysToSkip
 The number of reconstructable cosmic rays to skip. More...
 
bool m_visualize
 Whether to visualize the MC and reco leading particles. More...
 
bool m_ignoreIncorrectCosmicRays
 Whether to remove the leading particles with incorrrectly reconstructed parents from metrics. More...
 
bool m_writeRawMatchesToTree
 Whether to write all matches to output tree. More...
 
std::vector< int > m_deltaRayIDs
 If filled, to contain the list leading particles to run metrics over. More...
 

Detailed Description

Constructor & Destructor Documentation

lar_content::MuonLeadingEventValidationAlgorithm::MuonLeadingEventValidationAlgorithm ( )

Default constructor.

Definition at line 25 of file MuonLeadingEventValidationAlgorithm.cc.

25  :
27  m_deltaRayMode(false),
28  m_michelMode(false),
30  m_visualize(false),
33 {
34 }
bool m_removeRecoCosmicRayHits
Whether to remove the reconstructed cosmic ray hits from leading particle metrics.
bool m_visualize
Whether to visualize the MC and reco leading particles.
int m_cosmicRaysToSkip
The number of reconstructable cosmic rays to skip.
bool m_ignoreIncorrectCosmicRays
Whether to remove the leading particles with incorrrectly reconstructed parents from metrics...
bool m_writeRawMatchesToTree
Whether to write all matches to output tree.
lar_content::MuonLeadingEventValidationAlgorithm::~MuonLeadingEventValidationAlgorithm ( )
virtual

Destructor.

Definition at line 38 of file MuonLeadingEventValidationAlgorithm.cc.

39 {
40 }

Member Function Documentation

void lar_content::MuonLeadingEventValidationAlgorithm::DetermineIncorrectlyReconstructedCosmicRays ( const pandora::MCParticleList *const  pMCParticleList,
const pandora::CaloHitList *const  pCaloHitList,
const pandora::PfoList *const  pPfoList,
pandora::MCParticleList &  incorrectlyReconstructedCosmicRays 
) const
private

Perform the cosmic ray matching procedure and identify incorrectly reconstructed cosmic rays.

Parameters
pMCParticleListthe address of the mc particle list
pCaloHitListthe address of the calo hit list
pPfoListthe address of the pfo list
incorrectlyReconstructedCosmicRaysthe output list of incorrectly reconstructed cosmic rays

Definition at line 191 of file MuonLeadingEventValidationAlgorithm.cc.

References f, lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetAllMCParticleToHitsMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetInterpretedMCToPfoHitSharingMap(), lar_content::LArMonitoringHelper::GetOrderedMCParticleVector(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetPfoToHitsMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetTargetMCParticleToHitsMap(), lar_content::LArMCParticleHelper::IsCosmicRay(), lar_content::EventValidationBaseAlgorithm::IsGoodMatch(), and PerformUnfoldedMatching().

Referenced by RemoveIncorrectlyReconstructedCosmicRays().

193 {
194  // Perform cosmic ray matching
195  CaloHitList recoCosmicRayHitList;
196  ValidationInfo validationInfo;
197  this->PerformUnfoldedMatching(pMCParticleList, pCaloHitList, pPfoList, recoCosmicRayHitList, 0.f, validationInfo);
198 
199  const LArMCParticleHelper::MCContributionMap &allMCToHitsMap(validationInfo.GetAllMCParticleToHitsMap());
200  const LArMCParticleHelper::MCContributionMap &targetMCToHitsMap(validationInfo.GetTargetMCParticleToHitsMap());
201  const LArMCParticleHelper::PfoContributionMap &pfoToHitsMap(validationInfo.GetPfoToHitsMap());
202  const LArMCParticleHelper::MCParticleToPfoHitSharingMap &interpretedMatchingMap(validationInfo.GetInterpretedMCToPfoHitSharingMap());
203 
204  // Determine incorrectly reconstructed cosmic rays
205  MCParticleVector targetCosmicRayVector;
206  LArMonitoringHelper::GetOrderedMCParticleVector({targetMCToHitsMap}, targetCosmicRayVector);
207 
208  for (const MCParticle *const pTargetCosmicRay : targetCosmicRayVector)
209  {
210  if (!LArMCParticleHelper::IsCosmicRay(pTargetCosmicRay))
211  continue;
212 
213  if (interpretedMatchingMap.at(pTargetCosmicRay).empty())
214  {
215  incorrectlyReconstructedCosmicRays.push_back(pTargetCosmicRay);
216  continue;
217  }
218 
219  const CaloHitList &mcHitList(allMCToHitsMap.at(pTargetCosmicRay));
220 
221  unsigned int nAboveThresholdMatches(0);
222  for (const LArMCParticleHelper::PfoCaloHitListPair &pfoToSharedHits : interpretedMatchingMap.at(pTargetCosmicRay))
223  {
224  const CaloHitList &sharedHitList(pfoToSharedHits.second);
225  const CaloHitList &pfoHitList(pfoToHitsMap.at(pfoToSharedHits.first));
226 
227  const bool isGoodMatch(this->IsGoodMatch(mcHitList, pfoHitList, sharedHitList));
228 
229  if (isGoodMatch)
230  ++nAboveThresholdMatches;
231  }
232 
233  if (nAboveThresholdMatches != 1)
234  incorrectlyReconstructedCosmicRays.push_back(pTargetCosmicRay);
235  }
236 }
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCContributionMap
void PerformUnfoldedMatching(const pandora::MCParticleList *const pMCParticleList, const pandora::CaloHitList *const pCaloHitList, const pandora::PfoList *const pPfoList, const pandora::CaloHitList &recoCosmicRayHitList, const float minHitSharingFraction, ValidationInfo &validationInfo) const
Perform the main matching procedure.
std::map< const pandora::MCParticle *, PfoToSharedHitsVector > MCParticleToPfoHitSharingMap
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.
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
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.
std::unordered_map< const pandora::ParticleFlowObject *, pandora::CaloHitList > PfoContributionMap
void lar_content::MuonLeadingEventValidationAlgorithm::FillContaminationHitsDistance ( const pandora::CaloHitList &  contaminationHits,
const pandora::CaloHitList &  leadingMCHits,
pandora::FloatVector &  bestMatchContaminationHitsDistance 
) const
private

Fill an input contamination hit distance vector with the closest distance of each contaminant hit to the true leading particle hits.

Parameters
contaminationHitsthe list of contaminant hits
leadingMCHitListthe list of true MCParticles hits
bestMatchContaminationHitsDistancethe output contaminant hit distance vector

Definition at line 872 of file MuonLeadingEventValidationAlgorithm.cc.

References lar_content::LArClusterHelper::GetClosestDistance(), and GetHitsOfType().

Referenced by ProcessOutput().

874 {
875  CaloHitList leadingU, leadingV, leadingW;
876  this->GetHitsOfType(leadingMCHits, TPC_VIEW_U, leadingU);
877  this->GetHitsOfType(leadingMCHits, TPC_VIEW_V, leadingV);
878  this->GetHitsOfType(leadingMCHits, TPC_VIEW_W, leadingW);
879 
880  for (const CaloHit *const pContaminationHit : contaminationHits)
881  {
882  const CartesianVector &hitPosition(pContaminationHit->GetPositionVector());
883 
884  if ((pContaminationHit->GetHitType() == TPC_VIEW_U) && (!leadingU.empty()))
885  bestMatchContaminationHitsDistance.push_back(LArClusterHelper::GetClosestDistance(hitPosition, leadingU));
886 
887  if ((pContaminationHit->GetHitType() == TPC_VIEW_V) && (!leadingV.empty()))
888  bestMatchContaminationHitsDistance.push_back(LArClusterHelper::GetClosestDistance(hitPosition, leadingV));
889 
890  if ((pContaminationHit->GetHitType() == TPC_VIEW_W) && (!leadingW.empty()))
891  bestMatchContaminationHitsDistance.push_back(LArClusterHelper::GetClosestDistance(hitPosition, leadingW));
892  }
893 }
void GetHitsOfType(const pandora::CaloHitList &inputList, const pandora::HitType hitType, pandora::CaloHitList &outputList) const
To filter out the hits of a given type from an input list.
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
void lar_content::MuonLeadingEventValidationAlgorithm::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 44 of file MuonLeadingEventValidationAlgorithm.cc.

References f, GetRecoCosmicRayHits(), m_deltaRayMode, m_ignoreIncorrectCosmicRays, m_michelMode, lar_content::LArMCParticleHelper::PrimaryParameters::m_minHitSharingFraction, m_removeRecoCosmicRayHits, m_validationParameters, m_visualize, PerformUnfoldedMatching(), and RemoveIncorrectlyReconstructedCosmicRays().

46 {
47  if (!(m_michelMode || m_deltaRayMode))
48  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
49 
50  if (m_visualize)
51  {
52 #ifdef MONITORING
53  PandoraMonitoringApi::SetEveDisplayParameters(this->GetPandora(), true, DETECTOR_VIEW_DEFAULT, -1.f, 1.f, 1.f);
54 #endif
55  }
56 
57  CaloHitList recoCosmicRayHitList;
59  this->GetRecoCosmicRayHits(pMCParticleList, pCaloHitList, pPfoList, recoCosmicRayHitList);
60 
62  pMCParticleList, pCaloHitList, pPfoList, recoCosmicRayHitList, m_validationParameters.m_minHitSharingFraction, validationInfo);
63 
65  this->RemoveIncorrectlyReconstructedCosmicRays(pMCParticleList, pCaloHitList, pPfoList, validationInfo);
66 }
bool m_removeRecoCosmicRayHits
Whether to remove the reconstructed cosmic ray hits from leading particle metrics.
void PerformUnfoldedMatching(const pandora::MCParticleList *const pMCParticleList, const pandora::CaloHitList *const pCaloHitList, const pandora::PfoList *const pPfoList, const pandora::CaloHitList &recoCosmicRayHitList, const float minHitSharingFraction, ValidationInfo &validationInfo) const
Perform the main matching procedure.
void RemoveIncorrectlyReconstructedCosmicRays(const pandora::MCParticleList *const pMCParticleList, const pandora::CaloHitList *const pCaloHitList, const pandora::PfoList *const pPfoList, ValidationInfo &validationInfo) const
Remove incorrectly reconstructed cosmic rays from main matching maps.
void GetRecoCosmicRayHits(const pandora::MCParticleList *const pMCParticleList, const pandora::CaloHitList *const pCaloHitList, const pandora::PfoList *const pPfoList, pandora::CaloHitList &recoCosmicRayHitList) const
Determine all reconstructable hits in cosmic ray pfos.
bool m_visualize
Whether to visualize the MC and reco leading particles.
TFile f
Definition: plotHisto.C:6
bool m_ignoreIncorrectCosmicRays
Whether to remove the leading particles with incorrrectly reconstructed parents from metrics...
float m_minHitSharingFraction
the minimum Hit sharing fraction
LArMuonLeadingHelper::ValidationParameters m_validationParameters
The definition of a reconstructable MCParticle.
void lar_content::MuonLeadingEventValidationAlgorithm::GetHitsOfType ( const pandora::CaloHitList &  inputList,
const pandora::HitType  hitType,
pandora::CaloHitList &  outputList 
) const
private

To filter out the hits of a given type from an input list.

Parameters
inputListthe input list of hits
hitTypethe specified TPC view
outputListthe output list of hits of the specified list

Definition at line 897 of file MuonLeadingEventValidationAlgorithm.cc.

Referenced by FillContaminationHitsDistance().

898 {
899  for (const CaloHit *const pCaloHit : inputList)
900  {
901  if (pCaloHit->GetHitType() == hitType)
902  outputList.push_back(pCaloHit);
903  }
904 }
void lar_content::MuonLeadingEventValidationAlgorithm::GetRecoCosmicRayHits ( const pandora::MCParticleList *const  pMCParticleList,
const pandora::CaloHitList *const  pCaloHitList,
const pandora::PfoList *const  pPfoList,
pandora::CaloHitList &  recoCosmicRayHitList 
) const
private

Determine all reconstructable hits in cosmic ray pfos.

Parameters
pMCParticleListthe address of the mc particle list
pCaloHitListthe address of the calo hit list
pPfoListthe address of the pfo list
recoCosmicRayHitListthe output list of cosmic ray pfo reconstructable hits

Definition at line 70 of file MuonLeadingEventValidationAlgorithm.cc.

References f, lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetAllMCParticleToHitsMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetInterpretedMCToPfoHitSharingMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetPfoToHitsMap(), lar_content::LArMCParticleHelper::IsCosmicRay(), and PerformUnfoldedMatching().

Referenced by FillValidationInfo().

72 {
73  recoCosmicRayHitList.clear();
74 
75  ValidationInfo validationInfo;
76  this->PerformUnfoldedMatching(pMCParticleList, pCaloHitList, pPfoList, recoCosmicRayHitList, 0.f, validationInfo);
77 
78  const LArMCParticleHelper::MCContributionMap &allMCToHitsMap(validationInfo.GetAllMCParticleToHitsMap());
79  const LArMCParticleHelper::PfoContributionMap &pfoToHitsMap(validationInfo.GetPfoToHitsMap());
80  const LArMCParticleHelper::MCParticleToPfoHitSharingMap &interpretedMatchingMap(validationInfo.GetInterpretedMCToPfoHitSharingMap());
81 
82  for (auto &entry : allMCToHitsMap)
83  {
84  if (!LArMCParticleHelper::IsCosmicRay(entry.first))
85  continue;
86 
87  const MCParticle *const pCosmicRay(entry.first);
88 
89  for (LArMCParticleHelper::PfoToSharedHitsVector::const_iterator cosmicRayMatchedPfoPair = interpretedMatchingMap.at(pCosmicRay).begin();
90  cosmicRayMatchedPfoPair != interpretedMatchingMap.at(pCosmicRay).end(); ++cosmicRayMatchedPfoPair)
91  {
92  const ParticleFlowObject *const pCosmicRayPfo(cosmicRayMatchedPfoPair->first);
93  recoCosmicRayHitList.insert(recoCosmicRayHitList.end(), pfoToHitsMap.at(pCosmicRayPfo).begin(), pfoToHitsMap.at(pCosmicRayPfo).end());
94  }
95  }
96 }
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCContributionMap
void PerformUnfoldedMatching(const pandora::MCParticleList *const pMCParticleList, const pandora::CaloHitList *const pCaloHitList, const pandora::PfoList *const pPfoList, const pandora::CaloHitList &recoCosmicRayHitList, const float minHitSharingFraction, ValidationInfo &validationInfo) const
Perform the main matching procedure.
std::map< const pandora::MCParticle *, PfoToSharedHitsVector > MCParticleToPfoHitSharingMap
intermediate_table::const_iterator const_iterator
TFile f
Definition: plotHisto.C:6
static bool IsCosmicRay(const pandora::MCParticle *const pMCParticle)
Return true if passed a primary cosmic ray MCParticle.
std::unordered_map< const pandora::ParticleFlowObject *, pandora::CaloHitList > PfoContributionMap
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 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 DetermineIncorrectlyReconstructedCosmicRays(), lar_content::EventValidationBaseAlgorithm::GetStrongestPfoMatch(), lar_content::NeutrinoEventValidationAlgorithm::ProcessOutput(), and 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::MuonLeadingEventValidationAlgorithm::PerformUnfoldedMatching ( const pandora::MCParticleList *const  pMCParticleList,
const pandora::CaloHitList *const  pCaloHitList,
const pandora::PfoList *const  pPfoList,
const pandora::CaloHitList &  recoCosmicRayHitList,
const float  minHitSharingFraction,
ValidationInfo validationInfo 
) const
private

Perform the main matching procedure.

Parameters
pMCParticleListthe address of the mc particle list
pCaloHitListthe address of the calo hit list
pPfoListthe address of the pfo list
recoCosmicRayHitListthe list of cosmic ray pfo reconstructable hits to remove from leading particle maps
minHitSharingFractionthe minimum hit share fraction of a reconstructable hit
validationInfoto receive the validation info

Definition at line 100 of file MuonLeadingEventValidationAlgorithm.cc.

References lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetAllMCParticleToHitsMap(), lar_content::LArMCParticleHelper::GetPfoMCParticleHitSharingMaps(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetPfoToHitsMap(), lar_content::LArMCParticleHelper::GetPfoToReconstructable2DHitsMap(), lar_content::EventValidationBaseAlgorithm::InterpretMatching(), lar_content::LArMCParticleHelper::PrimaryParameters::m_minHitsForGoodView, lar_content::LArMCParticleHelper::PrimaryParameters::m_minHitSharingFraction, lar_content::LArMCParticleHelper::PrimaryParameters::m_minPrimaryGoodHits, m_validationParameters, lar_content::LArMuonLeadingHelper::SelectReconstructableLeadingParticles(), 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().

Referenced by DetermineIncorrectlyReconstructedCosmicRays(), FillValidationInfo(), and GetRecoCosmicRayHits().

102 {
103  if (pMCParticleList && pCaloHitList)
104  {
105  // Get reconstructable MCParticle hit ownership map (non-muon leading hierarchy is folded whilst muon is unfolded)
106  LArMuonLeadingHelper::ValidationParameters validationParams(m_validationParameters);
107  validationParams.m_minHitSharingFraction = minHitSharingFraction;
108  LArMCParticleHelper::MCContributionMap targetMCParticleToHitsMap;
110  pMCParticleList, pCaloHitList, validationParams, recoCosmicRayHitList, targetMCParticleToHitsMap);
111 
112  // Do not change the hit share fraction (these hits are classed as 'ambiguous' and should not be in the metrics)
113  LArMuonLeadingHelper::ValidationParameters allValidationParams(m_validationParameters);
114  allValidationParams.m_minPrimaryGoodHits = 0;
115  allValidationParams.m_minHitsForGoodView = 0;
116  allValidationParams.m_minHitSharingFraction = minHitSharingFraction;
117  LArMCParticleHelper::MCContributionMap allMCParticleToHitsMap;
119  pMCParticleList, pCaloHitList, allValidationParams, recoCosmicRayHitList, allMCParticleToHitsMap);
120 
121  validationInfo.SetTargetMCParticleToHitsMap(targetMCParticleToHitsMap);
122  validationInfo.SetAllMCParticleToHitsMap(allMCParticleToHitsMap);
123  }
124 
125  // ATTN: Can only do this because delta ray/michel hierarchy is folded back in reconstruction
126  if (pPfoList)
127  {
129  LArMCParticleHelper::GetPfoToReconstructable2DHitsMap(*pPfoList, validationInfo.GetAllMCParticleToHitsMap(), pfoToHitsMap, false);
130 
131  validationInfo.SetPfoToHitsMap(pfoToHitsMap);
132  }
133 
137  validationInfo.GetPfoToHitsMap(), {validationInfo.GetAllMCParticleToHitsMap()}, pfoToMCHitSharingMap, mcToPfoHitSharingMap);
138 
139  validationInfo.SetMCToPfoHitSharingMap(mcToPfoHitSharingMap);
140 
141  LArMCParticleHelper::MCParticleToPfoHitSharingMap interpretedMCToPfoHitSharingMap;
142  this->InterpretMatching(validationInfo, interpretedMCToPfoHitSharingMap);
143 
144  validationInfo.SetInterpretedMCToPfoHitSharingMap(interpretedMCToPfoHitSharingMap);
145 }
static void SelectReconstructableLeadingParticles(const pandora::MCParticleList *pMCParticleList, const pandora::CaloHitList *pCaloHitList, const ValidationParameters &parameters, const pandora::CaloHitList &recoMuonHitList, LArMCParticleHelper::MCContributionMap &selectedMCParticlesToHitsMap)
Select target, reconstructable mc particles in the cosmic ray hierarchy.
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
LArMuonLeadingHelper::ValidationParameters m_validationParameters
The definition of a reconstructable MCParticle.
std::unordered_map< const pandora::ParticleFlowObject *, pandora::CaloHitList > PfoContributionMap
std::map< const pandora::ParticleFlowObject *, MCParticleToSharedHitsVector > PfoToMCParticleHitSharingMap
void lar_content::MuonLeadingEventValidationAlgorithm::PrintHits ( const pandora::CaloHitList  totalCaloHitList,
const pandora::CaloHitList  leadingCaloHitList,
const std::string &  stringTag 
) const
private

Print leading MCParticle hits.

Parameters
caloHitListthe list of hits to print
isCRwhether the hits belong to a MC cosmic ray or delta ray/michel electron Print leading pfo hits
totalCaloHitListthe list of hits to print
otherShowerCaloHitListthe list of hits that in truth belong to a different shower
otherTrackCaloHitListthe list of hits that in truth belong to a cosmic ray that is not the parent
parentTrackCaloHitListthe list of hits that in truth belong to the parent cosmic ray
stringTagthe event display marker string Print hits of the parent cosmic ray
totalCaloHitListthe list of hits to print
leadingCaloHitListthe list of hits that in truth belong to the child hierarchy
stringTagthe event display marker string

Referenced by ProcessOutput().

void lar_content::MuonLeadingEventValidationAlgorithm::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 240 of file MuonLeadingEventValidationAlgorithm.cc.

References lar_content::LArMonitoringHelper::CountHitsByType(), f, FillContaminationHitsDistance(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetAllMCParticleToHitsMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetInterpretedMCToPfoHitSharingMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetMCToPfoHitSharingMap(), lar_content::LArMuonLeadingHelper::GetMuonPfoContaminationContribution(), lar_content::LArPfoHelper::GetParentPfo(), lar_content::LArMuonLeadingHelper::GetPfoMatchContamination(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetPfoToHitsMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetTargetMCParticleToHitsMap(), lar_content::LArMCParticleHelper::IsCosmicRay(), lar_content::LArMuonLeadingHelper::IsDeltaRay(), lar_content::EventValidationBaseAlgorithm::IsGoodMatch(), lar_content::LArMuonLeadingHelper::IsMichel(), m_cosmicRaysToSkip, m_deltaRayIDs, m_deltaRayMode, lar_content::EventValidationBaseAlgorithm::m_eventNumber, m_michelMode, lar_content::EventValidationBaseAlgorithm::m_treeName, m_visualize, m_writeRawMatchesToTree, PrintHits(), and lar_content::LArMCParticleHelper::SortByMomentum().

242 {
243  const LArMCParticleHelper::MCContributionMap &foldedAllMCToHitsMap(validationInfo.GetAllMCParticleToHitsMap());
244  const LArMCParticleHelper::MCContributionMap &foldedTargetMCToHitsMap(validationInfo.GetTargetMCParticleToHitsMap());
245  const LArMCParticleHelper::PfoContributionMap &foldedPfoToHitsMap(validationInfo.GetPfoToHitsMap());
246  const LArMCParticleHelper::MCParticleToPfoHitSharingMap &foldedMCToPfoHitSharingMap((fillTree && m_writeRawMatchesToTree)
247  ? validationInfo.GetMCToPfoHitSharingMap()
248  : useInterpretedMatching ? validationInfo.GetInterpretedMCToPfoHitSharingMap()
249  : validationInfo.GetMCToPfoHitSharingMap());
250 
251  // Consider only delta rays from reconstructable CR muons
252  MCParticleVector mcCRVector;
253  for (auto &entry : foldedTargetMCToHitsMap)
254  {
255  if (LArMCParticleHelper::IsCosmicRay(entry.first))
256  mcCRVector.push_back(entry.first);
257  }
258 
259  std::sort(mcCRVector.begin(), mcCRVector.end(), LArMCParticleHelper::SortByMomentum);
260 
261  // Process matches
262  int muonCount(0);
263  std::stringstream stringStream;
264 
265  for (const MCParticle *const pCosmicRay : mcCRVector)
266  {
267  // Move on if cosmic ray has not been reconstructed
268  if (foldedMCToPfoHitSharingMap.at(pCosmicRay).empty())
269  continue;
270 
271  // Cosmic ray parameters
272  int nReconstructableChildCRLs(0), nCorrectChildCRLs(0);
273 
274 #ifdef MONITORING
275  int ID_CR(0);
276  float mcE_CR(0.f), mcPX_CR(0.f), mcPY_CR(0.f), mcPZ_CR(0.f);
277  int nMCHitsTotal_CR(0), nMCHitsU_CR(0), nMCHitsV_CR(0), nMCHitsW_CR(0);
278  float mcVertexX_CR(0.f), mcVertexY_CR(0.f), mcVertexZ_CR(0.f), mcEndX_CR(0.f), mcEndY_CR(0.f), mcEndZ_CR(0.f);
279 #endif
280 
281  // Leading particle parameters
282  FloatVector mcE_CRL, mcPX_CRL, mcPY_CRL, mcPZ_CRL;
283  IntVector ID_CRL;
284  IntVector nMCHitsTotal_CRL, nMCHitsU_CRL, nMCHitsV_CRL, nMCHitsW_CRL;
285  FloatVector mcVertexX_CRL, mcVertexY_CRL, mcVertexZ_CRL, mcEndX_CRL, mcEndY_CRL, mcEndZ_CRL;
286  IntVector nAboveThresholdMatches_CRL, isCorrect_CRL, isCorrectParentLink_CRL;
287  IntVector bestMatchNHitsTotal_CRL, bestMatchNHitsU_CRL, bestMatchNHitsV_CRL, bestMatchNHitsW_CRL;
288  IntVector bestMatchNSharedHitsTotal_CRL, bestMatchNSharedHitsU_CRL, bestMatchNSharedHitsV_CRL, bestMatchNSharedHitsW_CRL;
289  IntVector bestMatchNParentTrackHitsTotal_CRL, bestMatchNParentTrackHitsU_CRL, bestMatchNParentTrackHitsV_CRL, bestMatchNParentTrackHitsW_CRL;
290  IntVector bestMatchNOtherTrackHitsTotal_CRL, bestMatchNOtherTrackHitsU_CRL, bestMatchNOtherTrackHitsV_CRL, bestMatchNOtherTrackHitsW_CRL;
291  IntVector bestMatchNOtherShowerHitsTotal_CRL, bestMatchNOtherShowerHitsU_CRL, bestMatchNOtherShowerHitsV_CRL, bestMatchNOtherShowerHitsW_CRL;
292  IntVector totalCRLHitsInBestMatchParentCR_CRL, uCRLHitsInBestMatchParentCR_CRL, vCRLHitsInBestMatchParentCR_CRL, wCRLHitsInBestMatchParentCR_CRL;
293  FloatVector bestMatchVertexX_CRL, bestMatchVertexY_CRL, bestMatchVertexZ_CRL;
294 
295  // Contamination parameters
296  IntVector bestMatchOtherShowerHitsID_CRL, bestMatchOtherTrackHitsID_CRL, bestMatchParentTrackHitsID_CRL, bestMatchCRLHitsInCRID_CRL;
297  FloatVector bestMatchOtherShowerHitsDistance_CRL, bestMatchOtherTrackHitsDistance_CRL, bestMatchParentTrackHitsDistance_CRL,
298  bestMatchCRLHitsInCRDistance_CRL;
299 
300  // Obtain reconstructable leading particles
301  MCParticleVector childLeadingParticles;
302 
303  for (const MCParticle *const pCosmicRayChild : pCosmicRay->GetDaughterList())
304  {
305  if (!m_deltaRayIDs.empty())
306  {
307  int mcIndex((size_t)(intptr_t *)pCosmicRayChild->GetUid());
308 
309  if (std::find(m_deltaRayIDs.begin(), m_deltaRayIDs.end(), mcIndex) == m_deltaRayIDs.end())
310  continue;
311  }
312 
313  if (m_deltaRayMode && (!LArMuonLeadingHelper::IsDeltaRay(pCosmicRayChild)))
314  continue;
315 
316  if (m_michelMode && (!LArMuonLeadingHelper::IsMichel(pCosmicRayChild)))
317  continue;
318 
319  // Move on if leading particle is not reconstructable
320  if (foldedTargetMCToHitsMap.find(pCosmicRayChild) == foldedTargetMCToHitsMap.end())
321  continue;
322 
323  childLeadingParticles.push_back(pCosmicRayChild);
324  }
325 
326  // Move on if cosmic ray has no leading delta ray child particles
327  if (childLeadingParticles.empty())
328  continue;
329 
330  std::sort(childLeadingParticles.begin(), childLeadingParticles.end(), LArMCParticleHelper::SortByMomentum);
331 
332  ++muonCount;
333 
334  if (muonCount < (m_cosmicRaysToSkip))
335  continue;
336 
337  // Pull cosmic ray info
338  const CaloHitList &cosmicRayHitList(foldedAllMCToHitsMap.at(pCosmicRay));
339 
341  if (m_visualize && useInterpretedMatching)
342  {
343 #ifdef MONITORING
344  std::cout << "MC COSMIC RAY HITS" << std::endl;
345  this->PrintHits(cosmicRayHitList, true);
346 
347  const CartesianVector vertex(pCosmicRay->GetVertex()), endpoint(pCosmicRay->GetEndpoint());
348  const float x0(cosmicRayHitList.front()->GetX0());
349  const CartesianVector shiftedVertex(vertex.GetX() - x0, vertex.GetY(), vertex.GetZ());
350  const CartesianVector shiftedEndpoint(endpoint.GetX() - x0, vertex.GetY(), vertex.GetZ());
351 
352  PandoraMonitoringApi::AddMarkerToVisualization(this->GetPandora(), &shiftedVertex, "T0 shifted vertex ", BLACK, 2);
353  PandoraMonitoringApi::AddMarkerToVisualization(this->GetPandora(), &shiftedEndpoint, "T0 shifted endpoint", BLACK, 2);
354  PandoraMonitoringApi::ViewEvent(this->GetPandora());
355 #endif
356  }
358 
359 #ifdef MONITORING
360  ID_CR = muonCount;
361  mcE_CR = pCosmicRay->GetEnergy();
362  mcPX_CR = pCosmicRay->GetMomentum().GetX();
363  mcPY_CR = pCosmicRay->GetMomentum().GetY();
364  mcPZ_CR = pCosmicRay->GetMomentum().GetZ();
365  mcVertexX_CR = pCosmicRay->GetVertex().GetX();
366  mcVertexY_CR = pCosmicRay->GetVertex().GetY();
367  mcVertexZ_CR = pCosmicRay->GetVertex().GetZ();
368  mcEndX_CR = pCosmicRay->GetEndpoint().GetX();
369  mcEndY_CR = pCosmicRay->GetEndpoint().GetY();
370  mcEndZ_CR = pCosmicRay->GetEndpoint().GetZ();
371  nMCHitsTotal_CR = cosmicRayHitList.size();
372  nMCHitsU_CR = LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, cosmicRayHitList);
373  nMCHitsV_CR = LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, cosmicRayHitList);
374  nMCHitsW_CR = LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, cosmicRayHitList);
375 #endif
376  nReconstructableChildCRLs = childLeadingParticles.size();
377 
378  stringStream << "\033[34m"
379  << "(Parent CR: " << muonCount << ") "
380  << "\033[0m"
381  << "Energy " << pCosmicRay->GetEnergy() << ", Dist. " << (pCosmicRay->GetEndpoint() - pCosmicRay->GetVertex()).GetMagnitude()
382  << ", nMCHits " << cosmicRayHitList.size() << " (" << LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, cosmicRayHitList)
383  << ", " << LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, cosmicRayHitList) << ", "
384  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, cosmicRayHitList) << ")"
385  << ", nReconstructableCRLs " << nReconstructableChildCRLs << std::endl;
386 
387  // Pull delta ray info
388  int leadingCount(0);
389 
390  for (const MCParticle *const pLeadingParticle : childLeadingParticles)
391  {
392  ++leadingCount;
393 
394  // Pull delta ray MC info
395  const CaloHitList &leadingParticleHitList(foldedAllMCToHitsMap.at(pLeadingParticle));
396 
398  if (m_visualize && useInterpretedMatching)
399  {
400 #ifdef MONITORING
401  size_t mcIndex((size_t)(intptr_t *)pLeadingParticle->GetUid());
402 
403  std::cout << "mcID: " << mcIndex << std::endl;
404  std::cout << "MC DELTA RAY HITS" << std::endl;
405 
406  this->PrintHits(leadingParticleHitList, false);
407 
408  const CartesianVector vertex(pLeadingParticle->GetVertex()), endpoint(pLeadingParticle->GetEndpoint());
409  const float x0(leadingParticleHitList.front()->GetX0());
410  const CartesianVector shiftedVertex(vertex.GetX() - x0, vertex.GetY(), vertex.GetZ());
411  const CartesianVector shiftedEndpoint(endpoint.GetX() - x0, vertex.GetY(), vertex.GetZ());
412 
413  PandoraMonitoringApi::AddMarkerToVisualization(this->GetPandora(), &shiftedVertex, "T0 shifted vertex", BLACK, 2);
414  PandoraMonitoringApi::AddMarkerToVisualization(this->GetPandora(), &shiftedEndpoint, "T0 shifted endpoint", BLACK, 2);
415  PandoraMonitoringApi::ViewEvent(this->GetPandora());
416 #endif
417  }
419 
420  mcE_CRL.push_back(pLeadingParticle->GetEnergy());
421  ID_CRL.push_back(leadingCount);
422  mcPX_CRL.push_back(pLeadingParticle->GetMomentum().GetX());
423  mcPY_CRL.push_back(pLeadingParticle->GetMomentum().GetY());
424  mcPZ_CRL.push_back(pLeadingParticle->GetMomentum().GetZ());
425  mcVertexX_CRL.push_back(pLeadingParticle->GetVertex().GetX());
426  mcVertexY_CRL.push_back(pLeadingParticle->GetVertex().GetY());
427  mcVertexZ_CRL.push_back(pLeadingParticle->GetVertex().GetZ());
428  mcEndX_CRL.push_back(pLeadingParticle->GetEndpoint().GetX());
429  mcEndY_CRL.push_back(pLeadingParticle->GetEndpoint().GetY());
430  mcEndZ_CRL.push_back(pLeadingParticle->GetEndpoint().GetZ());
431  nMCHitsTotal_CRL.push_back(leadingParticleHitList.size());
432  nMCHitsU_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, leadingParticleHitList));
433  nMCHitsV_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, leadingParticleHitList));
434  nMCHitsW_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, leadingParticleHitList));
435 
436  stringStream << "\033[33m"
437  << "(Child " << (m_deltaRayMode ? "DR: " : "Michel: ") << leadingCount << ") "
438  << "\033[0m"
439  << "Energy " << pLeadingParticle->GetEnergy() << ", Dist. "
440  << (pLeadingParticle->GetEndpoint() - pLeadingParticle->GetVertex()).GetMagnitude() << ", nMCHits "
441  << leadingParticleHitList.size() << " (" << LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, leadingParticleHitList)
442  << ", " << LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, leadingParticleHitList) << ", "
443  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, leadingParticleHitList) << ")" << std::endl;
444 
445  // Look at the pfo matches
446  int nAboveThresholdMatches(0);
447  bool isCorrectParentLink(false);
448 
449  for (const LArMCParticleHelper::PfoCaloHitListPair &pfoToSharedHits : foldedMCToPfoHitSharingMap.at(pLeadingParticle))
450  {
451  const ParticleFlowObject *const pMatchedPfo(pfoToSharedHits.first);
452  const CaloHitList &pfoHitList(foldedPfoToHitsMap.at(pMatchedPfo));
453  const CaloHitList &sharedHitList(pfoToSharedHits.second);
454  const bool isGoodMatch(this->IsGoodMatch(leadingParticleHitList, pfoHitList, sharedHitList));
455 
456  if (isGoodMatch)
457  ++nAboveThresholdMatches;
458 
459  CaloHitList parentTrackHits, otherTrackHits, otherShowerHits;
460  LArMuonLeadingHelper::GetPfoMatchContamination(pLeadingParticle, pfoHitList, parentTrackHits, otherTrackHits, otherShowerHits);
461 
462  // Check whether the reconstructed pfo has the correct parent-child link
463  CaloHitList mcParentMatchedPfoHits;
464  bool isMatchedToCorrectCosmicRay(false);
465  const ParticleFlowObject *const pParentPfo(LArPfoHelper::GetParentPfo(pMatchedPfo));
466 
468  foldedMCToPfoHitSharingMap.at(pCosmicRay).begin();
469  cosmicRayMatchedPfoPair != foldedMCToPfoHitSharingMap.at(pCosmicRay).end(); ++cosmicRayMatchedPfoPair)
470  {
471  const ParticleFlowObject *const pCosmicRayPfo(cosmicRayMatchedPfoPair->first);
472 
473  mcParentMatchedPfoHits.insert(mcParentMatchedPfoHits.end(), foldedPfoToHitsMap.at(pCosmicRayPfo).begin(),
474  foldedPfoToHitsMap.at(pCosmicRayPfo).end());
475 
476  if (pCosmicRayPfo == pParentPfo)
477  isMatchedToCorrectCosmicRay = true;
478  }
479 
480  CaloHitList leadingParticleHitsInParentCosmicRay;
482  mcParentMatchedPfoHits, leadingParticleHitList, leadingParticleHitsInParentCosmicRay);
483 
484  if ((nAboveThresholdMatches == 1) && isGoodMatch)
485  {
486  isCorrectParentLink = isMatchedToCorrectCosmicRay;
487 
488  bestMatchNHitsTotal_CRL.push_back(pfoHitList.size());
489  bestMatchNHitsU_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, pfoHitList));
490  bestMatchNHitsV_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, pfoHitList));
491  bestMatchNHitsW_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, pfoHitList));
492 
493  bestMatchNSharedHitsTotal_CRL.push_back(sharedHitList.size());
494  bestMatchNSharedHitsU_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, sharedHitList));
495  bestMatchNSharedHitsV_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, sharedHitList));
496  bestMatchNSharedHitsW_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, sharedHitList));
497 
498  bestMatchNParentTrackHitsTotal_CRL.push_back(parentTrackHits.size());
499  bestMatchNParentTrackHitsU_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, parentTrackHits));
500  bestMatchNParentTrackHitsV_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, parentTrackHits));
501  bestMatchNParentTrackHitsW_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, parentTrackHits));
502 
503  bestMatchNOtherTrackHitsTotal_CRL.push_back(otherTrackHits.size());
504  bestMatchNOtherTrackHitsU_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, otherTrackHits));
505  bestMatchNOtherTrackHitsV_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, otherTrackHits));
506  bestMatchNOtherTrackHitsW_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, otherTrackHits));
507 
508  bestMatchNOtherShowerHitsTotal_CRL.push_back(otherShowerHits.size());
509  bestMatchNOtherShowerHitsU_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, otherShowerHits));
510  bestMatchNOtherShowerHitsV_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, otherShowerHits));
511  bestMatchNOtherShowerHitsW_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, otherShowerHits));
512 
513  totalCRLHitsInBestMatchParentCR_CRL.push_back(leadingParticleHitsInParentCosmicRay.size());
514  uCRLHitsInBestMatchParentCR_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, leadingParticleHitsInParentCosmicRay));
515  vCRLHitsInBestMatchParentCR_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, leadingParticleHitsInParentCosmicRay));
516  wCRLHitsInBestMatchParentCR_CRL.push_back(LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, leadingParticleHitsInParentCosmicRay));
517 
518  bestMatchOtherShowerHitsID_CRL.insert(bestMatchOtherShowerHitsID_CRL.end(), otherShowerHits.size(), leadingCount);
519  this->FillContaminationHitsDistance(otherShowerHits, leadingParticleHitList, bestMatchOtherShowerHitsDistance_CRL);
520 
521  bestMatchOtherTrackHitsID_CRL.insert(bestMatchOtherTrackHitsID_CRL.end(), otherTrackHits.size(), leadingCount);
522  this->FillContaminationHitsDistance(otherTrackHits, leadingParticleHitList, bestMatchOtherTrackHitsDistance_CRL);
523 
524  bestMatchParentTrackHitsID_CRL.insert(bestMatchParentTrackHitsID_CRL.end(), parentTrackHits.size(), leadingCount);
525  this->FillContaminationHitsDistance(parentTrackHits, leadingParticleHitList, bestMatchParentTrackHitsDistance_CRL);
526 
527  bestMatchCRLHitsInCRID_CRL.insert(bestMatchCRLHitsInCRID_CRL.end(), leadingParticleHitsInParentCosmicRay.size(), leadingCount);
528  this->FillContaminationHitsDistance(leadingParticleHitsInParentCosmicRay, cosmicRayHitList, bestMatchCRLHitsInCRDistance_CRL);
529 
530  const VertexList &deltaRayVertexList(pMatchedPfo->GetVertexList());
531 
532  if (deltaRayVertexList.size() > 1)
533  {
534  std::cout << "ISOBEL: DELTA RAY RECO VERTEX LIST LARGER THAN 1" << std::endl;
535  throw;
536  }
537 
538  bestMatchVertexX_CRL.push_back(deltaRayVertexList.empty() ? 1000001 : deltaRayVertexList.front()->GetPosition().GetX());
539  bestMatchVertexY_CRL.push_back(deltaRayVertexList.empty() ? 1000001 : deltaRayVertexList.front()->GetPosition().GetY());
540  bestMatchVertexZ_CRL.push_back(deltaRayVertexList.empty() ? 1000001 : deltaRayVertexList.front()->GetPosition().GetZ());
541  }
542 
543  stringStream << "-" << (!isGoodMatch ? "(Below threshold) " : "") << "nPfoHits " << pfoHitList.size() << " ("
544  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, pfoHitList) << ", "
545  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, pfoHitList) << ", "
546  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, pfoHitList) << ")"
547  << ", nMatchedHits " << sharedHitList.size() << " (" << LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, sharedHitList)
548  << ", " << LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, sharedHitList) << ", "
549  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, sharedHitList) << ")"
550  << ", nCRLHitsInParentCR " << leadingParticleHitsInParentCosmicRay.size() << " ("
551  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, leadingParticleHitsInParentCosmicRay) << ", "
552  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, leadingParticleHitsInParentCosmicRay) << ", "
553  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, leadingParticleHitsInParentCosmicRay) << ")" << std::endl
554  << (!isGoodMatch ? " " : " ") << "nParentTrackHits " << parentTrackHits.size() << " ("
555  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, parentTrackHits) << ", "
556  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, parentTrackHits) << ", "
557  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, parentTrackHits) << ")"
558  << ", nOtherTrackHits " << otherTrackHits.size() << " ("
559  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, otherTrackHits) << ", "
560  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, otherTrackHits) << ", "
561  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, otherTrackHits) << ")"
562  << ", nOtherShowerHits " << otherShowerHits.size() << " ("
563  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, otherShowerHits) << ", "
564  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, otherShowerHits) << ", "
565  << LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, otherShowerHits) << ")" << std::endl
566  << (!isGoodMatch ? " " : " ") << (isMatchedToCorrectCosmicRay ? "Correct" : "Incorrect") << "\033[0m"
567  << " parent link" << std::endl;
568 
570  if (m_visualize && useInterpretedMatching)
571  {
572 #ifdef MONITORING
573  std::cout << stringStream.str() << std::endl;
574  std::cout << "DELTA RAY PFO HITS" << std::endl;
575 
576  this->PrintHits(pfoHitList, otherShowerHits, otherTrackHits, parentTrackHits, "DR_PFO");
577 
578  if (pParentPfo != pMatchedPfo)
579  {
580  std::cout << "PARENT PFO" << std::endl;
581 
582  const CaloHitList &parentCRHits(foldedPfoToHitsMap.at(pParentPfo));
583  this->PrintHits(parentCRHits, leadingParticleHitList, "DR_PARENT_PFO");
584  }
585 
586  const VertexList &deltaRayVertexList(pMatchedPfo->GetVertexList());
587 
588  if (deltaRayVertexList.size() > 1)
589  {
590  std::cout << "ISOBEL: DELTA RAY RECO VERTEX LIST LARGER THAN 1" << std::endl;
591  throw;
592  }
593 
594  if (deltaRayVertexList.empty())
595  {
596  std::cout << "No reconstructed vertex" << std::endl;
597  }
598  else
599  {
600  const PfoList deltaRayList({pMatchedPfo}), cosmicList({pParentPfo});
601  const CartesianVector &vertex(deltaRayVertexList.front()->GetPosition());
602 
603  PandoraMonitoringApi::VisualizeParticleFlowObjects(this->GetPandora(), &deltaRayList, "Delta Ray Pfo", BLACK, false, false);
604  PandoraMonitoringApi::VisualizeParticleFlowObjects(this->GetPandora(), &cosmicList, "Delta Ray Pfo", RED, false, false);
605  PandoraMonitoringApi::AddMarkerToVisualization(this->GetPandora(), &vertex, "vertex", RED, 2);
606  PandoraMonitoringApi::ViewEvent(this->GetPandora());
607  }
608 #endif
609  }
611  }
612 
613  nAboveThresholdMatches_CRL.push_back(nAboveThresholdMatches);
614  isCorrectParentLink_CRL.push_back(isCorrectParentLink ? 1 : 0);
615 
616  const bool isCorrect((nAboveThresholdMatches == 1) && isCorrectParentLink);
617 
618  if (isCorrect)
619  {
620  ++nCorrectChildCRLs;
621  isCorrect_CRL.push_back(1);
622  }
623  else
624  {
625  isCorrect_CRL.push_back(0);
626  }
627 
628  if (foldedMCToPfoHitSharingMap.at(pLeadingParticle).empty())
629  {
630  stringStream << "-"
631  << "No matched pfo" << std::endl;
632 
633  if (m_visualize && useInterpretedMatching)
634  std::cout << stringStream.str() << std::endl;
635  }
636 
637  if (nAboveThresholdMatches == 0)
638  {
639  bestMatchNHitsTotal_CRL.push_back(0);
640  bestMatchNHitsU_CRL.push_back(0);
641  bestMatchNHitsV_CRL.push_back(0);
642  bestMatchNHitsW_CRL.push_back(0);
643  bestMatchNSharedHitsTotal_CRL.push_back(0);
644  bestMatchNSharedHitsU_CRL.push_back(0);
645  bestMatchNSharedHitsV_CRL.push_back(0);
646  bestMatchNSharedHitsW_CRL.push_back(0);
647  bestMatchNParentTrackHitsTotal_CRL.push_back(0);
648  bestMatchNParentTrackHitsU_CRL.push_back(0);
649  bestMatchNParentTrackHitsV_CRL.push_back(0);
650  bestMatchNParentTrackHitsW_CRL.push_back(0);
651  bestMatchNOtherTrackHitsTotal_CRL.push_back(0);
652  bestMatchNOtherTrackHitsU_CRL.push_back(0), bestMatchNOtherTrackHitsV_CRL.push_back(0);
653  bestMatchNOtherTrackHitsW_CRL.push_back(0);
654  bestMatchNOtherShowerHitsTotal_CRL.push_back(0);
655  bestMatchNOtherShowerHitsU_CRL.push_back(0);
656  bestMatchNOtherShowerHitsV_CRL.push_back(0), bestMatchNOtherShowerHitsW_CRL.push_back(0);
657  totalCRLHitsInBestMatchParentCR_CRL.push_back(0);
658  uCRLHitsInBestMatchParentCR_CRL.push_back(0);
659  vCRLHitsInBestMatchParentCR_CRL.push_back(0);
660  wCRLHitsInBestMatchParentCR_CRL.push_back(0);
661  }
662 
663  stringStream << nAboveThresholdMatches << " above threshold matches" << std::endl
664  << "Reconstruction is " << (isCorrect ? "\033[32m" : "\033[31m") << (isCorrect ? "CORRECT" : "INCORRECT")
665  << "\033[0m" << std::endl;
666 
667  if (m_visualize && useInterpretedMatching)
668  std::cout << stringStream.str() << std::endl;
669  }
670 
671  if (fillTree)
672  {
673  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "eventNumber", m_eventNumber - 1));
674  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "ID_CR", ID_CR));
675  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcE_CR", mcE_CR));
676  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPX_CR", mcPX_CR));
677  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPY_CR", mcPY_CR));
678  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPZ_CR", mcPZ_CR));
679  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "nMCHitsTotal_CR", nMCHitsTotal_CR));
680  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "nMCHitsU_CR", nMCHitsU_CR));
681  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "nMCHitsV_CR", nMCHitsV_CR));
682  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "nMCHitsW_CR", nMCHitsW_CR));
683  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcVertexX_CR", mcVertexX_CR));
684  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcVertexY_CR", mcVertexY_CR));
685  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcVertexZ_CR", mcVertexZ_CR));
686  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcEndX_CR", mcEndX_CR));
687  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcEndY_CR", mcEndY_CR));
688  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcEndZ_CR", mcEndZ_CR));
689  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "nReconstructableChildCRLs", nReconstructableChildCRLs));
690  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "nCorrectChildCRLs", nCorrectChildCRLs));
691 
692  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "ID_CRL", &ID_CRL));
693  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcE_CRL", &mcE_CRL));
694  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPX_CRL", &mcPX_CRL));
695  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPY_CRL", &mcPY_CRL));
696  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcPZ_CRL", &mcPZ_CRL));
697  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "nMCHitsTotal_CRL", &nMCHitsTotal_CRL));
698  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "nMCHitsU_CRL", &nMCHitsU_CRL));
699  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "nMCHitsV_CRL", &nMCHitsV_CRL));
700  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "nMCHitsW_CRL", &nMCHitsW_CRL));
701  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcVertexX_CRL", &mcVertexX_CRL));
702  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcVertexY_CRL", &mcVertexY_CRL));
703  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcVertexZ_CRL", &mcVertexZ_CRL));
704  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcEndX_CRL", &mcEndX_CRL));
705  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcEndY_CRL", &mcEndY_CRL));
706  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "mcEndZ_CRL", &mcEndZ_CRL));
707  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "nAboveThresholdMatches_CRL", &nAboveThresholdMatches_CRL));
708  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "isCorrect_CRL", &isCorrect_CRL));
709  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "isCorrectParentLink_CRL", &isCorrectParentLink_CRL));
710  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchNHitsTotal_CRL", &bestMatchNHitsTotal_CRL));
711  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchNHitsU_CRL", &bestMatchNHitsU_CRL));
712  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchNHitsV_CRL", &bestMatchNHitsV_CRL));
713  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchNHitsW_CRL", &bestMatchNHitsW_CRL));
714  PANDORA_MONITORING_API(
715  SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchNSharedHitsTotal_CRL", &bestMatchNSharedHitsTotal_CRL));
716  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchNSharedHitsU_CRL", &bestMatchNSharedHitsU_CRL));
717  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchNSharedHitsV_CRL", &bestMatchNSharedHitsV_CRL));
718  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchNSharedHitsW_CRL", &bestMatchNSharedHitsW_CRL));
719  PANDORA_MONITORING_API(SetTreeVariable(
720  this->GetPandora(), m_treeName.c_str(), "bestMatchNParentTrackHitsTotal_CRL", &bestMatchNParentTrackHitsTotal_CRL));
721  PANDORA_MONITORING_API(
722  SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchNParentTrackHitsU_CRL", &bestMatchNParentTrackHitsU_CRL));
723  PANDORA_MONITORING_API(
724  SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchNParentTrackHitsV_CRL", &bestMatchNParentTrackHitsV_CRL));
725  PANDORA_MONITORING_API(
726  SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchNParentTrackHitsW_CRL", &bestMatchNParentTrackHitsW_CRL));
727  PANDORA_MONITORING_API(
728  SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchNOtherTrackHitsTotal_CRL", &bestMatchNOtherTrackHitsTotal_CRL));
729  PANDORA_MONITORING_API(
730  SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchNOtherTrackHitsU_CRL", &bestMatchNOtherTrackHitsU_CRL));
731  PANDORA_MONITORING_API(
732  SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchNOtherTrackHitsV_CRL", &bestMatchNOtherTrackHitsV_CRL));
733  PANDORA_MONITORING_API(
734  SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchNOtherTrackHitsW_CRL", &bestMatchNOtherTrackHitsW_CRL));
735  PANDORA_MONITORING_API(SetTreeVariable(
736  this->GetPandora(), m_treeName.c_str(), "bestMatchNOtherShowerHitsTotal_CRL", &bestMatchNOtherShowerHitsTotal_CRL));
737  PANDORA_MONITORING_API(
738  SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchNOtherShowerHitsU_CRL", &bestMatchNOtherShowerHitsU_CRL));
739  PANDORA_MONITORING_API(
740  SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchNOtherShowerHitsV_CRL", &bestMatchNOtherShowerHitsV_CRL));
741  PANDORA_MONITORING_API(
742  SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchNOtherShowerHitsW_CRL", &bestMatchNOtherShowerHitsW_CRL));
743  PANDORA_MONITORING_API(SetTreeVariable(
744  this->GetPandora(), m_treeName.c_str(), "totalCRLHitsInBestMatchParentCR_CRL", &totalCRLHitsInBestMatchParentCR_CRL));
745  PANDORA_MONITORING_API(
746  SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "uCRLHitsInBestMatchParentCR_CRL", &uCRLHitsInBestMatchParentCR_CRL));
747  PANDORA_MONITORING_API(
748  SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "vCRLHitsInBestMatchParentCR_CRL", &vCRLHitsInBestMatchParentCR_CRL));
749  PANDORA_MONITORING_API(
750  SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "wCRLHitsInBestMatchParentCR_CRL", &wCRLHitsInBestMatchParentCR_CRL));
751 
752  PANDORA_MONITORING_API(
753  SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchOtherShowerHitsID_CRL", &bestMatchOtherShowerHitsID_CRL));
754  PANDORA_MONITORING_API(SetTreeVariable(
755  this->GetPandora(), m_treeName.c_str(), "bestMatchOtherShowerHitsDistance_CRL", &bestMatchOtherShowerHitsDistance_CRL));
756  PANDORA_MONITORING_API(
757  SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchOtherTrackHitsID_CRL", &bestMatchOtherTrackHitsID_CRL));
758  PANDORA_MONITORING_API(SetTreeVariable(
759  this->GetPandora(), m_treeName.c_str(), "bestMatchOtherTrackHitsDistance_CRL", &bestMatchOtherTrackHitsDistance_CRL));
760  PANDORA_MONITORING_API(
761  SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchParentTrackHitsID_CRL", &bestMatchParentTrackHitsID_CRL));
762  PANDORA_MONITORING_API(SetTreeVariable(
763  this->GetPandora(), m_treeName.c_str(), "bestMatchParentTrackHitsDistance_CRL", &bestMatchParentTrackHitsDistance_CRL));
764  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchCRLHitsInCRID_CRL", &bestMatchCRLHitsInCRID_CRL));
765  PANDORA_MONITORING_API(
766  SetTreeVariable(this->GetPandora(), m_treeName.c_str(), "bestMatchCRLHitsInCRDistance_CRL", &bestMatchCRLHitsInCRDistance_CRL));
767 
768  PANDORA_MONITORING_API(FillTree(this->GetPandora(), m_treeName.c_str()));
769  }
770 
771  stringStream << "------------------------------------------------------------------------------------------------" << std::endl;
772  stringStream << nCorrectChildCRLs << " / " << nReconstructableChildCRLs << " CRLs correctly reconstructed" << std::endl;
773  stringStream << "------------------------------------------------------------------------------------------------" << std::endl;
774  stringStream << "------------------------------------------------------------------------------------------------" << std::endl;
775  }
776 
777  if (printToScreen && !(m_visualize && useInterpretedMatching))
778  {
779  std::cout << stringStream.str() << std::endl;
780  }
781 }
static void GetMuonPfoContaminationContribution(const pandora::CaloHitList &cosmicRayPfoHitList, const pandora::CaloHitList &leadingMCHitList, pandora::CaloHitList &leadingHitsInParentCosmicRay)
Determine the leading MCParticle hits within a cosmic ray pfo hit list.
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCContributionMap
std::map< const pandora::MCParticle *, PfoToSharedHitsVector > MCParticleToPfoHitSharingMap
intermediate_table::const_iterator const_iterator
std::vector< int > m_deltaRayIDs
If filled, to contain the list leading particles to run metrics over.
std::vector< int > IntVector
bool m_visualize
Whether to visualize the MC and reco leading particles.
int m_cosmicRaysToSkip
The number of reconstructable cosmic rays to skip.
TFile f
Definition: plotHisto.C:6
static bool SortByMomentum(const pandora::MCParticle *const pLhs, const pandora::MCParticle *const pRhs)
Sort mc particles by their momentum.
static bool IsCosmicRay(const pandora::MCParticle *const pMCParticle)
Return true if passed a primary cosmic ray MCParticle.
static bool IsMichel(const pandora::MCParticle *const pMCParticle)
Return true if input MCParticle is a child of a cosmic ray and has &#39;decay&#39; process tag...
static const pandora::ParticleFlowObject * GetParentPfo(const pandora::ParticleFlowObject *const pPfo)
Get the primary parent pfo.
static void GetPfoMatchContamination(const pandora::MCParticle *const pLeadingParticle, const pandora::CaloHitList &matchedPfoHitList, pandora::CaloHitList &parentTrackHits, pandora::CaloHitList &otherTrackHits, pandora::CaloHitList &otherShowerHits)
Separate a leading pfo hit list according to the true owner of the hit e.g. other shower...
void PrintHits(const pandora::CaloHitList totalCaloHitList, const pandora::CaloHitList leadingCaloHitList, const std::string &stringTag) const
Print leading MCParticle hits.
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
void FillContaminationHitsDistance(const pandora::CaloHitList &contaminationHits, const pandora::CaloHitList &leadingMCHits, pandora::FloatVector &bestMatchContaminationHitsDistance) const
Fill an input contamination hit distance vector with the closest distance of each contaminant hit to ...
std::pair< const pandora::ParticleFlowObject *, pandora::CaloHitList > PfoCaloHitListPair
bool m_writeRawMatchesToTree
Whether to write all matches to output tree.
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
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.
std::list< Vertex > VertexList
Definition: DCEL.h:169
static bool IsDeltaRay(const pandora::MCParticle *const pMCParticle)
Return true if input MCParticle is a child of a cosmic ray and has &#39;delta ray&#39; process tag...
vertex reconstruction
StatusCode lar_content::MuonLeadingEventValidationAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 908 of file MuonLeadingEventValidationAlgorithm.cc.

References m_cosmicRaysToSkip, m_deltaRayIDs, m_deltaRayMode, lar_content::LArMCParticleHelper::PrimaryParameters::m_foldBackHierarchy, m_ignoreIncorrectCosmicRays, lar_content::LArMCParticleHelper::PrimaryParameters::m_maxPhotonPropagation, m_michelMode, lar_content::LArMCParticleHelper::PrimaryParameters::m_minHitsForGoodView, lar_content::LArMCParticleHelper::PrimaryParameters::m_minHitSharingFraction, lar_content::LArMCParticleHelper::PrimaryParameters::m_minPrimaryGoodHits, lar_content::LArMCParticleHelper::PrimaryParameters::m_minPrimaryGoodViews, m_removeRecoCosmicRayHits, lar_content::LArMCParticleHelper::PrimaryParameters::m_selectInputHits, m_validationParameters, m_visualize, m_writeRawMatchesToTree, and lar_content::EventValidationBaseAlgorithm::ReadSettings().

909 {
910  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
911  XmlHelper::ReadValue(xmlHandle, "MinPrimaryGoodHits", m_validationParameters.m_minPrimaryGoodHits));
912 
913  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
914  XmlHelper::ReadValue(xmlHandle, "MinHitsForGoodView", m_validationParameters.m_minHitsForGoodView));
915 
916  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
917  XmlHelper::ReadValue(xmlHandle, "MinPrimaryGoodViews", m_validationParameters.m_minPrimaryGoodViews));
918 
919  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
920  XmlHelper::ReadValue(xmlHandle, "SelectInputHits", m_validationParameters.m_selectInputHits));
921 
922  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
923  XmlHelper::ReadValue(xmlHandle, "MinHitSharingFraction", m_validationParameters.m_minHitSharingFraction));
924 
925  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
926  XmlHelper::ReadValue(xmlHandle, "MaxPhotonPropagation", m_validationParameters.m_maxPhotonPropagation));
927 
928  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
929  XmlHelper::ReadValue(xmlHandle, "FoldToPrimaries", m_validationParameters.m_foldBackHierarchy));
930 
932 
933  PANDORA_RETURN_RESULT_IF_AND_IF(
934  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "DeltaRayIDs", m_deltaRayIDs));
935 
936  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "DeltaRayMode", m_deltaRayMode));
937 
938  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MichelMode", m_michelMode));
939 
940  PANDORA_RETURN_RESULT_IF_AND_IF(
941  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "CosmicRaysToSkip", m_cosmicRaysToSkip));
942 
943  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "Visualize", m_visualize));
944 
945  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
946  XmlHelper::ReadValue(xmlHandle, "RemoveRecoCosmicRayHits", m_removeRecoCosmicRayHits));
947 
948  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
949  XmlHelper::ReadValue(xmlHandle, "IgnoreIncorrectCosmicRays", m_ignoreIncorrectCosmicRays));
950 
951  PANDORA_RETURN_RESULT_IF_AND_IF(
952  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "WriteRawMatchesToTree", m_writeRawMatchesToTree));
953 
955 }
unsigned int m_minPrimaryGoodViews
the minimum number of primary good views
bool m_removeRecoCosmicRayHits
Whether to remove the reconstructed cosmic ray hits from leading particle metrics.
bool m_selectInputHits
whether to select input hits
unsigned int m_minPrimaryGoodHits
the minimum number of primary good Hits
std::vector< int > m_deltaRayIDs
If filled, to contain the list leading particles to run metrics over.
bool m_foldBackHierarchy
whether to fold the hierarchy back to the primary (neutrino) or leading particles (test beam) ...
unsigned int m_minHitsForGoodView
the minimum number of Hits for a good view
bool m_visualize
Whether to visualize the MC and reco leading particles.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
float m_maxPhotonPropagation
the maximum photon propagation length
int m_cosmicRaysToSkip
The number of reconstructable cosmic rays to skip.
bool m_ignoreIncorrectCosmicRays
Whether to remove the leading particles with incorrrectly reconstructed parents from metrics...
float m_minHitSharingFraction
the minimum Hit sharing fraction
LArMuonLeadingHelper::ValidationParameters m_validationParameters
The definition of a reconstructable MCParticle.
bool m_writeRawMatchesToTree
Whether to write all matches to output tree.
void lar_content::MuonLeadingEventValidationAlgorithm::RemoveIncorrectlyReconstructedCosmicRays ( const pandora::MCParticleList *const  pMCParticleList,
const pandora::CaloHitList *const  pCaloHitList,
const pandora::PfoList *const  pPfoList,
ValidationInfo validationInfo 
) const
private

Remove incorrectly reconstructed cosmic rays from main matching maps.

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

Definition at line 149 of file MuonLeadingEventValidationAlgorithm.cc.

References DetermineIncorrectlyReconstructedCosmicRays(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetAllMCParticleToHitsMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetInterpretedMCToPfoHitSharingMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetMCToPfoHitSharingMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::GetTargetMCParticleToHitsMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::SetAllMCParticleToHitsMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::SetInterpretedMCToPfoHitSharingMap(), lar_content::EventValidationBaseAlgorithm::ValidationInfo::SetMCToPfoHitSharingMap(), and lar_content::EventValidationBaseAlgorithm::ValidationInfo::SetTargetMCParticleToHitsMap().

Referenced by FillValidationInfo().

151 {
152  MCParticleList incorrectlyReconstructedCosmicRays;
153  this->DetermineIncorrectlyReconstructedCosmicRays(pMCParticleList, pCaloHitList, pPfoList, incorrectlyReconstructedCosmicRays);
154 
155  LArMCParticleHelper::MCContributionMap allMCToHitsMap(validationInfo.GetAllMCParticleToHitsMap());
156  LArMCParticleHelper::MCContributionMap targetMCToHitsMap(validationInfo.GetTargetMCParticleToHitsMap());
157  LArMCParticleHelper::MCParticleToPfoHitSharingMap matchingMap(validationInfo.GetMCToPfoHitSharingMap());
158  LArMCParticleHelper::MCParticleToPfoHitSharingMap interpretedMatchingMap(validationInfo.GetInterpretedMCToPfoHitSharingMap());
159 
160  for (const MCParticle *const pIncorrectCosmicRay : incorrectlyReconstructedCosmicRays)
161  {
162  auto allIter(allMCToHitsMap.find(pIncorrectCosmicRay));
163 
164  if (allIter != allMCToHitsMap.end())
165  allMCToHitsMap.erase(allIter);
166 
167  auto targetIter(targetMCToHitsMap.find(pIncorrectCosmicRay));
168 
169  if (targetIter != targetMCToHitsMap.end())
170  targetMCToHitsMap.erase(targetIter);
171 
172  auto matchingIter(matchingMap.find(pIncorrectCosmicRay));
173 
174  if (matchingIter != matchingMap.end())
175  matchingMap.erase(matchingIter);
176 
177  auto interpretedMatchingIter(interpretedMatchingMap.find(pIncorrectCosmicRay));
178 
179  if (interpretedMatchingIter != interpretedMatchingMap.end())
180  interpretedMatchingMap.erase(interpretedMatchingIter);
181  }
182 
183  validationInfo.SetAllMCParticleToHitsMap(allMCToHitsMap);
184  validationInfo.SetTargetMCParticleToHitsMap(targetMCToHitsMap);
185  validationInfo.SetMCToPfoHitSharingMap(matchingMap);
186  validationInfo.SetInterpretedMCToPfoHitSharingMap(interpretedMatchingMap);
187 }
void DetermineIncorrectlyReconstructedCosmicRays(const pandora::MCParticleList *const pMCParticleList, const pandora::CaloHitList *const pCaloHitList, const pandora::PfoList *const pPfoList, pandora::MCParticleList &incorrectlyReconstructedCosmicRays) const
Perform the cosmic ray matching procedure and identify incorrectly reconstructed cosmic rays...
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCContributionMap
std::map< const pandora::MCParticle *, PfoToSharedHitsVector > MCParticleToPfoHitSharingMap

Member Data Documentation

int lar_content::MuonLeadingEventValidationAlgorithm::m_cosmicRaysToSkip
private

The number of reconstructable cosmic rays to skip.

Definition at line 168 of file MuonLeadingEventValidationAlgorithm.h.

Referenced by ProcessOutput(), and ReadSettings().

std::vector<int> lar_content::MuonLeadingEventValidationAlgorithm::m_deltaRayIDs
private

If filled, to contain the list leading particles to run metrics over.

Definition at line 172 of file MuonLeadingEventValidationAlgorithm.h.

Referenced by ProcessOutput(), and ReadSettings().

bool lar_content::MuonLeadingEventValidationAlgorithm::m_deltaRayMode
private

Whether to run in delta ray mode.

Definition at line 166 of file MuonLeadingEventValidationAlgorithm.h.

Referenced by FillValidationInfo(), ProcessOutput(), and ReadSettings().

int lar_content::EventValidationBaseAlgorithm::m_eventNumber
protectedinherited
int lar_content::EventValidationBaseAlgorithm::m_fileIdentifier
protectedinherited
bool lar_content::MuonLeadingEventValidationAlgorithm::m_ignoreIncorrectCosmicRays
private

Whether to remove the leading particles with incorrrectly reconstructed parents from metrics.

Definition at line 170 of file MuonLeadingEventValidationAlgorithm.h.

Referenced by FillValidationInfo(), and ReadSettings().

bool lar_content::MuonLeadingEventValidationAlgorithm::m_michelMode
private

Whether to run in michel mode.

Definition at line 167 of file MuonLeadingEventValidationAlgorithm.h.

Referenced by FillValidationInfo(), ProcessOutput(), and ReadSettings().

LArMCParticleHelper::PrimaryParameters lar_content::EventValidationBaseAlgorithm::m_primaryParameters
protectedinherited
bool lar_content::MuonLeadingEventValidationAlgorithm::m_removeRecoCosmicRayHits
private

Whether to remove the reconstructed cosmic ray hits from leading particle metrics.

Definition at line 165 of file MuonLeadingEventValidationAlgorithm.h.

Referenced by FillValidationInfo(), and ReadSettings().

std::string lar_content::EventValidationBaseAlgorithm::m_treeName
protectedinherited
LArMuonLeadingHelper::ValidationParameters lar_content::MuonLeadingEventValidationAlgorithm::m_validationParameters
private

The definition of a reconstructable MCParticle.

Definition at line 164 of file MuonLeadingEventValidationAlgorithm.h.

Referenced by FillValidationInfo(), PerformUnfoldedMatching(), and ReadSettings().

bool lar_content::MuonLeadingEventValidationAlgorithm::m_visualize
private

Whether to visualize the MC and reco leading particles.

Definition at line 169 of file MuonLeadingEventValidationAlgorithm.h.

Referenced by FillValidationInfo(), ProcessOutput(), and ReadSettings().

bool lar_content::MuonLeadingEventValidationAlgorithm::m_writeRawMatchesToTree
private

Whether to write all matches to output tree.

Definition at line 171 of file MuonLeadingEventValidationAlgorithm.h.

Referenced by ProcessOutput(), and ReadSettings().


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