ROOTANA
Loading...
Searching...
No Matches
TV1730RawWaveform.cxx
Go to the documentation of this file.
1#include "TV1730RawWaveform.h"
2
3#include "TV1730RawData.hxx"
4#include "TDirectory.h"
5
6/// Reset the histogram for this canvas
8
9 SetSubTabName("V1730 Waveforms");
11 SetNumSamples(64);
12 SetNanosecsPerSample(2); //ADC clock runs at 500Mhz on the v1730 = units of 2 nsecs
13
15}
16
17
19
20 std::cout << "Creating V1730 raw waveforms... " << std::endl;
21
22 // check if we already have histograms.
23 char tname[100];
24 sprintf(tname,"V1730Raw_%i_%i",0,0);
25
26 TH1D *tmp = (TH1D*)gDirectory->Get(tname);
27 if (tmp) return;
28
29 // Otherwise make histogram
30 clear();
31
32 for(int i = 0; i < 16; i++){ // loop over 16 channels
33
34 char name[100];
35 char title[100];
36 sprintf(name,"V1730Raw_%i",i);
37
38 sprintf(title,"V1730 Waveform for channel=%i",i);
39
40 TH1D *tmp = new TH1D(name, title, this->numSamples, 0, this->numSamples);
41 tmp->GetXaxis()->SetLimits(0, this->numSamples*this->nanosecsPerSample);
42 tmp->SetXTitle("ns");
43 tmp->SetYTitle("ADC value");
44
45 push_back(tmp);
46 }
47
48 std::cout << "Finish V1730 raw waveforms... " << std::endl;
49
50}
51
52
53
54
56
57 int eventid = dataContainer.GetMidasData().GetEventId();
58 int timestamp = dataContainer.GetMidasData().GetTimeStamp();
59
60 TV1730RawData *v1730 = dataContainer.GetEventData<TV1730RawData>("V730");
61
62 if(v1730 ){
63
64 std::vector<RawChannelMeasurement> measurements = v1730->GetMeasurements();
65
66 for(int i = 0; i < measurements.size(); i++){
67
68 int chan = measurements[i].GetChannel();
69
70 // Reset the histogram...
71 for(int ib = 0; ib < this->numSamples; ib++)
72 GetHistogram(chan)->SetBinContent(ib+1,0);
73
74 // Hack!
75 float offset = 0;
76 if(chan == 1)
77 offset = 35;
78 //std::cout << "Nsamples " << measurements[i].GetNSamples() << std::endl;
79 for(int ib = 0; ib < measurements[i].GetNSamples(); ib++){
80
81
82 GetHistogram(chan)->SetBinContent(ib+1, measurements[i].GetSample(ib)-offset);
83 //std::cout << "Setting " << chan << " " << ib << " " << measurements[i].GetSample(ib) << std::endl;
84
85 }
86
87 }
88
89 }
90
91}
92
93
95
96 // Loop over all the data, reset histos
97 for(int iBoard=0; iBoard<32; iBoard++){// Loop over V1730Dpp boards
98 for(int i = 0; i < 8; i++){ // loop over channels
99 int index = iBoard*8 + i;
100
101 // Reset the histogram...
102 for(int ib = 0; ib < 2500; ib++)
103 GetHistogram(index)->SetBinContent(ib,0);
104 GetHistogram(index)->Reset();
105 }
106 }
107}
108
109/// Take actions at begin run
110void TV1730RawWaveform::BeginRun(int transition,int run,int time){
111
113
114}
115
116/// Take actions at end run
117void TV1730RawWaveform::EndRun(int transition,int run,int time){
118
119}
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)
Class to store raw data from CAEN V1730 (for raw readout, no-DPP).
std::vector< RawChannelMeasurement > & GetMeasurements()
Get the Vector of TDC Measurements.
TV1730RawWaveform()
Reset the histogram for this canvas.
void EndRun(int transition, int run, int time)
Take actions at end run
void CreateHistograms()
Function to create histograms; users will want to implement this function.
void BeginRun(int transition, int run, int time)
Take actions at begin run.
void UpdateHistograms(TDataContainer &dataContainer)
void SetNumSamples(int numSamples)
void SetNanosecsPerSample(int nsecsPerSample)