27 m_printAllToScreen(false),
28 m_printMatchingToScreen(true),
30 m_useSmallPrimaries(true),
31 m_matchingMinSharedHits(5),
32 m_matchingMinCompleteness(0.1f),
33 m_matchingMinPurity(0.5f)
49 std::cout <<
"EventValidationBaseAlgorithm: Unable to write tree " <<
m_treeName <<
" to file " <<
m_fileName << std::endl;
66 const PfoList *pPfoList =
nullptr;
81 return STATUS_CODE_SUCCESS;
93 while (this->
GetStrongestPfoMatch(validationInfo, mcPrimaryVector, usedPfos, interpretedMCToPfoHitSharingMap))
99 for (
const MCParticle *
const pMCPrimary : mcPrimaryVector)
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));
117 for (
const MCParticle *
const pMCPrimary : mcPrimaryVector)
119 if (interpretedMCToPfoHitSharingMap.count(pMCPrimary))
130 if (usedPfos.count(pfoToSharedHits.first))
134 validationInfo.
GetPfoToHitsMap().at(pfoToSharedHits.first), pfoToSharedHits.second))
137 if (pfoToSharedHits.second.size() > bestPfoHitPair.second.size())
139 pBestMCParticle = pMCPrimary;
140 bestPfoHitPair = pfoToSharedHits;
145 if (!pBestMCParticle || !bestPfoHitPair.first)
148 interpretedMCToPfoHitSharingMap[pBestMCParticle].push_back(bestPfoHitPair);
149 usedPfos.insert(bestPfoHitPair.first);
160 for (
const MCParticle *
const pMCPrimary : mcPrimaryVector)
170 if (usedPfos.count(pfoToSharedHits.first))
174 LArMCParticleHelper::PfoToMCParticleHitSharingMap::iterator iter(pfoToMCParticleHitSharingMap.find(pfoToSharedHits.first));
176 if (pfoToMCParticleHitSharingMap.end() == iter)
178 pfoToMCParticleHitSharingMap[pfoToSharedHits.first].push_back(mcParticleToHits);
182 if (1 != iter->second.size())
187 if (mcParticleToHits.second.size() > originalMCParticleToHits.second.size())
188 originalMCParticleToHits = mcParticleToHits;
193 for (
const auto &mapEntry : pfoToMCParticleHitSharingMap)
196 interpretedMCToPfoHitSharingMap[mcParticleToHits.first].push_back(
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);
269 return STATUS_CODE_SUCCESS;
Header file for the event validation algorithm.
Header file for the interaction type helper class.
Header file for the lar monitoring helper helper class.
Header file for the pfo helper class.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
const LArMCParticleHelper::MCParticleToPfoHitSharingMap & GetMCToPfoHitSharingMap() const
Get the mc to pfo hit sharing map.
const LArMCParticleHelper::MCContributionMap & GetTargetMCParticleToHitsMap() const
Get the target mc particle to hits map.
const LArMCParticleHelper::MCContributionMap & GetAllMCParticleToHitsMap() const
Get the all mc particle to hits map.
const LArMCParticleHelper::PfoContributionMap & GetPfoToHitsMap() const
Get the pfo to hits map.
unsigned int m_matchingMinSharedHits
The minimum number of shared hits used in matching scheme.
bool m_useSmallPrimaries
Whether to consider matches to mc primaries with fewer than m_matchingMinPrimaryHits.
void PrintInterpretedMatches(const ValidationInfo &validationInfo) const
Print interpreted matching information to screen.
std::string m_treeName
Name of output tree.
void InterpretMatching(const ValidationInfo &validationInfo, LArMCParticleHelper::MCParticleToPfoHitSharingMap &interpretedMCToPfoHitSharingMap) const
Apply an interpretative matching procedure to the comprehensive matches in the provided validation in...
~EventValidationBaseAlgorithm()
Destructor.
bool m_printAllToScreen
Whether to print all/raw matching details to screen.
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 WriteInterpretedMatches(const ValidationInfo &validationInfo) const
Write interpreted matching information to tree.
virtual void FillValidationInfo(const pandora::MCParticleList *const pMCParticleList, const pandora::CaloHitList *const pCaloHitList, const pandora::PfoList *const pPfoList, ValidationInfo &validationInfo) const =0
Fill the validation info containers.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
bool m_writeToTree
Whether to write all/raw matching details to tree.
int m_fileIdentifier
The input file identifier.
bool m_printMatchingToScreen
Whether to print matching output to screen.
float m_matchingMinCompleteness
The minimum particle completeness to declare a match.
LArMCParticleHelper::PrimaryParameters m_primaryParameters
The mc particle primary selection parameters.
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.
void PrintAllMatches(const ValidationInfo &validationInfo) const
Print all/raw matching information to screen.
std::string m_caloHitListName
Name of input calo hit list.
float m_matchingMinPurity
The minimum particle purity to declare a match.
std::string m_mcParticleListName
Name of input MC particle list.
std::string m_fileName
Name of output file.
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::string m_pfoListName
Name of input Pfo list.
int m_eventNumber
The event number.
pandora::StatusCode Run()
Run the algorithm.
EventValidationBaseAlgorithm()
Default constructor.
bool m_foldBackHierarchy
whether to fold the hierarchy back to the primary (neutrino) or leading particles (test beam)
bool m_selectInputHits
whether to select input hits
float m_minHitSharingFraction
the minimum Hit sharing fraction
float m_maxPhotonPropagation
the maximum photon propagation length
unsigned int m_minPrimaryGoodHits
the minimum number of primary good Hits
unsigned int m_minPrimaryGoodViews
the minimum number of primary good views
unsigned int m_minHitsForGoodView
the minimum number of Hits for a good view
std::map< const pandora::ParticleFlowObject *, MCParticleToSharedHitsVector > PfoToMCParticleHitSharingMap
std::vector< PfoCaloHitListPair > PfoToSharedHitsVector
std::pair< const pandora::ParticleFlowObject *, pandora::CaloHitList > PfoCaloHitListPair
std::map< const pandora::MCParticle *, PfoToSharedHitsVector > MCParticleToPfoHitSharingMap
std::pair< const pandora::MCParticle *, pandora::CaloHitList > MCParticleCaloHitListPair
static void GetOrderedMCParticleVector(const LArMCParticleHelper::MCContributionMapVector &selectedMCParticleToGoodHitsMaps, pandora::MCParticleVector &orderedMCParticleVector)
Order input MCParticles by their number of hits.
const Pandora & GetPandora() const
Get the associated pandora instance.
StatusCodeException class.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
MANAGED_CONTAINER< const MCParticle * > MCParticleList
std::unordered_set< const ParticleFlowObject * > PfoSet
MANAGED_CONTAINER< const CaloHit * > CaloHitList
std::vector< const MCParticle * > MCParticleVector
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList