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

ThreeViewShowersAlgorithm class. More...

#include "ThreeViewShowersAlgorithm.h"

Inheritance diagram for lar_content::ThreeViewShowersAlgorithm:
lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< ShowerOverlapResult > > lar_content::MatchingBaseAlgorithm

Classes

class  XSampling
 XSampling class. More...
 

Public Types

typedef NViewMatchingAlgorithm< ThreeViewMatchingControl< ShowerOverlapResult > > BaseAlgorithm
 
typedef ThreeViewMatchingControl< ShowerOverlapResultMatchingType
 

Public Member Functions

 ThreeViewShowersAlgorithm ()
 Default constructor. More...
 
const TwoDSlidingShowerFitResultGetCachedSlidingFitResult (const pandora::Cluster *const pCluster) const
 Get a sliding shower fit result from the algorithm cache. More...
 
void UpdateForNewCluster (const pandora::Cluster *const pNewCluster)
 Update to reflect addition of a new cluster to the problem space. More...
 
void UpdateUponDeletion (const pandora::Cluster *const pDeletedCluster)
 Update to reflect cluster deletion. More...
 
void SelectInputClusters (const pandora::ClusterList *const pInputClusterList, pandora::ClusterList &selectedClusterList) const
 Select a subset of input clusters for processing in this algorithm. More...
 
void PrepareInputClusters (pandora::ClusterList &preparedClusterList)
 Perform any preparatory steps required on the input clusters, e.g. caching expensive fit results. More...
 
const std::string & GetClusterListName (const pandora::HitType hitType) const
 Get the cluster list name corresponding to a specified hit type. More...
 
const pandora::ClusterList & GetInputClusterList (const pandora::HitType hitType) const
 Get the input cluster list corresponding to a specified hit type. More...
 
const pandora::ClusterList & GetSelectedClusterList (const pandora::HitType hitType) const
 Get the selected cluster list corresponding to a specified hit type. More...
 
virtual bool MakeClusterMerges (const ClusterMergeMap &clusterMergeMap)
 Merge clusters together. More...
 
virtual bool CreateThreeDParticles (const ProtoParticleVector &protoParticleVector)
 Create particles using findings from recent algorithm processing. More...
 
