9 #include "Pandora/AlgorithmHeaders.h" 18 CheatingClusterCreationAlgorithm::CheatingClusterCreationAlgorithm() :
19 m_collapseToPrimaryMCParticles(false)
31 return STATUS_CODE_SUCCESS;
42 const MCParticleList *pMCParticleList(
nullptr);
43 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*
this,
m_mcParticleListName, pMCParticleList));
48 const CaloHitList *pCaloHitList(
nullptr);
49 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*
this, pCaloHitList));
51 for (
const CaloHit *
const pCaloHit : *pCaloHitList)
55 if (!PandoraContentApi::IsAvailable(*
this, pCaloHit))
60 catch (
const StatusCodeException &) {}
69 const MCParticle *pMCParticle(MCParticleHelper::GetMainMCParticle(pCaloHit));
78 if (mcPrimaryMap.end() == primaryIter)
79 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
81 pMCParticle = primaryIter->second;
84 mcParticleToHitListMap[pMCParticle].push_back(pCaloHit);
96 if (pMCParticle->GetParticleId() == particleId)
108 for (
const auto &mapEntry : mcParticleToHitListMap) mcParticleVector.push_back(mapEntry.first);
111 for (
const MCParticle *
const pMCParticle : mcParticleVector)
113 const CaloHitList &caloHitList(mcParticleToHitListMap.at(pMCParticle));
115 if (caloHitList.empty())
118 const Cluster *pCluster(
nullptr);
119 PandoraContentApi::Cluster::Parameters parameters;
120 parameters.m_caloHitList = caloHitList;
121 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*
this, parameters, pCluster));
123 PandoraContentApi::Cluster::Metadata metadata;
125 switch (pMCParticle->GetParticleId())
132 metadata.m_particleId = pMCParticle->GetParticleId();
138 if (metadata.m_particleId.IsInitialized())
139 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::AlterMetadata(*
this, pCluster, metadata));
147 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
152 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
156 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle,
159 return STATUS_CODE_SUCCESS;
pandora::IntVector m_particleIdList
list of particle ids of MCPFOs to be selected
void GetMCParticleToHitListMap(MCParticleToHitListMap &mcParticleToHitListMap) const
Create map between each (primary) MC particle and associated calo hits.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCParticleToHitListMap
std::string m_mcParticleListName
The mc particle list name, required if want to collapse mc particle hierarchy.
void SimpleMCParticleCollection(const pandora::CaloHit *const pCaloHit, const LArMCParticleHelper::MCRelationMap &mcPrimaryMap, MCParticleToHitListMap &mcParticleToHitListMap) const
Simple mc particle collection, using main mc particle associated with each calo hit.
static void GetMCPrimaryMap(const pandora::MCParticleList *const pMCParticleList, MCRelationMap &mcPrimaryMap)
Get mapping from individual mc particles (in a provided list) and their primary parent mc particles...
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
bool SelectMCParticlesForClustering(const pandora::MCParticle *const pMCParticle) const
Check whether mc particle is of a type specified for inclusion in cheated clustering.
static bool SortByMomentum(const pandora::MCParticle *const pLhs, const pandora::MCParticle *const pRhs)
Sort mc particles by their momentum.
Header file for the cheating cluster creation algorithm class.
bool m_collapseToPrimaryMCParticles
Whether to collapse mc particle hierarchies to primary particles.
pandora::StatusCode Run()
void CreateClusters(const MCParticleToHitListMap &mcParticleToHitListMap) const
Create clusters based on information in the mc particle to hit list map.
std::unordered_map< const pandora::MCParticle *, const pandora::MCParticle * > MCRelationMap