-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathORKatrinV4FLTEnergyHistogramTreeWriter.cc
81 lines (68 loc) · 3.24 KB
/
ORKatrinV4FLTEnergyHistogramTreeWriter.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
// ORKatrinV4FLTEnergyHistogramTreeWriter.cc
#include "ORKatrinV4FLTEnergyHistogramTreeWriter.hh"
#include "ORLogger.hh"
using namespace std;
ORKatrinV4FLTEnergyHistogramTreeWriter::ORKatrinV4FLTEnergyHistogramTreeWriter(string treeName) :
ORVTreeWriter(new ORKatrinV4FLTEnergyHistogramDecoder, treeName)
{
fEventDecoder = dynamic_cast<ORKatrinV4FLTEnergyHistogramDecoder*>(fDataDecoder);
Clear();
}
ORKatrinV4FLTEnergyHistogramTreeWriter::~ORKatrinV4FLTEnergyHistogramTreeWriter()
{
delete fEventDecoder;
}
ORDataProcessor::EReturnCode ORKatrinV4FLTEnergyHistogramTreeWriter::InitializeBranches()
{
fTree->Branch("crate", &fCrate, "crate/s");
fTree->Branch("card", &fCard, "card/s");
fTree->Branch("channel", &fChannel, "channel/s");
fTree->Branch("readoutSec", &fReadoutSec, "readoutSec/i");
fTree->Branch("refreshTime", &fRefreshTime, "refreshTime/i");
fTree->Branch("firstBin", &fFirstBin, "firstBin/i");
fTree->Branch("lastBin", &fLastBin, "lastBin/i");
fTree->Branch("histogramLength", &fHistogramLength, "histogramLength/i");
fTree->Branch("maxHistogramLength", &fMaxHistogramLength, "maxHistogramLength/i");
fTree->Branch("binSize", &fBinSize, "binSize/i");
fTree->Branch("offsetEMin", &fOffsetEMin, "offsetEMin/i");
fTree->Branch("histogramID", &fHistID, "histogramID/i");
fTree->Branch("histogramInfo", &fHistInfo, "histogramInfo/i");
fTree->Branch("histogram", fHistogram, "histogram[histogramLength]/i");
return kSuccess;
}
ORDataProcessor::EReturnCode ORKatrinV4FLTEnergyHistogramTreeWriter::ProcessMyDataRecord(UInt_t* record)
{
// the event decoder could run into a problem, but this might not
// ruin the rest of the run.
if(!fEventDecoder->SetDataRecord(record)) return kFailure;
// check severity to improve speed:
fCrate = fEventDecoder->CrateOf(record);
fCard = fEventDecoder->CardOf(record);
fChannel = fEventDecoder->ChannelOf(record);
fReadoutSec = fEventDecoder->ReadoutSecOf(record);
fRefreshTime = fEventDecoder->RefreshTimeOf(record);
fFirstBin = fEventDecoder->FirstBinOf(record);
fLastBin = fEventDecoder->LastBinOf(record);
fHistogramLength = fEventDecoder->HistogramLengthOf(record);
fMaxHistogramLength = fEventDecoder->MaxHistogramLengthOf(record);
fBinSize = fEventDecoder->BinSizeOf(record);
fOffsetEMin = fEventDecoder->OffsetEMinOf(record);
fHistID = fEventDecoder->HistogramIDOf(record);
fHistInfo = fEventDecoder->HistogramInfoOf(record);
if (ORLogger::GetSeverity() >= ORLogger::kDebug)
{
ORLog(kDebug) << "ProcessMyDataRecord(): "
<< "crate-card-channel-fReadoutSec-fRefreshTime-fFirstBin-fLastBin-fHistogramLength-fMaxHistogramLength-fBinSize-fOffsetEMin-fID-fInfo: "
<< fCrate << "-" << fCard << "-" << fChannel << "-"
<< fReadoutSec << "-" << fRefreshTime << "-" << fFirstBin << "-" << fLastBin << "-" << fHistogramLength << "-" << fMaxHistogramLength << "-" << fBinSize << "-" << fOffsetEMin
<< "-" << fHistID << "-" << fHistInfo
<< endl;
}
if(fHistogramLength > kMaxHistoLength) {
ORLog(kError) << "Histogram length (" << fHistogramLength
<< ") exceeds kMaxHistoLength (" << kMaxHistoLength << ")" << endl;
return kFailure;
}
fEventDecoder->CopyHistogramData( fHistogram, kMaxHistoLength );
return kSuccess;
}