virtual void SetPfoParameters (const ProtoParticle &protoParticle, PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const
 Set Pfo properties. More...
 
virtual void SetPfoParticleId (PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const
 Set pfo particle id. More...
 

Protected Member Functions

MatchingTypeGetMatchingControl ()
 Get the matching control. More...
 
virtual void SelectAllInputClusters ()
 Select a subset of input clusters for processing in this algorithm. More...
 
virtual void PrepareAllInputClusters ()
 Perform any preparatory steps required, e.g. caching expensive fit results for clusters. More...
 
virtual void PerformMainLoop ()
 Main loop over cluster combinations in order to populate the overlap container. Responsible for calling CalculateOverlapResult. More...
 

Protected Attributes

MatchingType m_matchingControl
 The matching control. More...
 

Private Types

typedef std::pair< ShowerPositionMap, ShowerPositionMapShowerPositionMapPair
 
typedef std::vector< ShowerTensorTool * > TensorToolVector
 

Private Member Functions

void TidyUp ()
 Tidy member variables in derived class. More...
 
void AddToSlidingFitCache (const pandora::Cluster *const pCluster)
 Add a new sliding fit result, for the specified cluster, to the algorithm cache. More...
 
void RemoveFromSlidingFitCache (const pandora::Cluster *const pCluster)
 Remova an existing sliding fit result, for the specified cluster, from the algorithm cache. More...
 
void CalculateOverlapResult (const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW)
 Calculate cluster overlap result and store in container. More...
 
pandora::StatusCode CalculateOverlapResult (const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW, ShowerOverlapResult &overlapResult)
 Calculate the overlap result for given group of clusters. More...
 
void GetShowerPositionMaps (const TwoDSlidingShowerFitResult &fitResultU, const TwoDSlidingShowerFitResult &fitResultV, const TwoDSlidingShowerFitResult &fitResultW, const XSampling &xSampling, ShowerPositionMapPair &positionMapsU, ShowerPositionMapPair &positionMapsV, ShowerPositionMapPair &positionMapsW) const
 Get the shower position maps. More...
 
void GetBestHitOverlapFraction (const pandora::Cluster *const pCluster, const XSampling &xSampling, const ShowerPositionMapPair &positionMaps, unsigned int &nSampledHits, unsigned int &nMatchedHits) const
 Get the best fraction of hits, in the common x-overlap range, contained within the provided pair of shower boundaries. More...
 
void ExamineOverlapContainer ()
 Examine contents of overlap container, collect together best-matching 2D particles and modify clusters as required. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

TensorToolVector m_algorithmToolVector
 The algorithm tool vector. More...
 
unsigned int m_nMaxTensorToolRepeats
 The maximum number of repeat loops over tensor tools. More...
 
unsigned int m_slidingFitWindow
 The layer window for the sliding linear fits. More...
 
TwoDSlidingShowerFitResultMap m_slidingFitResultMap
 The sliding shower fit result map. More...
 
bool m_ignoreUnavailableClusters
 Whether to ignore (skip-over) unavailable clusters. More...
 
unsigned int m_minClusterCaloHits
 The min number of hits in base cluster selection method. More...
 
float m_minClusterLengthSquared
 The min length (squared) in base cluster selection method. More...
 
float m_minShowerMatchedFraction
 The minimum shower matched sampling fraction to allow shower grouping. More...
 
unsigned int m_minShowerMatchedPoints
 The minimum number of matched shower sampling points to allow shower grouping. More...
 
bool m_visualize
 Visualize cluster matching procedure. More...
 

Detailed Description

ThreeViewShowersAlgorithm class.

Definition at line 29 of file ThreeViewShowersAlgorithm.h.

Member Typedef Documentation

Constructor & Destructor Documentation

lar_content::ThreeViewShowersAlgorithm::ThreeViewShowersAlgorithm ( )

Default constructor.

Definition at line 21 of file ThreeViewShowersAlgorithm.cc.

21  :
29  m_visualize(false)
30 {
31 }
unsigned int m_nMaxTensorToolRepeats
The maximum number of repeat loops over tensor tools.
TFile f
Definition: plotHisto.C:6
unsigned int m_minClusterCaloHits
The min number of hits in base cluster selection method.
unsigned int m_minShowerMatchedPoints
The minimum number of matched shower sampling points to allow shower grouping.
float m_minClusterLengthSquared
The min length (squared) in base cluster selection method.
bool m_visualize
Visualize cluster matching procedure.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
bool m_ignoreUnavailableClusters
Whether to ignore (skip-over) unavailable clusters.
float m_minShowerMatchedFraction
The minimum shower matched sampling fraction to allow shower grouping.

Member Function Documentation

void lar_content::ThreeViewShowersAlgorithm::AddToSlidingFitCache ( const pandora::Cluster *const  pCluster)
private

Add a new sliding fit result, for the specified cluster, to the algorithm cache.

Parameters
pClusteraddress of the relevant cluster

Definition at line 136 of file ThreeViewShowersAlgorithm.cc.

References lar_content::LArClusterHelper::GetClusterHitType(), lar_content::LArGeometryHelper::GetWirePitch(), m_slidingFitResultMap, and m_slidingFitWindow.

Referenced by PrepareInputClusters(), and UpdateForNewCluster().

137 {
138  const float slidingFitPitch(LArGeometryHelper::GetWirePitch(this->GetPandora(), LArClusterHelper::GetClusterHitType(pCluster)));
139  const TwoDSlidingShowerFitResult slidingShowerFitResult(pCluster, m_slidingFitWindow, slidingFitPitch);
140 
141  if (!m_slidingFitResultMap.insert(TwoDSlidingShowerFitResultMap::value_type(pCluster, slidingShowerFitResult)).second)
142  throw StatusCodeException(STATUS_CODE_FAILURE);
143 }
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
TwoDSlidingShowerFitResultMap m_slidingFitResultMap
The sliding shower fit result map.
static float GetWirePitch(const pandora::Pandora &pandora, const pandora::HitType view, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
void lar_content::ThreeViewShowersAlgorithm::CalculateOverlapResult ( const pandora::Cluster *const  pCluster1,
const pandora::Cluster *const  pCluster2,
const pandora::Cluster *const  pCluster3 
)
privatevirtual

Calculate cluster overlap result and store in container.

Parameters
pCluster1address of cluster1
pCluster2address of cluster2
pCluster3address of cluster3

Implements lar_content::MatchingBaseAlgorithm.

Referenced by RemoveFromSlidingFitCache().

pandora::StatusCode lar_content::ThreeViewShowersAlgorithm::CalculateOverlapResult ( const pandora::Cluster *const  pClusterU,
const pandora::Cluster *const  pClusterV,
const pandora::Cluster *const  pClusterW,
ShowerOverlapResult overlapResult 
)
private

Calculate the overlap result for given group of clusters.

Parameters
pClusterUthe cluster from the U view
pClusterVthe cluster from the V view
pClusterWthe cluster from the W view
overlapResultto receive the overlap result
bool lar_content::MatchingBaseAlgorithm::CreateThreeDParticles ( const ProtoParticleVector protoParticleVector)
virtualinherited

Create particles using findings from recent algorithm processing.

Parameters
protoParticleVectorthe proto particle vector
whetherparticles were created

Definition at line 88 of file MatchingBaseAlgorithm.cc.

Referenced by lar_content::NViewDeltaRayMatchingAlgorithm< T >::CreatePfos(), lar_content::ClearRemnantsTool::CreateThreeDParticles(), lar_content::ClearTracksTool::CreateThreeDParticles(), lar_content::TwoViewClearTracksTool::CreateThreeDParticles(), lar_content::ClearLongitudinalTracksTool::CreateThreeDParticles(), lar_content::ClearTrackFragmentsTool::FindTrackFragments(), lar_content::MatchedEndPointsTool::Run(), lar_content::SimpleShowersTool::Run(), lar_content::ConnectedRemnantsTool::Run(), lar_content::MopUpRemnantsTool::Run(), lar_content::TwoViewSimpleTracksTool::Run(), lar_content::MissingTrackTool::Run(), lar_content::TracksCrossingGapsTool::Run(), lar_content::MissingTrackSegmentTool::Run(), lar_content::LongTracksTool::Run(), lar_content::TwoViewLongTracksTool::Run(), and lar_content::ClearShowersTool::Run().

89 {
90  bool particlesMade(false);
91  const PfoList *pPfoList(nullptr);
92  std::string pfoListName;
93  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pPfoList, pfoListName));
94 
95  for (const ProtoParticle &protoParticle : protoParticleVector)
96  {
97  PandoraContentApi::ParticleFlowObject::Parameters pfoParameters;
98  this->SetPfoParameters(protoParticle, pfoParameters);
99 
100  const ParticleFlowObject *pPfo(nullptr);
101  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*this, pfoParameters, pPfo));
102  particlesMade = true;
103  }
104 
105  if (!pPfoList->empty())
106  {
107  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Pfo>(*this, m_outputPfoListName));
108  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Pfo>(*this, m_outputPfoListName));
109  }
110 
111  return particlesMade;
112 }
virtual void SetPfoParameters(const ProtoParticle &protoParticle, PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const
Set Pfo properties.
std::string m_outputPfoListName
The output pfo list name.
void lar_content::ThreeViewShowersAlgorithm::ExamineOverlapContainer ( )
privatevirtual

Examine contents of overlap container, collect together best-matching 2D particles and modify clusters as required.

Implements lar_content::MatchingBaseAlgorithm.

Definition at line 323 of file ThreeViewShowersAlgorithm.cc.

References m_algorithmToolVector, and m_nMaxTensorToolRepeats.

324 {
325  unsigned int repeatCounter(0);
326 
327  for (TensorToolVector::const_iterator iter = m_algorithmToolVector.begin(), iterEnd = m_algorithmToolVector.end(); iter != iterEnd;)
328  {
329  if ((*iter)->Run(this, this->GetMatchingControl().GetOverlapTensor()))
330  {
331  iter = m_algorithmToolVector.begin();
332 
333  if (++repeatCounter > m_nMaxTensorToolRepeats)
334  break;
335  }
336  else
337  {
338  ++iter;
339  }
340  }
341 }
TensorToolVector m_algorithmToolVector
The algorithm tool vector.
unsigned int m_nMaxTensorToolRepeats
The maximum number of repeat loops over tensor tools.
intermediate_table::const_iterator const_iterator
void lar_content::ThreeViewShowersAlgorithm::GetBestHitOverlapFraction ( const pandora::Cluster *const  pCluster,
const XSampling xSampling,
const ShowerPositionMapPair positionMaps,
unsigned int &  nSampledHits,
unsigned int &  nMatchedHits 
) const
private

Get the best fraction of hits, in the common x-overlap range, contained within the provided pair of shower boundaries.

Parameters
pClusterthe address of the candidate cluster
xSamplingthe x sampling details
positionMapsthe shower edge position maps
nSampledHitsto receive the number of hits in the common x-overlap range
nMatchedHitsto receive the number of sampled hits contained within the shower edges

Definition at line 282 of file ThreeViewShowersAlgorithm.cc.

References lar_content::ThreeViewShowersAlgorithm::XSampling::GetBin(), lar_content::ThreeViewShowersAlgorithm::XSampling::m_maxX, lar_content::ThreeViewShowersAlgorithm::XSampling::m_minX, x, and z.

Referenced by RemoveFromSlidingFitCache().

284 {
285  if ((xSampling.m_maxX - xSampling.m_minX) < std::numeric_limits<float>::epsilon())
286  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
287 
288  nSampledHits = 0;
289  nMatchedHits = 0;
290  unsigned int nMatchedHits1(0), nMatchedHits2(0);
291  const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
292 
293  for (OrderedCaloHitList::const_iterator iter = orderedCaloHitList.begin(), iterEnd = orderedCaloHitList.end(); iter != iterEnd; ++iter)
294  {
295  for (CaloHitList::const_iterator hIter = iter->second->begin(), hIterEnd = iter->second->end(); hIter != hIterEnd; ++hIter)
296  {
297  const CaloHit *const pCaloHit = *hIter;
298  const float x(pCaloHit->GetPositionVector().GetX());
299  const float z(pCaloHit->GetPositionVector().GetZ());
300 
301  int xBin(-1);
302  if (STATUS_CODE_SUCCESS != xSampling.GetBin(x, xBin))
303  continue;
304 
305  ++nSampledHits;
306 
307  ShowerPositionMap::const_iterator positionIter1 = positionMaps.first.find(xBin);
308  ShowerPositionMap::const_iterator positionIter2 = positionMaps.second.find(xBin);
309 
310  if ((positionMaps.first.end() != positionIter1) && (z > positionIter1->second.GetLowEdgeZ()) && (z < positionIter1->second.GetHighEdgeZ()))
311  ++nMatchedHits1;
312 
313  if ((positionMaps.second.end() != positionIter2) && (z > positionIter2->second.GetLowEdgeZ()) && (z < positionIter2->second.GetHighEdgeZ()))
314  ++nMatchedHits2;
315  }
316  }
317 
318  nMatchedHits = std::max(nMatchedHits1, nMatchedHits2);
319 }
Float_t x
Definition: compare.C:6
Double_t z
Definition: plot.C:276
intermediate_table::const_iterator const_iterator
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:82
const TwoDSlidingShowerFitResult & lar_content::ThreeViewShowersAlgorithm::GetCachedSlidingFitResult ( const pandora::Cluster *const  pCluster) const

Get a sliding shower fit result from the algorithm cache.

Parameters
pClusteraddress of the relevant cluster

Definition at line 35 of file ThreeViewShowersAlgorithm.cc.

References m_slidingFitResultMap.

Referenced by lar_content::SplitShowersTool::CheckClusterVertexRelations(), lar_content::SplitShowersTool::GetSplitXDetails(), RemoveFromSlidingFitCache(), and lar_content::SplitShowersTool::SpecifyClusterMerges().

36 {
38 
39  if (m_slidingFitResultMap.end() == iter)
40  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
41 
42  return iter->second;
43 }
intermediate_table::const_iterator const_iterator
TwoDSlidingShowerFitResultMap m_slidingFitResultMap
The sliding shower fit result map.
const std::string& lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< ShowerOverlapResult > >::GetClusterListName ( const pandora::HitType  hitType) const
virtualinherited

Get the cluster list name corresponding to a specified hit type.

Parameters
hitTypethe hit type
Returns
the cluster list name

Implements lar_content::MatchingBaseAlgorithm.

const pandora::ClusterList& lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< ShowerOverlapResult > >::GetInputClusterList ( const pandora::HitType  hitType) const
virtualinherited

Get the input cluster list corresponding to a specified hit type.

Parameters
hitTypethe hit type
Returns
the input cluster list

Implements lar_content::MatchingBaseAlgorithm.

Get the matching control.

Referenced by RemoveFromSlidingFitCache().

const pandora::ClusterList& lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< ShowerOverlapResult > >::GetSelectedClusterList ( const pandora::HitType  hitType) const
virtualinherited

Get the selected cluster list corresponding to a specified hit type.

Parameters
hitTypethe hit type
Returns
the selected cluster list

Implements lar_content::MatchingBaseAlgorithm.

void lar_content::ThreeViewShowersAlgorithm::GetShowerPositionMaps ( const TwoDSlidingShowerFitResult fitResultU,
const TwoDSlidingShowerFitResult fitResultV,
const TwoDSlidingShowerFitResult fitResultW,
const XSampling xSampling,
ShowerPositionMapPair positionMapsU,
ShowerPositionMapPair positionMapsV,
ShowerPositionMapPair positionMapsW 
) const
private

Get the shower position maps.

Parameters
fitResultUthe sliding shower fit result for the u view
fitResultVthe sliding shower fit result for the v view
fitResultWthe sliding shower fit result for the w view
xSamplingthe x sampling details
positionMapsUto receive the shower position maps for the u view
positionMapsVto receive the shower position maps for the v view
positionMapsWto receive the shower position maps for the w view

Definition at line 219 of file ThreeViewShowersAlgorithm.cc.

References lar_content::ThreeViewShowersAlgorithm::XSampling::GetBin(), lar_content::TwoDSlidingShowerFitResult::GetShowerEdges(), lar_content::ThreeViewShowersAlgorithm::XSampling::m_maxX, lar_content::ThreeViewShowersAlgorithm::XSampling::m_minX, lar_content::ThreeViewShowersAlgorithm::XSampling::m_nPoints, lar_content::LArGeometryHelper::MergeTwoPositions(), n, and x.

Referenced by RemoveFromSlidingFitCache().

222 {
223  const unsigned int nPoints(static_cast<unsigned int>(xSampling.m_nPoints));
224 
225  for (unsigned n = 0; n <= nPoints; ++n)
226  {
227  const float x(xSampling.m_minX + (xSampling.m_maxX - xSampling.m_minX) * static_cast<float>(n) / static_cast<float>(nPoints));
228 
229  int xBin(-1);
230  if (STATUS_CODE_SUCCESS != xSampling.GetBin(x, xBin))
231  continue;
232 
233  FloatVector uValues, vValues, wValues;
234  fitResultU.GetShowerEdges(x, true, uValues);
235  fitResultV.GetShowerEdges(x, true, vValues);
236  fitResultW.GetShowerEdges(x, true, wValues);
237 
238  std::sort(uValues.begin(), uValues.end());
239  std::sort(vValues.begin(), vValues.end());
240  std::sort(wValues.begin(), wValues.end());
241 
242  if ((uValues.size() > 1) && (vValues.size() > 1))
243  {
244  const float uMin(uValues.front()), uMax(uValues.back());
245  const float vMin(vValues.front()), vMax(vValues.back());
246  const float uv2wMinMin(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_U, TPC_VIEW_V, uMin, vMin));
247  const float uv2wMaxMax(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_U, TPC_VIEW_V, uMax, vMax));
248  const float uv2wMinMax(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_U, TPC_VIEW_V, uMin, vMax));
249  const float uv2wMaxMin(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_U, TPC_VIEW_V, uMax, vMin));
250  positionMapsW.first.insert(ShowerPositionMap::value_type(xBin, ShowerExtent(x, uv2wMinMin, uv2wMaxMax)));
251  positionMapsW.second.insert(ShowerPositionMap::value_type(xBin, ShowerExtent(x, uv2wMinMax, uv2wMaxMin)));
252  }
253 
254  if ((uValues.size() > 1) && (wValues.size() > 1))
255  {
256  const float uMin(uValues.front()), uMax(uValues.back());
257  const float wMin(wValues.front()), wMax(wValues.back());
258  const float uw2vMinMin(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_U, TPC_VIEW_W, uMin, wMin));
259  const float uw2vMaxMax(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_U, TPC_VIEW_W, uMax, wMax));
260  const float uw2vMinMax(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_U, TPC_VIEW_W, uMin, wMax));
261  const float uw2vMaxMin(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_U, TPC_VIEW_W, uMax, wMin));
262  positionMapsV.first.insert(ShowerPositionMap::value_type(xBin, ShowerExtent(x, uw2vMinMin, uw2vMaxMax)));
263  positionMapsV.second.insert(ShowerPositionMap::value_type(xBin, ShowerExtent(x, uw2vMinMax, uw2vMaxMin)));
264  }
265 
266  if ((vValues.size() > 1) && (wValues.size() > 1))
267  {
268  const float vMin(vValues.front()), vMax(vValues.back());
269  const float wMin(wValues.front()), wMax(wValues.back());
270  const float vw2uMinMin(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_V, TPC_VIEW_W, vMin, wMin));
271  const float vw2uMaxMax(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_V, TPC_VIEW_W, vMax, wMax));
272  const float vw2uMinMax(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_V, TPC_VIEW_W, vMin, wMax));
273  const float vw2uMaxMin(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_V, TPC_VIEW_W, vMax, wMin));
274  positionMapsU.first.insert(ShowerPositionMap::value_type(xBin, ShowerExtent(x, vw2uMinMin, vw2uMaxMax)));
275  positionMapsU.second.insert(ShowerPositionMap::value_type(xBin, ShowerExtent(x, vw2uMinMax, vw2uMaxMin)));
276  }
277  }
278 }
Float_t x
Definition: compare.C:6
static float MergeTwoPositions(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2, const float position1, const float position2)
Merge two views (U,V) to give a third view (Z).
Char_t n[5]
bool lar_content::MatchingBaseAlgorithm::MakeClusterMerges ( const ClusterMergeMap clusterMergeMap)
virtualinherited

