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