Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
PfoCharacterisationBaseAlgorithm.cc
Go to the documentation of this file.
1
10
13
15
16#include <set>
17
18using namespace pandora;
19
20namespace lar_content
21{
22
24 m_updateClusterIds(true),
25 m_postBranchAddition(false),
26 m_useThreeDInformation(true),
27 m_minTrackLikeViews(2)
28{
29}
30
31//------------------------------------------------------------------------------------------------------------------------------------------
32
36
37//------------------------------------------------------------------------------------------------------------------------------------------
38
40{
41 PfoList tracksToShowers, showersToTracks;
42
43 for (const std::string &pfoListName : m_inputPfoListNames)
44 {
45 const PfoList *pPfoList(nullptr);
46 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, pfoListName, pPfoList));
47
48 if (!pPfoList || pPfoList->empty())
49 {
51 std::cout << "PfoCharacterisationBaseAlgorithm: unable to find pfo list " << pfoListName << std::endl;
52
53 continue;
54 }
55
56 for (const ParticleFlowObject *const pPfo : *pPfoList)
57 {
58 PandoraContentApi::ParticleFlowObject::Metadata pfoMetadata;
59 const bool isTrackLike(m_useThreeDInformation ? this->IsClearTrack(pPfo) : this->IsClearTrack3x2D(pPfo));
60
61 if (isTrackLike)
62 {
63 pfoMetadata.m_particleId = MU_MINUS;
64
65 if (m_showerPfoListName == pfoListName)
66 showersToTracks.push_back(pPfo);
67 }
68 else
69 {
70 pfoMetadata.m_particleId = E_MINUS;
71
72 if (m_trackPfoListName == pfoListName)
73 tracksToShowers.push_back(pPfo);
74 }
75
76 if (pPfo->GetParticleId() != pfoMetadata.m_particleId.Get())
77 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*this, pPfo, pfoMetadata));
78
80 continue;
81
82 ClusterList twoDClusterList;
83 LArPfoHelper::GetTwoDClusterList(pPfo, twoDClusterList);
84
85 for (const Cluster *const pCluster : twoDClusterList)
86 {
87 if (pCluster->GetParticleId() == pfoMetadata.m_particleId.Get())
88 continue;
89
90 PandoraContentApi::Cluster::Metadata clusterMetadata;
91 clusterMetadata.m_particleId = pfoMetadata.m_particleId.Get();
92 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::AlterMetadata(*this, pCluster, clusterMetadata));
93 }
94 }
95 }
96
97 if (!tracksToShowers.empty())
98 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*this, m_trackPfoListName, m_showerPfoListName, tracksToShowers));
99
100 if (!showersToTracks.empty())
101 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*this, m_showerPfoListName, m_trackPfoListName, showersToTracks));
102
103 return STATUS_CODE_SUCCESS;
104}
105
106//------------------------------------------------------------------------------------------------------------------------------------------
107
109{
110 ClusterList twoDClusterList;
111 LArPfoHelper::GetTwoDClusterList(pPfo, twoDClusterList);
112
113 typedef std::set<pandora::HitType> HitTypeSet;
114 HitTypeSet hitTypeSet;
115
116 unsigned int nTrackLikeViews(0);
117 for (const Cluster *const pCluster : twoDClusterList)
118 {
119 const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
120 if (!hitTypeSet.insert(hitType).second)
121 continue;
122
123 if (this->IsClearTrack(pCluster))
124 ++nTrackLikeViews;
125
126 if (nTrackLikeViews >= m_minTrackLikeViews)
127 return true;
128 }
129
130 return false;
131}
132
133//------------------------------------------------------------------------------------------------------------------------------------------
134
136{
137 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "TrackPfoListName", m_trackPfoListName));
139
140 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "ShowerPfoListName", m_showerPfoListName));
142
144 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "UpdateClusterIds", m_updateClusterIds));
145
147 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinTrackLikeViews", m_minTrackLikeViews));
148
150 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "UseThreeDInformation", m_useThreeDInformation));
151
152 return STATUS_CODE_SUCCESS;
153}
154
155} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the cluster helper class.
Header file for the pfo helper class.
Header file for the pfo characterisation base algorithm class.
#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
static pandora::StatusCode SaveList(const pandora::Algorithm &algorithm, const T &t, const std::string &newListName)
Save a provided input object list under a new name.
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static void GetTwoDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 2D clusters from an input pfo.
virtual bool IsClearTrack3x2D(const pandora::ParticleFlowObject *const pPfo) const
Whether pfo is identified as a clear track using its three clusters.
virtual bool IsClearTrack(const pandora::ParticleFlowObject *const pPfo) const =0
Whether pfo is identified as a clear track.
pandora::StringVector m_inputPfoListNames
The names of the input pfo lists.
bool m_updateClusterIds
Whether to update daughter cluster particle id labels to match pfo id.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
bool m_useThreeDInformation
Whether to use PFO and 3D information or clusters for characterisation.
unsigned int m_minTrackLikeViews
The minimum number of track-like views to declare a pfo as track-like.
Cluster class.
Definition Cluster.h:31
StatusCode AlterMetadata(const object_creation::Cluster::Metadata &metadata)
Alter the metadata information stored in a cluster.
Definition Cluster.cc:275
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
ParticleFlowObject class.
StatusCode AlterMetadata(const object_creation::ParticleFlowObject::Metadata &metadata)
Alter particle flow object metadata parameters.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
HitType
Calorimeter hit type enum.
MANAGED_CONTAINER< const Cluster * > ClusterList
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList