-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTV1720Waveform.cxx
129 lines (83 loc) · 2.89 KB
/
TV1720Waveform.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#include "TV1720Waveform.h"
#include "TV1720RawData.h"
#include "TDirectory.h"
/// Reset the histograms for this canvas
TV1720Waveform::TV1720Waveform(){
SetNanosecsPerSample(4); //ADC clock runs at 250Mhz on the v1720 = units of 4 nsecs
CreateHistograms();
}
void TV1720Waveform::CreateHistograms(){
// check if we already have histogramss.
char tname[100];
sprintf(tname,"V1720_%i",0);
TH1D *tmp = (TH1D*)gDirectory->Get(tname);
if (tmp) return;
int fWFLength = 2000; // Need a better way of detecting this...
int numSamples = fWFLength / nanosecsPerSample;
// Otherwise make histograms
clear();
for(int i = 0; i < 8; i++){ // loop over 8 channels
char name[100];
char title[100];
sprintf(name,"V1720_%i",i);
sprintf(title,"V1720 Waveform for channel=%i",i);
TH1D *tmp = new TH1D(name, title, numSamples, 0, fWFLength);
tmp->SetXTitle("ns");
tmp->SetYTitle("ADC value");
push_back(tmp);
}
}
void TV1720Waveform::UpdateHistograms(TDataContainer& dataContainer){
int eventid = dataContainer.GetMidasData().GetEventId();
int timestamp = dataContainer.GetMidasData().GetTimeStamp();
// char name[100];
//sprintf(name,"W2%02d",iBoard);
TV1720RawData *v1720 = dataContainer.GetEventData<TV1720RawData>("W200");
if(v1720 && v1720->IsZLECompressed()){
for(int i = 0; i < 8; i++){ // loop over channels
// Check if this channel has any data in this event.
int chhex = 1 << i ;
if(!(v1720->GetChannelMask() & chhex)){
std::cout << "No data ... " << std::endl;
continue;
}
int index = i;
// Reset the histogram...
for(int ib = 0; ib < 250; ib++)
GetHistogram(index)->SetBinContent(ib+1,0);
TV1720RawChannel channelData = v1720->GetChannelData(i);
// Loop over pulses, filling the histogram
for(int j = 0; j < channelData.GetNZlePulses(); j++){
TV1720RawZlePulse pulse = channelData.GetZlePulse(j);
for(int k = 0; k < pulse.GetNSamples(); k++){
int bin = pulse.GetFirstBin() + k;
GetHistogram(index)->SetBinContent(bin,pulse.GetSample(k));
}
}
}
}
if(v1720 && !v1720->IsZLECompressed()){
for(int i = 0; i < 8; i++){ // loop over channels
int index = i;
// Reset the histogram...
// for(int ib = 0; ib < 2500; ib++)
for(int ib = 0; ib < 250; ib++)
GetHistogram(index)->SetBinContent(ib+1,0);
TV1720RawChannel channelData = v1720->GetChannelData(i);
for(int j = 0; j < channelData.GetNSamples(); j++){
double adc = channelData.GetADCSample(j);
GetHistogram(index)->SetBinContent(j+1,adc);
}
}
}
}
void TV1720Waveform::Reset(){
for(int i = 0; i < 8; i++){ // loop over channels
int index = i;
// Reset the histogram...
for(int ib = 0; ib < GetHistogram(index)->GetNbinsX(); ib++) {
GetHistogram(index)->SetBinContent(ib, 0);
}
GetHistogram(index)->Reset();
}
}