DlPfoCharacterisationAlgorithm.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArTrackShowerId/DlPfoCharacterisationAlgorithm.cc
3  *
4  * @brief Implementation of the cut based pfo characterisation algorithm class.
5  *
6  * $Log: $
7  */
8 
9 #include "Pandora/AlgorithmHeaders.h"
10 
13 
15 
16 #include <numeric>
17 
18 using namespace pandora;
19 using namespace lar_content;
20 
21 namespace lar_dl_content
22 {
23 
24 DlPfoCharacterisationAlgorithm::DlPfoCharacterisationAlgorithm()
25 {
26 }
27 
28 //------------------------------------------------------------------------------------------------------------------------------------------
29 
30 bool DlPfoCharacterisationAlgorithm::IsClearTrack(const Cluster *const pCluster) const
31 {
32  const OrderedCaloHitList &orderedCaloHitList{pCluster->GetOrderedCaloHitList()};
33  CaloHitList caloHits;
34  orderedCaloHitList.FillCaloHitList(caloHits);
35  const CaloHitList &isolatedHits{pCluster->GetIsolatedCaloHitList()};
36  caloHits.insert(caloHits.end(), isolatedHits.begin(), isolatedHits.end());
37  FloatVector trackLikelihoods;
38  try
39  {
40  for (const CaloHit *pCaloHit : caloHits)
41  {
42  const LArCaloHit *pLArCaloHit{dynamic_cast<const LArCaloHit *>(pCaloHit)};
43  const float pTrack{pLArCaloHit->GetTrackProbability()};
44  const float pShower{pLArCaloHit->GetShowerProbability()};
45  if ((pTrack + pShower) > std::numeric_limits<float>::epsilon())
46  trackLikelihoods.emplace_back(pTrack / (pTrack + pShower));
47  }
48 
49  const unsigned long N{trackLikelihoods.size()};
50  if (N > 0)
51  {
52  float mean{std::accumulate(std::begin(trackLikelihoods), std::end(trackLikelihoods), 0.f) / N};
53  if (mean >= 0.5f)
54  return true;
55  else
56  return false;
57  }
58  }
59  catch (const StatusCodeException &)
60  {
61  }
62 
63  return true;
64 }
65 
66 //------------------------------------------------------------------------------------------------------------------------------------------
67 
68 bool DlPfoCharacterisationAlgorithm::IsClearTrack(const pandora::ParticleFlowObject *const pPfo) const
69 {
70  ClusterList allClusters;
71  LArPfoHelper::GetTwoDClusterList(pPfo, allClusters);
72  FloatVector trackLikelihoods;
73  for (const Cluster *pCluster : allClusters)
74  {
75  const OrderedCaloHitList &orderedCaloHitList{pCluster->GetOrderedCaloHitList()};
76  CaloHitList caloHits;
77  orderedCaloHitList.FillCaloHitList(caloHits);
78  const CaloHitList &isolatedHits{pCluster->GetIsolatedCaloHitList()};
79  caloHits.insert(caloHits.end(), isolatedHits.begin(), isolatedHits.end());
80  try
81  {
82  for (const CaloHit *pCaloHit : caloHits)
83  {
84  const LArCaloHit *pLArCaloHit{dynamic_cast<const LArCaloHit *>(pCaloHit)};
85  const float pTrack{pLArCaloHit->GetTrackProbability()};
86  const float pShower{pLArCaloHit->GetShowerProbability()};
87  if ((pTrack + pShower) > std::numeric_limits<float>::epsilon())
88  trackLikelihoods.emplace_back(pTrack / (pTrack + pShower));
89  }
90  }
91  catch (const StatusCodeException &)
92  {
93  }
94  }
95 
96  const unsigned long N{trackLikelihoods.size()};
97  if (N > 0)
98  {
99  float mean{std::accumulate(std::begin(trackLikelihoods), std::end(trackLikelihoods), 0.f) / N};
100  if (mean >= 0.5f)
101  return true;
102  else
103  return false;
104  }
105 
106  return true;
107 }
108 
109 //------------------------------------------------------------------------------------------------------------------------------------------
110 
111 StatusCode DlPfoCharacterisationAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
112 {
113  return PfoCharacterisationBaseAlgorithm::ReadSettings(xmlHandle);
114 }
115 
116 } // namespace lar_dl_content
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
Header file for the pfo helper class.
Header file for the cut based pfo characterisation algorithm class.
Header file for the lar calo hit class.
LAr calo hit class.
Definition: LArCaloHit.h:39
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
Dft::FloatVector FloatVector
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:16
float GetTrackProbability() const
Get the probability that the hit is track-like.
Definition: LArCaloHit.h:210