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 
15 namespace detinfo {
16  class DetectorClocksData;
17 }
18 
19 #include <functional>
20 #include <map>
21 #include <vector>
22 
23 namespace opdet {
24 
25  void RunFlashFinder(std::vector<recob::OpHit> const&,
26  std::vector<recob::OpFlash>&,
27  std::vector<std::vector<int>>&,
28  double,
29  geo::GeometryCore const&,
30  float,
31  float,
33  float);
34 
35  unsigned int GetAccumIndex(double PeakTime, double MinTime, double BinWidth, double BinOffset);
36 
37  void FillAccumulator(unsigned int const& AccumIndex,
38  unsigned int const& HitIndex,
39  double PE,
40  float FlashThreshold,
41  std::vector<double>& Binned,
42  std::vector<std::vector<int>>& Contributors,
43  std::vector<int>& FlashesInAccumulator);
44 
45  void AssignHitsToFlash(std::vector<int> const&,
46  std::vector<int> const&,
47  std::vector<double> const&,
48  std::vector<double> const&,
49  std::vector<std::vector<int>> const&,
50  std::vector<std::vector<int>> const&,
51  std::vector<recob::OpHit> const&,
52  std::vector<std::vector<int>>&,
53  float);
54 
56  std::vector<int> const& FlashesInAccumulator,
57  std::vector<double> const& BinnedPE,
58  int const& Accumulator,
59  std::map<double, std::map<int, std::vector<int>>, std::greater<double>>& FlashesBySize);
60 
61  void FillHitsThisFlash(std::vector<std::vector<int>> const& Contributors,
62  int const& Bin,
63  std::vector<int> const& HitClaimedByFlash,
64  std::vector<int>& HitsThisFlash);
65 
66  void ClaimHits(std::vector<recob::OpHit> const& HitVector,
67  std::vector<int> const& HitsThisFlash,
68  float FlashThreshold,
69  std::vector<std::vector<int>>& HitsPerFlash,
70  std::vector<int>& HitClaimedByFlash);
71 
72  void RefineHitsInFlash(std::vector<int> const& HitsThisFlash,
73  std::vector<recob::OpHit> const& HitVector,
74  std::vector<std::vector<int>>& RefinedHitsPerFlash,
75  float WidthTolerance,
76  float FlashThreshold);
77 
78  void FindSeedHit(std::map<double, std::vector<int>, std::greater<double>> const& HitsBySize,
79  std::vector<bool>& HitsUsed,
80  std::vector<recob::OpHit> const& HitVector,
81  std::vector<int>& HitsThisRefinedFlash,
82  double& PEAccumulated,
83  double& FlashMaxTime,
84  double& FlashMinTime);
85 
86  void AddHitToFlash(int const& HitID,
87  std::vector<bool>& HitsUsed,
88  recob::OpHit const& currentHit,
89  double WidthTolerance,
90  std::vector<int>& HitsThisRefinedFlash,
91  double& PEAccumulated,
92  double& FlashMaxTime,
93  double& FlashMinTime);
94 
95  void CheckAndStoreFlash(std::vector<std::vector<int>>& RefinedHitsPerFlash,
96  std::vector<int> const& HitsThisRefinedFlash,
97  double PEAccumulated,
98  float FlashThreshold,
99  std::vector<bool>& HitsUsed);
100 
101  void ConstructFlash(std::vector<int> const& HitsPerFlashVec,
102  std::vector<recob::OpHit> const& HitVector,
103  std::vector<recob::OpFlash>& FlashVector,
104  geo::GeometryCore const& geom,
106  float TrigCoinc);
107 
108  void AddHitContribution(recob::OpHit const& currentHit,
109  double& MaxTime,
110  double& MinTime,
111  double& AveTime,
112  double& FastToTotal,
113  double& AveAbsTime,
114  double& TotalPE,
115  std::vector<double>& PEs);
116 
117  void GetHitGeometryInfo(recob::OpHit const& currentHit,
118  geo::GeometryCore const& geom,
119  std::vector<double>& sumw,
120  std::vector<double>& sumw2,
121  double& sumy,
122  double& sumy2,
123  double& sumz,
124  double& sumz2);
125 
126  void RemoveLateLight(std::vector<recob::OpFlash>&, std::vector<std::vector<int>>&);
127 
128  double GetLikelihoodLateLight(double iPE,
129  double iTime,
130  double iWidth,
131  double jPE,
132  double jTime,
133  double jWidth);
134 
135  void MarkFlashesForRemoval(std::vector<recob::OpFlash> const& FlashVector,
136  size_t BeginFlash,
137  std::vector<bool>& MarkedForRemoval);
138 
139  void RemoveFlashesFromVectors(std::vector<bool> const& MarkedForRemoval,
140  std::vector<recob::OpFlash>& FlashVector,
141  size_t BeginFlash,
142  std::vector<std::vector<int>>& RefinedHitsPerFlash);
143 
144  template <typename T, typename Compare>
145  std::vector<int> sort_permutation(std::vector<T> const& vec, int offset, Compare compare);
146 
147  template <typename T>
148  void apply_permutation(std::vector<T>& vec, std::vector<int> const& p);
149 
150 } // End opdet namespace
151 
152 #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:213
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:358
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:62
int compare(unsigned *r, sha1::digest_t const &d)
Definition: sha1_test_2.cc:60
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:524
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:455
struct vector vector
void apply_permutation(std::vector< T > &vec, std::vector< int > const &p)
Definition: OpFlashAlg.cxx:703
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:249
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:300
void MarkFlashesForRemoval(std::vector< recob::OpFlash > const &FlashVector, size_t const BeginFlash, std::vector< bool > &MarkedForRemoval)
Definition: OpFlashAlg.cxx:622
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:226
constexpr float FlashThreshold
std::vector< int > sort_permutation(std::vector< T > const &vec, int offset, Compare compare)
Definition: OpFlashAlg.cxx:690
p
Definition: test.py:223
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:201
void RemoveLateLight(std::vector< recob::OpFlash > &FlashVector, std::vector< std::vector< int >> &RefinedHitsPerFlash)
Definition: OpFlashAlg.cxx:664
General LArSoft Utilities.
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:330
std::vector< reco::ClusterHit2D * > HitVector
What follows are several highly useful typedefs which we want to expose to the outside world...
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:383
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:171
Access the description of detector geometry.
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:482
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:650
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:181
double GetLikelihoodLateLight(double const iPE, double const iTime, double const iWidth, double const jPE, double const jTime, double const jWidth)
Definition: OpFlashAlg.cxx:604