9 #include "Pandora/AlgorithmHeaders.h" 20 TestBeamParticleCreationAlgorithm::TestBeamParticleCreationAlgorithm() :
21 m_keepInteractionVertex(true),
22 m_keepStartVertex(false)
30 const PfoList *pParentNuPfoList(
nullptr);
32 if (STATUS_CODE_SUCCESS != PandoraContentApi::GetList(*
this,
m_parentPfoListName, pParentNuPfoList))
34 if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
35 std::cout <<
"TestBeamParticleCreationAlgorithm: pfo list " <<
m_parentPfoListName <<
" unavailable." << std::endl;
37 return STATUS_CODE_SUCCESS;
42 for (
const Pfo *
const pNuPfo : *pParentNuPfoList)
47 neutrinoPfos.push_back(pNuPfo);
49 const Pfo *pTestBeamPfo(
nullptr);
51 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->
SetupTestBeamPfo(pNuPfo, pTestBeamPfo, testBeamStartVertex));
52 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->
SetupTestBeamVertex(pNuPfo, pTestBeamPfo, testBeamStartVertex));
55 for (
const Pfo *
const pNuPfo : neutrinoPfos)
56 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete<Pfo>(*
this, pNuPfo,
m_parentPfoListName));
58 return STATUS_CODE_SUCCESS;
65 pTestBeamPfo =
nullptr;
68 for (
const Pfo *
const pNuDaughterPfo : pNuPfo->GetDaughterPfoList())
70 CaloHitList collectedHits;
73 for (
const CaloHit *
const pCaloHit : collectedHits)
75 if (pCaloHit->GetPositionVector().GetZ() < testBeamStartVertex.GetZ())
77 testBeamStartVertex = pCaloHit->GetPositionVector();
78 pTestBeamPfo = pNuDaughterPfo;
84 return STATUS_CODE_NOT_FOUND;
86 for (
const Pfo *
const pNuDaughterPfo : pNuPfo->GetDaughterPfoList())
88 if (pNuDaughterPfo != pTestBeamPfo)
89 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*
this, pTestBeamPfo, pNuDaughterPfo));
94 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*
this, originalListName,
m_parentPfoListName, PfoList(1, pTestBeamPfo)));
97 PandoraContentApi::ParticleFlowObject::Metadata pfoMetadata;
98 pfoMetadata.m_propertiesToAdd[
"IsTestBeam"] = 1.f;
99 pfoMetadata.m_propertiesToAdd[
"TestBeamScore"] = (pNuPfo->GetPropertiesMap().count(
"TestBeamScore")) ? pNuPfo->GetPropertiesMap().at(
"TestBeamScore") : 1.f;
100 pfoMetadata.m_particleId = (std::fabs(pTestBeamPfo->GetParticleId()) == E_MINUS) ? E_MINUS : PI_PLUS;
101 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*
this, pTestBeamPfo, pfoMetadata));
103 return STATUS_CODE_SUCCESS;
113 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RemoveFromPfo(*
this, pTestBeamPfo, pInitialVertex));
114 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete<Vertex>(*
this, pInitialVertex,
m_daughterVertexListName));
116 catch (
const StatusCodeException &)
118 std::cout <<
"TestBeamParticleCreationAlgorithm::SetupTestBeamVertex - Test beam particle has no initial vertex" << std::endl;
123 std::string vertexListName;
125 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*
this, pVertexList, vertexListName));
127 PandoraContentApi::Vertex::Parameters parameters;
128 parameters.m_position = testBeamStartVertex;
129 parameters.m_vertexLabel = VERTEX_START;
130 parameters.m_vertexType = VERTEX_3D;
131 const Vertex *pTestBeamStartVertex(
nullptr);
132 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*
this, parameters, pTestBeamStartVertex));
134 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Vertex>(*
this,
m_parentVertexListName));
135 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Vertex>(*
this,
m_parentVertexListName));
136 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*
this, pTestBeamPfo, pTestBeamStartVertex));
143 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RemoveFromPfo(*
this, pNuPfo, pNuVertex));
144 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*
this, pTestBeamPfo, pNuVertex));
147 catch (
const StatusCodeException &)
149 std::cout <<
"TestBeamParticleCreationAlgorithm::SetupTestBeamVertex - Cannot transfer interaction vertex to test beam particle" << std::endl;
153 return STATUS_CODE_SUCCESS;
160 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
163 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
166 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
169 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
172 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
175 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
178 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
183 std::cout <<
"TestBeamParticleCreationAlgorithm::ReadSettings - Must persist exactly one vertex per test beam particle." << std::endl;
184 return STATUS_CODE_INVALID_PARAMETER;
187 return STATUS_CODE_SUCCESS;
Header file for the pfo helper class.
bool m_keepInteractionVertex
Keep the vertex for the test beam particle at the interaction point.
static const pandora::Vertex * GetVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo vertex.
pandora::StatusCode Run()
static bool IsTrack(const pandora::ParticleFlowObject *const pPfo)
Return track flag based on Pfo Particle ID.
bool m_keepStartVertex
Keep the vertex for the test beam particle at the position of hit at minimum z.
pandora::StatusCode SetupTestBeamVertex(const pandora::Pfo *const pNuPfo, const pandora::Pfo *const pTestBeamPfo, const pandora::CartesianVector &testBeamStartVertex) const
Set up the test beam vertex.
std::string m_parentPfoListName
The parent pfo list name.
static bool IsNeutrino(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a neutrino or (antineutrino)
std::string m_daughterVertexListName
The daughter vertex list name.
std::string m_parentVertexListName
The parent vertex list name.
pandora::StatusCode SetupTestBeamPfo(const pandora::Pfo *const pNuPfo, const pandora::Pfo *&pTestBeamPfo, pandora::CartesianVector &testBeamStartVertex) const
Set up the test beam pfo.
std::string m_trackPfoListName
The track pfo list name.
Header file for the test beam particle creation algorithm class.
static void GetCaloHits(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList)
Get a list of calo hits of a particular hit type from a list of pfos.
std::string m_showerPfoListName
The shower pfo list name.
std::list< Vertex > VertexList
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)