-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathORAcqirisDC440TreeWriter.cc
71 lines (63 loc) · 2.09 KB
/
ORAcqirisDC440TreeWriter.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
// ORAcqirisDC440TreeWriter.cc
#include "ORAcqirisDC440TreeWriter.hh"
#include "ORLogger.hh"
#include <sstream>
#include "ORRunContext.hh"
#include "ORDictionary.hh"
using namespace std;
ORAcqirisDC440TreeWriter::ORAcqirisDC440TreeWriter(string treeName) :
ORVTreeWriter(new ORAcqirisDC440Decoder, treeName)
{
fEventDecoder = dynamic_cast<ORAcqirisDC440Decoder*>(fDataDecoder);
fEventTime = 0;
fCrate = 0;
fCard = 0;
fChannel = 0;
fWaveformLength = 0;
SetDoNotAutoFillTree();
}
ORAcqirisDC440TreeWriter::~ORAcqirisDC440TreeWriter()
{
delete fEventDecoder;
}
ORDataProcessor::EReturnCode ORAcqirisDC440TreeWriter::InitializeBranches()
{
fTree->Branch("wfLength", &fWaveformLength, "wfLength/i");
fTree->Branch("EventTime", &fEventTime, "LEDEventTime/l");
fTree->Branch("crate", &fCrate, "crate/s");
fTree->Branch("card", &fCard, "card/s");
fTree->Branch("channel", &fChannel, "channel/s");
fTree->Branch("waveform", fWaveform, "waveform[wfLength]/s");
fTree->Branch("samplingPeriod", &fSamplingPeriod, "samplingPeriod/D");
return kSuccess;
}
ORDataProcessor::EReturnCode ORAcqirisDC440TreeWriter::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;
fEventTime = fEventDecoder->GetTimeStamp();
fCrate = fEventDecoder->CrateOf();
fCard = fEventDecoder->CardOf();
fChannel = fEventDecoder->GetChannelNum();
fWaveformLength = fEventDecoder->GetWaveformLen();
if (ORLogger::GetSeverity() >= ORLogger::kDebug)
{
ORLog(kDebug) << "ProcessMyDataRecord(): "
<< "time-crate-card-channel-length- = "
<< fEventTime << "-"
<< fCrate << "-"
<< fCard << "-"
<< fChannel << "-"
<< fWaveformLength << "-"
<< endl;
}
fSamplingPeriod = fEventDecoder->GetSampleInterval();
if (fWaveformLength > kMaxWFLength) {
ORLog(kError) << "Waveform too long for kMaxWFLength!" << endl;
return kFailure;
}
fEventDecoder->CopyWaveformData(fWaveform, fWaveformLength);
fTree->Fill();
return kSuccess;
}