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

Ratpac-two: /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/ds/include/RAT/DS/Digit.hh Source File
Ratpac-two
Digit.hh
1 
8 #ifndef __RAT_DS_Digit__
9 #define __RAT_DS_Digit__
10 
11 #include <TMath.h>
12 #include <TObject.h>
13 
14 #include <iostream>
15 #include <map>
16 #include <string>
17 #include <vector>
18 
19 namespace RAT {
20 namespace DS {
21 
22 class Digit : public TObject {
23  public:
24  Digit() : TObject() {}
25  virtual ~Digit() {}
26 
27  // Digitizer name
28  virtual void SetDigitName(std::string _name) { name = _name; };
29  virtual std::string GetDigitName() const { return name; };
30 
31  // Sampling rate
32  virtual void SetSamplingRate(Double_t _sampling_rate) { sampling_rate = _sampling_rate; };
33  virtual Double_t GetSamplingRate() const { return sampling_rate; };
34 
35  // Total number of samples
36  virtual void SetNSamples(uint32_t _nsamples) { nsamples = _nsamples; };
37  virtual uint32_t GetNSamples() const { return nsamples; };
38 
39  // ADC bits
40  virtual void SetNBits(UShort_t _nbits) { nbits = _nbits; };
41  virtual UShort_t GetNBits() const { return nbits; };
42 
43  // Dynamic range (mV)
44  virtual void SetDynamicRange(double _dynamic_range) { dynamic_range = _dynamic_range; };
45  virtual Double_t GetDynamicRange() const { return dynamic_range; };
46 
47  // Termination ohms
48  virtual void SetTerminationOhms(double _termination_ohms) { termination_ohms = _termination_ohms; };
49  virtual Double_t GetTerminationOhms() const { return termination_ohms; };
50 
51  // Calculate time step (ns)
52  virtual Double_t GetTimeStepNS() const { return 1.0 / sampling_rate; };
53 
54  // Calculate voltage resolution (mV)
55  virtual Double_t GetVoltageResolution() const { return dynamic_range / pow(2, nbits); };
56 
58  virtual void SetWaveform(const int waveformID, const std::vector<UShort_t> &samples) {
59  waveforms[waveformID] = samples;
60  }
61 
62  // Get a map of waveform IDs to digitized waveforms
63  virtual std::map<int, std::vector<UShort_t>> GetAllWaveforms() const { return waveforms; }
64 
65  // Get the waveform for a digitizer
66  virtual std::vector<UShort_t> GetWaveform(const int waveformID) const { return waveforms.at(waveformID); }
67 
69  Bool_t ExistsWaveform(const int waveformID) const { return waveforms.count(waveformID) > 0; }
70 
72  std::vector<int> GetIDs() const {
73  std::vector<int> ret;
74  for (std::map<int, std::vector<UShort_t>>::const_iterator it = waveforms.begin(); it != waveforms.end(); it++) {
75  ret.push_back(it->first);
76  }
77  return ret;
78  }
79 
81  virtual void PruneWaveforms() { waveforms.clear(); }
82 
83  ClassDef(Digit, 4);
84 
85  protected:
86  std::string name;
87  Double_t sampling_rate;
88  uint32_t nsamples;
89  UShort_t nbits;
90  Double_t dynamic_range;
91  Double_t termination_ohms;
92  std::map<int, std::vector<UShort_t>> waveforms;
93 };
94 
95 } // namespace DS
96 } // namespace RAT
97 
98 #endif // __RAT_DS_Digit__
Definition: Digit.hh:22
std::vector< int > GetIDs() const
Get a list (vector) of all the IDs that are available.
Definition: Digit.hh:72
virtual void SetWaveform(const int waveformID, const std::vector< UShort_t > &samples)
Set a waveform, overwrites existing.
Definition: Digit.hh:58
Bool_t ExistsWaveform(const int waveformID) const
Check if a waveform exists.
Definition: Digit.hh:69
virtual void PruneWaveforms()
Delete all waveforms.
Definition: Digit.hh:81
std::map< int, std::vector< UShort_t > > waveforms
Map of input number to samples.
Definition: Digit.hh:92
Definition: CCCrossSecMessenger.hh:29