MDQ_PulseShapes
[Low Level Data Quality Checks]

Plots the persistance plots and Y projections of these, along with pedestal and pedestal noise of each bank averaged over the run. More...

Functions

INT MDQ_PulseShapes_init (void)
INT MDQ_PulseShapes (EVENT_HEADER *, void *)
INT MDQ_PulseShapes_eor (INT)
static int GetLastPresampleBin (std::string bankname)

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.
TDirectory * gManaHistsDir
TFile * gManaOutputFile
TApplication * manaApp
TROOT * gROOT
map< std::string, TH2F * > DQ_PulseShapes_histograms_map
 Map of bank names to 2D histograms that represent the persitance oscilliscope plots of TPIs.
map< std::string, TH1D * > DQ_PulseShapesProjectionY_histograms_map
 Map of bank names to Y projections of full histograms in DQ_PulseShapes_histograms_map.
TH1F * hDQ_PulseShapes_Pedestals
 Histogram with bank name on horizontal axis and and pedestal on vertical. The pedestal is the bin with the peak in DQ_PulseShapesProjectionY_histograms_map.
TH1F * hDQ_PulseShapes_Noises
 Histogram with bank name on horizontal axis and noise on vertical. The noise is twice the the first bin in DQ_PulseShapesProjectionY_histograms_map at half the value in hDQ_PulseShapes_Pedestals.
ANA_MODULE MDQ_PulseShapes_module

Detailed Description

Plots the persistance plots and Y projections of these, along with pedestal and pedestal noise of each bank averaged over the run.

Author:
Nam Tran

Creates a number of histograms.


Function Documentation

static int GetLastPresampleBin ( std::string  bankname  )  [static]
INT MDQ_PulseShapes ( EVENT_HEADER *  pheader,
void *  pevent 
)

This method fills the histograms

Definition at line 171 of file MDQ_PulseShapes.cpp.

References DQ_PulseShapes_histograms_map, TGlobalData::fPulseIslandToChannelMap, and TSetupData::GetDetectorName().

00172 {
00173         // Get the event number
00174         int midas_event_number = pheader->serial_number;
00175 
00176         // Some typedefs
00177         typedef map<string, vector<TPulseIsland*> > TStringPulseIslandMap;
00178         typedef pair<string, vector<TPulseIsland*> > TStringPulseIslandPair;
00179         typedef map<string, vector<TPulseIsland*> >::iterator map_iterator;
00180 
00181         // Fetch a reference to the gData structure that stores a map
00182         // of (bank_name, vector<TPulseIsland*>) pairs
00183         TStringPulseIslandMap& pulse_islands_map =
00184                 gData->fPulseIslandToChannelMap;
00185 
00186         // Loop over the map and get each bankname, vector pair
00187         for (map_iterator mapIter = pulse_islands_map.begin(); 
00188                         mapIter != pulse_islands_map.end(); ++mapIter) 
00189         {
00190           std::string bankname = mapIter->first;
00191           std::string detname = gSetup->GetDetectorName(bankname);
00192           std::vector<TPulseIsland*> thePulses = mapIter->second;
00193           
00194           // Get the histograms before looping through the pulses
00195           TH2F* hDQ_PulseShapes = DQ_PulseShapes_histograms_map[bankname];
00196 
00197           // Loop over the TPulseIslands and plot the histogram
00198                 for (std::vector<TPulseIsland*>::iterator pulseIter = thePulses.begin();
00199                                 pulseIter != thePulses.end(); ++pulseIter) {
00200 
00201             // Make sure the histograms exist and then fill them
00202                         if (DQ_PulseShapes_histograms_map.find(bankname) !=
00203                                         DQ_PulseShapes_histograms_map.end()) 
00204                         { 
00205                                 const std::vector<int>& theSamples = (*pulseIter)->GetSamples();
00206                                 for (std::vector<int>::const_iterator sampleIter = theSamples.begin(); 
00207                                                 sampleIter != theSamples.end(); ++sampleIter)
00208                                 {
00209                                         int sample_number = sampleIter - theSamples.begin();
00210                                         //int sample_number = 0;
00211                                         int sample_value = *sampleIter;
00212                                         hDQ_PulseShapes->Fill(sample_number,sample_value);
00213                                 }
00214             }
00215           }
00216         }
00217         return SUCCESS;
00218 }

INT MDQ_PulseShapes_eor ( INT  run_number  ) 

Definition at line 220 of file MDQ_PulseShapes.cpp.

