94 const ValidationInfo &validationInfo,
const bool useInterpretedMatching,
const bool printToScreen,
const bool fillTree)
const
96 static int eventNumber{-1};
98 if (printToScreen && useInterpretedMatching)
99 std::cout <<
"---INTERPRETED-MATCHING-OUTPUT------------------------------------------------------------------" << std::endl;
100 else if (printToScreen)
101 std::cout <<
"---RAW-MATCHING-OUTPUT--------------------------------------------------------------------------" << std::endl;
113 int pfoIndex(0), testBeamPfoIndex(0);
116 for (
const Pfo *
const pPrimaryPfo : primaryPfoVector)
118 pfoToIdMap.insert(PfoToIdMap::value_type(pPrimaryPfo, ++pfoIndex));
121 if (pRecoTestBeam && !testBeamPfoToIdMap.count(pRecoTestBeam))
122 testBeamPfoToIdMap.insert(PfoToIdMap::value_type(pRecoTestBeam, ++testBeamPfoIndex));
129 int nCorrectTB(0), nTotalTB(0), nCorrectCR(0), nTotalCR(0), nFakeTB(0), nFakeCR(0), nSplitTB(0), nSplitCR(0), nLost(0);
130 int mcPrimaryIndex(0), nTargetMatches(0), nTargetTBMatches(0), nTargetCRMatches(0);
131 IntVector mcPrimaryId, mcPrimaryPdg, nMCHitsTotal, nMCHitsU, nMCHitsV, nMCHitsW;
132 FloatVector mcPrimaryE, mcPrimaryPX, mcPrimaryPY, mcPrimaryPZ;
133 FloatVector mcPrimaryVtxX, mcPrimaryVtxY, mcPrimaryVtxZ, mcPrimaryEndX, mcPrimaryEndY, mcPrimaryEndZ;
134 IntVector nPrimaryMatchedPfos, nPrimaryMatchedTBPfos, nPrimaryMatchedCRPfos;
135 IntVector bestMatchPfoId, bestMatchPfoPdg, bestMatchPfoIsTB;
136 IntVector bestMatchPfoNHitsTotal, bestMatchPfoNHitsU, bestMatchPfoNHitsV, bestMatchPfoNHitsW;
137 IntVector bestMatchPfoNSharedHitsTotal, bestMatchPfoNSharedHitsU, bestMatchPfoNSharedHitsV, bestMatchPfoNSharedHitsW;
140 std::stringstream targetSS;
142 for (
const MCParticle *
const pMCPrimary : mcPrimaryVector)
144 const bool hasMatch(mcToPfoHitSharingMap.count(pMCPrimary) && !mcToPfoHitSharingMap.at(pMCPrimary).empty());
147 if (!isTargetPrimary && !hasMatch)
150 associatedMCPrimaries.push_back(pMCPrimary);
158 const int nTargetPrimaries(associatedMCPrimaries.size());
160 const float targetVertexX(targetVertex.
GetX()), targetVertexY(targetVertex.
GetY()), targetVertexZ(targetVertex.
GetZ());
163 targetSS << (!isTargetPrimary ?
"(Non target) " :
"") <<
"PrimaryId " << mcPrimaryIndex <<
", TB " << isBeamParticle <<
", CR "
164 << isCosmicRay <<
", MCPDG " << pMCPrimary->GetParticleId() <<
", Energy " << pMCPrimary->GetEnergy() <<
", Dist. "
165 << (pMCPrimary->GetEndpoint() - pMCPrimary->GetVertex()).GetMagnitude() <<
", nMCHits " << mcPrimaryHitList.size() <<
" ("
170 mcPrimaryId.push_back(mcPrimaryIndex);
171 mcPrimaryPdg.push_back(pMCPrimary->GetParticleId());
172 mcPrimaryE.push_back(pMCPrimary->GetEnergy());
173 mcPrimaryPX.push_back(pMCPrimary->GetMomentum().GetX());
174 mcPrimaryPY.push_back(pMCPrimary->GetMomentum().GetY());
175 mcPrimaryPZ.push_back(pMCPrimary->GetMomentum().GetZ());
176 mcPrimaryVtxX.push_back(pMCPrimary->GetVertex().GetX());
177 mcPrimaryVtxY.push_back(pMCPrimary->GetVertex().GetY());
178 mcPrimaryVtxZ.push_back(pMCPrimary->GetVertex().GetZ());
179 mcPrimaryEndX.push_back(pMCPrimary->GetEndpoint().GetX());
180 mcPrimaryEndY.push_back(pMCPrimary->GetEndpoint().GetY());
181 mcPrimaryEndZ.push_back(pMCPrimary->GetEndpoint().GetZ());
182 nMCHitsTotal.push_back(mcPrimaryHitList.size());
187 int matchIndex(0), nPrimaryMatches(0), nPrimaryTBMatches(0), nPrimaryCRMatches(0);
189 float recoVertexX(std::numeric_limits<float>::max()), recoVertexY(std::numeric_limits<float>::max()),
190 recoVertexZ(std::numeric_limits<float>::max());
194 const CaloHitList &sharedHitList(pfoToSharedHits.second);
198 const bool isGoodMatch(this->
IsGoodMatch(mcPrimaryHitList, pfoHitList, sharedHitList));
200 const int pfoId(pfoToIdMap.at(pfoToSharedHits.first));
202 if (0 == matchIndex++)
204 bestMatchPfoId.push_back(pfoId);
205 bestMatchPfoPdg.push_back(pfoToSharedHits.first->GetParticleId());
206 bestMatchPfoIsTB.push_back(isRecoTestBeam ? 1 : 0);
207 bestMatchPfoNHitsTotal.push_back(pfoHitList.size());
211 bestMatchPfoNSharedHitsTotal.push_back(sharedHitList.size());
215 bestMatchPfoX0.push_back(pfoToSharedHits.first->GetPropertiesMap().count(
"X0") ? pfoToSharedHits.first->GetPropertiesMap().at(
"X0")
216 : std::numeric_limits<float>::max());
235 if (isRecoTestBeam && isGoodMatch)
237 if (!isRecoTestBeam && isGoodMatch)
240 targetSS <<
"-" << (!isGoodMatch ?
"(Below threshold) " :
"") <<
"MatchedPfoId " << pfoId <<
", TB " << isRecoTestBeam
241 <<
", CR " << (!isRecoTestBeam) <<
", PDG " << pfoToSharedHits.first->GetParticleId() <<
", nMatchedHits "
250 if (mcToPfoHitSharingMap.at(pMCPrimary).empty())
252 targetSS <<
"-No matched Pfo" << std::endl;
253 bestMatchPfoId.push_back(-1);
254 bestMatchPfoPdg.push_back(0);
255 bestMatchPfoIsTB.push_back(0);
256 bestMatchPfoNHitsTotal.push_back(0);
257 bestMatchPfoNHitsU.push_back(0);
258 bestMatchPfoNHitsV.push_back(0);
259 bestMatchPfoNHitsW.push_back(0);
260 bestMatchPfoNSharedHitsTotal.push_back(0);
261 bestMatchPfoNSharedHitsU.push_back(0);
262 bestMatchPfoNSharedHitsV.push_back(0);
263 bestMatchPfoNSharedHitsW.push_back(0);
264 bestMatchPfoX0.push_back(std::numeric_limits<float>::max());
267 nPrimaryMatchedPfos.push_back(nPrimaryMatches);
268 nPrimaryMatchedTBPfos.push_back(nPrimaryTBMatches);
269 nPrimaryMatchedCRPfos.push_back(nPrimaryCRMatches);
270 nTargetMatches += nPrimaryMatches;
271 nTargetTBMatches += nPrimaryTBMatches;
272 nTargetCRMatches += nPrimaryCRMatches;
324 if (isBeamParticle || isCosmicRay)
328 const int interactionTypeInt(
static_cast<int>(interactionType));
331 const int isCorrectTB(isBeamParticle && (nTargetTBMatches == 1) && (nTargetCRMatches == 0));
332 const int isCorrectCR(isCosmicRay && (nTargetTBMatches == 0) && (nTargetCRMatches == 1));
333 const int isFakeTB(isCosmicRay && (nTargetTBMatches > 0));
334 const int isFakeCR(!isCosmicRay && (nTargetCRMatches > 0));
335 const int isSplitTB(!isCosmicRay && (nTargetTBMatches > 1));
336 const int isSplitCR(isCosmicRay && (nTargetCRMatches > 1));
337 const int isLost(nTargetMatches == 0);
339 std::stringstream outcomeSS;
341 <<
", CR " << isCosmicRay <<
")" << std::endl;
363 outcomeSS <<
"IsCorrectTB ";
365 outcomeSS <<
"IsCorrectCR ";
367 outcomeSS <<
"IsFakeTB ";
369 outcomeSS <<
"IsFakeCR ";
371 outcomeSS <<
"isSplitTB ";
373 outcomeSS <<
"IsSplitCR ";
375 outcomeSS <<
"IsLost ";
376 if (nTargetTBMatches > 0)
377 outcomeSS <<
"(NTBMatches: " << nTargetTBMatches <<
") ";
378 if (nTargetCRMatches > 0)
379 outcomeSS <<
"(NCRMatches: " << nTargetCRMatches <<
") ";
381 std::cout << outcomeSS.str() << std::endl << targetSS.str() << std::endl;
396 targetSS.str(std::string());
398 associatedMCPrimaries.clear();
400 nTargetTBMatches = 0;
401 nTargetCRMatches = 0;
403 mcPrimaryPdg.clear();
404 nMCHitsTotal.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();
436 if (useInterpretedMatching)
438 std::stringstream summarySS;
439 summarySS <<
"---SUMMARY--------------------------------------------------------------------------------------" << std::endl;
441 summarySS <<
"#CorrectTB: " << nCorrectTB <<
"/" << nTotalTB
442 <<
", Fraction: " << (nTotalTB > 0 ?
static_cast<float>(nCorrectTB) /
static_cast<float>(nTotalTB) : 0.f) << std::endl;
444 summarySS <<
"#CorrectCR: " << nCorrectCR <<
"/" << nTotalCR
445 <<
", Fraction: " << (nTotalCR > 0 ?
static_cast<float>(nCorrectCR) /
static_cast<float>(nTotalCR) : 0.f) << std::endl;
447 summarySS <<
"#FakeTB: " << nFakeTB <<
" ";
449 summarySS <<
"#FakeCR: " << nFakeCR <<
" ";
451 summarySS <<
"#SplitTB: " << nSplitTB <<
" ";
453 summarySS <<
"#SplitCR: " << nSplitCR <<
" ";
455 summarySS <<
"#Lost: " << nLost <<
" ";
456 if (nFakeTB || nFakeCR || nSplitTB || nSplitCR || nLost)
457 summarySS << std::endl;
459 std::cout << summarySS.str();
463 std::cout <<
"------------------------------------------------------------------------------------------------" << std::endl
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...
static void SelectReconstructableMCParticles(const pandora::MCParticleList *pMCParticleList, const pandora::CaloHitList *pCaloHitList, const PrimaryParameters ¶meters, std::function< bool(const pandora::MCParticle *const)> fCriteria, MCContributionMap &selectedMCParticlesToHitsMap)
Select target, reconstructable mc particles that match given criteria.