CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/Validation/EcalRecHits/src/EcalBarrelRecHitsValidation.cc

Go to the documentation of this file.
00001 /*
00002  * \file EcalBarrelRecHitsValidation.cc
00003  *
00004  * $Date: 2009/12/14 22:24:44 $
00005  * \author C. Rovelli
00006  *
00007  */
00008 
00009 #include <Validation/EcalRecHits/interface/EcalBarrelRecHitsValidation.h>
00010 #include <DataFormats/EcalDetId/interface/EBDetId.h>
00011 #include "DQMServices/Core/interface/DQMStore.h"
00012 
00013 using namespace cms;
00014 using namespace edm;
00015 using namespace std;
00016 
00017 EcalBarrelRecHitsValidation::EcalBarrelRecHitsValidation(const ParameterSet& ps){
00018   
00019   // ---------------------- 
00020   EBdigiCollection_          = ps.getParameter<edm::InputTag>("EBdigiCollection");
00021   EBuncalibrechitCollection_ = ps.getParameter<edm::InputTag>("EBuncalibrechitCollection");
00022   
00023   // ---------------------- 
00024   // verbosity switch 
00025   verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
00026     
00027   // ----------------------                 
00028   // get hold of back-end interface 
00029   dbe_ = 0;
00030   dbe_ = Service<DQMStore>().operator->();                   
00031   if ( dbe_ ) {
00032     if ( verbose_ ) {
00033       dbe_->setVerbose(1);
00034     } else {
00035       dbe_->setVerbose(0);
00036     }
00037   }                                                                  
00038   if ( dbe_ ) {
00039     if ( verbose_ ) dbe_->showDirStructure();
00040   }
00041 
00042 
00043   // ----------------------   
00044   meEBUncalibRecHitsOccupancy_             = 0;
00045   meEBUncalibRecHitsAmplitude_             = 0;
00046   meEBUncalibRecHitsPedestal_              = 0;
00047   meEBUncalibRecHitsJitter_                = 0;
00048   meEBUncalibRecHitsChi2_                  = 0;
00049   meEBUncalibRecHitMaxSampleRatio_         = 0;
00050   meEBUncalibRecHitsOccupancyGt100adc_     = 0;
00051   meEBUncalibRecHitsAmplitudeGt100adc_     = 0;
00052   meEBUncalibRecHitsPedestalGt100adc_      = 0;
00053   meEBUncalibRecHitsJitterGt100adc_        = 0;
00054   meEBUncalibRecHitsChi2Gt100adc_          = 0;
00055   meEBUncalibRecHitMaxSampleRatioGt100adc_ = 0;
00056   meEBUncalibRecHitsAmpFullMap_            = 0;
00057   meEBUncalibRecHitsPedFullMap_            = 0;
00058   for (int i=0; i<36 ; i++) 
00059     {
00060       meEBUncalibRecHitAmplMap_[i] = 0;
00061       meEBUncalibRecHitPedMap_[i]  = 0;
00062     }
00063 
00064   // ---------------------- 
00065   Char_t histo[200];
00066    
00067   if ( dbe_ ) 
00068     {
00069       dbe_->setCurrentFolder("EcalRecHitsV/EcalBarrelRecHitsTask");
00070       
00071       sprintf (histo, "EB Occupancy" );  
00072       meEBUncalibRecHitsOccupancy_ = dbe_->book2D(histo, histo, 170, -85., 85., 360, 0., 360.);
00073       
00074       sprintf (histo, "EB Amplitude" );
00075       meEBUncalibRecHitsAmplitude_ = dbe_->book1D(histo, histo, 201, -20., 4000.);
00076       
00077       sprintf (histo, "EB Pedestal" );
00078       meEBUncalibRecHitsPedestal_ = dbe_->book1D(histo, histo, 50, 190., 210.);
00079       
00080       sprintf (histo, "EB Jitter" );
00081       meEBUncalibRecHitsJitter_ = dbe_->book1D(histo, histo, 100, 0., 100.);
00082       
00083       sprintf (histo, "EB Chi2" );
00084       meEBUncalibRecHitsChi2_ = dbe_->book1D(histo, histo, 100, 18000., 22000.);
00085 
00086       sprintf (histo, "EB RecHit Max Sample Ratio"); 
00087       meEBUncalibRecHitMaxSampleRatio_ = dbe_->book1D(histo, histo, 120, 0.90, 1.05);
00088 
00089       sprintf (histo, "EB Occupancy gt 100 adc counts" );
00090       meEBUncalibRecHitsOccupancyGt100adc_ = dbe_->book2D(histo, histo, 170, -85., 85., 360, 0., 360.);
00091       
00092       sprintf (histo, "EB Amplitude gt 100 adc counts" );
00093       meEBUncalibRecHitsAmplitudeGt100adc_ = dbe_->book1D(histo, histo, 200, 0., 4000.);
00094 
00095       sprintf (histo, "EB Pedestal gt 100 adc counts" );
00096       meEBUncalibRecHitsPedestalGt100adc_ = dbe_->book1D(histo, histo, 50, 190., 210.);
00097 
00098       sprintf (histo, "EB Jitter gt 100 adc counts" );
00099       meEBUncalibRecHitsJitterGt100adc_ = dbe_->book1D(histo, histo, 100, 0., 100.);
00100 
00101       sprintf (histo, "EB Chi2 gt 100 adc counts" );
00102       meEBUncalibRecHitsChi2Gt100adc_ = dbe_->book1D(histo, histo, 100, 18000., 22000.);
00103     
00104       sprintf (histo, "EB RecHit Max Sample Ratio gt 100 adc counts"); 
00105       meEBUncalibRecHitMaxSampleRatioGt100adc_ = dbe_->book1D(histo, histo, 120, 0.90, 1.05);
00106       
00107       sprintf (histo, "EB Amplitude Full Map");
00108       meEBUncalibRecHitsAmpFullMap_ = dbe_->bookProfile2D(histo, histo, 170, -85., 85., 360, 0., 360., 200, 0., 4000.);
00109 
00110       sprintf (histo, "EB Pedestal Full Map");
00111       meEBUncalibRecHitsPedFullMap_ = dbe_->bookProfile2D(histo, histo, 170, -85., 85., 360, 0., 360., 50, 194., 201.);
00112 
00113       for (int i=0; i<36 ; i++) 
00114         {
00115           sprintf(histo, "EB Amp SM%02d", i+1);
00116           meEBUncalibRecHitAmplMap_[i] = dbe_->bookProfile2D(histo, histo, 85, 0., 85., 20, 0., 20., 200, 0., 4000.);
00117           
00118           sprintf(histo, "EB Ped SM%02d", i+1);
00119           meEBUncalibRecHitPedMap_[i] = dbe_->bookProfile2D(histo, histo, 85, 0., 85., 20, 0., 20., 50, 194., 201.);
00120         }
00121     }
00122 }
00123 
00124 EcalBarrelRecHitsValidation::~EcalBarrelRecHitsValidation(){   
00125 
00126 }
00127 
00128 void EcalBarrelRecHitsValidation::beginJob(){  
00129 
00130 }
00131 
00132 void EcalBarrelRecHitsValidation::endJob(){
00133 
00134 }
00135 
00136 void EcalBarrelRecHitsValidation::analyze(const Event& e, const EventSetup& c){
00137 
00138   
00139   const EBUncalibratedRecHitCollection *EBUncalibRecHit = 0;
00140   Handle< EBUncalibratedRecHitCollection > EcalUncalibRecHitEB;
00141   e.getByLabel( EBuncalibrechitCollection_, EcalUncalibRecHitEB);
00142   if (EcalUncalibRecHitEB.isValid()) {
00143     EBUncalibRecHit = EcalUncalibRecHitEB.product();
00144   } else {
00145     return;
00146   }
00147 
00148   bool skipDigis = false;
00149   const EBDigiCollection *EBDigi = 0;
00150   Handle< EBDigiCollection > EcalDigiEB;
00151   e.getByLabel( EBdigiCollection_, EcalDigiEB);
00152   if (EcalDigiEB.isValid()) {
00153     EBDigi = EcalDigiEB.product();    
00154   } else {
00155     skipDigis = true;
00156   }
00157 
00158   edm::ESHandle<EcalPedestals> ecalPeds; 
00159   c.get<EcalPedestalsRcd>().get(ecalPeds);
00160 
00161   // ---------------------- 
00162   // loop over UncalibRecHits
00163   for (EcalUncalibratedRecHitCollection::const_iterator uncalibRecHit = EBUncalibRecHit->begin(); uncalibRecHit != EBUncalibRecHit->end() ; ++uncalibRecHit)
00164     {
00165       EBDetId EBid = EBDetId(uncalibRecHit->id());
00166       
00167       // general checks
00168       if (meEBUncalibRecHitsOccupancy_)  meEBUncalibRecHitsOccupancy_  -> Fill(EBid.ieta(), EBid.iphi());
00169       if (meEBUncalibRecHitsAmplitude_)  meEBUncalibRecHitsAmplitude_  -> Fill(uncalibRecHit->amplitude());
00170       if (meEBUncalibRecHitsPedestal_)   meEBUncalibRecHitsPedestal_   -> Fill(uncalibRecHit->pedestal());
00171       if (meEBUncalibRecHitsJitter_)     meEBUncalibRecHitsJitter_     -> Fill(uncalibRecHit->jitter());
00172       if (meEBUncalibRecHitsChi2_)       meEBUncalibRecHitsChi2_       -> Fill(uncalibRecHit->chi2());
00173       if (meEBUncalibRecHitsAmpFullMap_) meEBUncalibRecHitsAmpFullMap_ -> Fill(EBid.ieta(), EBid.iphi(), uncalibRecHit->amplitude()); 
00174       if (meEBUncalibRecHitsPedFullMap_) meEBUncalibRecHitsPedFullMap_ -> Fill(EBid.ieta(), EBid.iphi(), uncalibRecHit->pedestal()); 
00175 
00176       // general checks, with threshold at 3.5 GeV = 100 ADC counts
00177       if ( uncalibRecHit->amplitude() > 100 ) 
00178         {
00179           if (meEBUncalibRecHitsOccupancyGt100adc_)  meEBUncalibRecHitsOccupancyGt100adc_  -> Fill(EBid.ieta(), EBid.iphi());
00180           if (meEBUncalibRecHitsAmplitudeGt100adc_)  meEBUncalibRecHitsAmplitudeGt100adc_  -> Fill(uncalibRecHit->amplitude());
00181           if (meEBUncalibRecHitsPedestalGt100adc_)   meEBUncalibRecHitsPedestalGt100adc_   -> Fill(uncalibRecHit->pedestal());
00182           if (meEBUncalibRecHitsJitterGt100adc_)     meEBUncalibRecHitsJitterGt100adc_     -> Fill(uncalibRecHit->jitter());
00183           if (meEBUncalibRecHitsChi2Gt100adc_)       meEBUncalibRecHitsChi2Gt100adc_       -> Fill(uncalibRecHit->chi2());
00184         }
00185 
00186       // supermodule maps
00187       int ic = EBid.ic();              
00188       int ie = (ic-1)/20 + 1;          
00189       int ip = (ic-1)%20 + 1;
00190       int ism = EBid.ism();
00191       float xie = ie - 0.5;
00192       float xip = ip - 0.5;      
00193       if( meEBUncalibRecHitPedMap_[ism-1] ) meEBUncalibRecHitPedMap_[ism-1]->Fill(xie, xip, uncalibRecHit->pedestal());
00194       if( meEBUncalibRecHitAmplMap_[ism-1] ) meEBUncalibRecHitAmplMap_[ism-1]->Fill(xie, xip, uncalibRecHit->amplitude());
00195       
00196       if ( ! skipDigis ) { 
00197         // find the rechit corresponding digi and the max sample
00198         EBDigiCollection::const_iterator myDigi = EBDigi->find(EBid);
00199         int sMax = -1;
00200         double eMax = 0.;
00201         if (myDigi != EBDigi->end()){
00202           for (unsigned int sample = 0 ; sample < myDigi->size(); ++sample){
00203             EcalMGPASample thisSample = (*myDigi)[sample];
00204             double analogSample = thisSample.adc();
00205             if ( eMax < analogSample ){
00206               eMax = analogSample;
00207               sMax = sample;
00208             }
00209           }
00210         }
00211         else
00212           continue;
00213 
00214         // ratio uncalibratedRecHit amplitude + ped / max energy digi  
00215         const EcalPedestals* myped = ecalPeds.product();
00216         EcalPedestalsMap::const_iterator it=myped->getMap().find( EBid );
00217         if( it != myped->getMap().end() ){
00218           
00219           if (eMax > (*it).mean_x1 + 5 * (*it).rms_x1 && eMax != 0 ) {//only real signal RecHit
00220             
00221             if ( meEBUncalibRecHitMaxSampleRatio_ ) meEBUncalibRecHitMaxSampleRatio_->Fill( (uncalibRecHit->amplitude()+uncalibRecHit->pedestal())/eMax);
00222             if ( meEBUncalibRecHitMaxSampleRatioGt100adc_ && (uncalibRecHit->amplitude()>100) ) meEBUncalibRecHitMaxSampleRatioGt100adc_->Fill( (uncalibRecHit->amplitude()+uncalibRecHit->pedestal())/eMax);
00223             LogDebug("EcalRecHitsTaskInfo") << "barrel, eMax = " << eMax << " Amplitude = " << uncalibRecHit->amplitude()+uncalibRecHit->pedestal();  
00224           }
00225           else
00226             continue;
00227         }
00228         else
00229           continue;
00230       }
00231       
00232     }  // loop over the UncalibratedRecHitCollection
00233 }