MDQ_DigitizerOverflow
[Low Level Data Quality Checks]

Plots information related to FADC sample overflow, as in samples that went off scale. More...

Functions

INT MDQ_DigitizerOverflow_init (void)
INT MDQ_DigitizerOverflow (EVENT_HEADER *, void *)
INT MDQ_DigitizerOverflow_eor (INT)

Variables

HNDLE hDB
TGlobalDatagData
 Object to hold data used and produced by modules throughout alcapana stage of analysis.
TSetupDatagSetup
 Hardware information about digitizers and detectors to be used during alcapana stage of analysis.
static TH2 * hDQ_DigitizerOverflow_FractionByEvent
 Plots the fraction of TPIs with any sample above the largest possible ADC value for each channel on an event-by-event basis.
static TH2 * hDQ_DigitizerOverflow_TotalByEvent
 Plots total number of TPulseIslands in each channel on an event-by-event basis (for normalisation hDQ_DigitizerOverflow_FractionByEvent).
static TH1 * hDQ_DigitizerOverflow_Fraction
 Plots the fraction of TPIs with any sample above the largest possible ADC value for each channel.
static TH1 * hDQ_DigitizerOverflow_Total
 Plots the total number of TPulseIslands in each channel (for normalisation of hDQ_DigitizerOverflow_Fraction).
ANA_MODULE MDQ_DigitizerOverflow_module

Detailed Description

Plots information related to FADC sample overflow, as in samples that went off scale.

Author:
Joe Grange

Creates hDQ_DigitizerOverflow_Fraction, hDQ_DigitizerOverflow_FractionByEvent, hDQ_DigitizerOverflow_Total, hDQ_DigitizerOverFlow_TotalByEvent.


Function Documentation

INT MDQ_DigitizerOverflow ( EVENT_HEADER *  pheader,
void *  pevent 
)

This method fills the histograms

Definition at line 155 of file MDQ_DigitizerOverflow.cpp.

References TGlobalData::fPulseIslandToChannelMap, TSetupData::GetDetectorName(), TSetupData::GetNBits(), hDQ_DigitizerOverflow_Fraction, hDQ_DigitizerOverflow_FractionByEvent, hDQ_DigitizerOverflow_Total, and hDQ_DigitizerOverflow_TotalByEvent.

00156 {
00157         // Get the event number
00158         int midas_event_number = pheader->serial_number;
00159 
00160         bool pulse_overflow = 0;
00161         int overflow_value = 0;
00162 
00163         // Some typedefs
00164         typedef map<string, vector<TPulseIsland*> > TStringPulseIslandMap;
00165         typedef pair<string, vector<TPulseIsland*> > TStringPulseIslandPair;
00166         typedef map<string, vector<TPulseIsland*> >::iterator map_iterator;
00167 
00168         // Fetch a reference to the gData structure that stores a map
00169         // of (bank_name, vector<TPulseIsland*>) pairs
00170         TStringPulseIslandMap& pulse_islands_map =
00171                 gData->fPulseIslandToChannelMap;
00172 
00173         // Loop over the map and get each bankname, vector pair
00174         for (map_iterator mapIter = pulse_islands_map.begin(); mapIter != pulse_islands_map.end(); ++mapIter) 
00175         {
00176           std::string bankname = mapIter->first;
00177           std::string detname = gSetup->GetDetectorName(bankname);
00178           std::vector<TPulseIsland*> thePulses = mapIter->second;
00179 
00180           int n_bits = gSetup->GetNBits(bankname);
00181           overflow_value = std::pow(2, n_bits) - 1;
00182 
00183           // Loop over the TPulseIslands and plot the histogram
00184           for (std::vector<TPulseIsland*>::iterator pulseIter = thePulses.begin(); pulseIter != thePulses.end(); ++pulseIter) {
00185 
00186             pulse_overflow = 0;
00187 
00188             //loop over samples, check for overflow value
00189             const std::vector<int>& theSamples = (*pulseIter)->GetSamples();
00190             for (std::vector<int>::const_iterator sampleIter = theSamples.begin(); sampleIter != theSamples.end(); ++sampleIter){
00191               int sample_number = sampleIter - theSamples.begin();
00192               int sample_value = *sampleIter;
00193 
00194               if (sample_value >= overflow_value){
00195                 //printf(" sample overflow! sample #%d value %d midas event #%d bankname %s detname %s\n",sample_number,sample_value,midas_event_number,bankname.c_str(),detname.c_str());
00196                 pulse_overflow = 1;
00197 
00198               }
00199                 
00200             
00201               std::string binname = bankname + "(" + detname + ")";
00202               hDQ_DigitizerOverflow_Total->Fill(binname.c_str(),1);
00203               hDQ_DigitizerOverflow_TotalByEvent->Fill(binname.c_str(),midas_event_number,1);
00204               if ((pulse_overflow)){
00205                 hDQ_DigitizerOverflow_Fraction->Fill(binname.c_str(),1);
00206                 hDQ_DigitizerOverflow_FractionByEvent->Fill(binname.c_str(),midas_event_number,1);
00207                 //printf(" total pulses %d integral %f\n",total_pulses,hDQ_ADCSampleOverflow->Integral());
00208               }
00209 
00210             }
00211           }
00212         }
00213 
00214         return SUCCESS;
00215 }

