All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NeutrinoCreationAlgorithm.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArThreeDReco/LArEventBuilding/NeutrinoCreationAlgorithm.cc
3  *
4  * @brief Implementation of the neutrino creation algorithm class.
5  *
6  * $Log: $
7  */
8 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
14 
15 using namespace pandora;
16 
17 namespace lar_content
18 {
19 
20 //------------------------------------------------------------------------------------------------------------------------------------------
21 
22 NeutrinoCreationAlgorithm::NeutrinoCreationAlgorithm() : m_forceSingleEmptyNeutrino(false)
23 {
24 }
25 
26 //------------------------------------------------------------------------------------------------------------------------------------------
27 
29 {
31  return this->ForceSingleEmptyNeutrino();
32 
33  const VertexList *pVertexList(nullptr);
34  PANDORA_RETURN_RESULT_IF_AND_IF(
35  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_vertexListName, pVertexList));
36 
37  if (!pVertexList || pVertexList->empty())
38  {
39  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
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
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 
68  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Pfo>(*this, m_neutrinoPfoListName));
69  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Pfo>(*this, m_neutrinoPfoListName));
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 
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 
91  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Pfo>(*this, m_neutrinoPfoListName));
92  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Pfo>(*this, m_neutrinoPfoListName));
93 
94  return STATUS_CODE_SUCCESS;
95 }
96 
97 //------------------------------------------------------------------------------------------------------------------------------------------
98 
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 
111 StatusCode NeutrinoCreationAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
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
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...
Header file for the neutrino creation algorithm class.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
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.
fhicl::Table< sbnd::crt::CRTDetSimParams > Parameters
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
Definition: reco_sbnd.fcl:182
std::list< Vertex > VertexList
Definition: DCEL.h:182
pandora::StatusCode ForceSingleEmptyNeutrino() const
Force creation of a single neutrino, with no vertex, regardless of number of input vertices...
BEGIN_PROLOG could also be cout