TV1720Waveform.cxx

Go to the documentation of this file.
00001 #include "TV1720Waveform.h"
00002 
00003 #include "TV1720RawData.h"
00004 #include "TDirectory.h"
00005 
00006 
00007 /// Reset the histograms for this canvas
00008 TV1720Waveform::TV1720Waveform(){
00009 
00010   SetNanosecsPerSample(4); //ADC clock runs at 250Mhz on the v1720 = units of 4 nsecs
00011 
00012   CreateHistograms();
00013 }
00014 
00015 
00016 void TV1720Waveform::CreateHistograms(){
00017 
00018   // check if we already have histogramss.
00019   char tname[100];
00020   sprintf(tname,"V1720_%i",0);
00021 
00022   TH1D *tmp = (TH1D*)gDirectory->Get(tname);
00023   if (tmp) return;
00024 
00025         int fWFLength = 1000; // Need a better way of detecting this...
00026   int numSamples = fWFLength / nanosecsPerSample;
00027 
00028   // Otherwise make histograms
00029   clear();
00030 
00031         for(int i = 0; i < 8; i++){ // loop over 8 channels
00032                 
00033                 char name[100];
00034                 char title[100];
00035                 sprintf(name,"V1720_%i",i);
00036 
00037                 sprintf(title,"V1720 Waveform for channel=%i",i);       
00038                 
00039                 TH1D *tmp = new TH1D(name, title, numSamples, 0, fWFLength);
00040                 tmp->SetXTitle("ns");
00041                 tmp->SetYTitle("ADC value");
00042                 
00043                 push_back(tmp);
00044         }
00045 
00046 }
00047 
00048 
00049 void TV1720Waveform::UpdateHistograms(TDataContainer& dataContainer){
00050 
00051   int eventid = dataContainer.GetMidasData().GetEventId();
00052   int timestamp = dataContainer.GetMidasData().GetTimeStamp();
00053 
00054 
00055         //    char name[100];
00056         //sprintf(name,"W2%02d",iBoard);
00057 
00058         TV1720RawData *v1720 = dataContainer.GetEventData<TV1720RawData>("W200");
00059         
00060         if(v1720 && v1720->IsZLECompressed()){      
00061                 
00062                 for(int i = 0; i < 8; i++){ // loop over channels
00063                         
00064                         // Check if this channel has any data in this event.
00065                         int chhex = 1 << i  ;
00066                         if(!(v1720->GetChannelMask() & chhex)){
00067                                 std::cout << "No data ... " << std::endl;
00068                                 continue;
00069                         }
00070                         
00071                         int index =  i;
00072                         // Reset the histogram...
00073                         for(int ib = 0; ib < 250; ib++)
00074                                 GetHistogram(index)->SetBinContent(ib+1,0);
00075                         
00076                         TV1720RawChannel channelData = v1720->GetChannelData(i);
00077                         
00078                         // Loop over pulses, filling the histogram
00079                         for(int j = 0; j < channelData.GetNZlePulses(); j++){
00080                                 TV1720RawZlePulse pulse = channelData.GetZlePulse(j);
00081                                 for(int k = 0; k < pulse.GetNSamples(); k++){
00082                                         int bin = pulse.GetFirstBin() + k;
00083                                         GetHistogram(index)->SetBinContent(bin,pulse.GetSample(k));
00084                                 }
00085                         }
00086                         
00087                 }
00088         }
00089         
00090         if(v1720 && !v1720->IsZLECompressed()){      
00091                 
00092                 for(int i = 0; i < 8; i++){ // loop over channels
00093                         
00094                         int index = i;
00095                         
00096                         // Reset the histogram...
00097                         //        for(int ib = 0; ib < 2500; ib++)
00098                         for(int ib = 0; ib < 250; ib++)
00099                                 GetHistogram(index)->SetBinContent(ib+1,0);
00100                         
00101                         
00102                         TV1720RawChannel channelData = v1720->GetChannelData(i);
00103                         for(int j = 0; j < channelData.GetNSamples(); j++){
00104                                 double adc = channelData.GetADCSample(j);
00105                                 GetHistogram(index)->SetBinContent(j+1,adc);
00106                                 
00107                         }                       
00108     }
00109   }
00110 
00111 }
00112 
00113 
00114 
00115 void TV1720Waveform::Reset(){
00116 
00117 
00118         for(int i = 0; i < 8; i++){ // loop over channels
00119                 int index =  i;
00120 
00121                 // Reset the histogram...
00122                 for(int ib = 0; ib < GetHistogram(index)->GetNbinsX(); ib++) {
00123                         GetHistogram(index)->SetBinContent(ib, 0);
00124                 }
00125 
00126                 GetHistogram(index)->Reset();
00127     
00128   }
00129 }

Generated on 12 Feb 2016 for ROOT Analyzer by  doxygen 1.6.1