Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
lar_content::DeltaRayParentAlgorithm Class Reference

DeltaRayParentAlgorithm class. More...

#include <DeltaRayParentAlgorithm.h>

Inheritance diagram for lar_content::DeltaRayParentAlgorithm:

Public Types

typedef std::map< const pandora::ParticleFlowObject *, float > PfoLengthMap
 

Public Member Functions

 DeltaRayParentAlgorithm ()
 Default constructor. More...
 
pandora::StatusCode Run ()
 

Private Member Functions

void InitialisePfoLengthMap (const pandora::PfoList *const muonPfoList, const pandora::PfoList *const deltaRayPfoList, PfoLengthMap &pfoLengthMap) const
 Initialise the delta ray pfo length map. More...
 
void FindParentPfo (const PfoLengthMap &pfoLengthMap, const pandora::ParticleFlowObject *const pPfo, const pandora::ParticleFlowObject *&pParentPfo) const
 Identify the parent pfo of a given delta ray pfo (can be either a cosmic ray or delta ray pfo) More...
 
pandora::StatusCode GetTwoDSeparation (const pandora::ParticleFlowObject *const pPfo1, const pandora::ParticleFlowObject *const pPfo2, float &separation) const
 Get distance between two Pfos using 2D clusters. More...
 
void AssignToParentPfo (const pandora::PfoList *const muonPfoList, const pandora::PfoList *const deltaRayPfoList, const pandora::ParticleFlowObject *const pPfo, const pandora::ParticleFlowObject *const pParentPfo, PfoLengthMap &pfoLengthMap) const
 Apply parent-child link (if parent is a cosmic ray create parent-child link else merge the delta ray cluster into parent delta ray pfo) More...
 
void UpdatePfoLengthMap (const pandora::PfoList &pfosToRemove, const pandora::ParticleFlowObject *const pPfoToAdd, PfoLengthMap &pfoLengthMap) const
 Update the pfo length map after a parent-child delta ray merge. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

std::string m_muonPfoListName
 The list of reconstructed muon pfos. More...
 
std::string m_deltaRayPfoListName
 The list of reconstructed delta ray pfos. More...
 
float m_distanceForMatching
 The maximum separation of a delta ray pfo from its parent. More...
 

Detailed Description

DeltaRayParentAlgorithm class.

Definition at line 19 of file DeltaRayParentAlgorithm.h.

Member Typedef Documentation

typedef std::map<const pandora::ParticleFlowObject *, float> lar_content::DeltaRayParentAlgorithm::PfoLengthMap

Definition at line 22 of file DeltaRayParentAlgorithm.h.

Constructor & Destructor Documentation

lar_content::DeltaRayParentAlgorithm::DeltaRayParentAlgorithm ( )

Default constructor.

Definition at line 21 of file DeltaRayParentAlgorithm.cc.

22 {
23 }
float m_distanceForMatching
The maximum separation of a delta ray pfo from its parent.

Member Function Documentation

void lar_content::DeltaRayParentAlgorithm::AssignToParentPfo ( const pandora::PfoList *const  muonPfoList,
const pandora::PfoList *const  deltaRayPfoList,
const pandora::ParticleFlowObject *const  pPfo,
const pandora::ParticleFlowObject *const  pParentPfo,
PfoLengthMap pfoLengthMap 
) const
private

Apply parent-child link (if parent is a cosmic ray create parent-child link else merge the delta ray cluster into parent delta ray pfo)

Parameters
muonPfoListthe list of all cosmic ray pfos
deltaRayPfoListthe list of all delta ray pfos
pPfothe address of the input delta ray pfo
pParentPfothe address of the parent pfo
pfoLengthMapthe mapping of pfos to their 2D length

Definition at line 165 of file DeltaRayParentAlgorithm.cc.

