LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::OneViewDeltaRayMatchingAlgorithm Class Reference

OneViewDeltaRayMatchingAlgorithm class. More...

#include "OneViewDeltaRayMatchingAlgorithm.h"

Inheritance diagram for lar_content::OneViewDeltaRayMatchingAlgorithm:

Public Member Functions

 OneViewDeltaRayMatchingAlgorithm ()
 Default constructor. More...
 

Private Member Functions

pandora::StatusCode Run ()
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
const pandora::ClusterList GetInputClusterList (const pandora::HitType hitType)
 Get the input cluster list of a given hit type. More...
 
const pandora::PfoList GetMuonPfoList ()
 Get the input cosmic ray pfo list. More...
 
const pandora::PfoList GetDeltaRayPfoList ()
 Get the input delta ray pfo list. More...
 
void PerformOneViewMatching (const pandora::HitType hitType)
 Use nearby muon pfos to project into other views and attempt to match the remaining delta ray clusters. More...
 
bool IsMuonPfo (const pandora::Cluster *const pCluster)
 Determine whether an input cluster belongs to a cosmic ray pfo. More...
 
bool AddIntoExistingDeltaRay (const pandora::Cluster *const pAvailableCluster, const pandora::PfoVector &nearbyMuonPfoVector)
 Use nearby muon pfos to project into other views and attempt to add a remaining delta ray cluster into an existing delta ray pfo. More...
 
const pandora::Cluster * GetBestProjectedCluster (const pandora::ClusterList &deltaRayClusterGroup, const pandora::ParticleFlowObject *const pNearbyMuonPfo, const pandora::HitType hitType, const bool findAvailable)
 Get the best matched available or unavailable cluster of a remaining delta ray cluster group wrt a cosmic ray pfo. More...
 
bool IsDeltaRayPfo (const pandora::Cluster *const pCluster)
 Determine whether an input cluster belongs to a delta ray pfo. More...
 
void GetClusterSpanX (const pandora::ClusterList &clusterList, float &spanMinX, float &spanMaxX)
 Determine cluster span (in x) of a group of clusters. More...
 
void CreateDeltaRay (const pandora::Cluster *const pAvailableCluster, const pandora::PfoVector &nearbyMuonPfoVector, pandora::ClusterSet &modifiedClusters)
 Use nearby muon pfos to project into other views and attempt to match a remaining delta ray cluster to form a delta ray pfo. More...
 
void GetNearbyAvailableClusters (const pandora::Cluster *const pCluster, pandora::ClusterList &consideredClusters, pandora::ClusterList &foundClusters)
 In the view of the input available cluster, gather nearby available clusters. More...
 
const pandora::Cluster * MergeClusterGroup (const pandora::ClusterList &clusterGroup)
 Merge a collection of available clusters together updating hit containers accordingly. More...
 
void CreatePfo (const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const pCluster3)
 Create a pfo from the input clusters updating the cluster to pfo map accordingly. More...
 
void PerformRecovery (const pandora::HitType hitType)
 Create a delta ray pfo from any remaining, significant clusters. More...
 

Private Attributes

std::string m_muonPfoListName
 The list of reconstructed cosmic ray pfos. More...
 
std::string m_deltaRayPfoListName
 The list of reconstructed delta ray pfos. More...
 
std::string m_inputClusterListNameU
 The list of reconstructed U clusters. More...
 
std::string m_inputClusterListNameV
 The list of reconstructed V clusters. More...
 
std::string m_inputClusterListNameW
 The list of reconstructed W clusters. More...
 
std::string m_outputPfoListName
 The list to receive the created delta ray pfos. More...
 
DeltaRayMatchingContainers m_deltaRayMatchingContainers
 The class of hit, cluster and pfo ownership and proximity maps. More...
 
float m_overlapExtension
 The extension to each side of the x overlap region in which to search for matched clusters. More...
 
unsigned int m_minClusterHits
 The minimum number of hits for a cluster to be significant. More...
 

Detailed Description

Constructor & Destructor Documentation

lar_content::OneViewDeltaRayMatchingAlgorithm::OneViewDeltaRayMatchingAlgorithm ( )

Default constructor.

Definition at line 23 of file OneViewDeltaRayMatchingAlgorithm.cc.

23  :
26 {
27 }
unsigned int m_minClusterHits
The minimum number of hits for a cluster to be significant.
TFile f
Definition: plotHisto.C:6
float m_overlapExtension
The extension to each side of the x overlap region in which to search for matched clusters...

Member Function Documentation

bool lar_content::OneViewDeltaRayMatchingAlgorithm::AddIntoExistingDeltaRay ( const pandora::Cluster *const  pAvailableCluster,
const pandora::PfoVector &  nearbyMuonPfoVector 
)
private

Use nearby muon pfos to project into other views and attempt to add a remaining delta ray cluster into an existing delta ray pfo.

Parameters
pAvailableClusterthe address of the delta ray cluster to add
nearbyMuonPfoVectorthe vector of nearby cosmic ray pfos
Returns
whether the input cluster was aded into an existing delta ray pfo

Definition at line 194 of file OneViewDeltaRayMatchingAlgorithm.cc.

References lar_content::DeltaRayMatchingContainers::AddClustersToPfoMaps(), GetBestProjectedCluster(), lar_content::LArClusterHelper::GetClusterHitType(), lar_content::DeltaRayMatchingContainers::GetClusterToPfoMap(), and m_deltaRayMatchingContainers.

