QwAnalysis
QwSIS3320_Accumulator.h
Go to the documentation of this file.
1 /**
2  * \class QwSIS3320_Accumulator QwSIS3320_Accumulator.h
3  *
4  * \brief SIS3320 sampling ADC accumulator
5  *
6  * \author W. Deconinck
7  * \date 2009-09-04 18:06:23
8  * \ingroup QwCompton
9  *
10  * The QwSIS3320_Accumulator should allow convenient access to the accumulator
11  * data collected with the SIS3320 for the Compton photon detector. This class
12  * implements its own sum, difference, and ratio methods inherited from the
13  * general VQwDataElement.
14  *
15  */
16 
17 #ifndef __QwSIS3320_Accumulator__
18 #define __QwSIS3320_Accumulator__
19 
20 // System headers
21 #include <iostream>
22 #include <vector>
23 #include <numeric>
24 
25 // ROOT headers
26 #include <TTree.h>
27 
28 // Boost math library for random number generation
29 #include <boost/random.hpp>
30 
31 // Qweak headers
32 #include "VQwDataElement.h"
33 
35 
36  public:
37 
38  QwSIS3320_Accumulator(TString name = "") {
39  SetElementName(name);
41  fMinValue = 0; fMaxValue = 0;
42  fMinTime = 0; fMaxTime = 0;
43  };
44  virtual ~QwSIS3320_Accumulator() { };
45 
46  Int_t GetMinValue() const { return fMinValue; };
47  Int_t GetMaxValue() const { return fMaxValue; };
48  Int_t GetMinTime() const { return fMinTime; };
49  Int_t GetMaxTime() const { return fMaxTime; };
50 
51  Double_t GetNumberOfSamples() const { return fNumberOfSamples; };
52  Double_t GetAccumulatorSum() const { return fAccumulatorSum; };
53  Double_t GetAccumulatorAvg() const {
54  if (fAccumulatorSum > 0)
56  else return 0.0;
57  };
58 
60  Int_t ProcessEvBuffer(UInt_t* buffer, UInt_t num_words_left, UInt_t subelement = 0);
61  void ProcessEvent() { };
62 
63  const QwSIS3320_Accumulator operator/ (const Double_t &value) const;
64  const QwSIS3320_Accumulator operator* (const Double_t &value) const;
65  const QwSIS3320_Accumulator operator+ (const Double_t &value) const;
66  const QwSIS3320_Accumulator operator- (const Double_t &value) const;
67  QwSIS3320_Accumulator& operator/= (const Double_t &value);
68  QwSIS3320_Accumulator& operator*= (const Double_t &value);
69  QwSIS3320_Accumulator& operator+= (const Double_t &value);
70  QwSIS3320_Accumulator& operator-= (const Double_t &value);
71  const QwSIS3320_Accumulator operator+ (const QwSIS3320_Accumulator &value) const;
72  const QwSIS3320_Accumulator operator- (const QwSIS3320_Accumulator &value) const;
76  void Sum(const QwSIS3320_Accumulator &value1, const QwSIS3320_Accumulator &value2);
77  void Difference(const QwSIS3320_Accumulator &value1, const QwSIS3320_Accumulator &value2);
78  void Ratio(const QwSIS3320_Accumulator &numer, const QwSIS3320_Accumulator &denom);
79 
80  void ConstructHistograms(TDirectory *folder, TString &prefix);
81  void FillHistograms();
82 
83  void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector<Double_t> &values);
84  void FillTreeVector(std::vector<Double_t> &values) const;
85 
86  // Output stream operator<< for an accumulator
87  friend std::ostream& operator<< (std::ostream& stream, const QwSIS3320_Accumulator& a);
88 
89  // Define operator+=, operator-=, etc, for accumulator asymmetries
90 
91  protected:
92 
93  Double_t fNumberOfSamples; ///< Number of accumulated samples
94  Double_t fAccumulatorSum; ///< Accumulator sum
95  Double_t fAccumulatorAvg; ///< Accumulator average
96 
97  private:
98 
99  int fMinValue, fMaxValue; //! Value-based accumulator limits
100  int fMinTime, fMaxTime; //! Time-based accumulator limits
101 
102  // Ntuple array indices
103  size_t fTreeArrayIndex; //! Index of this data element in tree
104  size_t fTreeArrayNumEntries; //! Number of entries from this data element
105 
106  static const unsigned int INDEX_NUM;
107  static const unsigned int INDEX_SUM;
108 
109 };
110 
111 // Output stream operator<< for the accumulators
112 inline std::ostream& operator<< (std::ostream& stream, const QwSIS3320_Accumulator& a) {
113  stream << a.GetAccumulatorSum() << " (" << a.GetNumberOfSamples() << ")";
114  return stream;
115 }
116 
117 #endif // __QwSIS3320_Accumulator__
friend std::ostream & operator<<(std::ostream &stream, const QwSIS3320_Accumulator &a)
static const unsigned int INDEX_SUM
std::ostream & operator<<(std::ostream &out, const QwColor &color)
Output stream operator which uses the enum-to-escape-code mapping.
Definition: QwColor.h:153
Double_t GetAccumulatorAvg() const
Double_t fAccumulatorSum
Accumulator sum.
QwSIS3320_Accumulator(TString name="")
static const unsigned int INDEX_NUM
Number of entries from this data element.
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
int fMinTime
Value-based accumulator limits.
void Difference(const QwSIS3320_Accumulator &value1, const QwSIS3320_Accumulator &value2)
const QwSIS3320_Accumulator operator/(const Double_t &value) const
SIS3320 sampling ADC accumulator.
QwSIS3320_Accumulator & operator=(const QwSIS3320_Accumulator &value)
Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t num_words_left, UInt_t subelement=0)
Process the CODA event buffer for this element.
QwSIS3320_Accumulator & operator/=(const Double_t &value)
void FillTreeVector(std::vector< Double_t > &values) const
QwSIS3320_Accumulator & operator-=(const Double_t &value)
Definition of the pure virtual base class of all data elements.
void ClearEventData()
Clear the event data in this element.
The pure virtual base class of all data elements.
Double_t fAccumulatorAvg
Accumulator average.
size_t fTreeArrayIndex
Time-based accumulator limits.
void SetElementName(const TString &name)
Set the name of this element.
const QwSIS3320_Accumulator operator-(const Double_t &value) const
Double_t GetAccumulatorSum() const
Double_t fNumberOfSamples
Number of accumulated samples.
void SetNumberOfDataWords(const UInt_t &numwords)
Set the number of data words in this data element.
QwSIS3320_Accumulator & operator*=(const Double_t &value)
const QwSIS3320_Accumulator operator*(const Double_t &value) const
void Ratio(const QwSIS3320_Accumulator &numer, const QwSIS3320_Accumulator &denom)
void Sum(const QwSIS3320_Accumulator &value1, const QwSIS3320_Accumulator &value2)
QwSIS3320_Accumulator & operator+=(const Double_t &value)
void ConstructHistograms(TDirectory *folder, TString &prefix)
Construct the histograms for this data element.
Double_t GetNumberOfSamples() const
size_t fTreeArrayNumEntries
Index of this data element in tree.
void FillHistograms()
Fill the histograms for this data element.
const QwSIS3320_Accumulator operator+(const Double_t &value) const