ROOTANA
Loading...
Searching...
No Matches
TV792Histogram.cxx
Go to the documentation of this file.
1#include "TV792Histogram.h"
2
3#include "TV792Data.hxx"
4#include "TDirectory.h"
5
6const int Nchannels = 32;
7 #include <sys/time.h>
8
9/// Reset the histograms for this canvas
15
16
18
19
20 // Otherwise make histograms
21 clear();
22
23 for(int i = 0; i < Nchannels; i++){ // loop over channels
24
25 char name[100];
26 char title[100];
27 sprintf(name,"V792_%i_%i",0,i);
28
29 // Delete old histograms, if we already have them
30 TH1D *old = (TH1D*)gDirectory->Get(name);
31 if (old){
32 delete old;
33 }
34
35
36 // Create new histograms
37
38 sprintf(title,"V792 Waveform for channel=%i",i);
39
40 TH1D *tmp = new TH1D(name,title,4200,0,4200);
41 tmp->SetYTitle("ADC value");
42 tmp->SetXTitle("Bin");
43 push_back(tmp);
44 }
45
46}
47
48
49
50
51/// Update the histograms for this canvas.
53
54 struct timeval start,stop;
55 gettimeofday(&start,NULL);
56 //printf ("About to sert rtrequest: %f\n",start.tv_sec
57 // + 0.000001*start.tv_usec);
58
59 TV792Data *data = dataContainer.GetEventData<TV792Data>("ADC0");
60 if(!data) return;
61
62 /// Get the Vector of ADC Measurements.
63 std::vector<VADCMeasurement> measurements = data->GetMeasurements();
64 for(unsigned int i = 0; i < measurements.size(); i++){ // loop over measurements
65
66 int chan = measurements[i].GetChannel();
67 uint32_t adc = measurements[i].GetMeasurement();
68
69 if(chan >= 0 && chan < Nchannels)
70 GetHistogram(chan)->Fill(adc);
71
72
73 }
74
75}
76
77
78
79/// Take actions at begin run
80void TV792Histograms::BeginRun(int transition,int run,int time){
81
83
84}
85
86/// Take actions at end run
87void TV792Histograms::EndRun(int transition,int run,int time){
88
89}
const int Nchannels
R__EXTERN TDirectory * gDirectory
const int Nchannels
T * GetEventData(const char *name)
Add a templated function that returns event data in the format that we want.
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.
TH1 * GetHistogram(unsigned i)
A helper method for accessing each histogram. Does bounds checking.
Class for storing data from CAEN V792 module.
Definition TV792Data.hxx:53
std::vector< VADCMeasurement > & GetMeasurements()
Get the Vector of TDC Measurements.
Definition TV792Data.hxx:77
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)
Update the histograms for this canvas.
void EndRun(int transition, int run, int time)
Take actions at end run
TV792Histograms()
Reset the histograms for this canvas.