CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/RecoEgamma/Examples/plugins/ElectronIDAnalyzer.cc

Go to the documentation of this file.
00001 #include "RecoEgamma/Examples/plugins/ElectronIDAnalyzer.h"
00002 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00003 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00004 #include "DataFormats/Common/interface/ValueMap.h"
00005 
00006 ElectronIDAnalyzer::ElectronIDAnalyzer(const edm::ParameterSet& conf) : conf_(conf) {
00007   electronProducer_=conf.getParameter<std::string>("electronProducer") ;
00008   electronLabelRobustLoose_=conf.getParameter<std::string>("electronLabelRobustLoose") ;
00009   electronLabelRobustTight_=conf.getParameter<std::string>("electronLabelRobustTight") ; 
00010   electronLabelLoose_=conf.getParameter<std::string>("electronLabelLoose") ;
00011   electronLabelTight_=conf.getParameter<std::string>("electronLabelTight") ;
00012 }  
00013 
00014 void ElectronIDAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& c) {
00015 
00016   //Read selectrons
00017   edm::Handle<reco::GsfElectronCollection> electrons ;
00018   e.getByLabel(electronProducer_,electrons) ;
00019 
00020   //Read eID results
00021   std::vector<edm::Handle<edm::ValueMap<float> > > eIDValueMap(4); 
00022   //Robust-Loose 
00023   e.getByLabel( electronLabelRobustLoose_ , eIDValueMap[0] ); 
00024   const edm::ValueMap<float> & eIDmapRL = * eIDValueMap[0] ;
00025   //Robust-Tight 
00026   e.getByLabel( electronLabelRobustTight_ , eIDValueMap[1] ); 
00027   const edm::ValueMap<float> & eIDmapRT = * eIDValueMap[1] ;
00028   //Loose 
00029   e.getByLabel( electronLabelLoose_ , eIDValueMap[2] ); 
00030   const edm::ValueMap<float> & eIDmapL = * eIDValueMap[2] ;
00031   //Tight 
00032   e.getByLabel( electronLabelTight_ , eIDValueMap[3] ); 
00033   const edm::ValueMap<float> & eIDmapT = * eIDValueMap[3] ;
00034 
00035   // Loop over electrons
00036   for (unsigned int i = 0; i < electrons->size(); i++){
00037     edm::Ref<reco::GsfElectronCollection> electronRef(electrons,i);
00038     std::cout << "Event " << e.id() 
00039               << " , electron " << i+1 
00040               << " , Robust Loose = " << eIDmapRL[electronRef] 
00041               << " , Robust Tight = " << eIDmapRT[electronRef] 
00042               << " , Loose = " << eIDmapL[electronRef] 
00043               << " , Tight = " << eIDmapT[electronRef] 
00044               << std::endl;
00045   }
00046 
00047 }