-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathORKatrinFLTWaveformTreeWriter.cc
88 lines (77 loc) · 3.24 KB
/
ORKatrinFLTWaveformTreeWriter.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
// ORKatrinFLTWaveformTreeWriter.cc
#include "ORKatrinFLTWaveformTreeWriter.hh"
#include "ORLogger.hh"
#include "ORUtils.hh"
using namespace std;
ORKatrinFLTWaveformTreeWriter::ORKatrinFLTWaveformTreeWriter(string treeName) :
ORVTreeWriter(new ORKatrinFLTWaveformDecoder, treeName)
{
fEventDecoder = dynamic_cast<ORKatrinFLTWaveformDecoder*>(fDataDecoder);
Clear();
fWaveform[0] = 0; // this is on the stack, not the heap.
}
ORKatrinFLTWaveformTreeWriter::~ORKatrinFLTWaveformTreeWriter()
{
delete fEventDecoder;
}
/** Create the ROOT branches.
*
*/ //-tb- 2008-02-12
ORDataProcessor::EReturnCode ORKatrinFLTWaveformTreeWriter::InitializeBranches()
{
fTree->Branch("wfLength", &fWaveformLength, "wfLength/i");
fTree->Branch("eventSec", &fSec, "eventSec/i");
fTree->Branch("eventSubSec", &fSubSec, "eventSubSec/i");
fTree->Branch("eventID", &fEventID, "eventID/s");
fTree->Branch("crate", &fCrate, "crate/s");
fTree->Branch("card", &fCard, "card/s");
fTree->Branch("channel", &fChannel, "channel/s");
fTree->Branch("channelMap", &fChannelMap, "channelMap/s");
fTree->Branch("pageNumber", &fPageNumber, "pageNumber/s");
fTree->Branch("energy_adc", &fEnergy, "energy_adc/i");
fTree->Branch("resetSec", &fResetSec, "resetSec/i");
fTree->Branch("resetSubSec", &fResetSubSec, "resetSubSec/i");
fTree->Branch("waveform", fWaveform, "waveform[wfLength]/s");
return kSuccess;
}
/** This sets the data/variables for the ROOT branches.
* TTree::Fill() is called in ORBasicTreeWriter::ProcessMyDataRecord(UInt_t* record) (?)
* This class is a ORDataProcessor and ORVTreeWriter, NOT a ORBasicTreeWriter!
* (See comments in ORDataProcessor.hh and ORVTreeWriter.hh)
*/ //-tb- 2008-02-12
ORDataProcessor::EReturnCode ORKatrinFLTWaveformTreeWriter::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:
fSec = fEventDecoder->GetSec();
fSubSec = fEventDecoder->GetSubSec();
fEventID = fEventDecoder->GetEventID();
fEnergy = fEventDecoder->GetEnergy();
fCrate = fEventDecoder->CrateOf();
fCard = fEventDecoder->CardOf();
fChannel = fEventDecoder->GetChannel();
fChannelMap = fEventDecoder->GetChannelMap();
fPageNumber = fEventDecoder->GetPageNumber();
fWaveformLength = fEventDecoder->GetWaveformLen();
fResetSec = fEventDecoder->GetResetSec();
fResetSubSec = fEventDecoder->GetResetSubSec();
if (ORLogger::GetSeverity() >= ORLogger::kDebug)
{
ORLog(kDebug) << "ProcessMyDataRecord(): "
<< "event-sec-subsec-crate-card-channel-energy_adc-resetsec-resetsubsec-chmap-pagenum = "
<< fEventID << "-" << fSec << "-" << fSubSec << "-" << fCrate << "-"
<< fCard << "-" << fChannel << "-" << fEnergy
<< "-" << fResetSec << "-" << fResetSubSec //-tb- 2008-02-12
<< "-" << fChannelMap << "-" << fPageNumber //-tb- 2008-02-12
<< endl;
}
if(fWaveformLength > kMaxWFLength) {
ORLog(kError) << "Waveform length (" << fWaveformLength
<< ") exceeds kMaxWFLength (" << kMaxWFLength << ")" << endl;
return kFailure;
}
fEventDecoder->CopyWaveformData( fWaveform, kMaxWFLength );
return kSuccess;
}