LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
NeutrinoCreationAlgorithm.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
14 
15 using namespace pandora;
16 
17 namespace lar_content
18 {
19 
20 //------------------------------------------------------------------------------------------------------------------------------------------
21 
22 NeutrinoCreationAlgorithm::NeutrinoCreationAlgorithm() :
23  m_forceSingleEmptyNeutrino(false)
24 {
25 }
26 
27 //------------------------------------------------------------------------------------------------------------------------------------------
28 
30 {
32  return this->ForceSingleEmptyNeutrino();
33 
34  const VertexList *pVertexList(nullptr);
35  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_vertexListName,
36  pVertexList));
37 
38  if (!pVertexList || pVertexList->empty())
39  {
40  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
41  std::cout << "NeutrinoCreationAlgorithm: unable to find vertex list " << m_vertexListName << std::endl;
42 
43  return STATUS_CODE_SUCCESS;
44  }
45 
46  std::string neutrinoPfoListName;
47  const PfoList *pNeutrinoPfoList(nullptr);
48  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pNeutrinoPfoList,
49  neutrinoPfoListName));
50 
51  for (VertexList::const_iterator vIter = pVertexList->begin(), vIterEnd = pVertexList->end(); vIter != vIterEnd; ++vIter)
52  {
53  const Vertex *const pVertex = *vIter;
54 
55  if (VERTEX_3D != pVertex->GetVertexType())
56  throw StatusCodeException(STATUS_CODE_FAILURE);
57 
58  // ATTN Placeholder properties to be set by a later neutrino properties algorithm
59  PandoraContentApi::ParticleFlowObject::Parameters pfoParameters;
60  this->FillDefaultNeutrinoParameters(pfoParameters);
61  pfoParameters.m_vertexList.push_back(pVertex);
62 
63  const ParticleFlowObject *pNeutrinoPfo(nullptr);
64  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*this, pfoParameters, pNeutrinoPfo));
65  }
66 
67  if ((!pNeutrinoPfoList) || pNeutrinoPfoList->empty())
68  throw StatusCodeException(STATUS_CODE_FAILURE);
69 
70  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Pfo>(*this, m_neutrinoPfoListName));
71  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Pfo>(*this, m_neutrinoPfoListName));
72 
73  return STATUS_CODE_SUCCESS;
74 }
75 
76 //------------------------------------------------------------------------------------------------------------------------------------------
77 
79 {
80  std::string neutrinoPfoListName;
81  const PfoList *pNeutrinoPfoList(nullptr);
82  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pNeutrinoPfoList,
83  neutrinoPfoListName));
84 
85  PandoraContentApi::ParticleFlowObject::Parameters pfoParameters;
86  this->FillDefaultNeutrinoParameters(pfoParameters);
87 
88  const ParticleFlowObject *pNeutrinoPfo(nullptr);
89  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*this, pfoParameters, pNeutrinoPfo));
90 
91  if ((!pNeutrinoPfoList) || pNeutrinoPfoList->empty())
92  throw StatusCodeException(STATUS_CODE_FAILURE);
93 
94  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Pfo>(*this, m_neutrinoPfoListName));
95  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Pfo>(*this, m_neutrinoPfoListName));
96 
97  return STATUS_CODE_SUCCESS;
98 }
99 
100 //------------------------------------------------------------------------------------------------------------------------------------------
101 
102 void NeutrinoCreationAlgorithm::FillDefaultNeutrinoParameters(PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const
103 {
104  pfoParameters.m_particleId = NU_MU;
105  pfoParameters.m_charge = PdgTable::GetParticleCharge(pfoParameters.m_particleId.Get());
106  pfoParameters.m_mass = PdgTable::GetParticleMass(pfoParameters.m_particleId.Get());
107  pfoParameters.m_energy = 0.f;
108  pfoParameters.m_momentum = CartesianVector(0.f, 0.f, 0.f);
109  pfoParameters.m_propertiesToAdd["IsNeutrino"] = 1.f;
110 }
111 
112 //------------------------------------------------------------------------------------------------------------------------------------------
113 
114 StatusCode NeutrinoCreationAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
115 {
116  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
117  "InputVertexListName", m_vertexListName));
118 
119  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
120  "NeutrinoPfoListName", m_neutrinoPfoListName));
121 
122  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
123  "ForceSingleEmptyNeutrino", m_forceSingleEmptyNeutrino));
124 
125  return STATUS_CODE_SUCCESS;
126 }
127 
128 } // namespace lar_content
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...
TFile f
Definition: plotHisto.C:6
Header file for the neutrino creation algorithm class.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
intermediate_table::const_iterator const_iterator
Header file for the cluster helper class.
void FillDefaultNeutrinoParameters(PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const
Fill provided pfo parameters with default/dummy values for later refinement.
std::string m_neutrinoPfoListName
The name of the neutrino pfo list.
std::list< Vertex > VertexList
Definition: DCEL.h:178
pandora::StatusCode ForceSingleEmptyNeutrino() const
Force creation of a single neutrino, with no vertex, regardless of number of input vertices...