All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OpFlashAlg.h
Go to the documentation of this file.
1 // -*- mode: c++; c-basic-offset: 2; -*-
2 #ifndef OPFLASHALG_H
3 #define OPFLASHALG_H
4 /*!
5  * Title: OpFlash Algorithims
6  * Author: Ben Jones, MIT (Edited by wketchum@lanl.gov and gleb.sinev@duke.edu)
7  *
8  * Description:
9  * These are the algorithms used by OpFlashFinder to produce flashes.
10  */
11 
14 namespace detinfo { class DetectorClocksData; }
15 namespace geo { class GeometryCore; }
16 
17 #include <functional>
18 #include <map>
19 #include <vector>
20 
21 namespace opdet {
22 
23  void RunFlashFinder(std::vector<recob::OpHit> const&,
24  std::vector<recob::OpFlash>&,
25  std::vector<std::vector<int>>&,
26  double,
27  geo::GeometryCore const&,
28  float,
29  float,
31  float);
32 
33  unsigned int GetAccumIndex(double PeakTime, double MinTime, double BinWidth, double BinOffset);
34 
35  void FillAccumulator(unsigned int const& AccumIndex,
36  unsigned int const& HitIndex,
37  double PE,
38  float FlashThreshold,
39  std::vector<double>& Binned,
40  std::vector<std::vector<int>>& Contributors,
41  std::vector<int>& FlashesInAccumulator);
42 
43  void AssignHitsToFlash(std::vector<int> const&,
44  std::vector<int> const&,
45  std::vector<double> const&,
46  std::vector<double> const&,
47  std::vector<std::vector<int>> const&,
48  std::vector<std::vector<int>> const&,
49  std::vector<recob::OpHit> const&,
50  std::vector<std::vector<int>>&,
51  float);
52 
54  std::vector<int> const& FlashesInAccumulator,
55  std::vector<double> const& BinnedPE,
56  int const& Accumulator,
57  std::map<double, std::map<int, std::vector<int>>, std::greater<double>>& FlashesBySize);
58 
59  void FillHitsThisFlash(std::vector<std::vector<int>> const& Contributors,
60  int const& Bin,
61  std::vector<int> const& HitClaimedByFlash,
62  std::vector<int>& HitsThisFlash);
63 
64  void ClaimHits(std::vector<recob::OpHit> const& HitVector,
65  std::vector<int> const& HitsThisFlash,
66  float FlashThreshold,
67  std::vector<std::vector<int>>& HitsPerFlash,
68  std::vector<int>& HitClaimedByFlash);
69 
70  void RefineHitsInFlash(std::vector<int> const& HitsThisFlash,
71  std::vector<recob::OpHit> const& HitVector,
72  std::vector<std::vector<int>>& RefinedHitsPerFlash,
73  float WidthTolerance,
74  float FlashThreshold);
75 
76  void FindSeedHit(std::map<double, std::vector<int>, std::greater<double>> const& HitsBySize,
77  std::vector<bool>& HitsUsed,
78  std::vector<recob::OpHit> const& HitVector,
79  std::vector<int>& HitsThisRefinedFlash,
80  double& PEAccumulated,
81  double& FlashMaxTime,
82  double& FlashMinTime);
83 
84  void AddHitToFlash(int const& HitID,
85  std::vector<bool>& HitsUsed,
86  recob::OpHit const& currentHit,
87  double WidthTolerance,
88  std::vector<int>& HitsThisRefinedFlash,
89  double& PEAccumulated,
90  double& FlashMaxTime,
91  double& FlashMinTime);
92 
93  void CheckAndStoreFlash(std::vector<std::vector<int>>& RefinedHitsPerFlash,
94  std::vector<int> const& HitsThisRefinedFlash,
95  double PEAccumulated,
96  float FlashThreshold,
97  std::vector<bool>& HitsUsed);
98 
99  void ConstructFlash(std::vector<int> const& HitsPerFlashVec,
100  std::vector<recob::OpHit> const& HitVector,
101  std::vector<recob::OpFlash>& FlashVector,
102  geo::GeometryCore const& geom,
103  detinfo::DetectorClocksData const& data,
104  float TrigCoinc);
105 
106  void AddHitContribution(recob::OpHit const& currentHit,
107  double& MaxTime,
108  double& MinTime,
109  double& AveTime,
110  double& FastToTotal,
111  double& AveAbsTime,
112  double& TotalPE,
113  std::vector<double>& PEs);
114 
115  void GetHitGeometryInfo(recob::OpHit const& currentHit,
116  geo::GeometryCore const& geom,
117  std::vector<double>& sumw,
118  std::vector<double>& sumw2,
119  double& sumy,
120  double& sumy2,
121  double& sumz,
122  double& sumz2);
123 
124  void RemoveLateLight(std::vector<recob::OpFlash>&, std::vector<std::vector<int>>&);
125 
126  double GetLikelihoodLateLight(double iPE,
127  double iTime,
128  double iWidth,
129  double jPE,
130  double jTime,
131  double jWidth);
132 
133  void MarkFlashesForRemoval(std::vector<recob::OpFlash> const& FlashVector,
134  size_t BeginFlash,
135  std::vector<bool>& MarkedForRemoval);
136 
137  void RemoveFlashesFromVectors(std::vector<bool> const& MarkedForRemoval,
138  std::vector<recob::OpFlash>& FlashVector,
139  size_t BeginFlash,
140  std::vector<std::vector<int>>& RefinedHitsPerFlash);
141 
142  template <typename T, typename Compare>
143  std::vector<int> sort_permutation(std::vector<T> const& vec, int offset, Compare compare);
144 
145  template <typename T>
146  void apply_permutation(std::vector<T>& vec, std::vector<int> const& p);
147 
148 } // End opdet namespace
149 
150 #endif
void FillHitsThisFlash(std::vector< std::vector< int >> const &Contributors, int const &Bin, std::vector< int > const &HitClaimedByFlash, std::vector< int > &HitsThisFlash)
Definition: OpFlashAlg.cxx:214
BEGIN_PROLOG TPC Trig offset(g4 rise time) ProjectToHeight
Definition: CORSIKAGen.fcl:7
void CheckAndStoreFlash(std::vector< std::vector< int >> &RefinedHitsPerFlash, std::vector< int > const &HitsThisRefinedFlash, double const PEAccumulated, float const FlashThreshold, std::vector< bool > &HitsUsed)
Definition: OpFlashAlg.cxx:359
void RunFlashFinder(std::vector< recob::OpHit > const &HitVector, std::vector< recob::OpFlash > &FlashVector, std::vector< std::vector< int >> &AssocList, double const BinWidth, geo::GeometryCore const &geom, float const FlashThreshold, float const WidthTolerance, detinfo::DetectorClocksData const &ClocksData, float const TrigCoinc)
Definition: OpFlashAlg.cxx:63
void ConstructFlash(std::vector< int > const &HitsPerFlashVec, std::vector< recob::OpHit > const &HitVector, std::vector< recob::OpFlash > &FlashVector, geo::GeometryCore const &geom, detinfo::DetectorClocksData const &ClocksData, float const TrigCoinc)
Definition: OpFlashAlg.cxx:525
pdgs p
Definition: selectors.fcl:22
void AddHitContribution(recob::OpHit const &currentHit, double &MaxTime, double &MinTime, double &AveTime, double &FastToTotal, double &AveAbsTime, double &TotalPE, std::vector< double > &PEs)
Definition: OpFlashAlg.cxx:456
void apply_permutation(std::vector< T > &vec, std::vector< int > const &p)
Definition: OpFlashAlg.cxx:704
void AssignHitsToFlash(std::vector< int > const &FlashesInAccumulator1, std::vector< int > const &FlashesInAccumulator2, std::vector< double > const &Binned1, std::vector< double > const &Binned2, std::vector< std::vector< int >> const &Contributors1, std::vector< std::vector< int >> const &Contributors2, std::vector< recob::OpHit > const &HitVector, std::vector< std::vector< int >> &HitsPerFlash, float const FlashThreshold)
Definition: OpFlashAlg.cxx:250
std::array< float, 2 > HitVector(const recob::Hit &hit, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
bool Compare(const T &a, const T &b, const std::string &key)
Definition: diff_spectra.cc:93
void FindSeedHit(std::map< double, std::vector< int >, std::greater< double >> const &HitsBySize, std::vector< bool > &HitsUsed, std::vector< recob::OpHit > const &HitVector, std::vector< int > &HitsThisRefinedFlash, double &PEAccumulated, double &FlashMaxTime, double &FlashMinTime)
Definition: OpFlashAlg.cxx:301
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
void MarkFlashesForRemoval(std::vector< recob::OpFlash > const &FlashVector, size_t const BeginFlash, std::vector< bool > &MarkedForRemoval)
Definition: OpFlashAlg.cxx:623
void ClaimHits(std::vector< recob::OpHit > const &HitVector, std::vector< int > const &HitsThisFlash, float const FlashThreshold, std::vector< std::vector< int >> &HitsPerFlash, std::vector< int > &HitClaimedByFlash)
Definition: OpFlashAlg.cxx:227
constexpr float FlashThreshold
std::vector< int > sort_permutation(std::vector< T > const &vec, int offset, Compare compare)
Definition: OpFlashAlg.cxx:691
void FillFlashesBySizeMap(std::vector< int > const &FlashesInAccumulator, std::vector< double > const &BinnedPE, int const &Accumulator, std::map< double, std::map< int, std::vector< int >>, std::greater< double >> &FlashesBySize)
Definition: OpFlashAlg.cxx:202
void RemoveLateLight(std::vector< recob::OpFlash > &FlashVector, std::vector< std::vector< int >> &RefinedHitsPerFlash)
Definition: OpFlashAlg.cxx:665
Description of geometry of one entire detector.
void AddHitToFlash(int const &HitID, std::vector< bool > &HitsUsed, recob::OpHit const &currentHit, double const WidthTolerance, std::vector< int > &HitsThisRefinedFlash, double &PEAccumulated, double &FlashMaxTime, double &FlashMinTime)
Definition: OpFlashAlg.cxx:331
void RefineHitsInFlash(std::vector< int > const &HitsThisFlash, std::vector< recob::OpHit > const &HitVector, std::vector< std::vector< int >> &RefinedHitsPerFlash, float const WidthTolerance, float const FlashThreshold)
Definition: OpFlashAlg.cxx:384
Contains all timing reference information for the detector.
unsigned int GetAccumIndex(double const PeakTime, double const MinTime, double const BinWidth, double const BinOffset)
Definition: OpFlashAlg.cxx:172
constexpr double WidthTolerance
void GetHitGeometryInfo(recob::OpHit const &currentHit, geo::GeometryCore const &geom, std::vector< double > &sumw, std::vector< double > &sumw2, double &sumy, double &sumy2, double &sumz, double &sumz2)
Definition: OpFlashAlg.cxx:483
void RemoveFlashesFromVectors(std::vector< bool > const &MarkedForRemoval, std::vector< recob::OpFlash > &FlashVector, size_t const BeginFlash, std::vector< std::vector< int >> &RefinedHitsPerFlash)
Definition: OpFlashAlg.cxx:651
void FillAccumulator(unsigned int const &AccumIndex, unsigned int const &HitIndex, double const PE, float const FlashThreshold, std::vector< double > &Binned, std::vector< std::vector< int >> &Contributors, std::vector< int > &FlashesInAccumulator)
Definition: OpFlashAlg.cxx:182
double GetLikelihoodLateLight(double const iPE, double const iTime, double const iWidth, double const jPE, double const jTime, double const jWidth)
Definition: OpFlashAlg.cxx:605