-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathORCaen5720Decoder.cc
executable file
·162 lines (131 loc) · 4.88 KB
/
ORCaen5720Decoder.cc
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
// ORCaen5720Decoder.cc
// Basic information taken from ORCaen1720Decoder.cc provided by Jarek Kaspar.
// Updated by Laura Bodine
// Zpack2.5 and zerolengthencoding are not currently handled here...
// if your data is formatted that way then you must add that functionality to this decoder
#include "TROOT.h"
#include "ORCaen5720Decoder.hh"
#include "ORLogger.hh"
/**************************************************************************
// Get number of samples in each trace (single channel)
**************************************************************************/
UInt_t ORCaen5720Decoder::TraceLength(UInt_t* record) {
UInt_t numChan = 0;
UInt_t chanMask = ChannelMask(record);
for (; chanMask; numChan++) chanMask &= chanMask - 1; //check number of channels in record
return (EventSize(record) - 4) / numChan * 2; // 4 longs header, then 2 samples per long
}
/**************************************************************************
//Copy the trace for the first ACTIVE channel. Check ChannelMap to tell.
**************************************************************************/
void ORCaen5720Decoder::CopyTrace(UInt_t* record, UInt_t* Waveform, UInt_t numSamples) {
UInt_t * evtpointer = GetEventPointer(record);
UShort_t* sample = (UShort_t*) evtpointer;
//iterative way, because of the coming packed2.5 mode
for (unsigned int i = 0; i < numSamples; i++) {
Waveform[i] = sample[i+8] & 0x0fff;
//std::cout << "Waveform [" << i << "] = " << Waveform[i] << std::endl;
}
}
/**************************************************************************
// Get at all traces (array arithmetic based on ChannelMask active channels)
**************************************************************************/
void ORCaen5720Decoder::CopyTraces(UInt_t* record, UInt_t *Waveform0, UInt_t *Waveform1,UInt_t *Waveform2,UInt_t *Waveform3, UInt_t numSamples){
UInt_t * evtpointer = GetEventPointer(record);
UShort_t* sample = (UShort_t*) evtpointer;
UInt_t chanMask = ChannelMask(record); //chanMask: int between 1 and 15
switch(chanMask){
case 1 :
for(UInt_t i = 0 ; i<numSamples;i++){
Waveform0[i] = sample[i+8] & 0x0fff;
};
break;
case 2 :
for(UInt_t i = 0 ; i<numSamples;i++){
Waveform1[i] = sample[i+8] & 0x0fff;
};
break;
case 3:
for(UInt_t i = 0 ; i<numSamples;i++){
Waveform0[i] = sample[i+8] & 0x0fff;
Waveform1[i] = sample[i+8+numSamples] & 0x0fff;
};
break;
case 4:
for(UInt_t i = 0 ; i<numSamples;i++){
Waveform2[i] = sample[i+8] & 0x0fff;
};
break;
case 5:
for(UInt_t i = 0 ; i<numSamples;i++){
Waveform0[i] = sample[i+8] & 0x0fff;
Waveform2[i] = sample[i+8+numSamples] & 0x0fff;
};
break;
case 6:
for(UInt_t i = 0 ; i<numSamples;i++){
Waveform1[i] = sample[i+8] & 0x0fff;
Waveform2[i] = sample[i+8+numSamples] & 0x0fff;
};
break;
case 7:
for(UInt_t i = 0 ; i<numSamples;i++){
Waveform0[i] = sample[i+8] & 0x0fff;
Waveform1[i] = sample[i+8+numSamples] & 0x0fff;
Waveform2[i] = sample[i+8+2*numSamples] & 0x0fff;
};
break;
case 8:
for(UInt_t i = 0 ; i<numSamples;i++){
Waveform3[i] = sample[i+8] & 0x0fff;
};
break;
case 9:
for(UInt_t i = 0 ; i<numSamples;i++){
Waveform0[i] = sample[i+8] & 0x0fff;
Waveform3[i] = sample[i+8+numSamples] & 0x0fff;
};
break;
case 10:
for(UInt_t i = 0 ; i<numSamples;i++){
Waveform1[i] = sample[i+8] & 0x0fff;
Waveform3[i] = sample[i+8+numSamples] & 0x0fff;
};
break;
case 11:
for(UInt_t i = 0 ; i<numSamples;i++){
Waveform0[i] = sample[i+8] & 0x0fff;
Waveform1[i] = sample[i+8+numSamples] & 0x0fff;
Waveform3[i] = sample[i+8+2*numSamples] & 0x0fff;
};
break;
case 12:
for(UInt_t i = 0 ; i<numSamples;i++){
Waveform2[i] = sample[i+8] & 0x0fff;
Waveform3[i] = sample[i+8+numSamples] & 0x0fff;
};
break;
case 13:
for(UInt_t i = 0 ; i<numSamples;i++){
Waveform0[i] = sample[i+8] & 0x0fff;
Waveform2[i] = sample[i+8+numSamples] & 0x0fff;
Waveform3[i] = sample[i+8+2*numSamples] & 0x0fff;
};
break;
case 14:
for(UInt_t i = 0 ; i<numSamples;i++){
Waveform1[i] = sample[i+8] & 0x0fff;
Waveform2[i] = sample[i+8+numSamples] & 0x0fff;
Waveform3[i] = sample[i+8+2*numSamples] & 0x0fff;
};
break;
case 15:
for(UInt_t i = 0 ; i<numSamples;i++){
Waveform0[i] = sample[i+8] & 0x0fff;
Waveform1[i] = sample[i+8+numSamples] & 0x0fff;
Waveform2[i] = sample[i+8+2*numSamples] & 0x0fff;
Waveform3[i] = sample[i+8+3*numSamples] & 0x0fff;
};
break;
}//end of switch(chanMask)
}