Referenced by PerformOneViewMatching().

195 {
196  const HitType hitType(LArClusterHelper::GetClusterHitType(pAvailableCluster));
197  const HitType projectedHitType1((hitType == TPC_VIEW_U) ? TPC_VIEW_V : (hitType == TPC_VIEW_V) ? TPC_VIEW_W : TPC_VIEW_U);
198  const HitType projectedHitType2((projectedHitType1 == TPC_VIEW_U) ? TPC_VIEW_V
199  : (projectedHitType1 == TPC_VIEW_V) ? TPC_VIEW_W
200  : TPC_VIEW_U);
203 
204  for (const ParticleFlowObject *const pNearbyMuonPfo : nearbyMuonPfoVector)
205  {
206  const Cluster *const pProjectedCluster1(this->GetBestProjectedCluster({pAvailableCluster}, pNearbyMuonPfo, projectedHitType1, false));
207  const Cluster *const pProjectedCluster2(this->GetBestProjectedCluster({pAvailableCluster}, pNearbyMuonPfo, projectedHitType2, false));
208 
209  if ((!pProjectedCluster1) || (!pProjectedCluster2))
210  continue;
211 
212  const ParticleFlowObject *const pPfo1(clusterToPfoMap1.at(pProjectedCluster1));
213  const ParticleFlowObject *const pPfo2(clusterToPfoMap2.at(pProjectedCluster2));
214 
215  if (pPfo1 == pPfo2)
216  {
217  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*this, pPfo1, pAvailableCluster));
218 
220 
221  return true;
222  }
223  }
224 
225  return false;
226 }
std::map< const pandora::Cluster *, const pandora::ParticleFlowObject * > ClusterToPfoMap
void AddClustersToPfoMaps(const pandora::ParticleFlowObject *const pPfo)
Add the clusters of a cosmic ray/delta ray pfo to the cluster to pfo maps.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
const pandora::Cluster * GetBestProjectedCluster(const pandora::ClusterList &deltaRayClusterGroup, const pandora::ParticleFlowObject *const pNearbyMuonPfo, const pandora::HitType hitType, const bool findAvailable)
Get the best matched available or unavailable cluster of a remaining delta ray cluster group wrt a co...
const ClusterToPfoMap & GetClusterToPfoMap(const pandora::HitType hitType) const
Get the mapping of clusters to the pfos to which they belong.
DeltaRayMatchingContainers m_deltaRayMatchingContainers
The class of hit, cluster and pfo ownership and proximity maps.
HitType
Definition: HitType.h:12
void lar_content::OneViewDeltaRayMatchingAlgorithm::CreateDeltaRay ( const pandora::Cluster *const  pAvailableCluster,
const pandora::PfoVector &  nearbyMuonPfoVector,
pandora::ClusterSet &  modifiedClusters 
)
private

Use nearby muon pfos to project into other views and attempt to match a remaining delta ray cluster to form a delta ray pfo.

Parameters
pAvailableClusterthe address of the delta ray cluster to add
nearbyMuonPfoVectorthe vector of nearby cosmic ray pfos
modifiedClustersthe output list of any delta ray clusters in the view of pAvailableCluster made unavailable in this process

Definition at line 315 of file OneViewDeltaRayMatchingAlgorithm.cc.

References CreatePfo(), GetBestProjectedCluster(), lar_content::LArClusterHelper::GetClusterHitType(), GetNearbyAvailableClusters(), and MergeClusterGroup().

Referenced by PerformOneViewMatching().

316 {
317  ClusterList clusterGroup, consideredClusters;
318  this->GetNearbyAvailableClusters(pAvailableCluster, consideredClusters, clusterGroup);
319 
320  for (const Cluster *const pModifiedCluster : clusterGroup)
321  modifiedClusters.insert(pModifiedCluster);
322 
323  const HitType hitType(LArClusterHelper::GetClusterHitType(pAvailableCluster));
324  const HitType projectedHitType1((hitType == TPC_VIEW_U) ? TPC_VIEW_V : (hitType == TPC_VIEW_V) ? TPC_VIEW_W : TPC_VIEW_U);
325  const HitType projectedHitType2((projectedHitType1 == TPC_VIEW_U) ? TPC_VIEW_V
326  : (projectedHitType1 == TPC_VIEW_V) ? TPC_VIEW_W
327  : TPC_VIEW_U);
328  ClusterList projectedClusters1, projectedClusters2;
329 
330  for (const ParticleFlowObject *const pNearbyMuonPfo : nearbyMuonPfoVector)
331  {
332  const Cluster *const pProjectedCluster1(this->GetBestProjectedCluster(clusterGroup, pNearbyMuonPfo, projectedHitType1, true));
333  const Cluster *const pProjectedCluster2(this->GetBestProjectedCluster(clusterGroup, pNearbyMuonPfo, projectedHitType2, true));
334 
335  if ((!pProjectedCluster1) && (!pProjectedCluster2))
336  continue;
337 
338  ClusterList consideredClusters1;
339  if (pProjectedCluster1)
340  this->GetNearbyAvailableClusters(pProjectedCluster1, consideredClusters1, projectedClusters1);
341 
342  ClusterList consideredClusters2;
343  if (pProjectedCluster2)
344  this->GetNearbyAvailableClusters(pProjectedCluster2, consideredClusters2, projectedClusters2);
345  }
346 
347  const Cluster *const pCluster1(this->MergeClusterGroup(clusterGroup));
348  const Cluster *const pCluster2(this->MergeClusterGroup(projectedClusters1));
349  const Cluster *const pCluster3(this->MergeClusterGroup(projectedClusters2));
350 
351  this->CreatePfo(pCluster1, pCluster2, pCluster3);
352 }
void CreatePfo(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const pCluster3)
Create a pfo from the input clusters updating the cluster to pfo map accordingly. ...
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
const pandora::Cluster * GetBestProjectedCluster(const pandora::ClusterList &deltaRayClusterGroup, const pandora::ParticleFlowObject *const pNearbyMuonPfo, const pandora::HitType hitType, const bool findAvailable)
Get the best matched available or unavailable cluster of a remaining delta ray cluster group wrt a co...
const pandora::Cluster * MergeClusterGroup(const pandora::ClusterList &clusterGroup)
Merge a collection of available clusters together updating hit containers accordingly.
HitType
Definition: HitType.h:12
void GetNearbyAvailableClusters(const pandora::Cluster *const pCluster, pandora::ClusterList &consideredClusters, pandora::ClusterList &foundClusters)
In the view of the input available cluster, gather nearby available clusters.
void lar_content::OneViewDeltaRayMatchingAlgorithm::CreatePfo ( const pandora::Cluster *const  pCluster1,
const pandora::Cluster *const  pCluster2,
const pandora::Cluster *const  pCluster3 
)
private

