-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathORKatrinV4FLTWaveformTreeWriter.cc
87 lines (76 loc) · 3.13 KB
/
ORKatrinV4FLTWaveformTreeWriter.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
// ORKatrinV4FLTWaveformTreeWriter.cc
#include "ORKatrinV4FLTWaveformTreeWriter.hh"
#include "ORLogger.hh"
#include "ORUtils.hh"
using namespace std;
ORKatrinV4FLTWaveformTreeWriter::ORKatrinV4FLTWaveformTreeWriter(string treeName) :
ORVTreeWriter(new ORKatrinV4FLTWaveformDecoder, treeName)
{
fEventDecoder = dynamic_cast<ORKatrinV4FLTWaveformDecoder*>(fDataDecoder);
Clear();
fWaveform[0] = 0; // this is on the stack, not the heap.
}
ORKatrinV4FLTWaveformTreeWriter::~ORKatrinV4FLTWaveformTreeWriter()
{
delete fEventDecoder;
}
/** Create the ROOT branches.
*
*/ //-tb- 2008-02-12
ORDataProcessor::EReturnCode ORKatrinV4FLTWaveformTreeWriter::InitializeBranches()
{
fTree->Branch("wfLength", &fWaveformLength, "wfLength/i");
fTree->Branch("eventSec", &fSec, "eventSec/i");
fTree->Branch("eventSubSec", &fSubSec, "eventSubSec/i");
fTree->Branch("crate", &fCrate, "crate/s");
fTree->Branch("card", &fCard, "card/s");
fTree->Branch("channel", &fChannel, "channel/s");
fTree->Branch("channelMap", &fChannelMap, "channelMap/i");
fTree->Branch("fifoEventID", &fEventID, "fifoEventID/i");
fTree->Branch("energy_adc", &fEnergy, "energy_adc/i");
fTree->Branch("eventFlags", &fEventFlags, "eventFlags/i");
fTree->Branch("eventInfo", &fEventInfo, "eventInfo/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 ORKatrinV4FLTWaveformTreeWriter::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();
fCard = fEventDecoder->CardOf();
fChannel = fEventDecoder->GetChannel();
fChannelMap = fEventDecoder->GetChannelMap();
fSec = fEventDecoder->GetSec();
fSubSec = fEventDecoder->GetSubSec();
fEventID = fEventDecoder->GetEventID();
fEnergy = fEventDecoder->GetEnergy();
fWaveformLength = fEventDecoder->GetWaveformLen();
fEventFlags = fEventDecoder->GetEventFlags();
fEventInfo = fEventDecoder->GetEventInfo();
if (ORLogger::GetSeverity() >= ORLogger::kDebug)
{
ORLog(kDebug) << "ProcessMyDataRecord(): "
<< "crate-card-channel-sec-subsec-energy_adc-chmap-eventID-eventFlags-eventInfo = "
<< fCrate << "-" << fCard << "-" << fChannel << "-"
<< fSec << "-" << fSubSec << "-" << fEnergy
<< "-" << fChannelMap
<< "-" << fEventID << "-" << fEventFlags //-tb- 2010-02-16
<< "-" << fEventInfo //-tb- 2010-02-16
<< endl;
}
if(fWaveformLength > kMaxWFLength) {
ORLog(kError) << "Waveform length (" << fWaveformLength
<< ") exceeds kMaxWFLength (" << kMaxWFLength << ")" << endl;
return kFailure;
}
fEventDecoder->CopyWaveformData( fWaveform, kMaxWFLength );
return kSuccess;
}