Merge clusters together.

Parameters
clusterMergeMapthe cluster merge map
Returns
whether changes to the overlap container have been made

Definition at line 48 of file MatchingBaseAlgorithm.cc.

Referenced by lar_content::SplitShowersTool::ApplyChanges(), lar_content::ThreeDKinkBaseTool::ApplyChanges(), lar_content::TwoViewThreeDKinkTool::ApplyChanges(), lar_content::ConnectedRemnantsTool::Run(), and lar_content::MissingTrackSegmentTool::Run().

49 {
50  ClusterSet deletedClusters;
51 
52  ClusterList parentClusters;
53  for (const auto &mapEntry : clusterMergeMap)
54  parentClusters.push_back(mapEntry.first);
55  parentClusters.sort(LArClusterHelper::SortByNHits);
56 
57  for (const Cluster *const pParentCluster : parentClusters)
58  {
59  const HitType hitType(LArClusterHelper::GetClusterHitType(pParentCluster));
60  const std::string &clusterListName(this->GetClusterListName(hitType));
61 
62  if (!((TPC_VIEW_U == hitType) || (TPC_VIEW_V == hitType) || (TPC_VIEW_W == hitType)))
63  throw StatusCodeException(STATUS_CODE_FAILURE);
64 
65  ClusterList daughterClusters(clusterMergeMap.at(pParentCluster));
66  daughterClusters.sort(LArClusterHelper::SortByNHits);
67 
68  for (const Cluster *const pDaughterCluster : daughterClusters)
69  {
70  if (deletedClusters.count(pParentCluster) || deletedClusters.count(pDaughterCluster))
71  throw StatusCodeException(STATUS_CODE_FAILURE);
72 
73  this->UpdateUponDeletion(pDaughterCluster);
74  this->UpdateUponDeletion(pParentCluster);
75  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=,
76  PandoraContentApi::MergeAndDeleteClusters(*this, pParentCluster, pDaughterCluster, clusterListName, clusterListName));
77 
78  this->UpdateForNewCluster(pParentCluster);
79  deletedClusters.insert(pDaughterCluster);
80  }
81  }
82 
83  return !(deletedClusters.empty());
84 }
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.
virtual void UpdateUponDeletion(const pandora::Cluster *const pDeletedCluster)=0
Update to reflect cluster deletion.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
virtual const std::string & GetClusterListName(const pandora::HitType hitType) const =0
Get the cluster list name corresponding to a specified hit type.
virtual void UpdateForNewCluster(const pandora::Cluster *const pNewCluster)=0
Update to reflect addition of a new cluster to the problem space.
HitType
Definition: HitType.h:12
virtual void lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< ShowerOverlapResult > >::PerformMainLoop ( )
protectedvirtualinherited