Create a pfo from the input clusters updating the cluster to pfo map accordingly.

Parameters
pCluster1the address of the first cluster
pCluster2the address of the second cluster
pCluster3the address of the third cluster

Definition at line 424 of file OneViewDeltaRayMatchingAlgorithm.cc.

References lar_content::DeltaRayMatchingContainers::AddClustersToPfoMaps(), f, m_deltaRayMatchingContainers, and m_outputPfoListName.

Referenced by CreateDeltaRay(), and PerformRecovery().

425 {
426  const PfoList *pPfoList(nullptr);
427  std::string pfoListName;
428  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pPfoList, pfoListName));
429 
430  PandoraContentApi::ParticleFlowObject::Parameters pfoParameters;
431  pfoParameters.m_particleId = E_MINUS;
432  pfoParameters.m_charge = PdgTable::GetParticleCharge(E_MINUS);
433  pfoParameters.m_mass = PdgTable::GetParticleMass(E_MINUS);
434  pfoParameters.m_energy = 0.f;
435  pfoParameters.m_momentum = CartesianVector(0.f, 0.f, 0.f);
436 
437  if (pCluster1)
438  pfoParameters.m_clusterList.push_back(pCluster1);
439 
440  if (pCluster2)
441  pfoParameters.m_clusterList.push_back(pCluster2);
442 
443  if (pCluster3)
444  pfoParameters.m_clusterList.push_back(pCluster3);
445 
446  if (pfoParameters.m_clusterList.empty())
447  throw StatusCodeException(STATUS_CODE_FAILURE);
448 
449  const ParticleFlowObject *pPfo(nullptr);
450 
451  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*this, pfoParameters, pPfo));
452  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Pfo>(*this, m_outputPfoListName));
453  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Pfo>(*this, m_outputPfoListName));
454 
456 }
void AddClustersToPfoMaps(const pandora::ParticleFlowObject *const pPfo)
Add the clusters of a cosmic ray/delta ray pfo to the cluster to pfo maps.
TFile f
Definition: plotHisto.C:6
DeltaRayMatchingContainers m_deltaRayMatchingContainers
The class of hit, cluster and pfo ownership and proximity maps.
std::string m_outputPfoListName
The list to receive the created delta ray pfos.
const Cluster * lar_content::OneViewDeltaRayMatchingAlgorithm::GetBestProjectedCluster ( const pandora::ClusterList &  deltaRayClusterGroup,
const pandora::ParticleFlowObject *const  pNearbyMuonPfo,
const pandora::HitType  hitType,
const bool  findAvailable 
)
private

Get the best matched available or unavailable cluster of a remaining delta ray cluster group wrt a cosmic ray pfo.

Parameters
deltaRayClusterGroupthe input group of to be merged remaining delta ray clusters
pNearbyMuonPfothe address of the nearby cosmic ray pfo
hitTypethe hit type to project into
findAvailablewhether to search for available or unavailable delta ray clusters
Returns
whether the best matched cluster of the specified view

Definition at line 230 of file OneViewDeltaRayMatchingAlgorithm.cc.

References f, lar_content::DeltaRayMatchingContainers::GetClusterProximityMap(), lar_content::LArPfoHelper::GetClusters(), GetClusterSpanX(), IsDeltaRayPfo(), m_deltaRayMatchingContainers, and m_overlapExtension.

Referenced by AddIntoExistingDeltaRay(), and CreateDeltaRay().

