-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathORGretaDecoder.hh
227 lines (188 loc) · 7.12 KB
/
ORGretaDecoder.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
// ORGretaDecoder.hh
#ifndef _ORGretaDecoder_hh_
#define _ORGretaDecoder_hh_
#include "ORVDigitizerDecoder.hh"
#include "ORUtils.hh"
using ORUtils::BitConcat;
class ORGretaDecoder: public ORVDigitizerDecoder
{
public:
ORGretaDecoder();
virtual ~ORGretaDecoder() {}
enum EGretaConsts { kBufHeadLen = 6 };
enum EGretaPolarity { kNone = 0,
kPos,
kNeg,
kBoth };
enum EGretaTriggerMode { kInternal = 0,
kExternal,
kValidation };
virtual std::string GetDataObjectPath() { return "ORGretinaModel:Gretina"; }
virtual std::string GetDictionaryObjectPath() { return "ORGretinaModel"; }
//virtual void Swap(UInt_t* dataRecord);
/* Overloading swap, this is a 16-bit style record. */
virtual bool SetDataRecord(UInt_t* record);
//Functions that return data from buffer header:
virtual inline size_t GetBufHeadLen() {return (size_t) kBufHeadLen;}
virtual inline UShort_t GetBoardId();
virtual inline UShort_t GetChannelNum();
virtual inline UShort_t GetPacketLength();
virtual inline UShort_t GetLEDExtTimeStampLo();
virtual inline UShort_t GetLEDExtTimeStampMed();
virtual inline UShort_t GetLEDExtTimeStampHi();
virtual inline ULong64_t GetLEDExtTimeStamp();
virtual inline UShort_t GetEnergyLo();
virtual inline UShort_t GetEnergyHi();
virtual inline UInt_t GetEnergy();
virtual inline Bool_t IsLEDCrossingNeg();
virtual inline Bool_t IsExternalTrigFlag();
virtual inline Bool_t IsCFDCrossingFlag();
virtual inline Bool_t IsPileupFlag();
virtual inline UShort_t GetCFDTimeStampLo();
virtual inline UShort_t GetCFDTimeStampMed();
virtual inline UShort_t GetCFDTimeStampHi();
virtual inline ULong64_t GetCFDTimeStamp();
virtual inline UInt_t GetCFDPointOne();
virtual inline UInt_t GetCFDPointTwo();
// Waveform Functions
virtual inline size_t GetWaveformLen();
virtual size_t CopyWaveformData(UShort_t* waveform, size_t len);
virtual size_t CopyWaveformDataDouble(double* waveform, size_t len);
virtual size_t CopyWaveformDataShort(short* waveform, size_t len);
virtual inline UInt_t* GetWaveformDataPointer();
/* Functions that return information about card/channel settings. */
/* These are static throughout a run, so a processor should take *
* advantage of this and maybe not query during each record. */
virtual UInt_t GetBaseAddress();
virtual UInt_t GetCFDDelay();
virtual UInt_t GetCFDFraction();
virtual UInt_t GetCFDThreshold();
virtual UInt_t GetCollectionTime();
virtual UInt_t GetDataDelay();
virtual UInt_t GetDataLength();
virtual Bool_t IsDebugModeOn();
virtual Bool_t IsEnabled();
virtual UInt_t GetExternalTriggerLength();
virtual UInt_t GetExternalWindow();
virtual UInt_t GetIntegrationTime();
virtual UInt_t GetLEDThreshold();
virtual UInt_t GetNoiseWindow();
virtual Bool_t IsPileUpEnabled();
virtual UInt_t GetPileUpWindow();
virtual EGretaPolarity GetPolarity();
virtual EGretaTriggerMode GetTriggerMode();
/* Functions satisfying the ORVDigitizerDecoder interface. */
virtual inline double GetSamplingFrequency() { return .1; }
virtual inline UShort_t GetBitResolution() { return 12; }
virtual inline size_t GetNumberOfEvents() { return 1; }
virtual inline ULong64_t GetEventTime(size_t /*event*/) {return GetLEDExtTimeStamp();}
virtual inline UInt_t GetEventEnergy(size_t /*event*/) {return GetEnergy();}
virtual inline UShort_t GetEventChannel(size_t /*event*/) {return GetChannelNum();}
virtual size_t GetEventWaveformLength(size_t /*event*/)
{ return GetWaveformLen(); }
virtual UInt_t GetEventWaveformPoint( size_t /*event*/,
size_t waveformPoint );
virtual UInt_t GetEventFlags(size_t /*event*/);
//Error checking:
virtual bool IsValid();
virtual void DumpBufferHeader();
//debugging:
void Dump(UInt_t* dataRecord);
protected:
/* GetRecordOffset() returns how many words the record is offset from the
beginning. This is useful when additional headers are added. */
virtual inline size_t GetRecordOffset() {return 2;}
// This is a bit mask to grab the correct values from the waveform data.
UInt_t fBitMask;
};
//inline functions: ************************************************************************
inline UShort_t ORGretaDecoder::GetBoardId()
{
return (UShort_t)(fDataRecord[GetRecordOffset()] & 0xffff) >> 3;
}
inline UShort_t ORGretaDecoder::GetChannelNum()
{
return (UShort_t) (fDataRecord[GetRecordOffset()] & 0x7);
}
inline UShort_t ORGretaDecoder::GetPacketLength()
{
return (UShort_t) (( fDataRecord[GetRecordOffset()] & 0x7FF0000 ) >> 16);
}
inline UShort_t ORGretaDecoder::GetLEDExtTimeStampLo()
{
return (UShort_t) (fDataRecord[GetRecordOffset()+1] & 0xffff);
}
inline UShort_t ORGretaDecoder::GetLEDExtTimeStampMed()
{
return (UShort_t) (fDataRecord[GetRecordOffset()+1] >> 16);
}
inline UShort_t ORGretaDecoder::GetLEDExtTimeStampHi()
{
return (UShort_t) (fDataRecord[GetRecordOffset()+2] & 0xffff);
}
inline ULong64_t ORGretaDecoder::GetLEDExtTimeStamp()
{
return BitConcat(GetLEDExtTimeStampLo(), GetLEDExtTimeStampMed(), GetLEDExtTimeStampHi());
}
inline UShort_t ORGretaDecoder::GetEnergyLo()
{
return (UShort_t) (fDataRecord[GetRecordOffset()+2] >> 16);
}
inline UShort_t ORGretaDecoder::GetEnergyHi()
{
return (UShort_t) (fDataRecord[GetRecordOffset()+3] & 0x7f);
}
inline UInt_t ORGretaDecoder::GetEnergy()
{
return (UInt_t) BitConcat(GetEnergyLo(), GetEnergyHi());
}
inline Bool_t ORGretaDecoder::IsLEDCrossingNeg()
{
return ((fDataRecord[GetRecordOffset()+3] >> 12) & 0x1) == 1;
}
inline Bool_t ORGretaDecoder::IsExternalTrigFlag()
{
return ((fDataRecord[GetRecordOffset()+3] >> 13) & 0x1) == 1;
}
inline Bool_t ORGretaDecoder::IsCFDCrossingFlag()
{
return ((fDataRecord[GetRecordOffset()+3] >> 14) & 0x1) == 1;
}
inline Bool_t ORGretaDecoder::IsPileupFlag()
{
return ((fDataRecord[GetRecordOffset()+3] >> 15) & 0x1) == 1;
}
inline UShort_t ORGretaDecoder::GetCFDTimeStampLo()
{
return (UShort_t) (fDataRecord[GetRecordOffset()+3] >> 16);
}
inline UShort_t ORGretaDecoder::GetCFDTimeStampMed()
{
return (UShort_t) (fDataRecord[GetRecordOffset()+4] & 0xffff);
}
inline UShort_t ORGretaDecoder::GetCFDTimeStampHi()
{
return (UShort_t) (fDataRecord[GetRecordOffset()+4] >> 16);
}
inline ULong64_t ORGretaDecoder::GetCFDTimeStamp()
{
return BitConcat(GetCFDTimeStampLo(), GetCFDTimeStampMed(), GetCFDTimeStampHi());
}
inline UInt_t ORGretaDecoder::GetCFDPointOne()
{
return (fDataRecord[GetRecordOffset()+5] & 0xffff);
}
inline UInt_t ORGretaDecoder::GetCFDPointTwo()
{
return (fDataRecord[GetRecordOffset()+5] >> 16);
}
inline size_t ORGretaDecoder::GetWaveformLen()
{
// returns Waveform length in number of shorts
return (GetPacketLength() - GetBufHeadLen())*2;
}
inline UInt_t* ORGretaDecoder::GetWaveformDataPointer()
{
return (fDataRecord + GetRecordOffset() + GetBufHeadLen());
}
#endif