LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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.

21  :
23 {
24 }
TFile f
Definition: plotHisto.C:6
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 166 of file DeltaRayParentAlgorithm.cc.

References lar_content::LArPfoHelper::GetTwoDClusterList(), m_deltaRayPfoListName, and UpdatePfoLengthMap().

Referenced by Run().

168 {
169  if (std::find(pMuonPfoList->begin(), pMuonPfoList->end(), pParentPfo) != pMuonPfoList->end())
170  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pParentPfo, pPfo));
171 
172  if (std::find(pDeltaRayPfoList->begin(), pDeltaRayPfoList->end(), pParentPfo) != pDeltaRayPfoList->end())
173  {
174  ClusterList pfoClusters;
175  LArPfoHelper::GetTwoDClusterList(pPfo, pfoClusters);
176 
177  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete(*this, pPfo, m_deltaRayPfoListName));
178 
179  for (const Cluster *const pCluster : pfoClusters)
180  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*this, pParentPfo, pCluster));
181 
182  this->UpdatePfoLengthMap({pPfo, pParentPfo}, pParentPfo, pfoLengthMap);
183  }
184 }
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 80 of file DeltaRayParentAlgorithm.cc.

References GetTwoDSeparation(), and m_distanceForMatching.

Referenced by Run().

81 {
82  const PfoLengthMap::const_iterator currentIter(pfoLengthMap.find(pPfo));
83 
84  if (currentIter == pfoLengthMap.end())
85  throw StatusCodeException(STATUS_CODE_FAILURE);
86 
87  PfoVector allPfoVector;
88 
89  for (auto &entry : pfoLengthMap)
90  allPfoVector.push_back(entry.first);
91 
92  const float lengthSquared(currentIter->second);
93  float bestDistance(m_distanceForMatching);
94 
95  for (const ParticleFlowObject *const pTestParent : allPfoVector)
96  {
97  if (pTestParent == pPfo)
98  continue;
99 
100  const PfoLengthMap::const_iterator testIter(pfoLengthMap.find(pTestParent));
101 
102  if (testIter == pfoLengthMap.end())
103  throw StatusCodeException(STATUS_CODE_FAILURE);
104 
105  if (testIter->second < lengthSquared)
106  continue;
107 
108  float distance(std::numeric_limits<float>::max());
109 
110  if (this->GetTwoDSeparation(pPfo, pTestParent, distance) == STATUS_CODE_NOT_FOUND)
111  continue;
112 
113  if (distance < bestDistance)
114  {
115  pParentPfo = pTestParent;
116  bestDistance = distance;
117  }
118  }
119 }
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
float m_distanceForMatching
The maximum separation of a delta ray pfo from its parent.
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 123 of file DeltaRayParentAlgorithm.cc.

References f, lar_content::LArClusterHelper::GetClosestDistance(), and lar_content::LArPfoHelper::GetClusters().

Referenced by FindParentPfo().

124 {
125  ClusterList clusterListU1, clusterListV1, clusterListW1;
126  ClusterList clusterListU2, clusterListV2, clusterListW2;
127 
128  LArPfoHelper::GetClusters(pPfo1, TPC_VIEW_U, clusterListU1);
129  LArPfoHelper::GetClusters(pPfo1, TPC_VIEW_V, clusterListV1);
130  LArPfoHelper::GetClusters(pPfo1, TPC_VIEW_W, clusterListW1);
131 
132  LArPfoHelper::GetClusters(pPfo2, TPC_VIEW_U, clusterListU2);
133  LArPfoHelper::GetClusters(pPfo2, TPC_VIEW_V, clusterListV2);
134  LArPfoHelper::GetClusters(pPfo2, TPC_VIEW_W, clusterListW2);
135 
136  float numViews(0.f), distance(0.f);
137 
138  if (!clusterListU1.empty() && !clusterListU2.empty())
139  {
140  distance += LArClusterHelper::GetClosestDistance(clusterListU1, clusterListU2);
141  numViews += 1.f;
142  }
143 
144  if (!clusterListV1.empty() && !clusterListV2.empty())
145  {
146  distance += LArClusterHelper::GetClosestDistance(clusterListV1, clusterListV2);
147  numViews += 1.f;
148  }
149 
150  if (!clusterListW1.empty() && !clusterListW2.empty())
151  {
152  distance += LArClusterHelper::GetClosestDistance(clusterListW1, clusterListW2);
153  numViews += 1.f;
154  }
155 
156  if (numViews < std::numeric_limits<float>::epsilon())
157  return STATUS_CODE_NOT_FOUND;
158 
159  separation = distance / numViews;
160 
161  return STATUS_CODE_SUCCESS;
162 }
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.
TFile f
Definition: plotHisto.C:6
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 69 of file DeltaRayParentAlgorithm.cc.