232 {
233  ClusterList muonClusterList;
234  LArPfoHelper::GetClusters(pNearbyMuonPfo, hitType, muonClusterList);
235 
236  if (muonClusterList.size() != 1)
237  return nullptr;
238 
240  auto muonProximityIter(clusterProximityMap.find(muonClusterList.front()));
241 
242  if (muonProximityIter == clusterProximityMap.end())
243  return nullptr;
244 
245  float spanMinX(0.f), spanMaxX(0.f);
246  this->GetClusterSpanX(deltaRayClusterGroup, spanMinX, spanMaxX);
247 
248  unsigned int highestHit(0);
249  const Cluster *pProjectedCluster(nullptr);
250 
251  for (const Cluster *const pNearbyCluster : muonProximityIter->second)
252  {
253  if (findAvailable && !pNearbyCluster->IsAvailable())
254  continue;
255 
256  if (!findAvailable && !this->IsDeltaRayPfo(pNearbyCluster))
257  continue;
258 
259  float minX(0.f), maxX(0.f);
260  pNearbyCluster->GetClusterSpanX(minX, maxX);
261 
262  if ((maxX < (spanMinX - m_overlapExtension)) || (minX > (spanMaxX + m_overlapExtension)))
263  continue;
264 
265  if (pNearbyCluster->GetNCaloHits() > highestHit)
266  {
267  highestHit = pNearbyCluster->GetNCaloHits();
268  pProjectedCluster = pNearbyCluster;
269  }
270  }
271 
272  return pProjectedCluster;
273 }
const ClusterProximityMap & GetClusterProximityMap(const pandora::HitType hitType) const
Get the mapping of clusters to to their neighbouring clusters.
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.
bool IsDeltaRayPfo(const pandora::Cluster *const pCluster)
Determine whether an input cluster belongs to a delta ray pfo.
TFile f
Definition: plotHisto.C:6
void GetClusterSpanX(const pandora::ClusterList &clusterList, float &spanMinX, float &spanMaxX)
Determine cluster span (in x) of a group of clusters.
DeltaRayMatchingContainers m_deltaRayMatchingContainers
The class of hit, cluster and pfo ownership and proximity maps.
std::map< const pandora::Cluster *, pandora::ClusterList > ClusterProximityMap
float m_overlapExtension
The extension to each side of the x overlap region in which to search for matched clusters...
void lar_content::OneViewDeltaRayMatchingAlgorithm::GetClusterSpanX ( const pandora::ClusterList &  clusterList,
float &  spanMinX,
float &  spanMaxX 
)
private

Determine cluster span (in x) of a group of clusters.

Parameters
clusterListthe input list of clusters
spanMinXthe output minimum x value
spanMaxXthe output maximum x value

Definition at line 295 of file OneViewDeltaRayMatchingAlgorithm.cc.

References f.

Referenced by GetBestProjectedCluster().

296 {
297  spanMinX = std::numeric_limits<float>::max();
298  spanMaxX = -std::numeric_limits<float>::max();
299 
300  for (const Cluster *const pCluster : clusterList)
301  {
302  float minX(0.f), maxX(0.f);
303  pCluster->GetClusterSpanX(minX, maxX);
304 
305  if (minX < spanMinX)
306  spanMinX = minX;
307 
308  if (maxX > spanMaxX)
309  spanMaxX = maxX;
310  }
311 }
TFile f
Definition: plotHisto.C:6
const PfoList lar_content::OneViewDeltaRayMatchingAlgorithm::GetDeltaRayPfoList ( )
private

Get the input delta ray pfo list.

Returns
the input delta ray pfo list

Definition at line 88 of file OneViewDeltaRayMatchingAlgorithm.cc.

References m_deltaRayPfoListName.

Referenced by IsDeltaRayPfo(), and Run().

89 {
90  const PfoList *pDeltaRayPfoList(nullptr);
91 
92  PANDORA_THROW_RESULT_IF_AND_IF(
93  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_deltaRayPfoListName, pDeltaRayPfoList));
94 
95  if (!pDeltaRayPfoList)
96  return PfoList();
97 
98  return *pDeltaRayPfoList;
99 }
std::string m_deltaRayPfoListName
The list of reconstructed delta ray pfos.
const ClusterList lar_content::OneViewDeltaRayMatchingAlgorithm::GetInputClusterList ( const pandora::HitType  hitType)
private

Get the input cluster list of a given hit type.

Parameters
hitTypethe hit type of list to retrieve
Returns
the input cluster list of the specified hit type

Definition at line 54 of file OneViewDeltaRayMatchingAlgorithm.cc.

References m_inputClusterListNameU, m_inputClusterListNameV, and m_inputClusterListNameW.

Referenced by PerformRecovery(), and Run().

55 {
56  const std::string inputClusterListName((hitType == TPC_VIEW_U) ? m_inputClusterListNameU
57  : (hitType == TPC_VIEW_V) ? m_inputClusterListNameV
59 
60  const ClusterList *pInputClusterList(nullptr);
61 
62  PANDORA_THROW_RESULT_IF_AND_IF(
63  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, inputClusterListName, pInputClusterList));
64 
65  if (!pInputClusterList)
66  return ClusterList();
67 
68  return *pInputClusterList;
69 }
std::string m_inputClusterListNameW
The list of reconstructed W clusters.
std::string m_inputClusterListNameU
The list of reconstructed U clusters.
std::string m_inputClusterListNameV
The list of reconstructed V clusters.
const PfoList lar_content::OneViewDeltaRayMatchingAlgorithm::GetMuonPfoList ( )
private

Get the input cosmic ray pfo list.

Returns
the input cosmic ray pfo list

Definition at line 73 of file OneViewDeltaRayMatchingAlgorithm.cc.

References m_muonPfoListName.

Referenced by IsMuonPfo(), and Run().

74 {
75  const PfoList *pMuonPfoList(nullptr);
76 
77  PANDORA_THROW_RESULT_IF_AND_IF(
78  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_muonPfoListName, pMuonPfoList));
79 
80  if (!pMuonPfoList)
81  return PfoList();
82 
83  return *pMuonPfoList;
84 }
std::string m_muonPfoListName
The list of reconstructed cosmic ray pfos.
void lar_content::OneViewDeltaRayMatchingAlgorithm::GetNearbyAvailableClusters ( const pandora::Cluster *const  pCluster,
pandora::ClusterList &  consideredClusters,
pandora::ClusterList &  foundClusters 
)
private

