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