TV1730RawWaveform.cxx

Go to the documentation of this file.
00001 #include "TV1730RawWaveform.h"
00002 
00003 #include "TV1730RawData.hxx"
00004 #include "TDirectory.h"          
00005 
00006 /// Reset the histogram for this canvas
00007 TV1730RawWaveform::TV1730RawWaveform(){
00008 
00009         SetNumSamples(64);     
00010   SetNanosecsPerSample(2); //ADC clock runs at 500Mhz on the v1730 = units of 2 nsecs
00011 
00012   CreateHistograms();
00013 }
00014 
00015 
00016 void TV1730RawWaveform::CreateHistograms(){
00017 
00018         std::cout << "Creating V1730 raw waveforms... " << std::endl;
00019 
00020   // check if we already have histograms.
00021   char tname[100];
00022   sprintf(tname,"V1730Raw_%i_%i",0,0);
00023 
00024   TH1D *tmp = (TH1D*)gDirectory->Get(tname);
00025   if (tmp) return;
00026 
00027   // Otherwise make histogram
00028   clear();
00029 
00030         for(int i = 0; i < 16; i++){ // loop over 16 channels
00031                 
00032                 char name[100];
00033                 char title[100];
00034                 sprintf(name,"V1730Raw_%i",i);
00035                 
00036                 sprintf(title,"V1730 Waveform for channel=%i",i);       
00037                 
00038                 TH1D *tmp = new TH1D(name, title, this->numSamples, 0, this->numSamples);
00039                 tmp->GetXaxis()->SetLimits(0, this->numSamples*this->nanosecsPerSample);
00040                 tmp->SetXTitle("ns");
00041                 tmp->SetYTitle("ADC value");
00042                 
00043                 push_back(tmp);
00044         }
00045 
00046         std::cout << "Finish V1730 raw waveforms... " << std::endl;
00047 
00048 }
00049 
00050 
00051 
00052 
00053 void TV1730RawWaveform::UpdateHistograms(TDataContainer& dataContainer){
00054 
00055   int eventid = dataContainer.GetMidasData().GetEventId();
00056   int timestamp = dataContainer.GetMidasData().GetTimeStamp();
00057         
00058         TV1730RawData *v1730 = dataContainer.GetEventData<TV1730RawData>("V730");
00059 
00060         if(v1730 ){      
00061 
00062                 std::vector<RawChannelMeasurement> measurements = v1730->GetMeasurements();
00063 
00064                 for(int i = 0; i < measurements.size(); i++){
00065                         
00066                         int chan = measurements[i].GetChannel();
00067                         
00068         // Reset the histogram...
00069                         for(int ib = 0; ib < this->numSamples; ib++)
00070                                 GetHistogram(chan)->SetBinContent(ib+1,0);
00071 
00072                         // Hack!
00073                         float offset = 0;
00074                         if(chan == 1)
00075                                 offset = 35;
00076                         //std::cout << "Nsamples " <<  measurements[i].GetNSamples() << std::endl;
00077                         for(int ib = 0; ib < measurements[i].GetNSamples(); ib++){
00078 
00079 
00080                                 GetHistogram(chan)->SetBinContent(ib+1, measurements[i].GetSample(ib)-offset);
00081                                 //std::cout << "Setting " << chan << " " << ib << " " << measurements[i].GetSample(ib) << std::endl;
00082 
00083                         }
00084 
00085                 }
00086 
00087         }
00088 
00089 }
00090 
00091 
00092 void TV1730RawWaveform::Reset(){
00093 
00094         // Loop over all the data, reset histos
00095   for(int iBoard=0; iBoard<32; iBoard++){// Loop over V1730Dpp boards        
00096                 for(int i = 0; i < 8; i++){ // loop over channels                       
00097                         int index = iBoard*8 + i;
00098                         
00099                         // Reset the histogram...
00100                         for(int ib = 0; ib < 2500; ib++)
00101                                 GetHistogram(index)->SetBinContent(ib,0);
00102                         GetHistogram(index)->Reset();
00103                 }
00104         }
00105 }
00106                 
00107 /// Take actions at begin run
00108 void TV1730RawWaveform::BeginRun(int transition,int run,int time){
00109 
00110   CreateHistograms();
00111 
00112 }
00113 
00114 /// Take actions at end run  
00115 void TV1730RawWaveform::EndRun(int transition,int run,int time){
00116 
00117 }

Generated on 12 Feb 2016 for ROOT Analyzer by  doxygen 1.6.1