-
Notifications
You must be signed in to change notification settings - Fork 3
/
ORGretaMarkIVDecoder.hh
232 lines (187 loc) · 7.33 KB
/
ORGretaMarkIVDecoder.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
227
228
229
230
231
// ORGretaDecoder.hh
#ifndef _ORGretaMarkIVDecoder_hh_
#define _ORGretaMarkIVDecoder_hh_
#include "ORGretaDecoder.hh"
#include "ORUtils.hh"
using ORUtils::BitConcat;
/* This card is very similar to the original Greta card, but has some important
differences. For example, it is possible that a record has a Master record
accompanying it and so this is important to check when reading data from a
record. Also, the raw data points (i.e. waveform data) are given in sign
extended format, meaning that the points will occupy the entire 16-bit word.
Currently, the decoder assumes that these are just unsigned numbers and so
a cast should be done while processing to correctly decode these numbers.
The reason this is not done in the decoder is to remain consistent with the
old card. This can be re-evaluated in the future.
The old interface was changed to allow CFD Point One/Two to occupy 32 bits.
New Greta card additions:
- Master header (optional, must check for existence using HasMasterHeader())
- Trigger_TS
- HM Number
- Low Resolution Energy
- Slave header
- FB_LED
- HM Number
- IsTTCLTimeout() -> signifies data generated by a timeout signal during TTCL mode.
- CFD point 1/2 -> now occupies full 32 bits.
It is also important to note that currently the record does not support
running in TTCL (Trigger Timing and Control Link) mode which occurs when
a card is master over other cards (slaves).
*/
class ORGretaMarkIVDecoder: public ORGretaDecoder
{
public:
ORGretaMarkIVDecoder();
virtual ~ORGretaMarkIVDecoder() {}
enum EGretaMarkIVConsts {kORCAHeadLen = 2,
kMasterHeadLen = 4,
kSlaveHeaderLen = 4,
kMarkIVBufHeadLen = 7};
virtual std::string GetDataObjectPath() { return "ORGretina4Model:Gretina4"; }
virtual std::string GetDictionaryObjectPath() { return "ORGretina4Model"; }
virtual bool SetDataRecord(UInt_t* record);
virtual inline UShort_t GetEnergyNormalization();
virtual inline UInt_t GetEnergy();
virtual inline UShort_t GetEnergyHi();
virtual inline UShort_t GetChannelNum();
virtual inline Bool_t EnergyIsNegative();
virtual inline Int_t GetSignedEnergy();
// Functions that return data from Master Header
virtual inline Bool_t HasMasterHeader() {return fHasMasterHeader;}
virtual inline UShort_t GetMasterBoardID();
virtual inline UShort_t GetMasterHeaderLength();
virtual inline UShort_t GetMasterTrigger_TSLow();
virtual inline UShort_t GetMasterTrigger_TSMed();
virtual inline UShort_t GetMasterTrigger_TSHigh();
virtual inline ULong64_t GetMasterTrigger_TS();
virtual inline UShort_t GetMasterHMNum();
virtual inline UShort_t GetMasterLowResEnergy();
// Functions that return data from Slave Header
virtual inline Bool_t HasSlaverHeader() {return fHasSlaverHeader;}
virtual inline UShort_t GetSlaveBoardID();
virtual inline UShort_t GetSlaveHeaderLength();
virtual inline UShort_t GetSlaveFB_LEDLow();
virtual inline UShort_t GetSlaveFB_LEDMed();
virtual inline UShort_t GetSlaveFB_LEDHigh();
virtual inline ULong64_t GetSlaveFB_LED();
virtual inline UShort_t GetSlaveHMNum();
//Functions that return data from buffer header:
virtual inline size_t GetBufHeadLen() {return (size_t) kMarkIVBufHeadLen;}
virtual inline Bool_t IsTTCLTimeout();
virtual inline UInt_t GetCFDPointOne();
virtual inline UInt_t GetCFDPointTwo();
/* Functions satisfying the ORVDigitizerDecoder interface. */
virtual inline UShort_t GetBitResolution() { return 14; }
virtual UInt_t GetEventWaveformPoint( size_t /*event*/,
size_t waveformPoint );
/* All other functions are correctly inherited from the parent class. */
protected:
virtual inline size_t GetRecordOffset() {return kORCAHeadLen + fOffset;}
/* GetRecordOffset() returns how many words the record is offset from the
beginning. This is useful when additional headers are added. */
bool fHasMasterHeader;
bool fHasSlaverHeader;
size_t fOffset;
};
inline UShort_t ORGretaMarkIVDecoder::GetEnergyNormalization()
{
return (UShort_t) GetIntegrationTime();
}
inline UInt_t ORGretaMarkIVDecoder::GetEnergy()
{
UInt_t energy = ORGretaDecoder::GetEnergy();
if (energy & 0x1000000) energy = (~energy & 0x1ffffff) + 1;
return energy;
}
inline UShort_t ORGretaMarkIVDecoder::GetEnergyHi()
{
return (UShort_t) (fDataRecord[GetRecordOffset()+3] & 0x1ff);
}
inline Bool_t ORGretaMarkIVDecoder::EnergyIsNegative()
{
return (Bool_t) (GetEnergyHi() & 0x100);
}
inline Int_t ORGretaMarkIVDecoder::GetSignedEnergy()
{
if(EnergyIsNegative()) return -1 * (Int_t) GetEnergy();
else return GetEnergy();
}
inline UShort_t ORGretaMarkIVDecoder::GetChannelNum()
{
return (UShort_t) (fDataRecord[GetRecordOffset()] & 0xF);
}
inline UShort_t ORGretaMarkIVDecoder::GetMasterBoardID()
{
return (UShort_t) (fDataRecord[kORCAHeadLen] & 0xffff);
}
inline UShort_t ORGretaMarkIVDecoder::GetMasterHeaderLength()
{
return (UShort_t) ((fDataRecord[kORCAHeadLen] & 0x7FF0000) >> 16);
}
inline UShort_t ORGretaMarkIVDecoder::GetMasterTrigger_TSLow()
{
return (UShort_t) (fDataRecord[kORCAHeadLen + 1] & 0xffff);
}
inline UShort_t ORGretaMarkIVDecoder::GetMasterTrigger_TSMed()
{
return (UShort_t) (fDataRecord[kORCAHeadLen + 1] >> 16);
}
inline UShort_t ORGretaMarkIVDecoder::GetMasterTrigger_TSHigh()
{
return (UShort_t) (fDataRecord[kORCAHeadLen + 2] & 0xffff);
}
inline ULong64_t ORGretaMarkIVDecoder::GetMasterTrigger_TS()
{
return BitConcat(GetMasterTrigger_TSLow(), GetMasterTrigger_TSMed(),
GetMasterTrigger_TSHigh());;
}
inline UShort_t ORGretaMarkIVDecoder::GetMasterHMNum()
{
return (UShort_t) (fDataRecord[kORCAHeadLen + 2] >> 16);
}
inline UShort_t ORGretaMarkIVDecoder::GetMasterLowResEnergy()
{
return (UShort_t) (fDataRecord[kORCAHeadLen + 3] & 0xffff);
}
inline UShort_t ORGretaMarkIVDecoder::GetSlaveBoardID()
{
return (UShort_t) (fDataRecord[kORCAHeadLen+kMasterHeadLen] & 0xffff);
}
inline UShort_t ORGretaMarkIVDecoder::GetSlaveHeaderLength()
{
return (UShort_t) (fDataRecord[kORCAHeadLen+kMasterHeadLen] >> 16);
}
inline UShort_t ORGretaMarkIVDecoder::GetSlaveFB_LEDLow()
{
return (UShort_t) (fDataRecord[kORCAHeadLen+kMasterHeadLen + 1] & 0xffff);
}
inline UShort_t ORGretaMarkIVDecoder::GetSlaveFB_LEDMed()
{
return (UShort_t) (fDataRecord[kORCAHeadLen+kMasterHeadLen + 1] >> 16);
}
inline UShort_t ORGretaMarkIVDecoder::GetSlaveFB_LEDHigh()
{
return (UShort_t) (fDataRecord[kORCAHeadLen+kMasterHeadLen + 2] & 0xffff);
}
inline ULong64_t ORGretaMarkIVDecoder::GetSlaveFB_LED()
{
return BitConcat(GetSlaveFB_LEDLow(), GetSlaveFB_LEDMed(),
GetSlaveFB_LEDHigh());;
}
inline UShort_t ORGretaMarkIVDecoder::GetSlaveHMNum()
{
return (UShort_t) (fDataRecord[kORCAHeadLen+kMasterHeadLen + 2] >> 16);
}
inline Bool_t ORGretaMarkIVDecoder::IsTTCLTimeout()
{
return (Bool_t) (fDataRecord[GetRecordOffset()+3] >> 11);
}
inline UInt_t ORGretaMarkIVDecoder::GetCFDPointOne()
{
return (fDataRecord[GetRecordOffset()+5]);
}
inline UInt_t ORGretaMarkIVDecoder::GetCFDPointTwo()
{
return (fDataRecord[GetRecordOffset()+6]);
}
#endif