21 m_collapseToPrimaryMCParticles(false),
22 m_useOnlyAvailableClusters(true),
24 m_replaceCurrentVertexList(false),
26 m_nHitsForGoodHitType(10)
53 std::cout <<
"CheatingPfoCreationAlgorithm - Could not access cluster list with name " << clusterListName << std::endl;
62 return STATUS_CODE_SUCCESS;
70 for (
const Cluster *
const pCluster : *pClusterList)
81 LArMCParticleHelper::MCRelationMap::const_iterator primaryIter = mcPrimaryMap.find(pMCParticle);
83 if (mcPrimaryMap.end() == primaryIter)
86 pMCParticle = primaryIter->second;
92 mcParticleToClusterListMap[pMCParticle].push_back(pCluster);
104 if (mcParticleToClusterListMap.empty())
107 const PfoList *pPfoList(
nullptr);
108 std::string pfoListName;
112 std::string vertexListName;
116 for (
const auto &mapEntry : mcParticleToClusterListMap)
117 mcParticleVector.push_back(mapEntry.first);
120 for (
const MCParticle *
const pMCParticle : mcParticleVector)
122 const ClusterList &clusterList(mcParticleToClusterListMap.at(pMCParticle));
124 if (clusterList.empty())
132 PandoraContentApi::ParticleFlowObject::Parameters pfoParameters;
133 pfoParameters.m_particleId = (this->
IsShower(pMCParticle) ? E_MINUS : MU_MINUS);
136 pfoParameters.m_energy = pMCParticle->GetEnergy();
137 pfoParameters.m_momentum = pMCParticle->GetMomentum();
138 pfoParameters.m_clusterList.insert(pfoParameters.m_clusterList.end(), clusterList.begin(), clusterList.end());
141 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*
this, pfoParameters, pPfo));
145 PandoraContentApi::Vertex::Parameters parameters;
146 parameters.m_position = pMCParticle->GetVertex();
150 const Vertex *pVertex(
nullptr);
151 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*
this, parameters, pVertex));
157 std::cout <<
"CheatingPfoCreationAlgorithm: Could not create PFO for MCParticle with pdg code " << pMCParticle->GetParticleId()
162 if (!pPfoList->empty())
168 if (!pVertexList->empty())
183 for (
const Cluster *
const pCluster : clusterList)
188 unsigned int nGoodViews(0);
190 for (
const HitTypeMap::value_type &mapEntry : hitTypeMap)
192 if (mapEntry.second > nHitsThreshold)
205 return ((MU_MINUS == std::abs(pdg)) || (PI_PLUS == std::abs(pdg)) || (PROTON == std::abs(pdg)) || (K_PLUS == std::abs(pdg)));
214 return ((E_MINUS == std::abs(pdg)) || (PHOTON == std::abs(pdg)));
257 return STATUS_CODE_SUCCESS;
Header file for the cheating cluster creation algorithm class.
Header file for the cluster helper class.
#define PANDORA_THROW_RESULT_IF(StatusCode1, Operator, Command)
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
static bool IsAvailable(const pandora::Algorithm &algorithm, const T *const pT)
Is object, or a list of objects, available as a building block.
static pandora::StatusCode ReplaceCurrentList(const pandora::Algorithm &algorithm, const std::string &newListName)
Replace the current list with a pre-saved list; use this new list as a permanent replacement for the ...
static pandora::StatusCode CreateTemporaryListAndSetCurrent(const pandora::Algorithm &algorithm, const T *&pT, std::string &temporaryListName)
Create a temporary list and set it to be the current list, enabling object creation.
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
std::unordered_map< const pandora::MCParticle *, pandora::ClusterList > MCParticleToClusterListMap
pandora::StatusCode Run()
Run the algorithm.
bool m_useOnlyAvailableClusters
Whether to consider unavailable clusters when identifying cheated pfos.
void CreatePfos(const MCParticleToClusterListMap &mcParticleToClusterListMap) const
Create pfos corresponding to the details in a provided mc particle to cluster list map.
bool IsShower(const pandora::MCParticle *const pMCParticle) const
Determine whether an input MCParticle is a shower-like particle.
std::string m_outputPfoListName
The output pfo list name.
bool m_replaceCurrentVertexList
Whether to replace current vertex list.
bool m_addVertices
Whether to add the start vertex to the cheated pfo.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
unsigned int GetNHitTypesAboveThreshold(const pandora::ClusterList &clusterList, const unsigned int nHitsThreshold) const
Get the number of hit types containing more than a specified number of hits.
bool m_collapseToPrimaryMCParticles
Whether to collapse mc particle hierarchies to primary particles.
void GetMCParticleToClusterListMap(const pandora::ClusterList *const pClusterList, const LArMCParticleHelper::MCRelationMap &mcPrimaryMap, MCParticleToClusterListMap &mcParticleToClusterListMap) const
Get a map relating mc particles to a list of daughter clusters.
bool IsTrack(const pandora::MCParticle *const pMCParticle) const
Determine whether an input MCParticle is a track-like particle.
unsigned int m_nHitsForGoodHitType
The min number of hits of a particular hit type in order to declare the hit type is good.
pandora::StringVector m_inputClusterListNames
The names of the input cluster lists.
ParticleIdList m_particleIdList
The list of particle ids to consider for pfo creation; will consider all ids if empty.
unsigned int m_minGoodHitTypes
The min number of good hit types in the clusters collected for a given mc particle.
std::map< pandora::HitType, unsigned int > HitTypeMap
std::string m_mcParticleListName
The mc particle list name.
std::string m_outputVertexListName
The output vertex list name.
CheatingPfoCreationAlgorithm()
Default constructor.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static bool SortByMomentum(const pandora::MCParticle *const pLhs, const pandora::MCParticle *const pRhs)
Sort mc particles by their momentum.
std::unordered_map< const pandora::MCParticle *, const pandora::MCParticle * > MCRelationMap
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.
static const MCParticle * GetMainMCParticle(const T *const pT)
Find the mc particle making the largest contribution to a specified calo hit, track or cluster.
int GetParticleId() const
Get the PDG code of the mc particle.
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
ParticleFlowObject class.
static float GetParticleMass(const int pdgCode)
Get the mass of a particle type.
static int GetParticleCharge(const int pdgCode)
Get the charge of a particle type.
StatusCodeException class.
static StatusCode ReadVectorOfValues(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, std::vector< T > &vector)
Read a vector of values from a (space separated) list in an xml element.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
MANAGED_CONTAINER< const MCParticle * > MCParticleList
MANAGED_CONTAINER< const Cluster * > ClusterList
std::vector< int > IntVector
std::vector< const MCParticle * > MCParticleVector
MANAGED_CONTAINER< const Vertex * > VertexList
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList