All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DlClusterCharacterisationAlgorithm.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArTrackShowerId/DlClusterCharacterisationAlgorithm.cc
3  *
4  * @brief Implementation of the deep learning based cluster characterisation algorithm class.
5  *
6  * $Log: $
7  */
8 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
14 
15 #include <numeric>
16 
17 using namespace pandora;
18 using namespace lar_content;
19 
20 namespace lar_dl_content
21 {
22 
23 DlClusterCharacterisationAlgorithm::DlClusterCharacterisationAlgorithm()
24 {
25 }
26 
27 //------------------------------------------------------------------------------------------------------------------------------------------
28 
29 DlClusterCharacterisationAlgorithm::~DlClusterCharacterisationAlgorithm()
30 {
31 }
32 
33 //------------------------------------------------------------------------------------------------------------------------------------------
34 
35 bool DlClusterCharacterisationAlgorithm::IsClearTrack(const Cluster *const pCluster) const
36 {
37  const OrderedCaloHitList &orderedCaloHitList{pCluster->GetOrderedCaloHitList()};
38  CaloHitList caloHits;
39  orderedCaloHitList.FillCaloHitList(caloHits);
40  const CaloHitList &isolatedHits{pCluster->GetIsolatedCaloHitList()};
41  caloHits.insert(caloHits.end(), isolatedHits.begin(), isolatedHits.end());
42  FloatVector trackLikelihoods;
43  try
44  {
45  for (const CaloHit *pCaloHit : caloHits)
46  {
47  const LArCaloHit *pLArCaloHit{dynamic_cast<const LArCaloHit *>(pCaloHit)};
48  const float pTrack{pLArCaloHit->GetTrackProbability()};
49  const float pShower{pLArCaloHit->GetShowerProbability()};
50  if ((pTrack + pShower) > std::numeric_limits<float>::epsilon())
51  trackLikelihoods.emplace_back(pTrack / (pTrack + pShower));
52  }
53 
54  const unsigned long N{trackLikelihoods.size()};
55  if (N > 0)
56  {
57  float mean{std::accumulate(std::begin(trackLikelihoods), std::end(trackLikelihoods), 0.f) / N};
58  if (mean >= 0.5f)
59  return true;
60  else
61  return false;
62  }
63  }
64  catch (const StatusCodeException &)
65  {
66  }
67 
68  return true;
69 }
70 
71 //------------------------------------------------------------------------------------------------------------------------------------------
72 
73 StatusCode DlClusterCharacterisationAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
74 {
75  return ClusterCharacterisationBaseAlgorithm::ReadSettings(xmlHandle);
76 }
77 
78 } // namespace lar_dl_content
Header file for the lar calo hit class.
LAr calo hit class.
Definition: LArCaloHit.h:39
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:13
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
Definition: reco_sbnd.fcl:182
process_name largeant stream1 can override from command line with o or output physics producers generator N
float GetTrackProbability() const
Get the probability that the hit is track-like.
Definition: LArCaloHit.h:210