HitAnaAlg.h
Go to the documentation of this file.
1 #ifndef HITANAALG_H
2 #define HITANAALG_H
3 
4 /*!
5  * Title: HitAnaModule
6  * Author: wketchum@lanl.gov.
7  * Inputs: recob::Wire (calibrated), recob::Hit, Assns<recob::Wire, recob::Hit>
8  * Outputs: validation histograms for wire aggregated hits.
9  *
10  * Embellished by echurch@fnal.gov for just Hits
11  *
12  * Description:
13  * This module is intended to be yet another hit analyzer module. Its intention is
14  * (1) to compare hit-finding modules against each other, and eventually
15  * (2) to compare those to truth
16  */
17 
18 #include <exception>
19 #include <string>
20 #include <vector>
21 
25 
26 class TTree;
27 namespace detinfo {
28  class DetectorClocksData;
29 }
30 
31 namespace hit {
32 
33  struct HitInfo {
34 
35  //need a constructor here
36  HitInfo(float pt,
37  float pt_s,
38  float w,
39  int st,
40  int et,
41  float c,
42  float c_s,
43  float mc,
44  float mc_s,
45  float gof)
46  : peaktime(pt)
47  , peaktime_sigma(pt_s)
48  , rms(w)
49  , starttick(st)
50  , endtick(et)
51  , charge(c)
52  , charge_sigma(c_s)
53  , maxcharge(mc)
54  , maxcharge_sigma(mc_s)
55  , goodness_of_fit(gof)
56  {}
57 
58  float peaktime;
60  float rms;
61  int starttick;
62  int endtick;
63  float charge;
64  float charge_sigma;
65  float maxcharge;
68  };
69 
70  struct WireROIInfo {
71  unsigned int event;
72  unsigned int run;
73  unsigned int channel;
74  unsigned int plane;
75  unsigned int range_index;
76  unsigned int range_start;
77  size_t range_size;
79  float peak_charge;
80  float peak_time;
82  std::vector<std::string> HitModuleLabels;
83  std::vector<int> NHits;
84  std::vector<float> Hits_IntegratedCharge;
85  std::vector<float> Hits_AverageCharge;
86  std::vector<float> Hits_PeakCharge;
87  std::vector<float> Hits_PeakTime;
88  std::vector<float> Hits_wAverageCharge;
89  std::vector<float> Hits_wAverageTime;
90  std::vector<float> Hits_MeanMultiplicity;
91  std::vector<std::vector<HitInfo>> Hits;
92  int NMCHits;
99  };
100 
102  virtual const char*
103  what() const throw()
104  {
105  return "HitAnaAlg Exception";
106  }
108 
109  class HitAnaAlg {
110 
111  typedef std::pair<const std::vector<recob::Hit>&, const std::vector<std::vector<int>>&>
113 
114  public:
115  HitAnaAlg();
116 
117  void SetWireDataTree(TTree*);
118 
119  void SetHitDataTree(std::vector<TTree*>& trees);
120 
121  void AnalyzeWires(std::vector<recob::Wire> const&,
122  std::vector<sim::MCHitCollection> const&,
123  std::vector<std::vector<int>> const&,
125  unsigned int,
126  unsigned int);
127 
128  void LoadHitAssocPair(std::vector<recob::Hit> const&,
129  std::vector<std::vector<int>> const&,
130  std::string const&);
131 
132  void ClearHitModules();
133 
134  private:
135  void InitWireData(unsigned int, unsigned int);
136  void ClearWireDataHitInfo();
137 
138  void FillHitInfo(recob::Hit const&, std::vector<HitInfo>&);
139 
140  void FillWireInfo(recob::Wire const&,
141  int,
142  std::vector<sim::MCHitCollection> const&,
143  std::vector<int> const&,
145 
146  void ProcessROI(lar::sparse_vector<float>::datarange_t const&,
147  int,
148  std::vector<sim::MCHitCollection> const&,
149  std::vector<int> const&,
151 
152  void ROIInfo(lar::sparse_vector<float>::datarange_t const&, float&, float&, float&);
153 
154  void FindAndStoreHitsInRange(std::vector<recob::Hit> const&,
155  std::vector<int> const&,
156  size_t,
157  size_t,
158  size_t);
159  void FindAndStoreMCHitsInRange(std::vector<sim::MCHitCollection> const&,
160  std::vector<int> const&,
161  size_t,
162  size_t,
164 
166  std::vector<recob::Hit*> hitData;
167 
168  std::vector<std::string> HitModuleLabels;
169  std::vector<HitAssocPair> HitProcessingQueue;
170 
171  void SetupWireDataTree();
172  TTree* wireDataTree;
173 
174  std::vector<TTree*> hitDataTree;
175 
176  //this is for unit testing...class has no other purpose
177  friend class HitAnaAlgTest;
178  };
179 
180 } //end namespace hit
181 
182 #endif
std::vector< std::string > HitModuleLabels
Definition: HitAnaAlg.h:168
TTree * wireDataTree
Definition: HitAnaAlg.h:172
unsigned int range_index
Definition: HitAnaAlg.h:75
int starttick
Definition: HitAnaAlg.h:61
unsigned int event
Definition: HitAnaAlg.h:71
float charge
Definition: HitAnaAlg.h:63
float peaktime_sigma
Definition: HitAnaAlg.h:59
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:40
WireROIInfo wireData
Definition: HitAnaAlg.h:165
std::vector< float > Hits_wAverageCharge
Definition: HitAnaAlg.h:88
std::vector< float > Hits_MeanMultiplicity
Definition: HitAnaAlg.h:90
std::string string
Definition: nybbler.cc:12
hit::HitAnaAlgException hitanaalgexception
std::vector< recob::Hit * > hitData
Definition: HitAnaAlg.h:166
virtual const char * what() const
Definition: HitAnaAlg.h:103
struct vector vector
std::vector< float > Hits_PeakTime
Definition: HitAnaAlg.h:87
float charge_sigma
Definition: HitAnaAlg.h:64
HitInfo(float pt, float pt_s, float w, int st, int et, float c, float c_s, float mc, float mc_s, float gof)
Definition: HitAnaAlg.h:36
unsigned int range_start
Definition: HitAnaAlg.h:76
std::vector< std::string > HitModuleLabels
Definition: HitAnaAlg.h:82
float MCHits_wAverageTime
Definition: HitAnaAlg.h:98
unsigned int run
Definition: HitAnaAlg.h:72
std::vector< float > Hits_PeakCharge
Definition: HitAnaAlg.h:86
float peaktime
Definition: HitAnaAlg.h:58
std::vector< int > NHits
Definition: HitAnaAlg.h:83
float MCHits_IntegratedCharge
Definition: HitAnaAlg.h:93
float MCHits_wAverageCharge
Definition: HitAnaAlg.h:97
float peak_charge
Definition: HitAnaAlg.h:79
std::vector< float > Hits_AverageCharge
Definition: HitAnaAlg.h:85
std::vector< float > Hits_wAverageTime
Definition: HitAnaAlg.h:89
unsigned int channel
Definition: HitAnaAlg.h:73
General LArSoft Utilities.
float MCHits_PeakCharge
Definition: HitAnaAlg.h:95
Detector simulation of raw signals on wires.
size_t range_size
Definition: HitAnaAlg.h:77
float MCHits_PeakTime
Definition: HitAnaAlg.h:96
std::pair< const std::vector< recob::Hit > &, const std::vector< std::vector< int > > & > HitAssocPair
Definition: HitAnaAlg.h:112
unsigned int plane
Definition: HitAnaAlg.h:74
Declaration of signal hit object.
Contains all timing reference information for the detector.
std::vector< float > Hits_IntegratedCharge
Definition: HitAnaAlg.h:84
float rms
Definition: HitAnaAlg.h:60
float goodness_of_fit
Definition: HitAnaAlg.h:67
std::vector< TTree * > hitDataTree
Definition: HitAnaAlg.h:174
std::vector< std::vector< HitInfo > > Hits
Definition: HitAnaAlg.h:91
float maxcharge
Definition: HitAnaAlg.h:65
Class holding the regions of interest of signal from a channel.
Definition: Wire.h:118
Range class, with range and data.
float integrated_charge
Definition: HitAnaAlg.h:78
float maxcharge_sigma
Definition: HitAnaAlg.h:66
float MCHits_AverageCharge
Definition: HitAnaAlg.h:94
Declaration of basic channel signal object.
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
std::vector< HitAssocPair > HitProcessingQueue
Definition: HitAnaAlg.h:169
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33