In the view of the input available cluster, gather nearby available clusters.

Parameters
pClusterthe input available cluster
consideredClustersthe list of investigated clusters
foundClustersthe output list of nearby available clusters (including the available cluster)

Definition at line 356 of file OneViewDeltaRayMatchingAlgorithm.cc.

References lar_content::LArClusterHelper::GetClusterHitType(), lar_content::DeltaRayMatchingContainers::GetClusterProximityMap(), and m_deltaRayMatchingContainers.

Referenced by CreateDeltaRay().

357 {
358  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
360 
361  consideredClusters.push_back(pCluster);
362 
363  if (!pCluster->IsAvailable())
364  return;
365 
366  if (std::find(foundClusters.begin(), foundClusters.end(), pCluster) == foundClusters.end())
367  foundClusters.push_back(pCluster);
368 
369  const DeltaRayMatchingContainers::ClusterProximityMap::const_iterator proximityIter(clusterProximityMap.find(pCluster));
370 
371  if (proximityIter == clusterProximityMap.end())
372  return;
373 
374  for (const Cluster *const pNearbyCluster : proximityIter->second)
375  {
376  if (!pNearbyCluster->IsAvailable())
377  continue;
378 
379  if (std::find(consideredClusters.begin(), consideredClusters.end(), pNearbyCluster) != consideredClusters.end())
380  continue;
381 
382  if (std::find(foundClusters.begin(), foundClusters.end(), pNearbyCluster) != foundClusters.end())
383  continue;
384 
385  this->GetNearbyAvailableClusters(pNearbyCluster, consideredClusters, foundClusters);
386  }
387 }
const ClusterProximityMap & GetClusterProximityMap(const pandora::HitType hitType) const
Get the mapping of clusters to to their neighbouring clusters.
intermediate_table::const_iterator const_iterator
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
DeltaRayMatchingContainers m_deltaRayMatchingContainers
The class of hit, cluster and pfo ownership and proximity maps.
std::map< const pandora::Cluster *, pandora::ClusterList > ClusterProximityMap
HitType
Definition: HitType.h:12
void GetNearbyAvailableClusters(const pandora::Cluster *const pCluster, pandora::ClusterList &consideredClusters, pandora::ClusterList &foundClusters)
In the view of the input available cluster, gather nearby available clusters.
bool lar_content::OneViewDeltaRayMatchingAlgorithm::IsDeltaRayPfo ( const pandora::Cluster *const  pCluster)
private

Determine whether an input cluster belongs to a delta ray pfo.

Parameters
pClusterthe address of the input cluster
Returns
whether the input cluster belongs to a delta ray pfo

Definition at line 277 of file OneViewDeltaRayMatchingAlgorithm.cc.

References lar_content::LArClusterHelper::GetClusterHitType(), lar_content::DeltaRayMatchingContainers::GetClusterToPfoMap(), GetDeltaRayPfoList(), and m_deltaRayMatchingContainers.

Referenced by GetBestProjectedCluster().

278 {
279  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
281 
282  const DeltaRayMatchingContainers::ClusterToPfoMap::const_iterator iter(clusterToPfoMap.find(pCluster));
283 
284  if (iter == clusterToPfoMap.end())
285  return false;
286 
287  const ParticleFlowObject *const pDeltaRayPfo(iter->second);
288  const PfoList &deltaRayPfoList(this->GetDeltaRayPfoList());
289 
290  return (std::find(deltaRayPfoList.begin(), deltaRayPfoList.end(), pDeltaRayPfo) != deltaRayPfoList.end());
291 }
std::map< const pandora::Cluster *, const pandora::ParticleFlowObject * > ClusterToPfoMap
const pandora::PfoList GetDeltaRayPfoList()
Get the input delta ray pfo list.
intermediate_table::const_iterator const_iterator
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
const ClusterToPfoMap & GetClusterToPfoMap(const pandora::HitType hitType) const
Get the mapping of clusters to the pfos to which they belong.
DeltaRayMatchingContainers m_deltaRayMatchingContainers
The class of hit, cluster and pfo ownership and proximity maps.
HitType
Definition: HitType.h:12
bool lar_content::OneViewDeltaRayMatchingAlgorithm::IsMuonPfo ( const pandora::Cluster *const  pCluster)
private

Determine whether an input cluster belongs to a cosmic ray pfo.

Parameters
pClusterthe address of the input cluster
Returns
whether the input cluster belongs to a cosmic ray pfo

Definition at line 177 of file OneViewDeltaRayMatchingAlgorithm.cc.

References lar_content::LArClusterHelper::GetClusterHitType(), lar_content::DeltaRayMatchingContainers::GetClusterToPfoMap(), GetMuonPfoList(), and m_deltaRayMatchingContainers.

Referenced by PerformOneViewMatching().

