CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DQM/HLTEvF/plugins/HLTAlCaMonEcalPhiSym.cc

Go to the documentation of this file.
00001 /*
00002  * \file HLTAlCaMonEcalPhiSym.cc
00003  *
00004  * \author Andrea Gozzelino - Universita%G�%@ e INFN Torino
00005  * \author Stefano Argiro
00006  *        
00007  * $Date: 2010/08/07 14:55:56 $
00008  * $Revision: 1.5 $
00009  *
00010  *
00011  * Description: Monitoring of Phi Symmetry Calibration Stream  
00012 */
00013 
00014 
00015 #include "FWCore/Framework/interface/Event.h"
00016 #include "FWCore/Framework/interface/EventSetup.h"
00017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00018 #include "FWCore/ServiceRegistry/interface/Service.h"
00019 
00020 // DQM include files
00021 
00022 #include "DQMServices/Core/interface/MonitorElement.h"
00023 
00024 // work on collections
00025 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00026 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00027 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00028 
00029 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
00030 
00031 #include "DQMServices/Core/interface/DQMStore.h"
00032 #include "DQM/HLTEvF/interface/HLTAlCaMonEcalPhiSym.h"
00033 
00034 
00035 using namespace std;
00036 using namespace edm;
00037 
00038 
00039 // ******************************************
00040 // constructors
00041 // *****************************************
00042 
00043 HLTAlCaMonEcalPhiSym::HLTAlCaMonEcalPhiSym( const edm::ParameterSet& ps ) :
00044 eventCounter_(0)
00045 {
00046   dbe_ = Service<DQMStore>().operator->();
00047   folderName_ = ps.getUntrackedParameter<std::string>("FolderName","ALCAStreamEcalPhiSym");
00048   prescaleFactor_ = ps.getUntrackedParameter<int>("prescaleFactor",1);
00049   productMonitoredEB_= ps.getUntrackedParameter<edm::InputTag>("AlCaStreamEBTag");
00050   productMonitoredEE_= ps.getUntrackedParameter<edm::InputTag>("AlCaStreamEETag");
00051 
00052   saveToFile_=ps.getUntrackedParameter<bool>("SaveToFile",false);
00053   fileName_=  ps.getUntrackedParameter<std::string>("FileName","MonitorAlCaEcalPhiSym.root");
00054 
00055   // histogram parameters
00056 
00057   // Distribution of rechits in iPhi
00058   hiPhiDistrEB_nbin_= ps.getUntrackedParameter<int>("hiPhiDistrEB_nbin",361);
00059   hiPhiDistrEB_min_=  ps.getUntrackedParameter<double>("hiPhiDistrEB_min",1.);
00060   hiPhiDistrEB_max_=  ps.getUntrackedParameter<double>("hiPhiDistrEB_max",361.);
00061     
00062   // Distribution of rechits in iEta
00063   hiEtaDistrEB_nbin_= ps.getUntrackedParameter<int>("hiEtaDistrEB_nbin",171); 
00064   hiEtaDistrEB_min_ = ps.getUntrackedParameter<double>("hiEtaDistrEB_min",-85);
00065   hiEtaDistrEB_max_ = ps.getUntrackedParameter<double>("hiEtaDistrEB_max",85);
00066   
00067   // Energy Distribution of rechits  
00068   hRechitEnergyEB_nbin_=ps.getUntrackedParameter<int>("hRechitEnergyEB_nbin",160);
00069   hRechitEnergyEB_min_=ps.getUntrackedParameter<double>("hRechitEnergyEB_min",0.);
00070   hRechitEnergyEB_max_= ps.getUntrackedParameter<double>("hRechitEnergyEB_max",2.);
00071   
00072   // Distribution of total event energy
00073   hEventEnergyEB_nbin_= ps.getUntrackedParameter<int>("hEventEnergyEB_nbin",100);
00074   hEventEnergyEB_min_ = ps.getUntrackedParameter<double>("hEventEnergyEB_min",0.);
00075   hEventEnergyEB_max_ = ps.getUntrackedParameter<double>("hEventEnergyEB_max",20.);
00076   
00077   // Distribution of number of RecHits
00078   hNRecHitsEB_nbin_= ps.getUntrackedParameter<int>("hNRecHitsEB_nbin",100);
00079   hNRecHitsEB_min_ = ps.getUntrackedParameter<double>("hNRecHitsEB_min",0);
00080   hNRecHitsEB_max_ = ps.getUntrackedParameter<double>("hNRecHitsEB_max",250);
00081   
00082   // Distribution of Mean energy per rechit
00083   hMeanRecHitEnergyEB_nbin_= ps.getUntrackedParameter<int>("hMeanRecHitEnergyEB_nbin",50);
00084   hMeanRecHitEnergyEB_min_ = ps.getUntrackedParameter<int>("hMeanRecHitEnergyEB_min",0); 
00085   hMeanRecHitEnergyEB_max_ = ps.getUntrackedParameter<int>("hMeanRecHitEnergyEB_max",2);
00086   
00087     // Energy Distribution of rechits  
00088   hRechitEnergyEE_nbin_=ps.getUntrackedParameter<int>("hRechitEnergyEE_nbin",160);
00089   hRechitEnergyEE_min_ =ps.getUntrackedParameter<double>("hRechitEnergyEE_min",0.);
00090   hRechitEnergyEE_max_ =ps.getUntrackedParameter<double>("hRechitEnergyEE_max",3.);
00091   
00092   // Distribution of total event energy
00093   hEventEnergyEE_nbin_= ps.getUntrackedParameter<int>("hEventEnergyEE_nbin",100);
00094   hEventEnergyEE_min_ = ps.getUntrackedParameter<double>("hEventEnergyEE_min",0.);
00095   hEventEnergyEE_max_ = ps.getUntrackedParameter<double>("hEventEnergyEE_max",20.);
00096   
00097   // Distribution of number of RecHits
00098   hNRecHitsEE_nbin_= ps.getUntrackedParameter<int>("hNRecHitsEE_nbin",100);
00099   hNRecHitsEE_min_ = ps.getUntrackedParameter<double>("hNRecHitsEE_min",0);
00100   hNRecHitsEE_max_ = ps.getUntrackedParameter<double>("hNRecHitsEE_max",250);
00101   
00102   // Distribution of Mean energy per rechit
00103   hMeanRecHitEnergyEE_nbin_= ps.getUntrackedParameter<int>("hMeanRecHitEnergyEE_nbin",50);
00104   hMeanRecHitEnergyEE_min_ = ps.getUntrackedParameter<double>("hMeanRecHitEnergyEE_min",0); 
00105   hMeanRecHitEnergyEE_max_ = ps.getUntrackedParameter<double>("hMeanRecHitEnergyEE_max",5);
00106 
00107  
00108 
00109 }
00110 
00111 
00112 HLTAlCaMonEcalPhiSym::~HLTAlCaMonEcalPhiSym()
00113 {}
00114 
00115 
00116 //--------------------------------------------------------
00117 void HLTAlCaMonEcalPhiSym::beginJob(){
00118 
00119 
00120   // create and cd into new folder
00121   dbe_->setCurrentFolder(folderName_);
00122 
00123   // book some histograms 1D
00124   hiPhiDistrEB_ = 
00125     dbe_->book1D("iphiDistributionEB", "RechitEB iphi",
00126                  hiPhiDistrEB_nbin_, 
00127                  hiPhiDistrEB_min_,
00128                  hiPhiDistrEB_max_);
00129 
00130   hiPhiDistrEB_->setAxisTitle("i#phi ", 1);
00131   hiPhiDistrEB_->setAxisTitle("# rechits", 2);
00132 
00133 
00134   hiEtaDistrEB_ = dbe_->book1D("iEtaDistributionEB", "RechitEB ieta",  
00135                                hiEtaDistrEB_nbin_,
00136                                hiEtaDistrEB_min_, 
00137                                hiEtaDistrEB_max_ );
00138 
00139   hiEtaDistrEB_->setAxisTitle("eta", 1);
00140   hiEtaDistrEB_->setAxisTitle("#rechits", 2);
00141 
00142 
00143   hRechitEnergyEB_ = dbe_->book1D("rhEnergyEB","rechits energy EB",
00144                                   hRechitEnergyEB_nbin_,
00145                                   hRechitEnergyEB_min_,
00146                                   hRechitEnergyEB_max_);
00147 
00148   hRechitEnergyEB_->setAxisTitle("energy (GeV) ",1);
00149   hRechitEnergyEB_->setAxisTitle("#rechits",2);
00150 
00151   hEventEnergyEB_ = dbe_->book1D("eventEnergyEB","event energy EB",
00152                                  hEventEnergyEB_nbin_,
00153                                  hEventEnergyEB_min_,
00154                                  hEventEnergyEB_max_);
00155 
00156   hEventEnergyEB_->setAxisTitle("energy (GeV) ",1);
00157 
00158   hNRecHitsEB_ = dbe_->book1D("nRechitsEB","#rechits in event EB",
00159                               hNRecHitsEB_nbin_,
00160                               hNRecHitsEB_min_,
00161                               hNRecHitsEB_max_);
00162 
00163   hNRecHitsEB_->setAxisTitle("rechits ",1);
00164  
00165   hMeanRecHitEnergyEB_ = dbe_->book1D("meanEnergyEB","Mean rechit energy EB",
00166                                       hMeanRecHitEnergyEB_nbin_,
00167                                       hMeanRecHitEnergyEB_min_,
00168                                       hMeanRecHitEnergyEB_max_);
00169 
00170   hMeanRecHitEnergyEB_-> setAxisTitle("Mean Energy [GeV] ",1);
00171  
00172   
00173   hRechitEnergyEE_ = dbe_->book1D("rhEnergyEE","rechits energy EE",
00174                                   hRechitEnergyEE_nbin_ ,
00175                                   hRechitEnergyEE_min_ ,
00176                                   hRechitEnergyEE_max_ );
00177 
00178   hRechitEnergyEE_->setAxisTitle("energy (GeV) ",1);
00179   hRechitEnergyEE_->setAxisTitle("#rechits",2);
00180 
00181   hEventEnergyEE_ = dbe_->book1D("eventEnergyEE","event energy EE",
00182                                  hEventEnergyEE_nbin_,
00183                                  hEventEnergyEE_min_,
00184                                  hEventEnergyEE_max_);
00185 
00186   hEventEnergyEE_->setAxisTitle("energy (GeV) ",1);
00187 
00188   hNRecHitsEE_ = dbe_->book1D("nRechitsEE","#rechits in event EE" ,
00189                               hNRecHitsEE_nbin_,
00190                               hNRecHitsEE_min_,
00191                               hNRecHitsEE_max_);
00192 
00193   hNRecHitsEE_->setAxisTitle("rechits ",1);
00194  
00195   hMeanRecHitEnergyEE_ = dbe_->book1D("meanEnergyEE","Mean rechit energy EE",
00196                                       hMeanRecHitEnergyEE_nbin_ ,
00197                                       hMeanRecHitEnergyEE_min_ ,
00198                                       hMeanRecHitEnergyEE_max_ );
00199 
00200   hMeanRecHitEnergyEE_-> setAxisTitle("Mean Energy [GeV] ",1);
00201 
00202 }
00203 
00204 //--------------------------------------------------------
00205 void HLTAlCaMonEcalPhiSym::beginRun(const edm::Run& r, const EventSetup& context) {
00206 
00207 }
00208 
00209 //--------------------------------------------------------
00210 void HLTAlCaMonEcalPhiSym::beginLuminosityBlock(const LuminosityBlock& lumiSeg, 
00211      const EventSetup& context) {
00212   
00213 }
00214 
00215 //-------------------------------------------------------------
00216 
00217 void HLTAlCaMonEcalPhiSym::analyze(const Event& iEvent, 
00218                                const EventSetup& iSetup ){  
00219  
00220   if (eventCounter_% prescaleFactor_ ) return; 
00221   eventCounter_++;
00222     
00223   edm::Handle<EcalRecHitCollection> rhEB;
00224   edm::Handle<EcalRecHitCollection> rhEE;
00225  
00226   iEvent.getByLabel(productMonitoredEB_, rhEB); 
00227   iEvent.getByLabel(productMonitoredEE_, rhEE);
00228 
00229   EcalRecHitCollection::const_iterator itb;
00230 
00231   // fill EB histos
00232   if (rhEB.isValid()){
00233     float etot =0;
00234     for(itb=rhEB->begin(); itb!=rhEB->end(); ++itb){
00235 
00236       EBDetId id(itb->id());
00237       
00238       hiPhiDistrEB_->Fill(id.iphi());
00239       hiEtaDistrEB_->Fill(id.ieta());
00240       hRechitEnergyEB_->Fill(itb->energy());
00241 
00242       etot+= itb->energy();      
00243     } // Eb rechits
00244     
00245     hNRecHitsEB_->Fill(rhEB->size());
00246     hMeanRecHitEnergyEB_->Fill(etot/rhEB->size());
00247     hEventEnergyEB_->Fill(etot);
00248 
00249   } // if valid
00250 
00251   // fill EE histos
00252 
00253   EcalRecHitCollection::const_iterator ite;
00254 
00255   if (rhEE.isValid()){
00256 
00257     float etot =0;
00258     for(ite=rhEE->begin(); ite!=rhEE->end(); ++ite){
00259 
00260       EEDetId id(ite->id());
00261       hRechitEnergyEE_->Fill(ite->energy());
00262       etot+= ite->energy();      
00263     } // EE rechits
00264     
00265     hNRecHitsEE_->Fill(rhEE->size());
00266     hMeanRecHitEnergyEE_->Fill(etot/rhEE->size());
00267     hEventEnergyEE_->Fill(etot);
00268   }
00269 
00270 
00271 } //analyze
00272 
00273 
00274 
00275 
00276 //--------------------------------------------------------
00277 void HLTAlCaMonEcalPhiSym::endLuminosityBlock(const LuminosityBlock& lumiSeg, 
00278                                           const EventSetup& context) {
00279 }
00280 //--------------------------------------------------------
00281 void HLTAlCaMonEcalPhiSym::endRun(const Run& r, const EventSetup& context){
00282 
00283 }
00284 //--------------------------------------------------------
00285 void HLTAlCaMonEcalPhiSym::endJob(){
00286   
00287   if (saveToFile_) {
00288      dbe_->save(fileName_);
00289   }
00290   
00291 }
00292 
00293