Main loop over cluster combinations in order to populate the overlap container. Responsible for calling CalculateOverlapResult.

Implements lar_content::MatchingBaseAlgorithm.

virtual void lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< ShowerOverlapResult > >::PrepareAllInputClusters ( )
protectedvirtualinherited

Perform any preparatory steps required, e.g. caching expensive fit results for clusters.

Implements lar_content::MatchingBaseAlgorithm.

void lar_content::ThreeViewShowersAlgorithm::PrepareInputClusters ( pandora::ClusterList &  preparedClusterList)
virtual

Perform any preparatory steps required on the input clusters, e.g. caching expensive fit results.

Parameters
preparedClusterListto receive the prepared cluster list, non const so as to be able to modify input selected list

Reimplemented from lar_content::MatchingBaseAlgorithm.

Definition at line 100 of file ThreeViewShowersAlgorithm.cc.

References AddToSlidingFitCache(), and m_visualize.

101 {
102  for (ClusterList::iterator iter = preparedClusterList.begin(), iterEnd = preparedClusterList.end(); iter != iterEnd;)
103  {
104  const Cluster *const pCluster(*iter);
105 
106  try
107  {
108  this->AddToSlidingFitCache(pCluster);
109  ++iter;
110  }
111  catch (StatusCodeException &statusCodeException)
112  {
113  preparedClusterList.erase(iter++);
114 
115  if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
116  throw statusCodeException;
117  }
118  }
119  if (m_visualize)
120  {
121  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &preparedClusterList, "Prepared Clusters", GREEN));
122  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
123  }
124 }
intermediate_table::iterator iterator
void AddToSlidingFitCache(const pandora::Cluster *const pCluster)
Add a new sliding fit result, for the specified cluster, to the algorithm cache.
bool m_visualize
Visualize cluster matching procedure.
StatusCode lar_content::ThreeViewShowersAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Reimplemented from lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< ShowerOverlapResult > >.