178 {
179  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
181  const DeltaRayMatchingContainers::ClusterToPfoMap::const_iterator iter(clusterToPfoMap.find(pCluster));
182 
183  if (iter == clusterToPfoMap.end())
184  return false;
185 
186  const ParticleFlowObject *const pPfo(iter->second);
187  const PfoList &muonPfoList(this->GetMuonPfoList());
188 
189  return (std::find(muonPfoList.begin(), muonPfoList.end(), pPfo) != muonPfoList.end());
190 }
std::map< const pandora::Cluster *, const pandora::ParticleFlowObject * > ClusterToPfoMap
intermediate_table::const_iterator const_iterator
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
const ClusterToPfoMap & GetClusterToPfoMap(const pandora::HitType hitType) const
Get the mapping of clusters to the pfos to which they belong.
DeltaRayMatchingContainers m_deltaRayMatchingContainers
The class of hit, cluster and pfo ownership and proximity maps.
HitType
Definition: HitType.h:12
const pandora::PfoList GetMuonPfoList()
Get the input cosmic ray pfo list.
const Cluster * lar_content::OneViewDeltaRayMatchingAlgorithm::MergeClusterGroup ( const pandora::ClusterList &  clusterGroup)
private

Merge a collection of available clusters together updating hit containers accordingly.

Parameters
clusterGroupthe input group of clusters to merge
themerged cluster

Definition at line 391 of file OneViewDeltaRayMatchingAlgorithm.cc.

References lar_content::DeltaRayMatchingContainers::AddClustersToContainers(), lar_content::LArClusterHelper::GetClusterHitType(), m_deltaRayMatchingContainers, m_inputClusterListNameU, m_inputClusterListNameV, m_inputClusterListNameW, and lar_content::DeltaRayMatchingContainers::RemoveClusterFromContainers().

Referenced by CreateDeltaRay().

392 {
393  if (clusterGroup.empty())
394  return nullptr;
395 
396  const Cluster *const pClusterToEnlarge(clusterGroup.front());
397 
398  if (clusterGroup.size() == 1)
399  return pClusterToEnlarge;
400 
401  const HitType hitType(LArClusterHelper::GetClusterHitType(pClusterToEnlarge));
402  const std::string inputClusterListName((hitType == TPC_VIEW_U) ? m_inputClusterListNameU
403  : (hitType == TPC_VIEW_V) ? m_inputClusterListNameV
405 
406  for (const Cluster *const pClusterToDelete : clusterGroup)
407  {
409 
410  if (pClusterToDelete != pClusterToEnlarge)
411  {
412  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Cluster>(*this, inputClusterListName));
413  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::MergeAndDeleteClusters(*this, pClusterToEnlarge, pClusterToDelete));
414  }
415  }
416 
417  m_deltaRayMatchingContainers.AddClustersToContainers({pClusterToEnlarge}, {nullptr});
418 
419  return pClusterToEnlarge;
420 }
std::string m_inputClusterListNameW
The list of reconstructed W clusters.
std::string m_inputClusterListNameU
The list of reconstructed U clusters.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
std::string m_inputClusterListNameV
The list of reconstructed V clusters.
void AddClustersToContainers(const pandora::ClusterVector &newClusterVector, const pandora::PfoVector &pfoVector)
Add a list of clusters to the hit to cluster and cluster proximity maps and, if appropriate, to the cluster to pfo map.
DeltaRayMatchingContainers m_deltaRayMatchingContainers
The class of hit, cluster and pfo ownership and proximity maps.
HitType
Definition: HitType.h:12
void RemoveClusterFromContainers(const pandora::Cluster *const pDeletedCluster)
Remove an input cluster&#39;s hits from the hit to cluster and cluster proximity maps and...
void lar_content::OneViewDeltaRayMatchingAlgorithm::PerformOneViewMatching ( const pandora::HitType  hitType)
private

Use nearby muon pfos to project into other views and attempt to match the remaining delta ray clusters.

Parameters
hitTypethe hit type of the input cluster and of the map to add to

Definition at line 103 of file OneViewDeltaRayMatchingAlgorithm.cc.

References AddIntoExistingDeltaRay(), CreateDeltaRay(), lar_content::LArClusterHelper::GetClosestDistance(), lar_content::DeltaRayMatchingContainers::GetClusterProximityMap(), lar_content::DeltaRayMatchingContainers::GetClusterToPfoMap(), IsMuonPfo(), m_deltaRayMatchingContainers, and lar_content::LArClusterHelper::SortByNHits().

Referenced by Run().

