All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Types | Private Member Functions | List of all members
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...
 

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)
 

Additional Inherited Members

- Protected Member Functions inherited from lar_content::EventValidationBaseAlgorithm
 EventValidationBaseAlgorithm ()
 Default constructor. More...
 
 ~EventValidationBaseAlgorithm ()
 Destructor. More...
 
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...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
- Protected Attributes inherited from lar_content::EventValidationBaseAlgorithm
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...
 

Detailed Description

TestBeamEventValidationAlgorithm class.

Definition at line 29 of file TestBeamEventValidationAlgorithm.h.

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.

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 -&gt; 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::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.

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

Definition at line 469 of file TestBeamEventValidationAlgorithm.cc.

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

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