/home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/ds/include/RAT/DS/WaveformAnalysisResult.hh Source File

Ratpac-two: /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/ds/include/RAT/DS/WaveformAnalysisResult.hh Source File
Ratpac-two
WaveformAnalysisResult.hh
1 
6 #ifndef __RAT_DS_WaveformAnalysisResult__
7 #define __RAT_DS_WaveformAnalysisResult__
8 
9 #include <Rtypes.h>
10 #include <TObject.h>
11 
12 #include <RAT/Log.hh>
13 #include <RAT/WaveformUtil.hh>
14 #include <algorithm>
15 #include <map>
16 #include <string>
17 
18 namespace RAT {
19 namespace DS {
20 
21 class WaveformAnalysisResult : public TObject {
22  public:
23  /* *
24  * Add information about a single reconstructed pulse.
25  * @param time The time of the pulse. Within the digitization window. No shifting due to cable delay or trigger
26  * should be applied here.
27  * @param charge charge the correspond to the pulse. Nominally in units of pC.
28  * @param fom map of all figures of merits. key should be name of the field (e.g. chi2ndf)
29  * */
30  virtual size_t AddPE(Double_t time, Double_t charge, std::map<std::string, Double_t> fom = {}) {
31  Double_t time_corrected = (time == WaveformUtil::INVALID) ? time : time - time_offset;
32  size_t insertion_index = std::upper_bound(times.begin(), times.end(), time_corrected) - times.begin();
33  times.insert(times.begin() + insertion_index, time_corrected);
34  charges.insert(charges.begin() + insertion_index, charge);
35  for (auto const& kv : fom) {
36  std::vector<Double_t>& fom_array = figures_of_merit[kv.first];
37  fom_array.insert(fom_array.begin() + insertion_index, kv.second);
38  }
39  return insertion_index;
40  }
41  virtual void setTimeOffset(Double_t _offset) { time_offset = _offset; }
42  virtual Double_t getTimeOffset() { return time_offset; }
43  virtual Double_t getTime(size_t idx) { return times.at(idx); }
44  virtual Double_t getCharge(size_t idx) { return charges.at(idx); }
45  virtual Double_t getFOM(std::string key, size_t idx) { return figures_of_merit.at(key).at(idx); }
46  virtual int getNPEs() { return times.size(); }
47 
48  virtual const std::vector<Double_t>& getTimes() { return times; }
49  virtual const std::vector<Double_t>& getCharges() { return charges; }
50  ClassDef(WaveformAnalysisResult, 2);
51 
52  protected:
53  // All arrays are parallel arrays. It is assumed that they are sorted in time
54  std::vector<Double_t> times;
55  std::vector<Double_t> charges;
56  std::map<std::string, std::vector<Double_t>> figures_of_merit;
57  Double_t time_offset;
58 };
59 
60 } // namespace DS
61 } // namespace RAT
62 
63 #endif
Definition: WaveformAnalysisResult.hh:21
Definition: CCCrossSecMessenger.hh:29