LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
SimpleShowersTool.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
13 using namespace pandora;
14 
15 namespace lar_content
16 {
17 
18 SimpleShowersTool::SimpleShowersTool() :
19  m_minMatchedFraction(0.2f),
20  m_minMatchedSamplingPoints(40),
21  m_minXOverlapFraction(0.5f)
22 {
23 }
24 
25 //------------------------------------------------------------------------------------------------------------------------------------------
26 
27 bool SimpleShowersTool::Run(ThreeDShowersAlgorithm *const pAlgorithm, TensorType &overlapTensor)
28 {
29  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
30  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
31 
32  ProtoParticleVector protoParticleVector;
33  this->FindBestShower(overlapTensor, protoParticleVector);
34 
35  const bool particlesMade(pAlgorithm->CreateThreeDParticles(protoParticleVector));
36  return particlesMade;
37 }
38 
39 //------------------------------------------------------------------------------------------------------------------------------------------
40 
41 void SimpleShowersTool::FindBestShower(const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector) const
42 {
43  ClusterVector sortedKeyClusters;
44  overlapTensor.GetSortedKeyClusters(sortedKeyClusters);
45 
46  for (const Cluster *const pKeyCluster : sortedKeyClusters)
47  {
48  if (!pKeyCluster->IsAvailable())
49  continue;
50 
51  unsigned int nU(0), nV(0), nW(0);
52  TensorType::ElementList elementList;
53  overlapTensor.GetConnectedElements(pKeyCluster, true, elementList, nU, nV, nW);
54 
55  if (elementList.empty())
56  continue;
57 
58  TensorType::Element bestElement(elementList.back());
59 
60  if (!bestElement.GetOverlapResult().IsInitialized())
61  continue;
62 
63  if ((NULL == bestElement.GetClusterU()) || (NULL == bestElement.GetClusterV()) || (NULL == bestElement.GetClusterW()))
64  continue;
65 
66  ProtoParticle protoParticle;
67  protoParticle.m_clusterListU.push_back(bestElement.GetClusterU());
68  protoParticle.m_clusterListV.push_back(bestElement.GetClusterV());
69  protoParticle.m_clusterListW.push_back(bestElement.GetClusterW());
70  protoParticleVector.push_back(protoParticle);
71 
72  return;
73  }
74 }
75 
76 //------------------------------------------------------------------------------------------------------------------------------------------
77 
79 {
80  if (eIter->GetOverlapResult().GetMatchedFraction() < m_minMatchedFraction)
81  return false;
82 
83  if (eIter->GetOverlapResult().GetNMatchedSamplingPoints() < m_minMatchedSamplingPoints)
84  return false;
85 
86  const XOverlap &xOverlap(eIter->GetOverlapResult().GetXOverlap());
87 
88  if ((xOverlap.GetXSpanU() > std::numeric_limits<float>::epsilon()) && (xOverlap.GetXOverlapSpan() / xOverlap.GetXSpanU() > m_minXOverlapFraction) &&
89  (xOverlap.GetXSpanV() > std::numeric_limits<float>::epsilon()) && (xOverlap.GetXOverlapSpan() / xOverlap.GetXSpanV() > m_minXOverlapFraction) &&
90  (xOverlap.GetXSpanW() > std::numeric_limits<float>::epsilon()) && (xOverlap.GetXOverlapSpan() / xOverlap.GetXSpanW() > m_minXOverlapFraction))
91  {
92  return true;
93  }
94 
95  return false;
96 }
97 
98 //------------------------------------------------------------------------------------------------------------------------------------------
99 
100 StatusCode SimpleShowersTool::ReadSettings(const TiXmlHandle xmlHandle)
101 {
102  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
103  "MinMatchedFraction", m_minMatchedFraction));
104 
105  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
106  "MinMatchedSamplingPoints", m_minMatchedSamplingPoints));
107 
108  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
109  "MinXOverlapFraction", m_minXOverlapFraction));
110 
111  return STATUS_CODE_SUCCESS;
112 }
113 
114 } // namespace lar_content
std::vector< ProtoParticle > ProtoParticleVector
void FindBestShower(const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector) const
Find best shower match as a simple way to (try to) resolve ambiguities in the tensor.
virtual bool CreateThreeDParticles(const ProtoParticleVector &protoParticleVector)
Create particles using findings from recent algorithm processing.
void GetConnectedElements(const pandora::Cluster *const pCluster, const bool ignoreUnavailable, ElementList &elementList) const
Get a list of elements connected to a specified cluster.
float m_minMatchedFraction
The min matched sampling point fraction for particle creation.
ThreeDShowersAlgorithm class.
TFile f
Definition: plotHisto.C:6
pandora::ClusterList m_clusterListW
List of 2D W clusters in a 3D proto particle.
bool Run(ThreeDShowersAlgorithm *const pAlgorithm, TensorType &overlapTensor)
Run the algorithm tool.
pandora::ClusterList m_clusterListV
List of 2D V clusters in a 3D proto particle.
pandora::ClusterList m_clusterListU
List of 2D U clusters in a 3D proto particle.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
void GetSortedKeyClusters(pandora::ClusterVector &sortedKeyClusters) const
Get a sorted vector of key clusters (U clusters with current implementation)
std::vector< art::Ptr< recob::Cluster > > ClusterVector
Header file for the simple showers tool class.
unsigned int m_minMatchedSamplingPoints
The min number of matched sampling points for particle creation.
float m_minXOverlapFraction
The min x overlap fraction (in each view) for particle creation.
bool PassesElementCuts(TensorType::ElementList::const_iterator eIter) const
Whether a provided (iterator to a) tensor element passes the selection cuts for particle creation...
XOverlap class.
Definition: LArXOverlap.h:17