Definition at line 383 of file ThreeViewShowersAlgorithm.cc.

References m_algorithmToolVector, m_ignoreUnavailableClusters, m_minClusterCaloHits, m_minClusterLengthSquared, m_minShowerMatchedFraction, m_minShowerMatchedPoints, m_nMaxTensorToolRepeats, m_slidingFitWindow, m_visualize, and lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< ShowerOverlapResult > >::ReadSettings().

384 {
385  AlgorithmToolVector algorithmToolVector;
386  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "ShowerTools", algorithmToolVector));
387 
388  for (AlgorithmToolVector::const_iterator iter = algorithmToolVector.begin(), iterEnd = algorithmToolVector.end(); iter != iterEnd; ++iter)
389  {
390  ShowerTensorTool *const pShowerTensorTool(dynamic_cast<ShowerTensorTool *>(*iter));
391 
392  if (!pShowerTensorTool)
393  return STATUS_CODE_INVALID_PARAMETER;
394 
395  m_algorithmToolVector.push_back(pShowerTensorTool);
396  }
397 
398  PANDORA_RETURN_RESULT_IF_AND_IF(
399  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NMaxTensorToolRepeats", m_nMaxTensorToolRepeats));
400 
401  PANDORA_RETURN_RESULT_IF_AND_IF(
402  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitWindow", m_slidingFitWindow));
403 
404  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
405  XmlHelper::ReadValue(xmlHandle, "IgnoreUnavailableClusters", m_ignoreUnavailableClusters));
406 
407  PANDORA_RETURN_RESULT_IF_AND_IF(
408  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinClusterCaloHits", m_minClusterCaloHits));
409 
410  float minClusterLength = std::sqrt(m_minClusterLengthSquared);
411  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinClusterLength", minClusterLength));
412  m_minClusterLengthSquared = minClusterLength * minClusterLength;
413 
414  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
415  XmlHelper::ReadValue(xmlHandle, "MinShowerMatchedFraction", m_minShowerMatchedFraction));
416 
417  PANDORA_RETURN_RESULT_IF_AND_IF(
418  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinShowerMatchedPoints", m_minShowerMatchedPoints));
419 
420  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "Visualize", m_visualize));
421 
422  return BaseAlgorithm::ReadSettings(xmlHandle);
423 }
TensorToolVector m_algorithmToolVector
The algorithm tool vector.
unsigned int m_nMaxTensorToolRepeats
The maximum number of repeat loops over tensor tools.
intermediate_table::const_iterator const_iterator
unsigned int m_minClusterCaloHits
The min number of hits in base cluster selection method.
unsigned int m_minShowerMatchedPoints
The minimum number of matched shower sampling points to allow shower grouping.
float m_minClusterLengthSquared
The min length (squared) in base cluster selection method.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
bool m_visualize
Visualize cluster matching procedure.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
bool m_ignoreUnavailableClusters
Whether to ignore (skip-over) unavailable clusters.
float m_minShowerMatchedFraction
The minimum shower matched sampling fraction to allow shower grouping.
void lar_content::ThreeViewShowersAlgorithm::RemoveFromSlidingFitCache ( const pandora::Cluster *const  pCluster)
private
virtual void lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< ShowerOverlapResult > >::SelectAllInputClusters ( )
protectedvirtualinherited

