-
Notifications
You must be signed in to change notification settings - Fork 3
/
ORCaen965qdcDecoder.cc
83 lines (75 loc) · 2.09 KB
/
ORCaen965qdcDecoder.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
// ORCaen965qdcDecoder.cc
#include "TROOT.h"
#include "ORCaen965qdcDecoder.hh"
#include "ORLogger.hh"
#include <iostream>
ORCaen965qdcDecoder::ORCaen965qdcDecoder()
{
fRecord = NULL;
}
size_t ORCaen965qdcDecoder::NValuesOf(UInt_t* record)
{
if(record != fRecord) {
LoadLocPtrs(record);
fRecord = record;
}
return fLocPtrs.size();
}
void ORCaen965qdcDecoder::LoadLocPtrs(UInt_t* record)
{
fLocPtrs.clear();
size_t i=2;
while(i<LengthOf(record)) {
if(!IthWordIsData(record, i)) {
ORLog(kWarning) << "expected word " << i+1 << " to be a data word." << std::endl;
return;
}
fLocPtrs.push_back(record+i);
i++;
if(i > LengthOf(record)) {
ORLog(kWarning) << "i = " << i << " is greater than the record length = "
<< LengthOf(record) << std::endl;
}
}
}
UInt_t* ORCaen965qdcDecoder::GetLocPtr(UInt_t* record, size_t i)
{
if(i >= NValuesOf(record)) {
ORLog(kWarning) << "you asked for qdc value " << i << ", but there are only "
<< NValuesOf(record) << " records" << std::endl;
return NULL;
}
return fLocPtrs[i];
}
std::string ORCaen965qdcDecoder::GetParName(size_t iPar)
{
switch(iPar) {
case 0: return "crate";
case 1: return "card";
case 2: return "channel";
case 3: return GetValueName();
case 4: return "underthresh";
case 5: return "overflow";
case 6: return "isValid";
default:
ORLog(kWarning) << "GetParName(): index (" << iPar
<< ") out of range." << std::endl;
return "unknown";
}
}
UInt_t ORCaen965qdcDecoder::GetPar(UInt_t* record, size_t iPar, size_t iRow)
{
switch(iPar) {
case 0: return CrateOf(record);
case 1: return CardOf(record);
case 2: return IthChannelOf(record, iRow);
case 3: return IthValueOf(record, iRow);
case 4: return IthValueIsUnderThreshold(record, iRow);
case 5: return IthValueIsOverflow(record, iRow);
case 6: return IthValueIsValid(record, iRow);
default:
ORLog(kWarning) << "GetPar(): index (" << iPar
<< ") out of range." << std::endl;
return 0;
}
}