-
Notifications
You must be signed in to change notification settings - Fork 3
/
ORAD3511ADCDecoder.cc
79 lines (67 loc) · 1.85 KB
/
ORAD3511ADCDecoder.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
// ORAD3511ADCDecoder.cc
#include "ORAD3511ADCDecoder.hh"
#include "ORLogger.hh"
#include "ORUtils.hh"
void ORAD3511ADCDecoder::Swap(UInt_t* record)
{
ORUtils::Swap(record[1]);
/* Swap so we can tell if this has a timestamp.*/
size_t startSwapFrom = 2;
if (HasReferenceDate(record)) {
ORUtils::Swap(record[2]);
ORUtils::Swap(record[3]);
UInt_t dummy = record[2];
record[2] = record[3];
record[3] = dummy;
startSwapFrom = 4;
}
for (size_t i=startSwapFrom;i<LengthOf(record);i++) {
ORUtils::Swap(record[i]);
}
}
double ORAD3511ADCDecoder::ReferenceDateOf(UInt_t* record)
{
if(!HasReferenceDate(record)) return 0.0;
double refDate = (*((double*)(record+2)));
return refDate;
}
std::string ORAD3511ADCDecoder::GetHistName(int iHist)
{
int iCard = iHist % kNCards;
int iCrate = (iHist - iCard) / kNCards;
return ::Form("hAD3511_%d_%d", iCrate, iCard);
}
std::string ORAD3511ADCDecoder::GetHistTitle(int iHist)
{
int iCard = iHist % kNCards;
int iCrate = (iHist - iCard) / kNCards;
return ::Form("AD3511: Crate %d, Card %d", iCrate, iCard);
}
int ORAD3511ADCDecoder::GetHistIndex(UInt_t* record)
{
return CardOf(record) + kNCards*CrateOf(record);
}
std::string ORAD3511ADCDecoder::GetParName(size_t iPar)
{
switch(iPar) {
case 0: return "crate";
case 1: return "card";
case 2: return "adc";
default:
ORLog(kWarning) << "GetParName(): index (" << iPar
<< ") out of range." << std::endl;
return "unknown";
}
}
UInt_t ORAD3511ADCDecoder::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 IthADCValueOf(record, iRow);
default:
ORLog(kWarning) << "GetPar(): index (" << iPar
<< ") out of range." << std::endl;
return 0;
}
}