Create pfos corresponding to the details in a provided mc particle to cluster list map.
104 if (mcParticleToClusterListMap.empty())
107 const PfoList *pPfoList(
nullptr);
108 std::string pfoListName;
109 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*
this, pPfoList, pfoListName));
112 std::string vertexListName;
113 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*
this, pVertexList, 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())
133 pfoParameters.m_particleId = pMCParticle->GetParticleId();
134 pfoParameters.m_charge = PdgTable::GetParticleCharge(pfoParameters.m_particleId.Get());
135 pfoParameters.m_mass = PdgTable::GetParticleMass(pfoParameters.m_particleId.Get());
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());
140 const ParticleFlowObject *pPfo(
nullptr);
141 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*
this, pfoParameters, pPfo));
146 parameters.m_position = pMCParticle->GetVertex();
147 parameters.m_vertexLabel = VERTEX_START;
148 parameters.m_vertexType = VERTEX_3D;
150 const Vertex *pVertex(
nullptr);
151 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*
this, parameters, pVertex));
152 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo<Vertex>(*
this, pPfo, pVertex));
155 catch (
const StatusCodeException &)
157 std::cout <<
"CheatingPfoCreationAlgorithm: Could not create PFO for MCParticle with pdg code " << pMCParticle->GetParticleId()
162 if (!pPfoList->empty())
164 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Pfo>(*
this,
m_outputPfoListName));
165 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Pfo>(*
this,
m_outputPfoListName));
168 if (!pVertexList->empty())
170 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Vertex>(*
this,
m_outputVertexListName));
173 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Vertex>(*
this,
m_outputVertexListName));
std::string m_outputVertexListName
The output vertex list name.
unsigned int m_minGoodHitTypes
The min number of good hit types in the clusters collected for a given mc particle.
static bool SortByMomentum(const pandora::MCParticle *const pLhs, const pandora::MCParticle *const pRhs)
Sort mc particles by their momentum.
std::string m_outputPfoListName
The output pfo list name.
unsigned int m_nHitsForGoodHitType
The min number of hits of a particular hit type in order to declare the hit type is good...
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
bool m_addVertices
Whether to add the start vertex to the cheated pfo.
fhicl::Table< sbnd::crt::CRTDetSimParams > Parameters
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_replaceCurrentVertexList
Whether to replace current vertex list.
std::list< Vertex > VertexList
BEGIN_PROLOG could also be cout