INT MDQ_DigitizerOverflow_eor ( INT  run_number  ) 

This method does any last minute things to the histograms at the end of the run

Definition at line 219 of file MDQ_DigitizerOverflow.cpp.

References hDQ_DigitizerOverflow_Fraction, hDQ_DigitizerOverflow_FractionByEvent, hDQ_DigitizerOverflow_Total, and hDQ_DigitizerOverflow_TotalByEvent.

00219                                               {
00220 
00221 //Total hist has more bins than overflow hist (includes banks with no overflow samples)
00222 int nBanksTotal = hDQ_DigitizerOverflow_Total->GetNbinsX();
00223 int nBanksOverflow = hDQ_DigitizerOverflow_Fraction->GetNbinsX();
00224 int nMidasEvents = hDQ_DigitizerOverflow_FractionByEvent->GetNbinsY();
00225 int nOverflow = 0;
00226 int nTotal = 0;
00227 
00228 //look for matching bank names, scale
00229 for (int i=1; i<=nBanksTotal; i++){
00230   //printf(" bin i: %d total label i %s\n",i,hDQ_ADCSampleTotal->GetXaxis()->GetBinLabel(i));
00231   for (int j=1; j<=nBanksOverflow; j++){
00232     //printf(" bin j %d overflow label %s\n",j,hDQ_DigitizerOverflow_Fraction->GetXaxis()->GetBinLabel(j));
00233     if (strcmp(hDQ_DigitizerOverflow_Total->GetXaxis()->GetBinLabel(i),hDQ_DigitizerOverflow_Fraction->GetXaxis()->GetBinLabel(j))==0){
00234         nOverflow = 0;
00235         nOverflow = hDQ_DigitizerOverflow_Fraction->GetBinContent(j); 
00236         nTotal = 0;
00237         nTotal = hDQ_DigitizerOverflow_Total->GetBinContent(i);
00238 
00239         //printf("match! total label %s overflow label %s\n",hDQ_DigitizerOverflow_Total->GetXaxis()->GetBinLabel(i),hDQ_DigitizerOverflow_Fraction->GetXaxis()->GetBinLabel(j));
00240         if (nTotal>0) hDQ_DigitizerOverflow_Fraction->SetBinContent(j,(double)nOverflow/nTotal);
00241         
00242         for (int k=1; k<nMidasEvents; k++){
00243           nOverflow = 0;
00244           nOverflow = hDQ_DigitizerOverflow_FractionByEvent->GetBinContent(j,k);
00245           nTotal = 0;
00246           nTotal = hDQ_DigitizerOverflow_TotalByEvent->GetBinContent(i,k);//i,k to match banks
00247           if (nTotal>0 && nOverflow>0){
00248             hDQ_DigitizerOverflow_FractionByEvent->SetBinContent(j,k,(double)nOverflow/nTotal);
00249             //printf(" bankname %s midas event %d nOverflow is %d nTotal is %d ratio is %f\n",hDQ_DigitizerOverflow_Total->GetXaxis()->GetBinLabel(i),k,nOverflow,nTotal,(float)nOverflow/nTotal);
00250           }  
00251       }
00252     }
00253   }
00254 }
00255 
00256 return SUCCESS;
00257 
00258 }

INT MDQ_DigitizerOverflow_init (  ) 

This method initializes histograms.

Definition at line 95 of file MDQ_DigitizerOverflow.cpp.

References TSetupData::fBankToDetectorMap, TSetupData::GetDetectorName(), hDB, hDQ_DigitizerOverflow_Fraction, hDQ_DigitizerOverflow_FractionByEvent, hDQ_DigitizerOverflow_Total, and hDQ_DigitizerOverflow_TotalByEvent.