104 {
107  ClusterVector availableClusterList;
108 
109  for (auto &entry : clusterProximityMap)
110  {
111  if (entry.first->IsAvailable())
112  availableClusterList.push_back(entry.first);
113  }
114 
115  std::sort(availableClusterList.begin(), availableClusterList.end(), LArClusterHelper::SortByNHits);
116 
117  ClusterSet modifiedClusters;
118 
119  for (const Cluster *const pAvailableCluster : availableClusterList)
120  {
121  if (modifiedClusters.count(pAvailableCluster))
122  continue;
123 
124  const DeltaRayMatchingContainers::ClusterProximityMap::const_iterator iter(clusterProximityMap.find(pAvailableCluster));
125 
126  // ATTN: Map will update during loop
127  if (iter == clusterProximityMap.end())
128  continue;
129 
130  bool found(false);
131  const ClusterList &nearbyClusters(clusterProximityMap.at(pAvailableCluster));
132  PfoVector nearbyMuonPfoVector;
133 
134  do
135  {
136  found = false;
137 
138  const ParticleFlowObject *pClosestMuonPfo(nullptr);
139  float closestDistance(std::numeric_limits<float>::max());
140 
141  for (const Cluster *const pNearbyCluster : nearbyClusters)
142  {
143  if (!this->IsMuonPfo(pNearbyCluster))
144  continue;
145 
146  if (std::find(nearbyMuonPfoVector.begin(), nearbyMuonPfoVector.end(), clusterToPfoMap.at(pNearbyCluster)) !=
147  nearbyMuonPfoVector.end())
148  continue;
149 
150  found = true;
151 
152  const float separation(LArClusterHelper::GetClosestDistance(pNearbyCluster, pAvailableCluster));
153 
154  if (separation < closestDistance)
155  {
156  closestDistance = separation;
157  pClosestMuonPfo = clusterToPfoMap.at(pNearbyCluster);
158  }
159  }
160 
161  if (pClosestMuonPfo)
162  nearbyMuonPfoVector.push_back(pClosestMuonPfo);
163  } while (found);
164 
165  if (nearbyMuonPfoVector.empty())
166  continue;
167 
168  if (this->AddIntoExistingDeltaRay(pAvailableCluster, nearbyMuonPfoVector))
169  continue;
170 
171  this->CreateDeltaRay(pAvailableCluster, nearbyMuonPfoVector, modifiedClusters);
172  }
173 }
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
std::map< const pandora::Cluster *, const pandora::ParticleFlowObject * > ClusterToPfoMap
const ClusterProximityMap & GetClusterProximityMap(const pandora::HitType hitType) const
Get the mapping of clusters to to their neighbouring clusters.
bool AddIntoExistingDeltaRay(const pandora::Cluster *const pAvailableCluster, const pandora::PfoVector &nearbyMuonPfoVector)
Use nearby muon pfos to project into other views and attempt to add a remaining delta ray cluster int...
void CreateDeltaRay(const pandora::Cluster *const pAvailableCluster, const pandora::PfoVector &nearbyMuonPfoVector, pandora::ClusterSet &modifiedClusters)
Use nearby muon pfos to project into other views and attempt to match a remaining delta ray cluster t...
intermediate_table::const_iterator const_iterator
const ClusterToPfoMap & GetClusterToPfoMap(const pandora::HitType hitType) const
Get the mapping of clusters to the pfos to which they belong.
DeltaRayMatchingContainers m_deltaRayMatchingContainers
The class of hit, cluster and pfo ownership and proximity maps.
bool IsMuonPfo(const pandora::Cluster *const pCluster)
Determine whether an input cluster belongs to a cosmic ray pfo.
std::map< const pandora::Cluster *, pandora::ClusterList > ClusterProximityMap
std::vector< art::Ptr< recob::Cluster > > ClusterVector
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::OneViewDeltaRayMatchingAlgorithm::PerformRecovery ( const pandora::HitType  hitType)
private

Create a delta ray pfo from any remaining, significant clusters.

Parameters
hitTypethe view to run in

Definition at line 460 of file OneViewDeltaRayMatchingAlgorithm.cc.

References CreatePfo(), GetInputClusterList(), and m_minClusterHits.

Referenced by Run().

461 {
462  const ClusterList &inputClusterList(this->GetInputClusterList(hitType));
463 
464  for (const Cluster *const pCluster : inputClusterList)
465  {
466  if (!pCluster->IsAvailable())
467  continue;
468 
469  if (pCluster->GetNCaloHits() < m_minClusterHits)
470  continue;
471 
472  this->CreatePfo(pCluster, nullptr, nullptr);
473  }
474 }
const pandora::ClusterList GetInputClusterList(const pandora::HitType hitType)
Get the input cluster list of a given hit type.
unsigned int m_minClusterHits
The minimum number of hits for a cluster to be significant.
void CreatePfo(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const pCluster3)
Create a pfo from the input clusters updating the cluster to pfo map accordingly. ...
StatusCode lar_content::OneViewDeltaRayMatchingAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 478 of file OneViewDeltaRayMatchingAlgorithm.cc.

References m_deltaRayMatchingContainers, m_deltaRayPfoListName, m_inputClusterListNameU, m_inputClusterListNameV, m_inputClusterListNameW, m_minClusterHits, m_muonPfoListName, m_outputPfoListName, m_overlapExtension, and lar_content::DeltaRayMatchingContainers::m_searchRegion1D.

479 {
480  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "MuonPfoListName", m_muonPfoListName));
481 
482  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "DeltaRayPfoListName", m_deltaRayPfoListName));
483 
484  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputClusterListNameU", m_inputClusterListNameU));
485 
486  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputClusterListNameV", m_inputClusterListNameV));
487 
488  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputClusterListNameW", m_inputClusterListNameW));
489 
490  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "OutputPfoListName", m_outputPfoListName));
491 
492  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
493  XmlHelper::ReadValue(xmlHandle, "SearchRegion1D", m_deltaRayMatchingContainers.m_searchRegion1D));
494 
495  PANDORA_RETURN_RESULT_IF_AND_IF(
496  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "OverlapExtension", m_overlapExtension));
497 
498  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinClusterHits", m_minClusterHits));
499 
500  return STATUS_CODE_SUCCESS;
501 }
std::string m_inputClusterListNameW
The list of reconstructed W clusters.
unsigned int m_minClusterHits
The minimum number of hits for a cluster to be significant.
std::string m_inputClusterListNameU
The list of reconstructed U clusters.
std::string m_muonPfoListName
The list of reconstructed cosmic ray pfos.
std::string m_inputClusterListNameV
The list of reconstructed V clusters.
DeltaRayMatchingContainers m_deltaRayMatchingContainers
The class of hit, cluster and pfo ownership and proximity maps.
float m_overlapExtension
The extension to each side of the x overlap region in which to search for matched clusters...
std::string m_deltaRayPfoListName
The list of reconstructed delta ray pfos.
std::string m_outputPfoListName
The list to receive the created delta ray pfos.
float m_searchRegion1D
Search region, applied to each dimension, for look-up from kd-tree.
StatusCode lar_content::OneViewDeltaRayMatchingAlgorithm::Run ( )
private

