CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/TopQuarkAnalysis/Examples/plugins/TopElecAnalyzer.cc

Go to the documentation of this file.
00001 #include "DataFormats/PatCandidates/interface/Electron.h"
00002 #include "TopQuarkAnalysis/Examples/plugins/TopElecAnalyzer.h"
00003 
00004 TopElecAnalyzer::TopElecAnalyzer(const edm::ParameterSet& cfg):
00005   input_  (cfg.getParameter<edm::InputTag>("input"  )),
00006   verbose_(cfg.getParameter<bool>         ("verbose"))
00007 {
00008   edm::Service<TFileService> fs;
00009   
00010   mult_ = fs->make<TH1F>("mult", "multiplicity (electrons)", 10,  0 ,   10);
00011   en_   = fs->make<TH1F>("en"  , "energy (electrons)"      , 60,  0., 300.);
00012   pt_   = fs->make<TH1F>("pt"  , "pt (electrons)"          , 60,  0., 300.);
00013   eta_  = fs->make<TH1F>("eta" , "eta (electrons)"         , 30, -3.,   3.);
00014   phi_  = fs->make<TH1F>("phi" , "phi (electrons)"         , 40, -4.,   4.);
00015 }
00016 
00017 TopElecAnalyzer::~TopElecAnalyzer()
00018 {
00019 }
00020 
00021 void
00022 TopElecAnalyzer::analyze(const edm::Event& evt, const edm::EventSetup& setup)
00023 {       
00024   edm::Handle<std::vector<pat::Electron> > elecs;
00025   evt.getByLabel(input_, elecs); 
00026 
00027   // fill histograms
00028 
00029   mult_->Fill( elecs->size() );
00030   for(std::vector<pat::Electron>::const_iterator elec=elecs->begin(); elec!=elecs->end(); ++elec){
00031     en_ ->Fill( elec->energy() );
00032     pt_ ->Fill( elec->pt()     );
00033     eta_->Fill( elec->eta()    );
00034     phi_->Fill( elec->phi()    );
00035   }
00036 
00037   // produce printout if desired
00038 
00039   if( elecs->size()<1 || !verbose_ )
00040     return;
00041 
00042   unsigned i=0;
00043 
00044   std::cout << "======================================================="
00045             << std::endl;
00046   std::cout << std::setw(5 ) << "ele :"
00047             << std::setw(13) << "et :"
00048             << std::setw(13) << "eta :"
00049             << std::setw(13) << "phi :"
00050             << std::setw(11) << "relIso" << std::endl;
00051   std::cout << "-------------------------------------------------------"
00052             << std::endl;
00053   for(std::vector<pat::Electron>::const_iterator elec=elecs->begin(); elec!=elecs->end(); ++elec){
00054     std::cout << std::setw(3 ) << i << " : "
00055               << std::setw(10) << elec->pt() << " : "
00056               << std::setw(10) << elec->eta() << " : "
00057               << std::setw(10) << elec->phi() << " : "
00058               << std::setw(10) << (elec->dr03TkSumPt()+elec->dr03EcalRecHitSumEt()+elec->dr03HcalTowerSumEt())/elec->et() << std::endl;
00059     i++;
00060   }
00061   std::cout << "======================================================="
00062             << std::endl;
00063 }
00064 
00065 void TopElecAnalyzer::beginJob()
00066 {
00067 }
00068 
00069 void TopElecAnalyzer::endJob()
00070 {
00071 }
00072