ROOTANA
TV1720RawData.h
Go to the documentation of this file.
1 #ifndef TV1720RawData_hxx_seen
2 #define TV1720RawData_hxx_seen
3 
4 #include <vector>
5 
6 #include "TGenericData.hxx"
7 
8 
9 /// Class to store information from a single V1720 ZLE pulse.
11 
12  public:
13 
14  /// Constructor
15  TV1720RawZlePulse(int firstBin, std::vector<uint32_t> samples):
16  fFirstBin(firstBin),fSamples(samples){};
17 
19 
20 
21  /// Get the first bin for this pulse
22  int GetFirstBin() const {
23  return fFirstBin;
24  }
25 
26  /// Get the number of samples.
27  int GetNSamples() const {
28  return fSamples.size();
29  }
30 
31  /// Get the first bin for this pulse
32  int GetSample(int i) const {
33  if(i >= 0 && i < (int)fSamples.size())
34  return fSamples[i];
35 
36  return -1;
37  }
38 
39  private:
40 
41  /// The first bin for this ZLE pulse.
42  int fFirstBin;
43 
44  /// The set of samples for this ZLE pulse.
45  std::vector<uint32_t> fSamples;
46 
47 
48 };
49 
50 /// Class to store information from a single V1720 channel.
51 /// Class will store either the full ADC waveform (if not compressed)
52 /// or a vector of TV1720RawZlePulse (if compressed).
54 
55  public:
56 
57  /// constructor
58  TV1720RawChannel(int channel, bool iscompressed):
59  fChannelNumber(channel),fIsZLECompressed(iscompressed){
60 
61  }
62 
63 
64  int GetChannelNumber() const {return fChannelNumber;};
65 
66 
67  bool IsZLECompressed() const {return fIsZLECompressed;};
68 
69 
70  /// Get the ADC sample for a particular bin (for uncompressed data).
71  int GetNSamples() const{return fWaveform.size();};
72 
73  /// Get the ADC sample for a particular bin (for uncompressed data).
74  int GetADCSample(int i) const{
75  if(i >= 0 && i < (int)fWaveform.size())
76  return fWaveform[i];
77 
78  // otherwise, return error value.
79  return -1;
80  }
81 
82  /// Get the number of ZLE pulses (for compressed data)
83  int GetNZlePulses() const {return fZlePulses.size();};
84 
85 
86  /// Get the ZLE pulse (for compressed data
88  if(i >= 0 && i < (int)fZlePulses.size())
89  return fZlePulses[i];
90 
91  // otherwise, return error value.
92  return TV1720RawZlePulse();
93 
94  }
95 
96  /// Returns true for objects with no ADC samples or ZLE pulses.
97  int IsEmpty() const {
98  if(fZlePulses.size()==0 && fWaveform.size()==0)
99  return true;
100  return false;
101  }
102 
103  /// Add an ADC sample
104  /// Warning: this method just adds an ADC sample to the back
105  /// of the vector. Must add in order and must not add any sample twice.
106  void AddADCSample(uint32_t sample){ fWaveform.push_back(sample);};
107 
108  /// Add an ZLE pulse
109  /// Warning: this method just adds a ZLE pulse to the back
110  /// of the vector. Must add in order and must not add any pulse twice.
111  void AddZlePulse(TV1720RawZlePulse pulse){ fZlePulses.push_back(pulse);};
112 
113 
114  private:
115 
116  /// Channel number
118 
119  /// Is ZLE compressed
121 
122  std::vector<TV1720RawZlePulse> fZlePulses;
123  std::vector<uint32_t> fWaveform;
124 
125 };
126 
127 
128 /// Class to store data from CAEN V1720, 250MHz FADC.
129 ///
130 /// Full info on CAEN V1720 module
131 /// http://daq-plone.triumf.ca/HR/VME/CAEN/v1720rev9.pdf/view
132 ///
133 /// This class encapsulates the data from a single board (in a single MIDAS bank).
134 /// This decoder is for the default or ZLE version of the firmware. Not the DPP firmware
136 
137 public:
138 
139  /// Constructor
140  TV1720RawData(int bklen, int bktype, const char* name, void *pdata);
141 
142  /// Get the number of 32-bit words in bank.
143  uint32_t GetEventSize() const {return (fGlobalHeader0 & 0xffffff);};
144 
145  /// Get the channel mask; ie, the set of channels for which we
146  /// have data for this event.
147  uint32_t GetChannelMask() const {return (fGlobalHeader1 & 0xff);};
148 
149  /// Is the V1720 data ZLE compressed?
150  bool IsZLECompressed() const {return ((fGlobalHeader1 >> 24) & 0x1);};
151 
152  /// Get event counter
153  uint32_t GetEventCounter() const {return ((fGlobalHeader2) & 0xffffff);};
154 
155  /// Get trigger tag
156  uint32_t GetTriggerTag() const {return ((fGlobalHeader3) & 0xffffffff);};
157 
158 
159  /// Get Number of channels in this bank.
160  int GetNChannels() const {return fMeasurements.size();}
161 
162  /// Get Channel Data
164  if(i >= 0 && i < (int)fMeasurements.size())
165  return fMeasurements[i];
166 
167  return TV1720RawChannel(0,0);
168  }
169 
170 
171  void Print();
172 
173 
174 private:
175 
176  /// Helper method to handle ZLE compressed data.
177  void HandlZLECompressedData();
178 
179  /// Helper method to handle uncompressed data.
180  void HandlUncompressedData();
181 
182  /// The overall global headers
183  uint32_t fGlobalHeader0;
184  uint32_t fGlobalHeader1;
185  uint32_t fGlobalHeader2;
186  uint32_t fGlobalHeader3;
187 
188 
189  /// Vector of V1720 measurements
190  std::vector<TV1720RawChannel> fMeasurements;
191 
192 };
193 
194 #endif
TV1720RawChannel(int channel, bool iscompressed)
constructor
Definition: TV1720RawData.h:58
int GetNSamples() const
Get the ADC sample for a particular bin (for uncompressed data).
Definition: TV1720RawData.h:71
int IsEmpty() const
Returns true for objects with no ADC samples or ZLE pulses.
Definition: TV1720RawData.h:97
int fChannelNumber
Channel number.
std::vector< uint32_t > fWaveform
int GetNZlePulses() const
Get the number of ZLE pulses (for compressed data)
Definition: TV1720RawData.h:83
void AddADCSample(uint32_t sample)
bool IsZLECompressed() const
Definition: TV1720RawData.h:67
int GetADCSample(int i) const
Get the ADC sample for a particular bin (for uncompressed data).
Definition: TV1720RawData.h:74
TV1720RawZlePulse GetZlePulse(int i) const
Get the ZLE pulse (for compressed data.
Definition: TV1720RawData.h:87
std::vector< TV1720RawZlePulse > fZlePulses
int GetChannelNumber() const
Definition: TV1720RawData.h:64
bool fIsZLECompressed
Is ZLE compressed.
void AddZlePulse(TV1720RawZlePulse pulse)
void Print()
Print the bank contents in a structured way.
void HandlUncompressedData()
Helper method to handle uncompressed data.
uint32_t GetEventSize() const
Get the number of 32-bit words in bank.
void HandlZLECompressedData()
Helper method to handle ZLE compressed data.
uint32_t fGlobalHeader3
std::vector< TV1720RawChannel > fMeasurements
Vector of V1720 measurements.
TV1720RawChannel GetChannelData(int i)
Get Channel Data.
TV1720RawData(int bklen, int bktype, const char *name, void *pdata)
Constructor.
int GetNChannels() const
Get Number of channels in this bank.
uint32_t fGlobalHeader2
uint32_t fGlobalHeader0
The overall global headers.
uint32_t GetChannelMask() const
uint32_t GetEventCounter() const
Get event counter.
uint32_t GetTriggerTag() const
Get trigger tag.
bool IsZLECompressed() const
Is the V1720 data ZLE compressed?
uint32_t fGlobalHeader1
Class to store information from a single V1720 ZLE pulse.
Definition: TV1720RawData.h:10
int GetSample(int i) const
Get the first bin for this pulse.
Definition: TV1720RawData.h:32
int GetNSamples() const
Get the number of samples.
Definition: TV1720RawData.h:27
int GetFirstBin() const
Get the first bin for this pulse.
Definition: TV1720RawData.h:22
std::vector< uint32_t > fSamples
The set of samples for this ZLE pulse.
Definition: TV1720RawData.h:45
int fFirstBin
The first bin for this ZLE pulse.
Definition: TV1720RawData.h:42
TV1720RawZlePulse(int firstBin, std::vector< uint32_t > samples)
Constructor.
Definition: TV1720RawData.h:15