Definition at line 31 of file OneViewDeltaRayMatchingAlgorithm.cc.

References lar_content::DeltaRayMatchingContainers::ClearContainers(), lar_content::DeltaRayMatchingContainers::FillContainers(), GetDeltaRayPfoList(), GetInputClusterList(), GetMuonPfoList(), m_deltaRayMatchingContainers, PerformOneViewMatching(), and PerformRecovery().

32 {
33  const PfoList muonPfoList(this->GetMuonPfoList());
34  PfoList allPfoList(this->GetDeltaRayPfoList());
35 
36  allPfoList.insert(allPfoList.end(), muonPfoList.begin(), muonPfoList.end());
37 
39  allPfoList, this->GetInputClusterList(TPC_VIEW_U), this->GetInputClusterList(TPC_VIEW_V), this->GetInputClusterList(TPC_VIEW_W));
40 
41  for (const HitType hitType : {TPC_VIEW_U, TPC_VIEW_V, TPC_VIEW_W})
42  this->PerformOneViewMatching(hitType);
43 
44  for (const HitType hitType : {TPC_VIEW_U, TPC_VIEW_V, TPC_VIEW_W})
45  this->PerformRecovery(hitType);
46 
48 
49  return STATUS_CODE_SUCCESS;
50 }
const pandora::ClusterList GetInputClusterList(const pandora::HitType hitType)
Get the input cluster list of a given hit type.
const pandora::PfoList GetDeltaRayPfoList()
Get the input delta ray pfo list.
void FillContainers(const pandora::PfoList &inputPfoList, const pandora::ClusterList &inputClusterList1, const pandora::ClusterList &inputClusterList2=pandora::ClusterList(), const pandora::ClusterList &inputClusterList3=pandora::ClusterList())
Fill the HitToClusterMap, the ClusterProximityMap and the ClusterToPfoMap in all input views...
void PerformOneViewMatching(const pandora::HitType hitType)
Use nearby muon pfos to project into other views and attempt to match the remaining delta ray cluster...
DeltaRayMatchingContainers m_deltaRayMatchingContainers
The class of hit, cluster and pfo ownership and proximity maps.
HitType
Definition: HitType.h:12
void PerformRecovery(const pandora::HitType hitType)
Create a delta ray pfo from any remaining, significant clusters.
const pandora::PfoList GetMuonPfoList()
Get the input cosmic ray pfo list.
void ClearContainers()
Empty all algorithm containers.

Member Data Documentation

DeltaRayMatchingContainers lar_content::OneViewDeltaRayMatchingAlgorithm::m_deltaRayMatchingContainers
private
std::string lar_content::OneViewDeltaRayMatchingAlgorithm::m_deltaRayPfoListName
private

The list of reconstructed delta ray pfos.

Definition at line 159 of file OneViewDeltaRayMatchingAlgorithm.h.

Referenced by GetDeltaRayPfoList(), and ReadSettings().

std::string lar_content::OneViewDeltaRayMatchingAlgorithm::m_inputClusterListNameU
private

The list of reconstructed U clusters.

Definition at line 160 of file OneViewDeltaRayMatchingAlgorithm.h.

Referenced by GetInputClusterList(), MergeClusterGroup(), and ReadSettings().

std::string lar_content::OneViewDeltaRayMatchingAlgorithm::m_inputClusterListNameV
private

The list of reconstructed V clusters.

Definition at line 161 of file OneViewDeltaRayMatchingAlgorithm.h.

Referenced by GetInputClusterList(), MergeClusterGroup(), and ReadSettings().

std::string lar_content::OneViewDeltaRayMatchingAlgorithm::m_inputClusterListNameW
private

The list of reconstructed W clusters.

Definition at line 162 of file OneViewDeltaRayMatchingAlgorithm.h.

Referenced by GetInputClusterList(), MergeClusterGroup(), and ReadSettings().

unsigned int lar_content::OneViewDeltaRayMatchingAlgorithm::m_minClusterHits
private

The minimum number of hits for a cluster to be significant.

Definition at line 166 of file OneViewDeltaRayMatchingAlgorithm.h.

Referenced by PerformRecovery(), and ReadSettings().

std::string lar_content::OneViewDeltaRayMatchingAlgorithm::m_muonPfoListName
private

The list of reconstructed cosmic ray pfos.

Definition at line 158 of file OneViewDeltaRayMatchingAlgorithm.h.

Referenced by GetMuonPfoList(), and ReadSettings().

std::string lar_content::OneViewDeltaRayMatchingAlgorithm::m_outputPfoListName
private

The list to receive the created delta ray pfos.

Definition at line 163 of file OneViewDeltaRayMatchingAlgorithm.h.

Referenced by CreatePfo(), and ReadSettings().

float lar_content::OneViewDeltaRayMatchingAlgorithm::m_overlapExtension
private

The extension to each side of the x overlap region in which to search for matched clusters.

Definition at line 165 of file OneViewDeltaRayMatchingAlgorithm.h.

Referenced by GetBestProjectedCluster(), and ReadSettings().


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