TwoDParticleCreationAlgorithm.cc
Go to the documentation of this file.
1 /**
2  * @file TwoDParticleCreationAlgorithm.cc
3  *
4  * @brief Implementation of the two dimensional particle creation algorithm class.
5  *
6  * $Log: $
7  */
8 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
13 using namespace pandora;
14 
15 namespace lar_content
16 {
17 
18 TwoDParticleCreationAlgorithm::TwoDParticleCreationAlgorithm() : m_minHitsInCluster(5), m_minClusterEnergy(0.f)
19 {
20 }
21 
22 //------------------------------------------------------------------------------------------------------------------------------------------
23 
25 {
26  const PfoList *pPfoList = nullptr;
27  std::string pfoListName;
28  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pPfoList, pfoListName));
29 
30  if (!m_inputClusterListNameU.empty())
31  {
32  const ClusterList *pClusterListU = nullptr;
33  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_inputClusterListNameU, pClusterListU));
34 
35  if (pClusterListU)
36  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->CreatePFOs(pClusterListU));
37  }
38 
39  if (!m_inputClusterListNameV.empty())
40  {
41  const ClusterList *pClusterListV = nullptr;
42  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_inputClusterListNameV, pClusterListV));
43 
44  if (pClusterListV)
45  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->CreatePFOs(pClusterListV));
46  }
47 
48  if (!m_inputClusterListNameW.empty())
49  {
50  const ClusterList *pClusterListW = nullptr;
51  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_inputClusterListNameW, pClusterListW));
52 
53  if (pClusterListW)
54  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->CreatePFOs(pClusterListW));
55  }
56 
57  if (!pPfoList->empty())
58  {
59  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Pfo>(*this, m_outputPfoListName));
60  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Pfo>(*this, m_outputPfoListName));
61  }
62 
63  return STATUS_CODE_SUCCESS;
64 }
65 
66 //------------------------------------------------------------------------------------------------------------------------------------------
67 
68 StatusCode TwoDParticleCreationAlgorithm::CreatePFOs(const ClusterList *const pClusterList) const
69 {
70  for (ClusterList::const_iterator iter = pClusterList->begin(), iterEnd = pClusterList->end(); iter != iterEnd; ++iter)
71  {
72  const Cluster *const pCluster = *iter;
73 
74  if (pCluster->GetNCaloHits() < m_minHitsInCluster)
75  continue;
76 
77  // TODO Finalize particle id and energy measurement here
78  const float clusterEnergy(pCluster->GetElectromagneticEnergy());
79 
80  if (clusterEnergy < m_minClusterEnergy)
81  continue;
82 
83  PandoraContentApi::ParticleFlowObject::Parameters pfoParameters;
84 
85  // TODO Finalize particle id here
86  const ParticleType particleType(PandoraContentApi::GetPlugins(*this)->GetParticleId()->IsMuon(pCluster) ? MU_MINUS : PHOTON);
87 
88  const ClusterFitResult &fitToAllHitsResult(pCluster->GetFitToAllHitsResult());
89 
90  if (!fitToAllHitsResult.IsFitSuccessful())
91  continue;
92 
93  // TODO Check remaining parameters
94  pfoParameters.m_particleId = particleType;
95  pfoParameters.m_charge = 0;
96  pfoParameters.m_mass = 0.;
97  pfoParameters.m_energy = clusterEnergy;
98  pfoParameters.m_momentum = CartesianVector(fitToAllHitsResult.GetDirection() * clusterEnergy);
99  pfoParameters.m_clusterList.push_back(pCluster);
100 
101  const ParticleFlowObject *pPfo(NULL);
102  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*this, pfoParameters, pPfo));
103  }
104 
105  return STATUS_CODE_SUCCESS;
106 }
107 
108 //------------------------------------------------------------------------------------------------------------------------------------------
109 
110 StatusCode TwoDParticleCreationAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
111 {
112  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "OutputPfoListName", m_outputPfoListName));
113 
114  PANDORA_RETURN_RESULT_IF_AND_IF(
115  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ClusterListNameU", m_inputClusterListNameU));
116 
117  PANDORA_RETURN_RESULT_IF_AND_IF(
118  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ClusterListNameV", m_inputClusterListNameV));
119 
120  PANDORA_RETURN_RESULT_IF_AND_IF(
121  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ClusterListNameW", m_inputClusterListNameW));
122 
123  PANDORA_RETURN_RESULT_IF_AND_IF(
124  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinHitsInCluster", m_minHitsInCluster));
125 
126  PANDORA_RETURN_RESULT_IF_AND_IF(
127  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinClusterEnergy", m_minClusterEnergy));
128 
129  return STATUS_CODE_SUCCESS;
130 }
131 
132 } // namespace lar_content
float m_minClusterEnergy
Min energy for clusters to form pfos.
std::string m_inputClusterListNameW
The input cluster list name for the W view.
std::string string
Definition: nybbler.cc:12
intermediate_table::const_iterator const_iterator
pandora::StatusCode CreatePFOs(const pandora::ClusterList *const pClusterList) const
Create pfos for provided clusters.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
std::string m_inputClusterListNameU
The input cluster list name for the U view.
std::string m_inputClusterListNameV
The input cluster list name for the V view.
std::string m_outputPfoListName
The output pfo list name.
Header file for the two dimensional particle creation algorithm class.
unsigned int m_minHitsInCluster
Min number of hits for clusters to form pfos.