References DQ_PulseShapes_histograms_map, DQ_PulseShapesProjectionY_histograms_map, TSetupData::fBankToDetectorMap, TSetupData::GetDetectorName(), hDQ_PulseShapes_Noises, and hDQ_PulseShapes_Pedestals.

00221 {
00222         typedef std::map<std::string, std::string>::iterator String2StringMapIter;
00223         std::map<std::string, std::string> Bank2DetMap = gSetup->fBankToDetectorMap;
00224 
00225         for(String2StringMapIter mapIter = Bank2DetMap.begin(); 
00226                         mapIter != Bank2DetMap.end(); mapIter++) 
00227         { 
00228                 std::string bankname = mapIter->first;
00229                 std::string detname = gSetup->GetDetectorName(bankname);
00230 
00231                 if (DQ_PulseShapes_histograms_map.find(bankname) !=
00232                                 DQ_PulseShapes_histograms_map.end())
00233                 {
00234                         TH2F* hPulseShapes = DQ_PulseShapes_histograms_map[bankname];
00235                         TH1D* hDQ_Histogram_projY = hPulseShapes->ProjectionY();
00236 
00237                         DQ_PulseShapesProjectionY_histograms_map[bankname]->Add(
00238                                         hDQ_Histogram_projY, 1);
00239                         hDQ_Histogram_projY->SetDirectory(0); // not save this in the output
00240 
00241                         // Take pedestal and noise as mean and RMS of the projections
00242                         // but first set the range so that we don't get the massive bins at 0 or the max_adc_value
00243                         hDQ_Histogram_projY->GetXaxis()->SetRange(2, hDQ_Histogram_projY->GetNbinsX()-1);
00244                         int max_bin = hDQ_Histogram_projY->GetMaximumBin();
00245 
00246                         double pedestal = hDQ_Histogram_projY->GetBinCenter(max_bin);
00247                         double pedestal_value = hDQ_Histogram_projY->GetBinContent(max_bin);
00248                         double noise = 0;
00249                         for (int iBin = max_bin; iBin < hDQ_Histogram_projY->GetNbinsX(); ++iBin) {
00250                           double value = hDQ_Histogram_projY->GetBinContent(iBin);
00251                           if (value < 0.5*pedestal_value) {
00252                             noise = hDQ_Histogram_projY->GetBinCenter(iBin) - pedestal;
00253                             break;
00254                           }
00255                         }
00256 
00257                         std::string binlabel = bankname + " (" + detname + ")";
00258                         hDQ_PulseShapes_Pedestals->Fill(binlabel.c_str(), pedestal);
00259                         hDQ_PulseShapes_Noises->Fill(binlabel.c_str(), 2*noise); // at the moment, noise is just from the peak to the half-way down on one side so multiply by 2
00260                 }
00261         }
00262 
00263         return SUCCESS;
00264 }

INT MDQ_PulseShapes_init (  ) 

This method initializes histograms.

Definition at line 108 of file MDQ_PulseShapes.cpp.

References DQ_PulseShapes_histograms_map, DQ_PulseShapesProjectionY_histograms_map, TSetupData::fBankToDetectorMap, TSetupData::GetDetectorName(), TSetupData::GetNBits(), hDQ_PulseShapes_Noises, and hDQ_PulseShapes_Pedestals.