References lar_content::LArPfoHelper::GetTwoDLengthSquared().

Referenced by Run().

70 {
71  for (const ParticleFlowObject *const pPfo : *muonPfoList)
72  pfoLengthMap[pPfo] = LArPfoHelper::GetTwoDLengthSquared(pPfo);
73 
74  for (const ParticleFlowObject *const pPfo : *deltaRayPfoList)
75  pfoLengthMap[pPfo] = LArPfoHelper::GetTwoDLengthSquared(pPfo);
76 }
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 205 of file DeltaRayParentAlgorithm.cc.

References m_deltaRayPfoListName, m_distanceForMatching, and m_muonPfoListName.

206 {
207  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "MuonPfoListName", m_muonPfoListName));
208 
209  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "DeltaRayPfoListName", m_deltaRayPfoListName));
210 
211  PANDORA_RETURN_RESULT_IF_AND_IF(
212  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "DistanceForMatching", m_distanceForMatching));
213 
214  return STATUS_CODE_SUCCESS;
215 }
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 28 of file DeltaRayParentAlgorithm.cc.

References AssignToParentPfo(), FindParentPfo(), InitialisePfoLengthMap(), m_deltaRayPfoListName, m_muonPfoListName, and lar_content::LArPfoHelper::SortByNHits().

29 {
30  const PfoList *pMuonPfoList(nullptr);
31  PANDORA_THROW_RESULT_IF_AND_IF(
32  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_muonPfoListName, pMuonPfoList));
33 
34  if (!pMuonPfoList || pMuonPfoList->empty())
35  return STATUS_CODE_SUCCESS;
36 
37  const PfoList *pDeltaRayPfoList(nullptr);
38  PANDORA_THROW_RESULT_IF_AND_IF(
39  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_deltaRayPfoListName, pDeltaRayPfoList));
40 
41  if (!pDeltaRayPfoList || pDeltaRayPfoList->empty())
42  return STATUS_CODE_SUCCESS;
43 
44  PfoLengthMap pfoLengthMap;
45  this->InitialisePfoLengthMap(pMuonPfoList, pDeltaRayPfoList, pfoLengthMap);
46 
47  PfoVector deltaRayPfoVector(pDeltaRayPfoList->begin(), pDeltaRayPfoList->end());
48  std::sort(deltaRayPfoVector.begin(), deltaRayPfoVector.end(), LArPfoHelper::SortByNHits);
49 
50  for (const ParticleFlowObject *const pPfo : deltaRayPfoVector)
51  {
52  if (!pPfo->GetParentPfoList().empty())
53  continue;
54 
55  const ParticleFlowObject *pParentPfo(nullptr);
56  this->FindParentPfo(pfoLengthMap, pPfo, pParentPfo);
57 
58  if (!pParentPfo)
59  continue;
60 
61  this->AssignToParentPfo(pMuonPfoList, pDeltaRayPfoList, pPfo, pParentPfo, pfoLengthMap);
62  }
63 
64  return STATUS_CODE_SUCCESS;
65 }
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 188 of file DeltaRayParentAlgorithm.cc.

References lar_content::LArPfoHelper::GetTwoDLengthSquared().

Referenced by AssignToParentPfo().

189 {
190  for (const ParticleFlowObject *const pPfoToRemove : pfosToRemove)
191  {
192  const PfoLengthMap::const_iterator iter(pfoLengthMap.find(pPfoToRemove));
193 
194  if (iter == pfoLengthMap.end())
195  throw StatusCodeException(STATUS_CODE_FAILURE);
196 
197  pfoLengthMap.erase(iter);
198  }
199 
200  pfoLengthMap[pPfoToAdd] = LArPfoHelper::GetTwoDLengthSquared(pPfoToAdd);
201 }
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.

Referenced by AssignToParentPfo(), ReadSettings(), and Run().

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.

Referenced by FindParentPfo(), and ReadSettings().

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

The list of reconstructed muon pfos.

Definition at line 85 of file DeltaRayParentAlgorithm.h.

Referenced by ReadSettings(), and Run().


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