109 const ValidationInfo &validationInfo,
const bool useInterpretedMatching,
const bool printToScreen,
const bool fillTree)
const
111 if (printToScreen && useInterpretedMatching)
112 std::cout <<
"---INTERPRETED-MATCHING-OUTPUT------------------------------------------------------------------" << std::endl;
113 else if (printToScreen)
114 std::cout <<
"---RAW-MATCHING-OUTPUT--------------------------------------------------------------------------" << std::endl;
123 int nNeutrinoPrimaries(0);
124 for (
const MCParticle *
const pMCPrimary : mcPrimaryVector)
126 ++nNeutrinoPrimaries;
131 int pfoIndex(0), neutrinoPfoIndex(0);
134 for (
const Pfo *
const pPrimaryPfo : primaryPfoVector)
136 pfoToIdMap.insert(PfoToIdMap::value_type(pPrimaryPfo, ++pfoIndex));
139 if (pRecoNeutrino && !neutrinoPfoToIdMap.count(pRecoNeutrino))
140 neutrinoPfoToIdMap.insert(PfoToIdMap::value_type(pRecoNeutrino, ++neutrinoPfoIndex));
148 int nCorrectNu(0), nTotalNu(0), nCorrectCR(0), nTotalCR(0);
149 int nFakeNu(0), nFakeCR(0), nSplitNu(0), nSplitCR(0), nLost(0), mcPrimaryIndex(0), nTargetMatches(0), nTargetNuMatches(0);
150 int nTargetCRMatches(0), nTargetGoodNuMatches(0), nTargetNuSplits(0), nTargetNuLosses(0);
151 IntVector mcPrimaryId, mcPrimaryPdg, nMCHitsTotal, nMCHitsU, nMCHitsV, nMCHitsW;
152 FloatVector mcPrimaryE, mcPrimaryPX, mcPrimaryPY, mcPrimaryPZ;
153 FloatVector mcPrimaryVtxX, mcPrimaryVtxY, mcPrimaryVtxZ, mcPrimaryEndX, mcPrimaryEndY, mcPrimaryEndZ;
154 IntVector nPrimaryMatchedPfos, nPrimaryMatchedNuPfos, nPrimaryMatchedCRPfos;
155 IntVector bestMatchPfoId, bestMatchPfoPdg, bestMatchPfoIsRecoNu, bestMatchPfoRecoNuId;
156 IntVector bestMatchPfoNHitsTotal, bestMatchPfoNHitsU, bestMatchPfoNHitsV, bestMatchPfoNHitsW;
157 IntVector bestMatchPfoNSharedHitsTotal, bestMatchPfoNSharedHitsU, bestMatchPfoNSharedHitsV, bestMatchPfoNSharedHitsW;
159 std::stringstream targetSS;
160 const std::string name(
"Nu");
162 for (
const MCParticle *
const pMCPrimary : mcPrimaryVector)
164 const bool hasMatch(mcToPfoHitSharingMap.count(pMCPrimary) && !mcToPfoHitSharingMap.at(pMCPrimary).empty());
167 if (!isTargetPrimary && !hasMatch)
170 associatedMCPrimaries.push_back(pMCPrimary);
171 const int nTargetPrimaries(associatedMCPrimaries.size());
172 const bool isLastNeutrinoPrimary(++mcPrimaryIndex == nNeutrinoPrimaries);
180 const float targetVertexX(targetVertex.
GetX()), targetVertexY(targetVertex.
GetY()), targetVertexZ(targetVertex.
GetZ());
183 targetSS << (!isTargetPrimary ?
"(Non target) " :
"") <<
"PrimaryId " << mcPrimaryIndex <<
", Nu " << isBeamNeutrinoFinalState
184 <<
", CR " << isCosmicRay <<
", MCPDG " << pMCPrimary->GetParticleId() <<
", Energy " << pMCPrimary->GetEnergy()
185 <<
", Dist. " << (pMCPrimary->GetEndpoint() - pMCPrimary->GetVertex()).GetMagnitude() <<
", nMCHits "
190 mcPrimaryId.push_back(mcPrimaryIndex);
191 mcPrimaryPdg.push_back(pMCPrimary->GetParticleId());
192 mcPrimaryE.push_back(pMCPrimary->GetEnergy());
193 mcPrimaryPX.push_back(pMCPrimary->GetMomentum().GetX());
194 mcPrimaryPY.push_back(pMCPrimary->GetMomentum().GetY());
195 mcPrimaryPZ.push_back(pMCPrimary->GetMomentum().GetZ());
196 mcPrimaryVtxX.push_back(pMCPrimary->GetVertex().GetX());
197 mcPrimaryVtxY.push_back(pMCPrimary->GetVertex().GetY());
198 mcPrimaryVtxZ.push_back(pMCPrimary->GetVertex().GetZ());
199 mcPrimaryEndX.push_back(pMCPrimary->GetEndpoint().GetX());
200 mcPrimaryEndY.push_back(pMCPrimary->GetEndpoint().GetY());
201 mcPrimaryEndZ.push_back(pMCPrimary->GetEndpoint().GetZ());
202 nMCHitsTotal.push_back(mcPrimaryHitList.size());
207 int matchIndex(0), nPrimaryMatches(0), nPrimaryNuMatches(0), nPrimaryCRMatches(0), nPrimaryGoodNuMatches(0), nPrimaryNuSplits(0);
209 float recoVertexX(std::numeric_limits<float>::max()), recoVertexY(std::numeric_limits<float>::max()),
210 recoVertexZ(std::numeric_limits<float>::max());
214 const CaloHitList &sharedHitList(pfoToSharedHits.second);
218 const bool isGoodMatch(this->
IsGoodMatch(mcPrimaryHitList, pfoHitList, sharedHitList));
220 const int pfoId(pfoToIdMap.at(pfoToSharedHits.first));
223 if (0 == matchIndex++)
225 bestMatchPfoId.push_back(pfoId);
226 bestMatchPfoPdg.push_back(pfoToSharedHits.first->GetParticleId());
227 bestMatchPfoIsRecoNu.push_back(isRecoNeutrinoFinalState ? 1 : 0);
228 bestMatchPfoRecoNuId.push_back(recoNuId);
229 bestMatchPfoNHitsTotal.push_back(pfoHitList.size());
233 bestMatchPfoNSharedHitsTotal.push_back(sharedHitList.size());
255 if (isRecoNeutrinoFinalState)
258 const bool isSplitRecoNeutrino(!recoNeutrinos.empty() && !recoNeutrinos.count(pRecoNeutrino));
259 if (!isSplitRecoNeutrino && isGoodMatch)
260 ++nPrimaryGoodNuMatches;
261 if (isSplitRecoNeutrino && isBeamNeutrinoFinalState && isGoodMatch)
263 recoNeutrinos.insert(pRecoNeutrino);
266 if (isRecoNeutrinoFinalState && isGoodMatch)
268 if (!isRecoNeutrinoFinalState && isGoodMatch)
271 targetSS <<
"-" << (!isGoodMatch ?
"(Below threshold) " :
"") <<
"MatchedPfoId " << pfoId <<
", Nu " << isRecoNeutrinoFinalState;
272 if (isRecoNeutrinoFinalState)
273 targetSS <<
" [NuId: " << recoNuId <<
"]";
274 targetSS <<
", CR " << (!isRecoNeutrinoFinalState) <<
", PDG " << pfoToSharedHits.first->GetParticleId() <<
", nMatchedHits "
283 if (mcToPfoHitSharingMap.at(pMCPrimary).empty())
285 targetSS <<
"-No matched Pfo" << std::endl;
286 bestMatchPfoId.push_back(-1);
287 bestMatchPfoPdg.push_back(0);
288 bestMatchPfoIsRecoNu.push_back(0);
289 bestMatchPfoRecoNuId.push_back(-1);
290 bestMatchPfoNHitsTotal.push_back(0);
291 bestMatchPfoNHitsU.push_back(0);
292 bestMatchPfoNHitsV.push_back(0);
293 bestMatchPfoNHitsW.push_back(0);
294 bestMatchPfoNSharedHitsTotal.push_back(0);
295 bestMatchPfoNSharedHitsU.push_back(0);
296 bestMatchPfoNSharedHitsV.push_back(0);
297 bestMatchPfoNSharedHitsW.push_back(0);
300 nPrimaryMatchedPfos.push_back(nPrimaryMatches);
301 nPrimaryMatchedNuPfos.push_back(nPrimaryNuMatches);
302 nPrimaryMatchedCRPfos.push_back(nPrimaryCRMatches);
303 nTargetMatches += nPrimaryMatches;
304 nTargetNuMatches += nPrimaryNuMatches;
305 nTargetCRMatches += nPrimaryCRMatches;
306 nTargetGoodNuMatches += nPrimaryGoodNuMatches;
307 nTargetNuSplits += nPrimaryNuSplits;
308 if (0 == nPrimaryMatches)
364 if (isLastNeutrinoPrimary || isCosmicRay)
368 const int interactionTypeInt(
static_cast<int>(interactionType));
371 const int isCorrectNu(isBeamNeutrinoFinalState && (nTargetGoodNuMatches == nTargetNuMatches) && (nTargetGoodNuMatches == nTargetPrimaries) &&
372 (nTargetCRMatches == 0) && (nTargetNuSplits == 0) && (nTargetNuLosses == 0));
373 const int isCorrectCR(isCosmicRay && (nTargetNuMatches == 0) && (nTargetCRMatches == 1));
374 const int isFakeNu(isCosmicRay && (nTargetNuMatches > 0));
375 const int isFakeCR(!isCosmicRay && (nTargetCRMatches > 0));
376 const int isSplitNu(!isCosmicRay && ((nTargetNuMatches > nTargetPrimaries) || (nTargetNuSplits > 0)));
377 const int isSplitCR(isCosmicRay && (nTargetCRMatches > 1));
378 const int isLost(nTargetMatches == 0);
380 std::stringstream outcomeSS;
382 << isBeamNeutrinoFinalState <<
", CR " << isCosmicRay <<
")" << std::endl;
384 if (isLastNeutrinoPrimary)
404 outcomeSS <<
"IsCorrectNu ";
406 outcomeSS <<
"IsCorrectCR ";
408 outcomeSS <<
"IsFake" << name <<
" ";
410 outcomeSS <<
"IsFakeCR ";
412 outcomeSS <<
"isSplit" << name <<
" ";
414 outcomeSS <<
"IsSplitCR ";
416 outcomeSS <<
"IsLost ";
417 if (nTargetNuMatches > 0)
418 outcomeSS <<
"(N" << name <<
"Matches: " << nTargetNuMatches <<
") ";
419 if (nTargetNuLosses > 0)
420 outcomeSS <<
"(N" << name <<
"Losses: " << nTargetNuLosses <<
") ";
421 if (nTargetNuSplits > 0)
422 outcomeSS <<
"(N" << name <<
"Splits: " << nTargetNuSplits <<
") ";
423 if (nTargetCRMatches > 0)
424 outcomeSS <<
"(NCRMatches: " << nTargetCRMatches <<
") ";
426 std::cout << outcomeSS.str() << std::endl << targetSS.str() << std::endl;
441 targetSS.str(std::string());
443 recoNeutrinos.clear();
444 associatedMCPrimaries.clear();
446 nTargetNuMatches = 0;
447 nTargetCRMatches = 0;
448 nTargetGoodNuMatches = 0;
452 mcPrimaryPdg.clear();
453 nMCHitsTotal.clear();
461 mcPrimaryVtxX.clear();
462 mcPrimaryVtxY.clear();
463 mcPrimaryVtxZ.clear();
464 mcPrimaryEndX.clear();
465 mcPrimaryEndY.clear();
466 mcPrimaryEndZ.clear();
467 nPrimaryMatchedPfos.clear();
468 nPrimaryMatchedNuPfos.clear();
469 nPrimaryMatchedCRPfos.clear();
470 bestMatchPfoId.clear();
471 bestMatchPfoPdg.clear();
472 bestMatchPfoIsRecoNu.clear();
473 bestMatchPfoRecoNuId.clear();
474 bestMatchPfoNHitsTotal.clear();
475 bestMatchPfoNHitsU.clear();
476 bestMatchPfoNHitsV.clear();
477 bestMatchPfoNHitsW.clear();
478 bestMatchPfoNSharedHitsTotal.clear();
479 bestMatchPfoNSharedHitsU.clear();
480 bestMatchPfoNSharedHitsV.clear();
481 bestMatchPfoNSharedHitsW.clear();
485 if (useInterpretedMatching)
487 std::stringstream summarySS;
488 summarySS <<
"---SUMMARY--------------------------------------------------------------------------------------" << std::endl;
490 summarySS <<
"#CorrectNu: " << nCorrectNu <<
"/" << nTotalNu
491 <<
", Fraction: " << (nTotalNu > 0 ?
static_cast<float>(nCorrectNu) /
static_cast<float>(nTotalNu) : 0.f) << std::endl;
493 summarySS <<
"#CorrectCR: " << nCorrectCR <<
"/" << nTotalCR
494 <<
", Fraction: " << (nTotalCR > 0 ?
static_cast<float>(nCorrectCR) /
static_cast<float>(nTotalCR) : 0.f) << std::endl;
496 summarySS <<
"#Fake" << name <<
": " << nFakeNu <<
" ";
498 summarySS <<
"#FakeCR: " << nFakeCR <<
" ";
500 summarySS <<
"#Split" << name <<
": " << nSplitNu <<
" ";
502 summarySS <<
"#SplitCR: " << nSplitCR <<
" ";
504 summarySS <<
"#Lost: " << nLost <<
" ";
505 if (nFakeNu || nFakeCR || nSplitNu || nSplitCR || nLost)
506 summarySS << std::endl;
508 std::cout << summarySS.str();
512 std::cout <<
"------------------------------------------------------------------------------------------------" << std::endl