TV792Histogram.cxx
Go to the documentation of this file.00001 #include "TV792Histogram.h"
00002
00003 #include "TV792Data.hxx"
00004 #include "TDirectory.h"
00005
00006 const int Nchannels = 32;
00007 #include <sys/time.h>
00008
00009
00010 TV792Histograms::TV792Histograms(){
00011
00012 CreateHistograms();
00013 }
00014
00015
00016 void TV792Histograms::CreateHistograms(){
00017
00018
00019
00020 clear();
00021
00022 for(int i = 0; i < Nchannels; i++){
00023
00024 char name[100];
00025 char title[100];
00026 sprintf(name,"V792_%i_%i",0,i);
00027
00028
00029 TH1D *old = (TH1D*)gDirectory->Get(name);
00030 if (old){
00031 delete old;
00032 }
00033
00034
00035
00036
00037 sprintf(title,"V792 Waveform for channel=%i",i);
00038
00039 TH1D *tmp = new TH1D(name,title,4200,0,4200);
00040 tmp->SetYTitle("ADC value");
00041 tmp->SetXTitle("Bin");
00042 push_back(tmp);
00043 }
00044
00045 }
00046
00047
00048
00049
00050
00051 void TV792Histograms::UpdateHistograms(TDataContainer& dataContainer){
00052
00053 struct timeval start,stop;
00054 gettimeofday(&start,NULL);
00055
00056
00057
00058 TV792Data *data = dataContainer.GetEventData<TV792Data>("ADC0");
00059 if(!data) return;
00060
00061
00062 std::vector<VADCMeasurement> measurements = data->GetMeasurements();
00063 for(unsigned int i = 0; i < measurements.size(); i++){
00064
00065 int chan = measurements[i].GetChannel();
00066 uint32_t adc = measurements[i].GetMeasurement();
00067
00068 if(chan >= 0 && chan < Nchannels)
00069 GetHistogram(chan)->Fill(adc);
00070
00071
00072 }
00073
00074 }
00075
00076
00077
00078
00079 void TV792Histograms::BeginRun(int transition,int run,int time){
00080
00081 CreateHistograms();
00082
00083 }
00084
00085
00086 void TV792Histograms::EndRun(int transition,int run,int time){
00087
00088 }