Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
TwoDParticleCreationAlgorithm.cc
Go to the documentation of this file.
1
10
12
13using namespace pandora;
14
15namespace lar_content
16{
17
18TwoDParticleCreationAlgorithm::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 {
61 }
62
63 return STATUS_CODE_SUCCESS;
64}
65
66//------------------------------------------------------------------------------------------------------------------------------------------
67
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
111{
112 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "OutputPfoListName", m_outputPfoListName));
113
115 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ClusterListNameU", m_inputClusterListNameU));
116
118 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ClusterListNameV", m_inputClusterListNameV));
119
121 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ClusterListNameW", m_inputClusterListNameW));
122
124 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinHitsInCluster", m_minHitsInCluster));
125
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
Grouping of header files for many classes of use in particle flow algorithms.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:31
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:19
Header file for the two dimensional particle creation algorithm class.
static pandora::StatusCode ReplaceCurrentList(const pandora::Algorithm &algorithm, const std::string &newListName)
Replace the current list with a pre-saved list; use this new list as a permanent replacement for the ...
static pandora::StatusCode CreateTemporaryListAndSetCurrent(const pandora::Algorithm &algorithm, const T *&pT, std::string &temporaryListName)
Create a temporary list and set it to be the current list, enabling object creation.
static const pandora::PluginManager * GetPlugins(const pandora::Algorithm &algorithm)
Get the pandora plugin instance, providing access to user registered functions and calculators.
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
pandora::StatusCode CreatePFOs(const pandora::ClusterList *const pClusterList) const
Create pfos for provided clusters.
unsigned int m_minHitsInCluster
Min number of hits for clusters to form pfos.
std::string m_outputPfoListName
The output pfo list name.
std::string m_inputClusterListNameU
The input cluster list name for the U view.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
std::string m_inputClusterListNameW
The input cluster list name for the W view.
std::string m_inputClusterListNameV
The input cluster list name for the V view.
float m_minClusterEnergy
Min energy for clusters to form pfos.
CartesianVector class.
ClusterFitResult class.
Cluster class.
Definition Cluster.h:31
unsigned int GetNCaloHits() const
Get the number of calo hits in the cluster.
Definition Cluster.h:484
float GetElectromagneticEnergy() const
Get the sum of electromagnetic energy measures of all constituent calo hits, units GeV.
Definition Cluster.h:519
const ClusterFitResult & GetFitToAllHitsResult() const
Get the result of a linear fit to all calo hits in the cluster.
Definition Cluster.cc:66
ParticleFlowObject class.
bool IsMuon(const T *const pT) const
Provide identification of whether a cluster or pfo is a muon.
const ParticleId * GetParticleId() const
Get the address of the pandora particle id instance.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
MANAGED_CONTAINER< const Cluster * > ClusterList
ParticleType
The particle type enum.
Definition PdgTable.h:101
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList