9 #include "Pandora/AlgorithmHeaders.h" 22 TestBeamParticleCreationAlgorithm::TestBeamParticleCreationAlgorithm() :
25 m_keepInteractionVertex(false),
26 m_keepStartVertex(true)
34 const PfoList *pPfoList(
nullptr);
35 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*
this,
m_pfoListName, pPfoList));
39 for (
const Pfo *
const pPfo : *pPfoList)
45 const PropertiesMap properties(pPfo->GetPropertiesMap());
47 const float testBeamScore(propertiesIter != properties.end() ? (*propertiesIter).second : 1.f);
49 const PfoList &daughterList(pPfo->GetDaughterPfoList());
50 const Pfo *pPrimaryPfo(
nullptr);
53 for (
const Pfo *
const pDaughterPfo : daughterList)
55 CaloHitList collectedHits;
58 for (
const CaloHit *
const pCaloHit : collectedHits)
60 if (pCaloHit->GetPositionVector().GetZ() < positionMinZCaloHit.GetZ())
62 positionMinZCaloHit = pCaloHit->GetPositionVector();
63 pPrimaryPfo = pDaughterPfo;
68 for (
const Pfo *
const pPrimaryDaughterPfo : daughterList)
70 if (pPrimaryDaughterPfo == pPrimaryPfo)
73 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*
this, pPrimaryPfo, pPrimaryDaughterPfo));
76 PandoraContentApi::ParticleFlowObject::Metadata pfoMetadata;
77 pfoMetadata.m_propertiesToAdd[
"IsTestBeam"] = 1.f;
78 pfoMetadata.m_propertiesToAdd[
"TestBeamScore"] = testBeamScore;
82 if (std::abs(pPrimaryPfo->GetParticleId()) != E_MINUS)
83 pfoMetadata.m_particleId = PI_PLUS;
85 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*
this, pPrimaryPfo, pfoMetadata));
94 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RemoveFromPfo(*
this, pPrimaryPfo, pVertex));
95 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete<Vertex>(*
this, pVertex));
98 std::string vertexListName;
100 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*
this, pVertexList, vertexListName));
102 PandoraContentApi::Vertex::Parameters parameters;
103 parameters.m_position = positionMinZCaloHit;
104 parameters.m_vertexLabel = VERTEX_START;
105 parameters.m_vertexType = VERTEX_3D;
107 const Vertex *pVertex(
nullptr);
108 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*
this, parameters, pVertex));
109 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*
this, pPrimaryPfo, pVertex));
110 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Vertex>(*
this,
m_vertexListName));
111 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Vertex>(*
this,
m_vertexListName));
114 catch (
const StatusCodeException &)
116 std::cout <<
"TestBeamParticleCreationAlgorithm::Run - unable to modify test beam particle vertex" << std::endl;
119 neutrinoPfos.push_back(pPfo);
122 for (
const Pfo *
const pNeutrinoPfo : neutrinoPfos)
123 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete<Pfo>(*
this, pNeutrinoPfo));
125 return STATUS_CODE_SUCCESS;
132 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
"PfoListName",
m_pfoListName));
134 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
137 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
141 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
"VertexListName",
m_vertexListName));
145 std::cout <<
"TestBeamParticleCreationAlgorithm::ReadSettings - must persist one vertex per pfo" << std::endl;
146 return STATUS_CODE_INVALID_PARAMETER;
149 return STATUS_CODE_SUCCESS;
Header file for the pfo helper class.
bool m_keepInteractionVertex
Retain the vertex for the test beam particle at the low z point.
static const pandora::Vertex * GetVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo vertex.
pandora::StatusCode Run()
std::string m_vertexListName
Input vertex list name.
bool m_keepStartVertex
Retain the vertex for the test beam particle at the interaction point.
std::string m_pfoListName
Input pfo list name.
static bool IsNeutrino(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a neutrino or (antineutrino)
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::list< Vertex > VertexList
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)