ROOTANA
Loading...
Searching...
No Matches
TV1720Waveform.cxx
Go to the documentation of this file.
1#include "TV1720Waveform.h"
2
3#include "TV1720RawData.h"
4#include "TDirectory.h"
5
6
7/// Reset the histograms for this canvas
9
10 SetSubTabName("V1720 Waveforms");
12 SetNanosecsPerSample(4); //ADC clock runs at 250Mhz on the v1720 = units of 4 nsecs
13
15}
16
17
19
20 // check if we already have histogramss.
21 char tname[100];
22 sprintf(tname,"V1720_%i",0);
23
24 TH1D *tmp = (TH1D*)gDirectory->Get(tname);
25 if (tmp) return;
26
27 int fWFLength = 2000; // Need a better way of detecting this...
28 int numSamples = fWFLength / nanosecsPerSample;
29
30 // Otherwise make histograms
31 clear();
32
33 for(int i = 0; i < 8; i++){ // loop over 8 channels
34
35 char name[100];
36 char title[100];
37 sprintf(name,"V1720_%i",i);
38
39 sprintf(title,"V1720 Waveform for channel=%i",i);
40
41 TH1D *tmp = new TH1D(name, title, numSamples, 0, fWFLength);
42 tmp->SetXTitle("ns");
43 tmp->SetYTitle("ADC value");
44
45 push_back(tmp);
46 }
47
48}
49
50
52
53 int eventid = dataContainer.GetMidasData().GetEventId();
54 int timestamp = dataContainer.GetMidasData().GetTimeStamp();
55
56
57 // char name[100];
58 //sprintf(name,"W2%02d",iBoard);
59
60 TV1720RawData *v1720 = dataContainer.GetEventData<TV1720RawData>("W200");
61
62 if(v1720 && v1720->IsZLECompressed()){
63
64 for(int i = 0; i < 8; i++){ // loop over channels
65
66 // Check if this channel has any data in this event.
67 int chhex = 1 << i ;
68 if(!(v1720->GetChannelMask() & chhex)){
69 std::cout << "No data ... " << std::endl;
70 continue;
71 }
72
73 int index = i;
74 // Reset the histogram...
75 for(int ib = 0; ib < 250; ib++)
76 GetHistogram(index)->SetBinContent(ib+1,0);
77
78 TV1720RawChannel channelData = v1720->GetChannelData(i);
79
80 // Loop over pulses, filling the histogram
81 for(int j = 0; j < channelData.GetNZlePulses(); j++){
82 TV1720RawZlePulse pulse = channelData.GetZlePulse(j);
83 for(int k = 0; k < pulse.GetNSamples(); k++){
84 int bin = pulse.GetFirstBin() + k;
85 GetHistogram(index)->SetBinContent(bin,pulse.GetSample(k));
86 }
87 }
88
89 }
90 }
91
92 if(v1720 && !v1720->IsZLECompressed()){
93
94 for(int i = 0; i < 8; i++){ // loop over channels
95
96 int index = i;
97
98 // Reset the histogram...
99 // for(int ib = 0; ib < 2500; ib++)
100 for(int ib = 0; ib < 250; ib++)
101 GetHistogram(index)->SetBinContent(ib+1,0);
102
103
104 TV1720RawChannel channelData = v1720->GetChannelData(i);
105 for(int j = 0; j < channelData.GetNSamples(); j++){
106 double adc = channelData.GetADCSample(j);
107 GetHistogram(index)->SetBinContent(j+1,adc);
108
109 }
110 }
111 }
112
113}
114
115
116
118
119
120 for(int i = 0; i < 8; i++){ // loop over channels
121 int index = i;
122
123 // Reset the histogram...
124 for(int ib = 0; ib < GetHistogram(index)->GetNbinsX(); ib++) {
125 GetHistogram(index)->SetBinContent(ib, 0);
126 }
127
128 GetHistogram(index)->Reset();
129
130 }
131}
R__EXTERN TDirectory * gDirectory
T * GetEventData(const char *name)
Add a templated function that returns event data in the format that we want.
TMidasEvent & GetMidasData() const
Get the MIDAS data for this event, in TMidasEvent format.
virtual TObject * Get(const char *namecycle)
virtual void SetSubTabName(std::string name)
Set the name of the sub-tab for these plots, if running DaqDisplay.
virtual void SetUpdateOnlyWhenPlotted(bool whenupdate)
TH1 * GetHistogram(unsigned i)
A helper method for accessing each histogram. Does bounds checking.
uint16_t GetEventId() const
return the event id
uint32_t GetTimeStamp() const
return the time stamp (unix time in seconds)
int GetNSamples() const
Get the ADC sample for a particular bin (for uncompressed data).
int GetNZlePulses() const
Get the number of ZLE pulses (for compressed data)
int GetADCSample(int i) const
Get the ADC sample for a particular bin (for uncompressed data).
TV1720RawZlePulse GetZlePulse(int i) const
Get the ZLE pulse (for compressed data.
TV1720RawChannel GetChannelData(int i)
Get Channel Data.
uint32_t GetChannelMask() const
bool IsZLECompressed() const
Is the V1720 data ZLE compressed?
Class to store information from a single V1720 ZLE pulse.
int GetSample(int i) const
Get the first bin for this pulse.
int GetNSamples() const
Get the number of samples.
int GetFirstBin() const
Get the first bin for this pulse.
void SetNanosecsPerSample(int nsecsPerSample)
void CreateHistograms()
Function to create histograms; users will want to implement this function.
void UpdateHistograms(TDataContainer &dataContainer)
Update the histograms for this canvas.
TV1720Waveform()
Reset the histograms for this canvas.