All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DlTrackShowerStreamSelectionAlgorithm.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoradlcontent/LArTwoDReco/DlTrackShowerStreamSelectionAlgorithm.cc
3  *
4  * @brief Implementation of the deep learning track shower cluster streaming algorithm.
5  *
6  * $Log: $
7  */
8 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
15 
17 
18 #include <numeric>
19 
20 using namespace pandora;
21 using namespace lar_content;
22 
23 namespace lar_dl_content
24 {
25 
26 StatusCode DlTrackShowerStreamSelectionAlgorithm::AllocateToStreams(const Cluster *const pCluster)
27 {
28  const OrderedCaloHitList &orderedCaloHitList{pCluster->GetOrderedCaloHitList()};
29  CaloHitList caloHits;
30  orderedCaloHitList.FillCaloHitList(caloHits);
31  const CaloHitList &isolatedHits{pCluster->GetIsolatedCaloHitList()};
32  caloHits.insert(caloHits.end(), isolatedHits.begin(), isolatedHits.end());
33  FloatVector trackLikelihoods;
34  try
35  {
36  for (const CaloHit *pCaloHit : caloHits)
37  {
38  const LArCaloHit *pLArCaloHit{dynamic_cast<const LArCaloHit *>(pCaloHit)};
39  const float pTrack{pLArCaloHit->GetTrackProbability()};
40  const float pShower{pLArCaloHit->GetShowerProbability()};
41  if ((pTrack + pShower) > std::numeric_limits<float>::epsilon())
42  trackLikelihoods.emplace_back(pTrack / (pTrack + pShower));
43  }
44 
45  const unsigned long N{trackLikelihoods.size()};
46  if (N > 0)
47  {
48  float mean{std::accumulate(std::begin(trackLikelihoods), std::end(trackLikelihoods), 0.f) / N};
49  if (mean >= 0.5f)
50  m_clusterListMap.at(m_trackListName).emplace_back(pCluster);
51  else
52  m_clusterListMap.at(m_showerListName).emplace_back(pCluster);
53  }
54  }
55  catch (const StatusCodeException &)
56  {
57  }
58 
59  return STATUS_CODE_SUCCESS;
60 }
61 //------------------------------------------------------------------------------------------------------------------------------------------
62 
63 StatusCode DlTrackShowerStreamSelectionAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
64 {
65  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, StreamSelectionAlgorithm::ReadSettings(xmlHandle));
66  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "TrackListName", m_trackListName));
67  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "ShowerListName", m_showerListName));
68 
69  m_listNames.emplace_back(m_trackListName);
70  m_listNames.emplace_back(m_showerListName);
71 
72  return STATUS_CODE_SUCCESS;
73 }
74 
75 } // namespace lar_dl_content
Header file for the lar calo hit class.
Header file for the lar monitoring helper helper class.
LAr calo hit class.
Definition: LArCaloHit.h:39
Header file for the lar monte carlo particle helper helper class.
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
Header file for the deep learning track shower cluster streaming algorithm.
float GetTrackProbability() const
Get the probability that the hit is track-like.
Definition: LArCaloHit.h:210