Select a subset of input clusters for processing in this algorithm.

Implements lar_content::MatchingBaseAlgorithm.

void lar_content::ThreeViewShowersAlgorithm::SelectInputClusters ( const pandora::ClusterList *const  pInputClusterList,
pandora::ClusterList &  selectedClusterList 
) const
virtual

Select a subset of input clusters for processing in this algorithm.

Parameters
pInputClusterListaddress of an input cluster list
selectedClusterListto receive the selected cluster list

Reimplemented from lar_content::MatchingBaseAlgorithm.

Definition at line 74 of file ThreeViewShowersAlgorithm.cc.

References lar_content::LArClusterHelper::GetLengthSquared(), m_ignoreUnavailableClusters, m_minClusterCaloHits, m_minClusterLengthSquared, and m_visualize.

75 {
76  for (ClusterList::const_iterator iter = pInputClusterList->begin(), iterEnd = pInputClusterList->end(); iter != iterEnd; ++iter)
77  {
78  const Cluster *const pCluster = *iter;
79 
80  if (m_ignoreUnavailableClusters && !pCluster->IsAvailable())
81  continue;
82 
83  if (pCluster->GetNCaloHits() < m_minClusterCaloHits)
84  continue;
85 
87  continue;
88 
89  selectedClusterList.push_back(pCluster);
90  }
91  if (m_visualize)
92  {
93  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &selectedClusterList, "Selected Clusters", RED));
94  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
95  }
96 }
intermediate_table::const_iterator const_iterator
unsigned int m_minClusterCaloHits
The min number of hits in base cluster selection method.
float m_minClusterLengthSquared
The min length (squared) in base cluster selection method.
bool m_visualize
Visualize cluster matching procedure.
bool m_ignoreUnavailableClusters
Whether to ignore (skip-over) unavailable clusters.
static float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
void lar_content::MatchingBaseAlgorithm::SetPfoParameters ( const ProtoParticle protoParticle,
PandoraContentApi::ParticleFlowObject::Parameters &  pfoParameters 
) const
virtualinherited

