CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/Validation/EcalRecHits/src/EcalEndcapRecHitsValidation.cc

Go to the documentation of this file.
00001 /*
00002  * \file EcalEndcapRecHitsValidation.cc
00003  *
00004  * $Date: 2011/10/31 16:09:19 $
00005  * \author C. Rovelli
00006  *
00007  */
00008 
00009 #include <Validation/EcalRecHits/interface/EcalEndcapRecHitsValidation.h>
00010 #include <DataFormats/EcalDetId/interface/EEDetId.h>
00011 #include "DQMServices/Core/interface/DQMStore.h"
00012 
00013 using namespace cms;
00014 using namespace edm;
00015 using namespace std;
00016 
00017 EcalEndcapRecHitsValidation::EcalEndcapRecHitsValidation(const ParameterSet& ps){
00018 
00019   // ---------------------- 
00020   EEdigiCollection_          = ps.getParameter<edm::InputTag>("EEdigiCollection");
00021   EEuncalibrechitCollection_ = ps.getParameter<edm::InputTag>("EEuncalibrechitCollection");
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   meEEUncalibRecHitsOccupancyPlus_         = 0;
00045   meEEUncalibRecHitsOccupancyMinus_        = 0;
00046   meEEUncalibRecHitsAmplitude_             = 0;
00047   meEEUncalibRecHitsPedestal_              = 0;
00048   meEEUncalibRecHitsJitter_                = 0;
00049   meEEUncalibRecHitsChi2_                  = 0;
00050   meEEUncalibRecHitMaxSampleRatio_         = 0;
00051   meEEUncalibRecHitsOccupancyPlusGt60adc_  = 0;
00052   meEEUncalibRecHitsOccupancyMinusGt60adc_ = 0;
00053   meEEUncalibRecHitsAmplitudeGt60adc_      = 0;
00054   meEEUncalibRecHitsPedestalGt60adc_       = 0;
00055   meEEUncalibRecHitsJitterGt60adc_         = 0;
00056   meEEUncalibRecHitsChi2Gt60adc_           = 0;
00057   meEEUncalibRecHitMaxSampleRatioGt60adc_  = 0;
00058   meEEUncalibRecHitsAmpFullMap_            = 0;
00059   meEEUncalibRecHitsPedFullMap_            = 0;
00060 
00061   // ---------------------- 
00062   Char_t histo[200];
00063    
00064   if ( dbe_ ) 
00065     {
00066       dbe_->setCurrentFolder("EcalRecHitsV/EcalEndcapRecHitsTask");
00067       
00068       sprintf (histo, "EE+ Occupancy" );  
00069       meEEUncalibRecHitsOccupancyPlus_ = dbe_->book2D(histo, histo, 100, 0., 100., 100, 0., 100.);
00070 
00071       sprintf (histo, "EE- Occupancy" );  
00072       meEEUncalibRecHitsOccupancyMinus_ = dbe_->book2D(histo, histo, 100, 0., 100., 100, 0., 100.);
00073       
00074       sprintf (histo, "EE Amplitude" );
00075       meEEUncalibRecHitsAmplitude_ = dbe_->book1D(histo, histo, 201, -20., 4000.);
00076       
00077       sprintf (histo, "EE Pedestal" );
00078       meEEUncalibRecHitsPedestal_ = dbe_->book1D(histo, histo, 50, 190., 210.);
00079       
00080       sprintf (histo, "EE Jitter" );
00081       meEEUncalibRecHitsJitter_ = dbe_->book1D(histo, histo, 100, 0., 100.);
00082       
00083       sprintf (histo, "EE Chi2" );
00084       meEEUncalibRecHitsChi2_ = dbe_->book1D(histo, histo, 100, 18000., 22000.);
00085 
00086       sprintf (histo, "EE RecHit Max Sample Ratio"); 
00087       meEEUncalibRecHitMaxSampleRatio_ = dbe_->book1D(histo, histo, 120, 0.90, 1.05);
00088       
00089       sprintf (histo, "EE+ Occupancy gt 60 adc counts" );  
00090       meEEUncalibRecHitsOccupancyPlusGt60adc_ = dbe_->book2D(histo, histo, 100, 0., 100., 100, 0., 100.);
00091 
00092       sprintf (histo, "EE- Occupancy gt 60 adc counts" );  
00093       meEEUncalibRecHitsOccupancyMinusGt60adc_ = dbe_->book2D(histo, histo, 100, 0., 100., 100, 0., 100.);
00094 
00095       sprintf (histo, "EE Amplitude gt 60 adc counts" );
00096       meEEUncalibRecHitsAmplitudeGt60adc_ = dbe_->book1D(histo, histo, 200, 0., 4000.);
00097       
00098       sprintf (histo, "EE Pedestal gt 60 adc counts" );
00099       meEEUncalibRecHitsPedestalGt60adc_ = dbe_->book1D(histo, histo, 50, 190., 210.);
00100       
00101       sprintf (histo, "EE Jitter gt 60 adc counts" );
00102       meEEUncalibRecHitsJitterGt60adc_ = dbe_->book1D(histo, histo, 100, 0., 100.);
00103       
00104       sprintf (histo, "EE Chi2 gt 60 adc counts" );
00105       meEEUncalibRecHitsChi2Gt60adc_ = dbe_->book1D(histo, histo, 100, 18000., 22000.);
00106 
00107       sprintf (histo, "EE RecHit Max Sample Ratio gt 60 adc counts"); 
00108       meEEUncalibRecHitMaxSampleRatioGt60adc_ = dbe_->book1D(histo, histo, 120, 0.90, 1.05);
00109 
00110       sprintf (histo, "EE Amplitude Full Map");
00111       meEEUncalibRecHitsAmpFullMap_ = dbe_->bookProfile2D(histo, histo, 100, 0., 100., 100, 0., 100., 200, 0., 4000.);
00112 
00113       sprintf (histo, "EE Pedestal Full Map");
00114       meEEUncalibRecHitsPedFullMap_ = dbe_->bookProfile2D(histo, histo, 100, 0., 100., 100, 0., 100., 50, 194., 201.);
00115     }
00116 }
00117 
00118 EcalEndcapRecHitsValidation::~EcalEndcapRecHitsValidation(){   
00119 
00120 }
00121 
00122 void EcalEndcapRecHitsValidation::beginJob(){  
00123 
00124 }
00125 
00126 void EcalEndcapRecHitsValidation::endJob(){
00127 
00128 }
00129 
00130 void EcalEndcapRecHitsValidation::analyze(const Event& e, const EventSetup& c){
00131 
00132   const EEUncalibratedRecHitCollection *EEUncalibRecHit = 0;
00133   Handle< EEUncalibratedRecHitCollection > EcalUncalibRecHitEE;
00134   e.getByLabel( EEuncalibrechitCollection_, EcalUncalibRecHitEE);
00135   if (EcalUncalibRecHitEE.isValid()) {
00136     EEUncalibRecHit = EcalUncalibRecHitEE.product() ;
00137   } else {
00138     return;
00139   }
00140   
00141   bool skipDigis = false;
00142   const EEDigiCollection *EEDigi = 0;
00143   Handle< EEDigiCollection > EcalDigiEE;
00144   e.getByLabel( EEdigiCollection_, EcalDigiEE);
00145   if (EcalDigiEE.isValid()) { 
00146     EEDigi = EcalDigiEE.product(); 
00147   } else { 
00148     skipDigis = true;
00149   }
00150   
00151   edm::ESHandle<EcalPedestals> ecalPeds; 
00152   c.get<EcalPedestalsRcd>().get(ecalPeds);
00153 
00154   // ---------------------- 
00155   // loop over UncalibRecHits
00156   for (EcalUncalibratedRecHitCollection::const_iterator uncalibRecHit = EEUncalibRecHit->begin(); uncalibRecHit != EEUncalibRecHit->end() ; ++uncalibRecHit)
00157     {
00158       EEDetId EEid = EEDetId(uncalibRecHit->id());
00159 
00160       int mySide = EEid.zside();      
00161 
00162       // general checks
00163       if (mySide > 0) { if (meEEUncalibRecHitsOccupancyPlus_)  meEEUncalibRecHitsOccupancyPlus_  ->Fill(EEid.ix(), EEid.iy()); }
00164       if (mySide < 0) { if (meEEUncalibRecHitsOccupancyMinus_) meEEUncalibRecHitsOccupancyMinus_ ->Fill(EEid.ix(), EEid.iy()); }
00165       if (meEEUncalibRecHitsAmplitude_)  meEEUncalibRecHitsAmplitude_  -> Fill(uncalibRecHit->amplitude());
00166       if (meEEUncalibRecHitsPedestal_)   meEEUncalibRecHitsPedestal_   -> Fill(uncalibRecHit->pedestal());
00167       if (meEEUncalibRecHitsJitter_)     meEEUncalibRecHitsJitter_     -> Fill(uncalibRecHit->jitter());
00168       if (meEEUncalibRecHitsChi2_)       meEEUncalibRecHitsChi2_       -> Fill(uncalibRecHit->chi2());
00169       if (meEEUncalibRecHitsAmpFullMap_) meEEUncalibRecHitsAmpFullMap_ -> Fill(EEid.ix(), EEid.iy(), uncalibRecHit->amplitude()); 
00170       if (meEEUncalibRecHitsPedFullMap_) meEEUncalibRecHitsPedFullMap_ -> Fill(EEid.ix(), EEid.iy(), uncalibRecHit->pedestal()); 
00171 
00172 
00173       // general checks, with threshold at 60 ADC counts
00174       if ( uncalibRecHit->amplitude() > 60 ) 
00175         {
00176           if (mySide > 0) { if (meEEUncalibRecHitsOccupancyPlusGt60adc_)  meEEUncalibRecHitsOccupancyPlusGt60adc_ ->Fill(EEid.ix(), EEid.iy()); }
00177           if (mySide < 0) { if (meEEUncalibRecHitsOccupancyMinusGt60adc_) meEEUncalibRecHitsOccupancyMinusGt60adc_->Fill(EEid.ix(), EEid.iy()); }
00178           if (meEEUncalibRecHitsAmplitudeGt60adc_)  meEEUncalibRecHitsAmplitudeGt60adc_  -> Fill(uncalibRecHit->amplitude());
00179           if (meEEUncalibRecHitsPedestalGt60adc_)   meEEUncalibRecHitsPedestalGt60adc_   -> Fill(uncalibRecHit->pedestal());
00180           if (meEEUncalibRecHitsJitterGt60adc_)     meEEUncalibRecHitsJitterGt60adc_     -> Fill(uncalibRecHit->jitter());
00181           if (meEEUncalibRecHitsChi2Gt60adc_)       meEEUncalibRecHitsChi2Gt60adc_       -> Fill(uncalibRecHit->chi2());
00182         }
00183 
00184       if ( ! skipDigis ) {
00185         // Find the rechit corresponding digi
00186         EEDigiCollection::const_iterator myDigi = EEDigi->find(EEid);
00187         // int sMax    = -1; // UNUSED
00188         double eMax = 0.;
00189         if (myDigi != EEDigi->end()){ 
00190           for (unsigned int sample = 0 ; sample < myDigi->size(); ++sample){
00191             EcalMGPASample thisSample = (*myDigi)[sample];
00192             double analogSample = thisSample.adc();
00193             if ( eMax < analogSample ){ 
00194               eMax = analogSample;
00195               // sMax = sample; // UNUSED
00196             }
00197           }
00198         }
00199         else
00200           continue;
00201       
00202         // ratio uncalibratedRecHit amplitude + ped / max energy digi  
00203         const EcalPedestals* myped = ecalPeds.product();
00204         EcalPedestalsMap::const_iterator it=myped->getMap().find( EEid );
00205         if( it != myped->getMap().end() ){
00206           
00207           if (eMax > (*it).mean_x1 + 5 * (*it).rms_x1 && eMax != 0 ){ //only real signal RecHit
00208             
00209             if ( meEEUncalibRecHitMaxSampleRatio_ )
00210               { meEEUncalibRecHitMaxSampleRatio_->Fill( (uncalibRecHit->amplitude()+uncalibRecHit->pedestal())/eMax); }
00211             
00212             if ( meEEUncalibRecHitMaxSampleRatioGt60adc_ && (uncalibRecHit->amplitude() > 60) ) 
00213               { meEEUncalibRecHitMaxSampleRatioGt60adc_->Fill( (uncalibRecHit->amplitude()+uncalibRecHit->pedestal())/eMax); }
00214             
00215             LogDebug("EcalRecHitsTaskInfo") << "endcap, eMax = " << eMax << " Amplitude = " << uncalibRecHit->amplitude()+uncalibRecHit->pedestal();  
00216           }
00217           else
00218             continue;
00219         }
00220         else
00221           continue;
00222       }
00223     } // loop over the UncalibratedRecHitCollection
00224 
00225 }