Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
NeutrinoCreationAlgorithm.cc
Go to the documentation of this file.
1
10
12
14
15using namespace pandora;
16
17namespace lar_content
18{
19
20//------------------------------------------------------------------------------------------------------------------------------------------
21
22NeutrinoCreationAlgorithm::NeutrinoCreationAlgorithm() : m_forceSingleEmptyNeutrino(false)
23{
24}
25
26//------------------------------------------------------------------------------------------------------------------------------------------
27
29{
31 return this->ForceSingleEmptyNeutrino();
32
33 const VertexList *pVertexList(nullptr);
35 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_vertexListName, pVertexList));
36
37 if (!pVertexList || pVertexList->empty())
38 {
40 std::cout << "NeutrinoCreationAlgorithm: unable to find vertex list " << m_vertexListName << std::endl;
41
42 return STATUS_CODE_SUCCESS;
43 }
44
45 std::string neutrinoPfoListName;
46 const PfoList *pNeutrinoPfoList(nullptr);
47 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pNeutrinoPfoList, neutrinoPfoListName));
48
49 for (VertexList::const_iterator vIter = pVertexList->begin(), vIterEnd = pVertexList->end(); vIter != vIterEnd; ++vIter)
50 {
51 const Vertex *const pVertex = *vIter;
52
53 if (VERTEX_3D != pVertex->GetVertexType())
54 throw StatusCodeException(STATUS_CODE_FAILURE);
55
56 // ATTN Placeholder properties to be set by a later neutrino properties algorithm
57 PandoraContentApi::ParticleFlowObject::Parameters pfoParameters;
58 this->FillDefaultNeutrinoParameters(pfoParameters);
59 pfoParameters.m_vertexList.push_back(pVertex);
60
61 const ParticleFlowObject *pNeutrinoPfo(nullptr);
62 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*this, pfoParameters, pNeutrinoPfo));
63 }
64
65 if ((!pNeutrinoPfoList) || pNeutrinoPfoList->empty())
66 throw StatusCodeException(STATUS_CODE_FAILURE);
67
70
71 return STATUS_CODE_SUCCESS;
72}
73
74//------------------------------------------------------------------------------------------------------------------------------------------
75
77{
78 std::string neutrinoPfoListName;
79 const PfoList *pNeutrinoPfoList(nullptr);
80 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pNeutrinoPfoList, neutrinoPfoListName));
81
82 PandoraContentApi::ParticleFlowObject::Parameters pfoParameters;
83 this->FillDefaultNeutrinoParameters(pfoParameters);
84
85 const ParticleFlowObject *pNeutrinoPfo(nullptr);
86 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*this, pfoParameters, pNeutrinoPfo));
87
88 if ((!pNeutrinoPfoList) || pNeutrinoPfoList->empty())
89 throw StatusCodeException(STATUS_CODE_FAILURE);
90
93
94 return STATUS_CODE_SUCCESS;
95}
96
97//------------------------------------------------------------------------------------------------------------------------------------------
98
99void NeutrinoCreationAlgorithm::FillDefaultNeutrinoParameters(PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const
100{
101 pfoParameters.m_particleId = NU_MU;
102 pfoParameters.m_charge = PdgTable::GetParticleCharge(pfoParameters.m_particleId.Get());
103 pfoParameters.m_mass = PdgTable::GetParticleMass(pfoParameters.m_particleId.Get());
104 pfoParameters.m_energy = 0.f;
105 pfoParameters.m_momentum = CartesianVector(0.f, 0.f, 0.f);
106 pfoParameters.m_propertiesToAdd["IsNeutrino"] = 1.f;
107}
108
109//------------------------------------------------------------------------------------------------------------------------------------------
110
112{
113 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputVertexListName", m_vertexListName));
114
115 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "NeutrinoPfoListName", m_neutrinoPfoListName));
116
117 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
118 XmlHelper::ReadValue(xmlHandle, "ForceSingleEmptyNeutrino", m_forceSingleEmptyNeutrino));
119
120 return STATUS_CODE_SUCCESS;
121}
122
123} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the cluster helper class.
Header file for the neutrino creation algorithm class.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:31
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:19
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::string m_neutrinoPfoListName
The name of the neutrino pfo list.
void FillDefaultNeutrinoParameters(PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const
Fill provided pfo parameters with default/dummy values for later refinement.
pandora::StatusCode ForceSingleEmptyNeutrino() const
Force creation of a single neutrino, with no vertex, regardless of number of input vertices.
std::string m_vertexListName
The name of the neutrino vertex list.
bool m_forceSingleEmptyNeutrino
Whether to force creation of a single neutrino, with no vertex, regardless of number of input vertice...
pandora::StatusCode Run()
Run the algorithm.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
CartesianVector class.
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.
Definition PdgTable.h:205
static int GetParticleCharge(const int pdgCode)
Get the charge of a particle type.
Definition PdgTable.h:227
StatusCodeException class.
Vertex class.
Definition Vertex.h:26
VertexType GetVertexType() const
Get the vertex type.
Definition Vertex.h:124
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
MANAGED_CONTAINER< const Vertex * > VertexList
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList