QwAnalysis
QwSIS3320_Channel.h
Go to the documentation of this file.
1 /**
2  * \class QwSIS3320_Channel QwSIS3320_Channel.h
3  *
4  * \brief Class for the decoding of the SIS3320 sampling ADC data
5  *
6  * \author W. Deconinck
7  * \date 2009-09-04 18:06:23
8  * \ingroup QwCompton
9  *
10  * The QwSIS3320_Channel class is defined to read the integrated and sampled
11  * data from the Compton photon detector. Because the scope of this module is
12  * similar the the VQWK ADC module (integration and asymmetries), parts of
13  * this class are very similar to QwVQWK_Channel.
14  *
15  * The main data members of a QwSIS3320_Channel are the vector fSamples of
16  * QwSIS3320_Samples where each entry stores a sample event, and the vector of
17  * fAccumulators of QwSIS3320_Accumulator where each entry stores an accumulator
18  * block. Both of these data members are derived from their --Raw counterparts
19  * by subtraction of pedestals and multiplication with calibration constants.
20  *
21  */
22 
23 #ifndef __QwSIS3320_Channel__
24 #define __QwSIS3320_Channel__
25 
26 // System headers
27 #include <iostream>
28 #include <vector>
29 #include <numeric>
30 
31 // ROOT headers
32 #include <TTree.h>
33 
34 // Boost math library for random number generation
35 #include <boost/random.hpp>
36 
37 // Qweak headers
38 #include "MQwMockable.h"
39 #include "VQwDataElement.h"
40 #include "QwSIS3320_Accumulator.h"
42 #include "QwSIS3320_Samples.h"
43 
45 
46  public:
47 
48  QwSIS3320_Channel(UInt_t channel = 0, TString name = "auto")
50  InitializeChannel(channel, name);
51  };
53  : VQwDataElement(source),MQwMockable(source),
54  fChannel(source.fChannel),
57  fPedestal(source.fPedestal),
62  fSamples(source.fSamples),
63  fSamplesRaw(source.fSamplesRaw),
66  fTimeWindows(source.fTimeWindows),
78  { }
79  virtual ~QwSIS3320_Channel() { };
80 
82  const TString name,
83  const std::vector<TString> accums,
84  const std::vector<Double_t> weights);
85 
86  void InitializeChannel(UInt_t channel, TString name);
87  void ClearEventData();
88 
89  void RandomizeEventData(int helicity = 0, double time = 0.0) { };
90  void EncodeEventData(std::vector<UInt_t> &buffer);
91 
92  Int_t ProcessEvBuffer(UInt_t* buffer, UInt_t num_words_left, UInt_t index = 0);
93  void ProcessEvent();
94 
95  const QwSIS3320_Channel operator+ (const Double_t &value) const;
96  const QwSIS3320_Channel operator- (const Double_t &value) const;
97  const QwSIS3320_Channel operator+ (const QwSIS3320_Channel &value) const;
98  const QwSIS3320_Channel operator- (const QwSIS3320_Channel &value) const;
100  QwSIS3320_Channel& operator+= (const Double_t &value);
101  QwSIS3320_Channel& operator-= (const Double_t &value);
104  void Sum(QwSIS3320_Channel &value1, QwSIS3320_Channel &value2);
105  void Difference(QwSIS3320_Channel &value1, QwSIS3320_Channel &value2);
106  void Ratio(QwSIS3320_Channel &numer, QwSIS3320_Channel &denom);
107  void Offset(Double_t Offset);
108  void Scale(Double_t Offset);
109 
110  void ConstructHistograms(TDirectory *folder, TString &prefix);
111  void FillHistograms();
112 
113  void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector<Double_t> &values);
114  void FillTreeVector(std::vector<Double_t> &values) const;
115 
116  QwSIS3320_Samples& GetSamples(size_t i) { return fSamples.at(i); };
117  QwSIS3320_Samples& GetSamplesRaw(size_t i) { return fSamplesRaw.at(i); };
118 
119  size_t GetNumberOfEvents() const { return (fNumberOfEvents); };
120  void SetNumberOfEvents(UInt_t nevents) {
121  fNumberOfEvents = nevents;
122  fSamplesRaw.resize(nevents);
123  fSamples.resize(nevents);
124  };
125 
126  size_t GetNumberOfAccumulators() const { return (fNumberOfAccumulators); };
127  void SetNumberOfAccumulators(UInt_t naccumulators) {
128  fNumberOfAccumulators = naccumulators;
129  fAccumulatorsRaw.resize(naccumulators);
130  fAccumulators.resize(naccumulators);
131  };
132 
133  void SetPedestal(const Double_t ped) { fPedestal = ped; };
134  Double_t GetPedestal() const { return fPedestal; };
135  void SetCalibrationFactor(const Double_t factor) { fCalibrationFactor = factor; };
136  Double_t GetCalibrationFactor() const { return fCalibrationFactor; };
137 
138  Bool_t IsGoodEvent();
139 
140  void PrintValue() const;
141  void PrintInfo() const;
142 
143  private:
144 
145  static const Bool_t kDEBUG;
146 
147  // Identification information
148  UInt_t fChannel;
151 
152  /* ADC Calibration */
153  static const Double_t kVoltsPerBit;
154  static const Double_t kNanoSecondsPerSample;
155  Double_t fPedestal;
157 
158  /* In sampling mode we have multiple events in a single data block */
159  Int_t fCurrentEvent; //! Current triggered event (allow for negative sentinel)
160  UInt_t fNumberOfEvents; //! Number of triggered events
161 
162  /* ADC sample data */
164  std::vector<QwSIS3320_Samples> fSamples;
165  std::vector<QwSIS3320_Samples> fSamplesRaw;
166  //
169  std::vector<Double_t> fTimeWindowAverages;
170  std::vector<std::pair<UInt_t, UInt_t> > fTimeWindows;
171  std::vector<Double_t> fSampleWindowAverages;
172  std::vector<std::pair<Double_t, Double_t> > fSampleWindows;
173 
174  /* ADC accumulator data */
180  std::vector<QwSIS3320_Accumulator> fAccumulators;
181  std::vector<QwSIS3320_Accumulator> fAccumulatorsRaw;
182  std::vector<QwSIS3320_LogicalAccumulator> fLogicalAccumulators;
183 
184  // Operation mode flags
185  static const unsigned int MODE_ACCUM_EVENT;
186  static const unsigned int MODE_MULTI_EVENT;
187  static const unsigned int MODE_SINGLE_EVENT;
188  static const unsigned int MODE_NOTREADY;
189 
190  // Data storage format flags
191  static const unsigned int FORMAT_ACCUMULATOR;
192  static const unsigned int FORMAT_LONG_WORD_SAMPLING;
193  static const unsigned int FORMAT_SHORT_WORD_SAMPLING;
194 
195 };
196 
197 #endif // __QwSIS3320_Channel__
QwSIS3320_Samples & GetSamplesRaw(size_t i)
static const Bool_t kDEBUG
Double_t GetCalibrationFactor() const
SIS3320 sampling ADC samples.
const QwSIS3320_Channel operator+(const Double_t &value) const
Class for the decoding of the SIS3320 sampling ADC data.
std::vector< Double_t > fSampleWindowAverages
static const unsigned int MODE_MULTI_EVENT
static const unsigned int FORMAT_ACCUMULATOR
const QwSIS3320_Channel operator-(const Double_t &value) const
size_t GetNumberOfAccumulators() const
QwSIS3320_Channel(UInt_t channel=0, TString name="auto")
QwSIS3320_Samples & GetSamples(size_t i)
Double_t GetPedestal() const
std::vector< QwSIS3320_Samples > fSamples
QwSIS3320_Channel & operator=(const QwSIS3320_Channel &value)
std::vector< QwSIS3320_Samples > fSamplesRaw
static const unsigned int MODE_SINGLE_EVENT
UInt_t fSampleFormat
Number of triggered events.
void FillHistograms()
Fill the histograms for this data element.
static const unsigned int FORMAT_SHORT_WORD_SAMPLING
void ConstructHistograms(TDirectory *folder, TString &prefix)
Construct the histograms for this data element.
void InitializeChannel(UInt_t channel, TString name)
size_t GetNumberOfEvents() const
static const unsigned int FORMAT_LONG_WORD_SAMPLING
Definition of the pure virtual base class of all data elements.
std::vector< QwSIS3320_Accumulator > fAccumulatorsRaw
std::vector< std::pair< UInt_t, UInt_t > > fTimeWindows
The pure virtual base class of all data elements.
void RandomizeEventData(int helicity=0, double time=0.0)
Internally generate random event data.
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
QwSIS3320_Channel & operator-=(const Double_t &value)
void Offset(Double_t Offset)
static const Double_t kVoltsPerBit
std::vector< QwSIS3320_LogicalAccumulator > fLogicalAccumulators
void Scale(Double_t Offset)
void EncodeEventData(std::vector< UInt_t > &buffer)
Encode the event data into a CODA buffer.
Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t num_words_left, UInt_t index=0)
void PrintInfo() const
void Difference(QwSIS3320_Channel &value1, QwSIS3320_Channel &value2)
void Sum(QwSIS3320_Channel &value1, QwSIS3320_Channel &value2)
void Ratio(QwSIS3320_Channel &numer, QwSIS3320_Channel &denom)
void AddLogicalAccumulator(const TString name, const std::vector< TString > accums, const std::vector< Double_t > weights)
void SetNumberOfEvents(UInt_t nevents)
void PrintValue() const
void FillTreeVector(std::vector< Double_t > &values) const
std::vector< QwSIS3320_Accumulator > fAccumulators
static const unsigned int MODE_ACCUM_EVENT
std::vector< Double_t > fTimeWindowAverages
virtual ~QwSIS3320_Channel()
void SetNumberOfAccumulators(UInt_t naccumulators)
QwSIS3320_Samples fAverageSamples
QwSIS3320_Samples fAverageSamplesRaw
static const Double_t kNanoSecondsPerSample
void SetCalibrationFactor(const Double_t factor)
std::vector< std::pair< Double_t, Double_t > > fSampleWindows
QwSIS3320_Channel & operator+=(const Double_t &value)
static const unsigned int MODE_NOTREADY
QwSIS3320_Channel(const QwSIS3320_Channel &source)
UInt_t fNumberOfEvents
Current triggered event (allow for negative sentinel)
void SetPedestal(const Double_t ped)