167 {
168  if (std::find(pMuonPfoList->begin(), pMuonPfoList->end(), pParentPfo) != pMuonPfoList->end())
169  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pParentPfo, pPfo));
170 
171  if (std::find(pDeltaRayPfoList->begin(), pDeltaRayPfoList->end(), pParentPfo) != pDeltaRayPfoList->end())
172  {
173  ClusterList pfoClusters;
174  LArPfoHelper::GetTwoDClusterList(pPfo, pfoClusters);
175 
176  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete(*this, pPfo, m_deltaRayPfoListName));
177 
178  for (const Cluster *const pCluster : pfoClusters)
179  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*this, pParentPfo, pCluster));
180 
181  this->UpdatePfoLengthMap({pPfo, pParentPfo}, pParentPfo, pfoLengthMap);
182  }
183 }
static void GetTwoDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 2D clusters from an input pfo.
void UpdatePfoLengthMap(const pandora::PfoList &pfosToRemove, const pandora::ParticleFlowObject *const pPfoToAdd, PfoLengthMap &pfoLengthMap) const
Update the pfo length map after a parent-child delta ray merge.
std::string m_deltaRayPfoListName
The list of reconstructed delta ray pfos.
void lar_content::DeltaRayParentAlgorithm::FindParentPfo ( const PfoLengthMap pfoLengthMap,
const pandora::ParticleFlowObject *const  pPfo,
const pandora::ParticleFlowObject *&  pParentPfo 
) const
private

Identify the parent pfo of a given delta ray pfo (can be either a cosmic ray or delta ray pfo)

Parameters
pfoLengthMapthe mapping of pfos to their 2D length
pPfothe address of the input delta ray pfo
pParentPfothe output address of the parent pfo

Definition at line 79 of file DeltaRayParentAlgorithm.cc.

80 {
81  const PfoLengthMap::const_iterator currentIter(pfoLengthMap.find(pPfo));
82 
83  if (currentIter == pfoLengthMap.end())
84  throw StatusCodeException(STATUS_CODE_FAILURE);
85 
86  PfoVector allPfoVector;
87 
88  for (auto &entry : pfoLengthMap)
89  allPfoVector.push_back(entry.first);
90 
91  const float lengthSquared(currentIter->second);
92  float bestDistance(m_distanceForMatching);
93 
94  for (const ParticleFlowObject *const pTestParent : allPfoVector)
95  {
96  if (pTestParent == pPfo)
97  continue;
98 
99  const PfoLengthMap::const_iterator testIter(pfoLengthMap.find(pTestParent));
100 
101  if (testIter == pfoLengthMap.end())
102  throw StatusCodeException(STATUS_CODE_FAILURE);
103 
104  if (testIter->second < lengthSquared)
105  continue;
106 
108 
109  if (this->GetTwoDSeparation(pPfo, pTestParent, distance) == STATUS_CODE_NOT_FOUND)
110  continue;
111 
112  if (distance < bestDistance)
113  {
114  pParentPfo = pTestParent;
115  bestDistance = distance;
116  }
117  }
118 }
QList< Entry > entry
pandora::StatusCode GetTwoDSeparation(const pandora::ParticleFlowObject *const pPfo1, const pandora::ParticleFlowObject *const pPfo2, float &separation) const
Get distance between two Pfos using 2D clusters.
intermediate_table::const_iterator const_iterator
QCollection::Item first()
Definition: qglist.cpp:807
float m_distanceForMatching
The maximum separation of a delta ray pfo from its parent.
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
static int max(int a, int b)
StatusCode lar_content::DeltaRayParentAlgorithm::GetTwoDSeparation ( const pandora::ParticleFlowObject *const  pPfo1,
const pandora::ParticleFlowObject *const  pPfo2,
float &  separation 
) const
private

Get distance between two Pfos using 2D clusters.

Parameters
pPfothe address of the first Pfo
pPfothe address of the second Pfo
torecieve the output pfo separation
Returns
whether the pfo separation could be calculated

Definition at line 122 of file DeltaRayParentAlgorithm.cc.

