CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/Validation/EcalRecHits/src/EcalPreshowerRecHitsValidation.cc

Go to the documentation of this file.
00001 /*
00002  * \file EcalPreshowerRecHitsValidation.cc
00003  *
00004  * $Date: 2010/05/20 11:27:43 $
00005  * \author C. Rovelli
00006  *
00007  */
00008 
00009 #include <Validation/EcalRecHits/interface/EcalPreshowerRecHitsValidation.h>
00010 #include <DataFormats/EcalDetId/interface/ESDetId.h>
00011 #include <DataFormats/EcalDetId/interface/EEDetId.h>
00012 #include "DQMServices/Core/interface/DQMStore.h"
00013 
00014 using namespace cms;
00015 using namespace edm;
00016 using namespace std;
00017 
00018 
00019 EcalPreshowerRecHitsValidation::EcalPreshowerRecHitsValidation(const ParameterSet& ps){
00020 
00021 
00022   // ----------------------
00023   EEuncalibrechitCollection_ = ps.getParameter<edm::InputTag>("EEuncalibrechitCollection");
00024   EErechitCollection_        = ps.getParameter<edm::InputTag>("EErechitCollection");
00025   ESrechitCollection_        = ps.getParameter<edm::InputTag>("ESrechitCollection");
00026 
00027 
00028   // ---------------------- 
00029   // verbosity switch 
00030   verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
00031   
00032   // ----------------------                 
00033   // get hold of back-end interface 
00034   dbe_ = 0;
00035   dbe_ = Service<DQMStore>().operator->();                   
00036   if ( dbe_ ) {
00037     if ( verbose_ ) {
00038       dbe_->setVerbose(1);
00039     } else {
00040       dbe_->setVerbose(0);
00041     }
00042   }                                                                  
00043   if ( dbe_ ) {
00044     if ( verbose_ ) dbe_->showDirStructure();
00045   }
00046 
00047 
00048   // ----------------------  
00049   meESRecHitsEnergy_           = 0;                // total energy
00050   meESRecHitsEnergy_zp1st_     = 0;    
00051   meESRecHitsEnergy_zp2nd_     = 0;    
00052   meESRecHitsEnergy_zm1st_     = 0;    
00053   meESRecHitsEnergy_zm2nd_     = 0;    
00054   meESRecHitsMultip_           = 0;                // total multiplicity
00055   meESRecHitsMultip_zp1st_     = 0;    
00056   meESRecHitsMultip_zp2nd_     = 0;    
00057   meESRecHitsMultip_zm1st_     = 0;    
00058   meESRecHitsMultip_zm2nd_     = 0;    
00059   meESEERecHitsEnergy_zp_      = 0;                // versus EE energy 
00060   meESEERecHitsEnergy_zm_      = 0;      
00061 
00062   for (int kk=0; kk<32; kk++)
00063     { 
00064       meESRecHitsStripOccupancy_zp1st_[kk] = 0;   
00065       meESRecHitsStripOccupancy_zm1st_[kk] = 0;   
00066       meESRecHitsStripOccupancy_zp2nd_[kk] = 0;   
00067       meESRecHitsStripOccupancy_zm2nd_[kk] = 0;   
00068     }
00069 
00070 
00071   // ---------------------- 
00072   Char_t histo[200];
00073   if ( dbe_ ) 
00074     {
00075       dbe_->setCurrentFolder("EcalRecHitsV/EcalPreshowerRecHitsTask");
00076 
00077       sprintf (histo, "ES Energy" );
00078       meESRecHitsEnergy_ = dbe_->book1D(histo, histo, 210, -0.0005, 0.01);
00079       
00080       sprintf (histo, "ES Energy Plane1 Side+" );
00081       meESRecHitsEnergy_zp1st_ = dbe_->book1D(histo, histo, 210, -0.0005, 0.01);
00082 
00083       sprintf (histo, "ES Energy Plane2 Side+");
00084       meESRecHitsEnergy_zp2nd_ = dbe_->book1D(histo, histo, 210, -0.0005, 0.01);
00085      
00086       sprintf (histo, "ES Energy Plane1 Side-");
00087       meESRecHitsEnergy_zm1st_ = dbe_->book1D(histo, histo, 210, -0.0005, 0.01);
00088 
00089       sprintf (histo, "ES Energy Plane2 Side-");
00090       meESRecHitsEnergy_zm2nd_ = dbe_->book1D(histo, histo, 210, -0.0005, 0.01);
00091 
00092       sprintf (histo, "ES Multiplicity" );
00093       meESRecHitsMultip_ = dbe_->book1D(histo, histo, 100, 0., 700.);
00094 
00095       sprintf (histo, "ES Multiplicity Plane1 Side+");
00096       meESRecHitsMultip_zp1st_ = dbe_->book1D(histo, histo, 100, 0., 700.);
00097 
00098       sprintf (histo, "ES Multiplicity Plane2 Side+");
00099       meESRecHitsMultip_zp2nd_ = dbe_->book1D(histo, histo, 100, 0., 700.);
00100 
00101       sprintf (histo, "ES Multiplicity Plane1 Side-");
00102       meESRecHitsMultip_zm1st_ = dbe_->book1D(histo, histo, 100, 0., 700.);
00103 
00104       sprintf (histo, "ES Multiplicity Plane2 Side-");
00105       meESRecHitsMultip_zm2nd_ = dbe_->book1D(histo, histo, 100, 0., 700.);
00106 
00107       sprintf (histo, "Preshower EE vs ES energy Side+");
00108       meESEERecHitsEnergy_zp_ = dbe_->book2D(histo, histo, 100, 0., 0.2, 100, 0., 150.);
00109 
00110       sprintf (histo, "Preshower EE vs ES energy Side-");
00111       meESEERecHitsEnergy_zm_ = dbe_->book2D(histo, histo, 100, 0., 0.2, 100, 0., 150.);
00112 
00113       for (int kk=0; kk<32; kk++)
00114         { 
00115           sprintf(histo, "ES Occupancy Plane1 Side+ Strip%02d", kk+1);    
00116           meESRecHitsStripOccupancy_zp1st_[kk] = dbe_->book2D(histo, histo, 40, 0., 40., 40, 0., 40.);
00117 
00118           sprintf(histo, "ES Occupancy Plane2 Side+ Strip%02d", kk+1);    
00119           meESRecHitsStripOccupancy_zp2nd_[kk] = dbe_->book2D(histo, histo, 40, 0., 40., 40, 0., 40.);
00120 
00121           sprintf(histo, "ES Occupancy Plane1 Side- Strip%02d", kk+1);    
00122           meESRecHitsStripOccupancy_zm1st_[kk] = dbe_->book2D(histo, histo, 40, 0., 40., 40, 0., 40.);
00123 
00124           sprintf(histo, "ES Occupancy Plane2 Side- Strip%02d", kk+1);    
00125           meESRecHitsStripOccupancy_zm2nd_[kk] = dbe_->book2D(histo, histo, 40, 0., 40., 40, 0., 40.);
00126         }
00127     }
00128 }
00129 
00130 EcalPreshowerRecHitsValidation::~EcalPreshowerRecHitsValidation(){   
00131 
00132 }
00133 
00134 void EcalPreshowerRecHitsValidation::beginJob(){  
00135 
00136 }
00137 
00138 void EcalPreshowerRecHitsValidation::endJob(){
00139 
00140 }
00141 
00142 void EcalPreshowerRecHitsValidation::analyze(const Event& e, const EventSetup& c){
00143 
00144   const ESRecHitCollection *ESRecHit = 0;
00145   Handle<ESRecHitCollection> EcalRecHitES;
00146   e.getByLabel( ESrechitCollection_, EcalRecHitES);
00147   if (EcalRecHitES.isValid()) {
00148     ESRecHit = EcalRecHitES.product ();
00149   } else {
00150     return;
00151   }
00152 
00153   bool skipEE = false;
00154   const EERecHitCollection *EERecHit = 0;
00155   Handle<EERecHitCollection> EcalRecHitEE;
00156   e.getByLabel( EErechitCollection_, EcalRecHitEE);
00157   if (EcalRecHitEE.isValid()){   
00158     EERecHit = EcalRecHitEE.product ();  
00159   } else {
00160     skipEE = true;
00161   }
00162 
00163   const EEUncalibratedRecHitCollection *EEUncalibRecHit = 0;
00164   Handle< EEUncalibratedRecHitCollection > EcalUncalibRecHitEE;
00165   e.getByLabel( EEuncalibrechitCollection_, EcalUncalibRecHitEE);
00166   if (EcalUncalibRecHitEE.isValid()) {
00167     EEUncalibRecHit = EcalUncalibRecHitEE.product() ;
00168   } else {
00169     skipEE = true;
00170   }
00171 
00172 
00173 
00174   // ---------------------- 
00175   // loop over RecHits
00176   // multiplicities
00177   int mult_tot       = 0;
00178   int mult_zp1st     = 0;
00179   int mult_zp2nd     = 0;
00180   int mult_zm1st     = 0;
00181   int mult_zm2nd     = 0;
00182 
00183   // energies
00184   float ene_zp1st      = 0.;
00185   float ene_zp2nd      = 0.;
00186   float ene_zm1st      = 0.;
00187   float ene_zm2nd      = 0.;
00188 
00189 
00190   // ES
00191   for (ESRecHitCollection::const_iterator recHit = ESRecHit->begin(); recHit != ESRecHit->end() ; ++recHit)
00192     {
00193       ESDetId ESid = ESDetId(recHit->id());
00194 
00195       int zside = ESid.zside();
00196       int plane = ESid.plane();
00197       int six   = ESid.six();
00198       int siy   = ESid.siy();
00199       int strip = ESid.strip();
00200       
00201       // global
00202       mult_tot++;
00203       if (meESRecHitsEnergy_) meESRecHitsEnergy_ ->Fill(recHit->energy());      
00204       
00205       // side +, plane 1
00206       if ( (zside == +1) && (plane == 1) )
00207         { 
00208           mult_zp1st++;
00209           ene_zp1st += recHit->energy();
00210           if ( meESRecHitsEnergy_zp1st_ )                 { meESRecHitsEnergy_zp1st_                 -> Fill(recHit->energy()); }
00211           if ( meESRecHitsStripOccupancy_zp1st_[strip-1] ){ meESRecHitsStripOccupancy_zp1st_[strip-1]-> Fill( six, siy ); }
00212         }
00213       
00214 
00215       // side +, plane 2
00216       if ( (zside == +1) && (plane == 2) )
00217         { 
00218           mult_zp2nd++; 
00219           ene_zp2nd += recHit->energy();
00220           if ( meESRecHitsEnergy_zp2nd_ )                 { meESRecHitsEnergy_zp2nd_                 -> Fill(recHit->energy()); }
00221           if ( meESRecHitsStripOccupancy_zp2nd_[strip-1] ){ meESRecHitsStripOccupancy_zp2nd_[strip-1]-> Fill( six, siy ); }
00222         }
00223 
00224 
00225       // side -, plane 1
00226       if ( (zside == -1) && (plane == 1) )
00227         { 
00228           mult_zm1st++;
00229           ene_zm1st += recHit->energy(); 
00230           if ( meESRecHitsEnergy_zm1st_ )                 { meESRecHitsEnergy_zm1st_                 -> Fill(recHit->energy()); }
00231           if ( meESRecHitsStripOccupancy_zm1st_[strip-1] ){ meESRecHitsStripOccupancy_zm1st_[strip-1]-> Fill( six, siy ); }
00232         }
00233 
00234 
00235       // side +, plane 2
00236       if ( (zside == -1) && (plane == 2) )
00237         { 
00238           mult_zm2nd ++; 
00239           ene_zm2nd += recHit->energy();
00240           if ( meESRecHitsEnergy_zm2nd_ )                 { meESRecHitsEnergy_zm2nd_                 -> Fill(recHit->energy()); }
00241           if ( meESRecHitsStripOccupancy_zm2nd_[strip-1] ){ meESRecHitsStripOccupancy_zm2nd_[strip-1]-> Fill( six, siy ); }
00242         }
00243 
00244     }  // loop over the ES RecHitCollection
00245 
00246 
00247 
00248   // EE
00249   double zpEE = 0.;
00250   double zmEE = 0.;
00251   if ( ! skipEE ) {
00252     
00253     for (EcalUncalibratedRecHitCollection::const_iterator uncalibRecHit = EEUncalibRecHit->begin(); uncalibRecHit != EEUncalibRecHit->end() ; ++uncalibRecHit)
00254       {
00255         EEDetId EEid = EEDetId(uncalibRecHit->id());
00256         int mySide = EEid.zside();
00257         
00258         // Find corresponding recHit
00259         EcalRecHitCollection::const_iterator myRecHit = EERecHit->find(EEid);
00260         
00261         if (myRecHit != EERecHit->end() )
00262           {
00263             if (mySide > 0) { zpEE = zpEE + myRecHit->energy(); }
00264             if (mySide < 0) { zmEE = zmEE + myRecHit->energy(); }
00265           }
00266       } 
00267   }
00268   
00269 
00270   // filling histos
00271   if (meESRecHitsMultip_)            { meESRecHitsMultip_           -> Fill(mult_tot);   }
00272   if (meESRecHitsMultip_zp1st_ )     { meESRecHitsMultip_zp1st_     -> Fill(mult_zp1st); }
00273   if (meESRecHitsMultip_zp2nd_ )     { meESRecHitsMultip_zp2nd_     -> Fill(mult_zp2nd); }
00274   if (meESRecHitsMultip_zm1st_ )     { meESRecHitsMultip_zm1st_     -> Fill(mult_zm1st); }
00275   if (meESRecHitsMultip_zm2nd_ )     { meESRecHitsMultip_zm2nd_     -> Fill(mult_zm2nd); }
00276   if (meESEERecHitsEnergy_zp_)       { meESEERecHitsEnergy_zp_      -> Fill( (ene_zp1st + 0.7*ene_zp2nd)/0.09, zpEE ); }
00277   if (meESEERecHitsEnergy_zm_)       { meESEERecHitsEnergy_zm_      -> Fill( (ene_zm1st + 0.7*ene_zm2nd)/0.09, zmEE ); }
00278 }