00109 {
00110   // See if the DataQuality_LowLevel/ directory already exists
00111   std::string dir_name("DataQuality_LowLevel/");
00112   if (!gDirectory->Cd(dir_name.c_str())) {
00113     gDirectory->mkdir(dir_name.c_str());
00114   }
00115   gDirectory->Cd(dir_name.c_str());
00116 
00117   // Create a histogram for each detector
00118   std::map<std::string, std::string> Bank2DetMap = gSetup->fBankToDetectorMap;
00119   for(std::map<std::string, std::string>::iterator mapIter = Bank2DetMap.begin(); 
00120       mapIter != Bank2DetMap.end(); mapIter++) { 
00121 
00122     std::string bankname = mapIter->first;
00123     std::string detname = gSetup->GetDetectorName(bankname);
00124 
00125     int n_bits = gSetup->GetNBits(bankname);
00126     int max_adc_value = std::pow(2, n_bits);
00127 
00128     // hDQ_PulseShapes_[DetName]_[BankName]
00129     std::string histname = "hDQ_PulseShapes_" + detname + "_" + bankname;
00130     std::string histtitle = "Pulse shape of " + detname;
00131     TH2F* hDQ_Histogram = new TH2F(histname.c_str(), histtitle.c_str(), 
00132                                 400, -0.5, 399.5,
00133                                 max_adc_value, 0, max_adc_value);
00134     hDQ_Histogram->GetXaxis()->SetTitle("Time Stamp [ns]");
00135     hDQ_Histogram->GetYaxis()->SetTitle("Pulse height [adc]");
00136     DQ_PulseShapes_histograms_map[bankname] = hDQ_Histogram;
00137 
00138     // hDQ_PulseShapesProjectionY_[DetName]_[BankName]
00139     histname = "hDQ_PulseShapes_ProjectionY_" + detname + "_" + bankname;
00140     histtitle = "Pulse shape Y-projection of " + detname;
00141     TH1D* hDQ_Histogram_TH1D = new TH1D(histname.c_str(), histtitle.c_str(), 
00142                                 max_adc_value, 0, max_adc_value);
00143     hDQ_Histogram_TH1D->GetXaxis()->SetTitle("ADC");
00144     hDQ_Histogram_TH1D->GetYaxis()->SetTitle("Arbitary unit");
00145     DQ_PulseShapesProjectionY_histograms_map[bankname] = hDQ_Histogram_TH1D;
00146   }
00147 
00148   // hDQ_PulseShapes_Pedestals
00149   std::string histname = "hDQ_PulseShapes_Pedestals";
00150   std::string histtitle = "Pedestals";
00151   hDQ_PulseShapes_Pedestals = new TH1F(histname.c_str(), histtitle.c_str(),1,0,1);
00152   hDQ_PulseShapes_Pedestals->GetXaxis()->SetTitle("Bank (Detector)");
00153   hDQ_PulseShapes_Pedestals->GetYaxis()->SetTitle("Pedestal [ADC]");
00154   hDQ_PulseShapes_Pedestals->SetBit(TH1::kCanRebin);
00155 
00156   // hDQ_PulseShapes_Noises
00157   histname = "hDQ_PulseShapes_Noises";
00158   histtitle = "Noises";
00159   hDQ_PulseShapes_Noises = new TH1F(histname.c_str(), histtitle.c_str(),1,0,1);
00160   hDQ_PulseShapes_Noises->GetXaxis()->SetTitle("Bank (Detector)");
00161   hDQ_PulseShapes_Noises->GetYaxis()->SetTitle("Noise (FWHM) [ADC]");
00162   hDQ_PulseShapes_Noises->SetBit(TH1::kCanRebin);
00163 
00164   // Back to root directory
00165   gDirectory->Cd("/MidasHists/");
00166   return SUCCESS;
00167 }


Variable Documentation

Map of bank names to 2D histograms that represent the persitance oscilliscope plots of TPIs.

Definition at line 85 of file MDQ_PulseShapes.cpp.

Referenced by MDQ_PulseShapes(), MDQ_PulseShapes_eor(), and MDQ_PulseShapes_init().

Map of bank names to Y projections of full histograms in DQ_PulseShapes_histograms_map.

Definition at line 86 of file MDQ_PulseShapes.cpp.

Referenced by MDQ_PulseShapes_eor(), and MDQ_PulseShapes_init().

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

Definition at line 76 of file analyzer.cpp.

TDirectory* gManaHistsDir
TROOT* gROOT

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

Definition at line 80 of file analyzer.cpp.

HNDLE hDB

Histogram with bank name on horizontal axis and noise on vertical. The noise is twice the the first bin in DQ_PulseShapesProjectionY_histograms_map at half the value in hDQ_PulseShapes_Pedestals.

Definition at line 88 of file MDQ_PulseShapes.cpp.

Referenced by MDQ_PulseShapes_eor(), and MDQ_PulseShapes_init().

Histogram with bank name on horizontal axis and and pedestal on vertical. The pedestal is the bin with the peak in DQ_PulseShapesProjectionY_histograms_map.

Definition at line 87 of file MDQ_PulseShapes.cpp.

Referenced by MDQ_PulseShapes_eor(), and MDQ_PulseShapes_init().

TApplication* manaApp
Initial value:
{
        "MDQ_PulseShapes",                    
        "Nam Tran",              
        MDQ_PulseShapes,                      
        NULL,                          
        MDQ_PulseShapes_eor,                          
        MDQ_PulseShapes_init,                 
        NULL,                          
        NULL,                          
        0,                             
        NULL,                          
}

Definition at line 92 of file MDQ_PulseShapes.cpp.


Generated on 15 Jun 2016 for AlcapDAQ by  doxygen 1.6.1