00096 {
00097     // See if the DataQuality_LowLevel/ directory already exists
00098   if (!gDirectory->Cd("DataQuality_LowLevel")) {
00099     
00100     std::string dir_name("DataQuality_LowLevel/");
00101     gDirectory->mkdir(dir_name.c_str());
00102     gDirectory->Cd(dir_name.c_str());
00103   }
00104 
00105   // Get run number
00106   char key_name[80];
00107   int size,run_number;
00108   sprintf(key_name, "Runinfo/Run number");
00109   size=sizeof(int);
00110   db_get_value(hDB,0,key_name, &run_number, &size, TID_INT,1);
00111 
00112   // Create the histograms
00113   hDQ_DigitizerOverflow_Fraction = new TH1D("hDQ_DigitizerOverflow_Fraction",Form("Fraction of TPIs with at least one overflow sample value, run %d",run_number),1,0,1);
00114   hDQ_DigitizerOverflow_Fraction->SetBit(TH1::kCanRebin);
00115   hDQ_DigitizerOverflow_Fraction->GetXaxis()->SetTitle("Bank (Detector)");
00116   hDQ_DigitizerOverflow_Fraction->GetYaxis()->SetTitle("Fraction of TPIs with overflow samples");
00117 
00118   hDQ_DigitizerOverflow_Total = new TH1D("hDQ_DigitizerOverflow_Total", "Total number of TPIs (for normalization)",1,0,1);
00119   hDQ_DigitizerOverflow_Total->SetBit(TH1::kCanRebin);
00120   hDQ_DigitizerOverflow_Total->GetXaxis()->SetTitle("Bank (Detector)");
00121   hDQ_DigitizerOverflow_Total->GetYaxis()->SetTitle("Number of TPIs with overflow samples");
00122 
00123   hDQ_DigitizerOverflow_FractionByEvent = new TH2D("hDQ_DigitizerOverflow_FractionByEvent", Form("Fraction of TPIs with at least one sample overflow value, run %d",run_number),1,0,1, 5000,0,5000);
00124   hDQ_DigitizerOverflow_FractionByEvent->SetBit(TH1::kCanRebin);
00125   hDQ_DigitizerOverflow_FractionByEvent->GetXaxis()->SetTitle("Bank (Detector)");
00126   hDQ_DigitizerOverflow_FractionByEvent->GetYaxis()->SetTitle("MIDAS event number");
00127 
00128   hDQ_DigitizerOverflow_TotalByEvent = new TH2I("hDQ_DigitizerOverflow_TotalByEvent", "Total number of TPIs (for normalization)",1,0,1, 5000,0,5000);
00129   hDQ_DigitizerOverflow_TotalByEvent->SetBit(TH1::kCanRebin);
00130   hDQ_DigitizerOverflow_TotalByEvent->GetXaxis()->SetTitle("Bank (Detector)");
00131   hDQ_DigitizerOverflow_TotalByEvent->GetYaxis()->SetTitle("MIDAS event number");
00132 
00133   // We want the number of x-bins to be the same in all the histograms so that we
00134   // can use the TrendPlot macro (which doesn't check that bin labels are the same)
00135   std::map<std::string, std::string> bank_to_detector_map = gSetup->fBankToDetectorMap;
00136   for(std::map<std::string, std::string>::iterator mapIter = bank_to_detector_map.begin(); 
00137       mapIter != bank_to_detector_map.end(); mapIter++) { 
00138 
00139     std::string bankname = mapIter->first;
00140     std::string detname = gSetup->GetDetectorName(bankname);
00141     std::string binname = bankname + "(" + detname + ")";
00142 
00143     hDQ_DigitizerOverflow_Fraction->Fill(binname.c_str(), 0);
00144     hDQ_DigitizerOverflow_Total->Fill(binname.c_str(), 0);
00145     hDQ_DigitizerOverflow_FractionByEvent->Fill(binname.c_str(), 0.0, 0.0);
00146     hDQ_DigitizerOverflow_TotalByEvent->Fill(binname.c_str(), 0.0, 0.0);
00147   }
00148 
00149   gDirectory->Cd("/MidasHists/");
00150   return SUCCESS;
00151 }


Variable Documentation

Object to hold data used and produced by modules throughout alcapana stage of analysis.

Definition at line 76 of file analyzer.cpp.

Hardware information about digitizers and detectors to be used during alcapana stage of analysis.

Definition at line 80 of file analyzer.cpp.

HNDLE hDB

Plots the fraction of TPIs with any sample above the largest possible ADC value for each channel.

Definition at line 76 of file MDQ_DigitizerOverflow.cpp.

Referenced by MDQ_DigitizerOverflow(), MDQ_DigitizerOverflow_eor(), and MDQ_DigitizerOverflow_init().

Plots the fraction of TPIs with any sample above the largest possible ADC value for each channel on an event-by-event basis.

Definition at line 74 of file MDQ_DigitizerOverflow.cpp.

Referenced by MDQ_DigitizerOverflow(), MDQ_DigitizerOverflow_eor(), and MDQ_DigitizerOverflow_init().

Plots the total number of TPulseIslands in each channel (for normalisation of hDQ_DigitizerOverflow_Fraction).

Definition at line 77 of file MDQ_DigitizerOverflow.cpp.

Referenced by MDQ_DigitizerOverflow(), MDQ_DigitizerOverflow_eor(), and MDQ_DigitizerOverflow_init().

Plots total number of TPulseIslands in each channel on an event-by-event basis (for normalisation hDQ_DigitizerOverflow_FractionByEvent).

Definition at line 75 of file MDQ_DigitizerOverflow.cpp.

Referenced by MDQ_DigitizerOverflow(), MDQ_DigitizerOverflow_eor(), and MDQ_DigitizerOverflow_init().

Initial value:
{
        "MDQ_DigitizerOverflow",                    
        "Joe Grange",              
        MDQ_DigitizerOverflow,                      
        NULL,                          
        MDQ_DigitizerOverflow_eor,                          
        MDQ_DigitizerOverflow_init,                 
        NULL,                          
        NULL,                          
        0,                             
        NULL,                          
}

Definition at line 79 of file MDQ_DigitizerOverflow.cpp.


Generated on 15 Jun 2016 for AlcapDAQ by  doxygen 1.6.1