9 #include "Pandora/AlgorithmHeaders.h" 20 StatusCode TestBeamParticleCreationAlgorithm::Run()
22 const PfoList *pParentNuPfoList(
nullptr);
24 if (STATUS_CODE_SUCCESS != PandoraContentApi::GetList(*
this, m_parentPfoListName, pParentNuPfoList))
26 if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
27 std::cout <<
"TestBeamParticleCreationAlgorithm: pfo list " << m_parentPfoListName <<
" unavailable." << std::endl;
29 return STATUS_CODE_SUCCESS;
34 for (
const Pfo *
const pNuPfo : *pParentNuPfoList)
36 if (!LArPfoHelper::IsNeutrino(pNuPfo))
39 neutrinoPfos.push_back(pNuPfo);
41 const Pfo *pTestBeamPfo(
nullptr);
42 CartesianVector testBeamStartVertex(std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max());
43 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->SetupTestBeamPfo(pNuPfo, pTestBeamPfo, testBeamStartVertex));
44 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->SetupTestBeamVertex(pNuPfo, pTestBeamPfo, testBeamStartVertex));
47 for (
const Pfo *
const pNuPfo : neutrinoPfos)
48 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete<Pfo>(*
this, pNuPfo, m_parentPfoListName));
50 return STATUS_CODE_SUCCESS;
55 StatusCode TestBeamParticleCreationAlgorithm::SetupTestBeamPfo(
const Pfo *
const pNuPfo,
const Pfo *&pTestBeamPfo, CartesianVector &testBeamStartVertex)
const 57 pTestBeamPfo =
nullptr;
58 testBeamStartVertex = CartesianVector(std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max());
60 for (
const Pfo *
const pNuDaughterPfo : pNuPfo->GetDaughterPfoList())
62 CaloHitList collectedHits;
63 LArPfoHelper::GetCaloHits(pNuDaughterPfo, TPC_3D, collectedHits);
65 for (
const CaloHit *
const pCaloHit : collectedHits)
67 if (pCaloHit->GetPositionVector().GetZ() < testBeamStartVertex.GetZ())
69 testBeamStartVertex = pCaloHit->GetPositionVector();
70 pTestBeamPfo = pNuDaughterPfo;
76 return STATUS_CODE_NOT_FOUND;
78 for (
const Pfo *
const pNuDaughterPfo : pNuPfo->GetDaughterPfoList())
80 if (pNuDaughterPfo != pTestBeamPfo)
81 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*
this, pTestBeamPfo, pNuDaughterPfo));
85 const std::string &originalListName(LArPfoHelper::IsTrack(pTestBeamPfo) ? m_trackPfoListName : m_showerPfoListName);
86 PANDORA_RETURN_RESULT_IF(
87 STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*
this, originalListName, m_parentPfoListName, PfoList(1, pTestBeamPfo)));
90 PandoraContentApi::ParticleFlowObject::Metadata pfoMetadata;
91 pfoMetadata.m_propertiesToAdd[
"IsTestBeam"] = 1.f;
92 pfoMetadata.m_propertiesToAdd[
"TestBeamScore"] =
93 (pNuPfo->GetPropertiesMap().count(
"TestBeamScore")) ? pNuPfo->GetPropertiesMap().at(
"TestBeamScore") : 1.f;
94 pfoMetadata.m_particleId = (std::fabs(pTestBeamPfo->GetParticleId()) == E_MINUS) ? E_MINUS : PI_PLUS;
95 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*
this, pTestBeamPfo, pfoMetadata));
97 return STATUS_CODE_SUCCESS;
102 StatusCode TestBeamParticleCreationAlgorithm::SetupTestBeamVertex(
103 const Pfo *
const pNuPfo,
const Pfo *
const pTestBeamPfo,
const CartesianVector &testBeamStartVertex)
const 107 const Vertex *
const pInitialVertex(LArPfoHelper::GetVertex(pTestBeamPfo));
108 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RemoveFromPfo(*
this, pTestBeamPfo, pInitialVertex));
109 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete<Vertex>(*
this, pInitialVertex, m_daughterVertexListName));
111 catch (
const StatusCodeException &)
113 std::cout <<
"TestBeamParticleCreationAlgorithm::SetupTestBeamVertex - Test beam particle has no initial vertex" << std::endl;
117 std::string vertexListName;
119 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*
this, pVertexList, vertexListName));
121 PandoraContentApi::Vertex::Parameters parameters;
122 parameters.m_position = testBeamStartVertex;
123 parameters.m_vertexLabel = VERTEX_START;
124 parameters.m_vertexType = VERTEX_3D;
125 const Vertex *pTestBeamStartVertex(
nullptr);
126 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*
this, parameters, pTestBeamStartVertex));
127 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Vertex>(*
this, m_parentVertexListName));
128 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*
this, pTestBeamPfo, pTestBeamStartVertex));
133 const Vertex *
const pNuVertex(LArPfoHelper::GetVertex(pNuPfo));
134 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RemoveFromPfo(*
this, pNuPfo, pNuVertex));
135 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*
this, pTestBeamPfo, pNuVertex));
138 catch (
const StatusCodeException &)
140 std::cout <<
"TestBeamParticleCreationAlgorithm::SetupTestBeamVertex - Cannot transfer interaction vertex to test beam particle" << std::endl;
143 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Vertex>(*
this, m_parentVertexListName));
144 return STATUS_CODE_SUCCESS;
149 StatusCode TestBeamParticleCreationAlgorithm::ReadSettings(
const TiXmlHandle xmlHandle)
151 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
"ParentPfoListName", m_parentPfoListName));
153 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
"TrackPfoListName", m_trackPfoListName));
155 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
"ShowerPfoListName", m_showerPfoListName));
157 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
"ParentVertexListName", m_parentVertexListName));
159 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
"DaughterVertexListName", m_daughterVertexListName));
161 return STATUS_CODE_SUCCESS;
Header file for the pfo helper class.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Header file for the test beam particle creation algorithm class.
std::list< Vertex > VertexList