123 {
124  ClusterList clusterListU1, clusterListV1, clusterListW1;
125  ClusterList clusterListU2, clusterListV2, clusterListW2;
126 
127  LArPfoHelper::GetClusters(pPfo1, TPC_VIEW_U, clusterListU1);
128  LArPfoHelper::GetClusters(pPfo1, TPC_VIEW_V, clusterListV1);
129  LArPfoHelper::GetClusters(pPfo1, TPC_VIEW_W, clusterListW1);
130 
131  LArPfoHelper::GetClusters(pPfo2, TPC_VIEW_U, clusterListU2);
132  LArPfoHelper::GetClusters(pPfo2, TPC_VIEW_V, clusterListV2);
133  LArPfoHelper::GetClusters(pPfo2, TPC_VIEW_W, clusterListW2);
134 
135  float numViews(0.f), distance(0.f);
136 
137  if (!clusterListU1.empty() && !clusterListU2.empty())
138  {
139  distance += LArClusterHelper::GetClosestDistance(clusterListU1, clusterListU2);
140  numViews += 1.f;
141  }
142 
143  if (!clusterListV1.empty() && !clusterListV2.empty())
144  {
145  distance += LArClusterHelper::GetClosestDistance(clusterListV1, clusterListV2);
146  numViews += 1.f;
147  }
148 
149  if (!clusterListW1.empty() && !clusterListW2.empty())
150  {
151  distance += LArClusterHelper::GetClosestDistance(clusterListW1, clusterListW2);
152  numViews += 1.f;
153  }
154 
155  if (numViews < std::numeric_limits<float>::epsilon())
156  return STATUS_CODE_NOT_FOUND;
157 
158  separation = distance / numViews;
159 
160  return STATUS_CODE_SUCCESS;
161 }
static void GetClusters(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::ClusterList &clusterList)
Get a list of clusters of a particular hit type from a list of pfos.
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
void lar_content::DeltaRayParentAlgorithm::InitialisePfoLengthMap ( const pandora::PfoList *const  muonPfoList,
const pandora::PfoList *const  deltaRayPfoList,
PfoLengthMap pfoLengthMap 
) const
private

Initialise the delta ray pfo length map.

Parameters
muonPfoListthe list of all cosmic ray pfos
deltaRayPfoListthe list of all delta ray pfos
pfoLengthMapthe output mapping of pfos to their 2D length

Definition at line 68 of file DeltaRayParentAlgorithm.cc.

69 {
70  for (const ParticleFlowObject *const pPfo : *muonPfoList)
71  pfoLengthMap[pPfo] = LArPfoHelper::GetTwoDLengthSquared(pPfo);
72 
73  for (const ParticleFlowObject *const pPfo : *deltaRayPfoList)
74  pfoLengthMap[pPfo] = LArPfoHelper::GetTwoDLengthSquared(pPfo);
75 }
static float GetTwoDLengthSquared(const pandora::ParticleFlowObject *const pPfo)
Calculate length of Pfo using 2D clusters.
StatusCode lar_content::DeltaRayParentAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 204 of file DeltaRayParentAlgorithm.cc.

205 {
206  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "MuonPfoListName", m_muonPfoListName));
207 
208  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "DeltaRayPfoListName", m_deltaRayPfoListName));
209 
210  PANDORA_RETURN_RESULT_IF_AND_IF(
211  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "DistanceForMatching", m_distanceForMatching));
212 
213  return STATUS_CODE_SUCCESS;
214 }
std::string m_muonPfoListName
The list of reconstructed muon pfos.
float m_distanceForMatching
The maximum separation of a delta ray pfo from its parent.
std::string m_deltaRayPfoListName
The list of reconstructed delta ray pfos.
StatusCode lar_content::DeltaRayParentAlgorithm::Run ( )

Definition at line 27 of file DeltaRayParentAlgorithm.cc.

