-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTigWaveformHisto.cxx
85 lines (71 loc) · 1.78 KB
/
TigWaveformHisto.cxx
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
// part of TigSortGUI
// author: Ulrike Hager
#include <iostream>
#include <sstream>
#include "TigTree.h"
#include "TigWaveformHisto.h"
using std::vector;
TigWaveformHisto::TigWaveformHisto()
{
mAddress = -1;
mChannel = -1;
}
bool
TigWaveformHisto::Evaluate(vector<short> pWf)
{
for (int i =0; i<pWf.size(); i++) mHisto->SetBinContent(i,pWf.at(i));
return true;
}
//---- Initialize
bool
TigWaveformHisto::Initialize()
{
bool check = this->TigDataObject::Initialize();
if (!check) return false;
if (mInputNames.size() > 1){
std::cout << "[TigWaveformHisto::Initialize] " << mName << " too many inputs" << std::endl;
return false;
}
if (mAddress < 0) mAddress = mParent->GetAddress(mInputNames.at(0), mChannel);
if (mAddress < 0) {
std::cout << "[TigWaveformHisto::Initialize] " << mName << " can't find address for input " << mInputNames.at(0) << " ch " << mChannel << std::endl;
return false;
}
mHisto = new TH1F(mName.c_str(),mName.c_str(),mXbins, 0, mXbins);
return true;
}
//---- ParseInput
bool
TigWaveformHisto::ParseInput(std::string line)
{
bool result = true;
std::string token;
std::istringstream stream(line.c_str());
stream >> token;
if ( token.compare("channel") == 0)
{
stream >> mChannel;
}
else if ( token.compare("xbins") == 0)
{
stream >> mXbins;
}
else if ( token.compare("address") == 0)
{
stream >> std::hex >> mAddress;
}
else result = this->TigDataObject::ParseInput(line);
return result;
}
bool
TigWaveformHisto::ProcessSignal(TigEvent* pEvent)
{
bool result = false;
if (pEvent->Address() == mAddress )
{
// vector<short> wf = pEvent->Waveform();
// for (int i =0; i<wf.size(); i++) mHisto->SetBinContent(i,wf.at(i));
result = true;
}
return result;
}