Set Pfo properties.

Parameters
protoParticlethe input proto particle
pfoParametersthe output pfo parameters

Definition at line 116 of file MatchingBaseAlgorithm.cc.

References f, and lar_content::ProtoParticle::m_clusterList.

117 {
118  this->SetPfoParticleId(pfoParameters);
119  pfoParameters.m_charge = PdgTable::GetParticleCharge(pfoParameters.m_particleId.Get());
120  pfoParameters.m_mass = PdgTable::GetParticleMass(pfoParameters.m_particleId.Get());
121  pfoParameters.m_energy = 0.f;
122  pfoParameters.m_momentum = CartesianVector(0.f, 0.f, 0.f);
123  pfoParameters.m_clusterList = protoParticle.m_clusterList;
124 }
TFile f
Definition: plotHisto.C:6
virtual void SetPfoParticleId(PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const
Set pfo particle id.
void lar_content::MatchingBaseAlgorithm::SetPfoParticleId ( PandoraContentApi::ParticleFlowObject::Parameters &  pfoParameters) const
virtualinherited
void lar_content::ThreeViewShowersAlgorithm::TidyUp ( )
privatevirtual
void lar_content::ThreeViewShowersAlgorithm::UpdateForNewCluster ( const pandora::Cluster *const  pNewCluster)
virtual

Update to reflect addition of a new cluster to the problem space.

Parameters
pNewClusteraddress of the new cluster

Implements lar_content::MatchingBaseAlgorithm.

Definition at line 47 of file ThreeViewShowersAlgorithm.cc.

References AddToSlidingFitCache(), and lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< ShowerOverlapResult > >::UpdateForNewCluster().

48 {
49  try
50  {
51  this->AddToSlidingFitCache(pNewCluster);
52  }
53  catch (StatusCodeException &statusCodeException)
54  {
55  if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
56  throw statusCodeException;
57 
58  return;
59  }
60 
62 }
void AddToSlidingFitCache(const pandora::Cluster *const pCluster)
Add a new sliding fit result, for the specified cluster, to the algorithm cache.
void lar_content::ThreeViewShowersAlgorithm::UpdateUponDeletion ( const pandora::Cluster *const  pDeletedCluster)
virtual

Update to reflect cluster deletion.

Parameters
pDeletedClusteraddress of the deleted cluster

Implements lar_content::MatchingBaseAlgorithm.

Definition at line 66 of file ThreeViewShowersAlgorithm.cc.

References RemoveFromSlidingFitCache(), and lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< ShowerOverlapResult > >::UpdateUponDeletion().

67 {
68  this->RemoveFromSlidingFitCache(pDeletedCluster);
69  BaseAlgorithm::UpdateUponDeletion(pDeletedCluster);
70 }
void RemoveFromSlidingFitCache(const pandora::Cluster *const pCluster)
Remova an existing sliding fit result, for the specified cluster, from the algorithm cache...

Member Data Documentation

TensorToolVector lar_content::ThreeViewShowersAlgorithm::m_algorithmToolVector
private

The algorithm tool vector.

Definition at line 151 of file ThreeViewShowersAlgorithm.h.

Referenced by ExamineOverlapContainer(), and ReadSettings().

bool lar_content::ThreeViewShowersAlgorithm::m_ignoreUnavailableClusters
private

Whether to ignore (skip-over) unavailable clusters.

Definition at line 157 of file ThreeViewShowersAlgorithm.h.

Referenced by ReadSettings(), and SelectInputClusters().

The matching control.

Definition at line 53 of file NViewMatchingAlgorithm.h.

unsigned int lar_content::ThreeViewShowersAlgorithm::m_minClusterCaloHits
private

The min number of hits in base cluster selection method.

Definition at line 158 of file ThreeViewShowersAlgorithm.h.

Referenced by ReadSettings(), and SelectInputClusters().

float lar_content::ThreeViewShowersAlgorithm::m_minClusterLengthSquared
private

The min length (squared) in base cluster selection method.

Definition at line 159 of file ThreeViewShowersAlgorithm.h.

Referenced by ReadSettings(), and SelectInputClusters().

float lar_content::ThreeViewShowersAlgorithm::m_minShowerMatchedFraction
private

The minimum shower matched sampling fraction to allow shower grouping.

Definition at line 161 of file ThreeViewShowersAlgorithm.h.

Referenced by ReadSettings(), and RemoveFromSlidingFitCache().

unsigned int lar_content::ThreeViewShowersAlgorithm::m_minShowerMatchedPoints
private

The minimum number of matched shower sampling points to allow shower grouping.

Definition at line 162 of file ThreeViewShowersAlgorithm.h.

Referenced by ReadSettings(), and RemoveFromSlidingFitCache().

unsigned int lar_content::ThreeViewShowersAlgorithm::m_nMaxTensorToolRepeats
private

The maximum number of repeat loops over tensor tools.

Definition at line 152 of file ThreeViewShowersAlgorithm.h.

Referenced by ExamineOverlapContainer(), and ReadSettings().

TwoDSlidingShowerFitResultMap lar_content::ThreeViewShowersAlgorithm::m_slidingFitResultMap
private

The sliding shower fit result map.

Definition at line 155 of file ThreeViewShowersAlgorithm.h.

Referenced by AddToSlidingFitCache(), GetCachedSlidingFitResult(), RemoveFromSlidingFitCache(), and TidyUp().

unsigned int lar_content::ThreeViewShowersAlgorithm::m_slidingFitWindow
private

The layer window for the sliding linear fits.

Definition at line 154 of file ThreeViewShowersAlgorithm.h.

Referenced by AddToSlidingFitCache(), and ReadSettings().

bool lar_content::ThreeViewShowersAlgorithm::m_visualize
private

Visualize cluster matching procedure.

Definition at line 163 of file ThreeViewShowersAlgorithm.h.

Referenced by PrepareInputClusters(), ReadSettings(), RemoveFromSlidingFitCache(), and SelectInputClusters().


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