28 {
29  const PfoList *pMuonPfoList(nullptr);
30  PANDORA_THROW_RESULT_IF_AND_IF(
31  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_muonPfoListName, pMuonPfoList));
32 
33  if (!pMuonPfoList || pMuonPfoList->empty())
34  return STATUS_CODE_SUCCESS;
35 
36  const PfoList *pDeltaRayPfoList(nullptr);
37  PANDORA_THROW_RESULT_IF_AND_IF(
38  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_deltaRayPfoListName, pDeltaRayPfoList));
39 
40  if (!pDeltaRayPfoList || pDeltaRayPfoList->empty())
41  return STATUS_CODE_SUCCESS;
42 
43  PfoLengthMap pfoLengthMap;
44  this->InitialisePfoLengthMap(pMuonPfoList, pDeltaRayPfoList, pfoLengthMap);
45 
46  PfoVector deltaRayPfoVector(pDeltaRayPfoList->begin(), pDeltaRayPfoList->end());
47  std::sort(deltaRayPfoVector.begin(), deltaRayPfoVector.end(), LArPfoHelper::SortByNHits);
48 
49  for (const ParticleFlowObject *const pPfo : deltaRayPfoVector)
50  {
51  if (!pPfo->GetParentPfoList().empty())
52  continue;
53 
54  const ParticleFlowObject *pParentPfo(nullptr);
55  this->FindParentPfo(pfoLengthMap, pPfo, pParentPfo);
56 
57  if (!pParentPfo)
58  continue;
59 
60  this->AssignToParentPfo(pMuonPfoList, pDeltaRayPfoList, pPfo, pParentPfo, pfoLengthMap);
61  }
62 
63  return STATUS_CODE_SUCCESS;
64 }
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
std::string m_muonPfoListName
The list of reconstructed muon pfos.
void AssignToParentPfo(const pandora::PfoList *const muonPfoList, const pandora::PfoList *const deltaRayPfoList, const pandora::ParticleFlowObject *const pPfo, const pandora::ParticleFlowObject *const pParentPfo, PfoLengthMap &pfoLengthMap) const
Apply parent-child link (if parent is a cosmic ray create parent-child link else merge the delta ray ...
void FindParentPfo(const PfoLengthMap &pfoLengthMap, const pandora::ParticleFlowObject *const pPfo, const pandora::ParticleFlowObject *&pParentPfo) const
Identify the parent pfo of a given delta ray pfo (can be either a cosmic ray or delta ray pfo) ...
std::map< const pandora::ParticleFlowObject *, float > PfoLengthMap
void InitialisePfoLengthMap(const pandora::PfoList *const muonPfoList, const pandora::PfoList *const deltaRayPfoList, PfoLengthMap &pfoLengthMap) const
Initialise the delta ray pfo length map.
std::string m_deltaRayPfoListName
The list of reconstructed delta ray pfos.
void lar_content::DeltaRayParentAlgorithm::UpdatePfoLengthMap ( const pandora::PfoList &  pfosToRemove,
const pandora::ParticleFlowObject *const  pPfoToAdd,
PfoLengthMap pfoLengthMap 
) const
private

Update the pfo length map after a parent-child delta ray merge.

Parameters
pfosToRemovethe list of pfos to remove from the map
pPfoToAddthe address of the pfo to add to the map
pfoLengthMapthe mapping of pfos to their 2D length

Definition at line 187 of file DeltaRayParentAlgorithm.cc.

188 {
189  for (const ParticleFlowObject *const pPfoToRemove : pfosToRemove)
190  {
191  const PfoLengthMap::const_iterator iter(pfoLengthMap.find(pPfoToRemove));
192 
193  if (iter == pfoLengthMap.end())
194  throw StatusCodeException(STATUS_CODE_FAILURE);
195 
196  pfoLengthMap.erase(iter);
197  }
198 
199  pfoLengthMap[pPfoToAdd] = LArPfoHelper::GetTwoDLengthSquared(pPfoToAdd);
200 }
intermediate_table::const_iterator const_iterator
static float GetTwoDLengthSquared(const pandora::ParticleFlowObject *const pPfo)
Calculate length of Pfo using 2D clusters.

Member Data Documentation

std::string lar_content::DeltaRayParentAlgorithm::m_deltaRayPfoListName
private

The list of reconstructed delta ray pfos.

Definition at line 86 of file DeltaRayParentAlgorithm.h.

float lar_content::DeltaRayParentAlgorithm::m_distanceForMatching
private

The maximum separation of a delta ray pfo from its parent.

Definition at line 87 of file DeltaRayParentAlgorithm.h.

std::string lar_content::DeltaRayParentAlgorithm::m_muonPfoListName
private

The list of reconstructed muon pfos.

Definition at line 85 of file DeltaRayParentAlgorithm.h.


The documentation for this class was generated from the following files: