CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/RecoEgamma/ElectronIdentification/src/ClassBasedElectronID.cc

Go to the documentation of this file.
00001 #include "RecoEgamma/ElectronIdentification/interface/ClassBasedElectronID.h"
00002 
00003 // ===========================================================================================================
00004 void ClassBasedElectronID::setup(const edm::ParameterSet& conf) 
00005 // ===========================================================================================================
00006 {
00007 
00008 
00009   // Get all the parameters
00010   baseSetup(conf);
00011   
00012   quality_ =  conf.getParameter<std::string>("electronQuality");
00013   
00014         if(quality_=="Eff95Cuts") {
00015                 cuts_ = conf.getParameter<edm::ParameterSet>("Eff95Cuts");
00016         }
00017         
00018         else if(quality_=="Eff90Cuts") {
00019                 cuts_ = conf.getParameter<edm::ParameterSet>("Eff90Cuts");
00020         }
00021         
00022         else {
00023     edm::LogError("ClassBasedElectronID") << "Invalid electronQuality parameter: must be tight, medium or loose." ;
00024     exit (1);
00025   }
00026   
00027 } // end of setup
00028 
00029 double ClassBasedElectronID::result(const reco::GsfElectron* electron,
00030                                     const edm::Event& e ,
00031                                                                         const edm::EventSetup& es) 
00032 {
00033 
00034   //determine which element of the cut arrays in cfi file to read
00035   //depending on the electron classification
00036   int icut=0;
00037   int elClass = electron->classification() ;
00038   if (electron->isEB()) //barrel
00039      {
00040        if (elClass == reco::GsfElectron::GOLDEN)    icut=0;
00041        if (elClass == reco::GsfElectron::BIGBREM)   icut=1;
00042        if (elClass == reco::GsfElectron::SHOWERING) icut=2;
00043        if (elClass == reco::GsfElectron::GAP)       icut=6;
00044      }
00045   if (electron->isEE()) //endcap
00046      {
00047        if (elClass == reco::GsfElectron::GOLDEN)    icut=3;
00048        if (elClass == reco::GsfElectron::BIGBREM)   icut=4;
00049        if (elClass == reco::GsfElectron::SHOWERING) icut=5;
00050        if (elClass == reco::GsfElectron::GAP)       icut=7;
00051      }
00052   if (elClass == reco::GsfElectron::UNKNOWN) 
00053      {
00054        edm::LogError("ClassBasedElectronID") << "Error: unrecognized electron classification ";
00055        return 1.;
00056      }
00057 
00058   bool useDeltaEtaIn       = true;
00059   bool useSigmaIetaIeta    = true;
00060   bool useHoverE           = true;
00061   bool useEoverPOut        = true;
00062   bool useDeltaPhiInCharge = true;
00063 
00064   // DeltaEtaIn
00065   if (useDeltaEtaIn) { 
00066     double value = electron->deltaEtaSuperClusterTrackAtVtx();
00067     std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("deltaEtaIn");
00068     if (fabs(value)>maxcut[icut]) return 0.;
00069   } 
00070 
00071   // SigmaIetaIeta
00072   if(useSigmaIetaIeta) {
00073     double value = electron->sigmaIetaIeta() ; 
00074     std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("sigmaIetaIetaMax");
00075     std::vector<double> mincut = cuts_.getParameter<std::vector<double> >("sigmaIetaIetaMin");
00076     if(value<mincut[icut] || value>maxcut[icut]) return 0.;   
00077   } 
00078 
00079   // H/E
00080   if (useHoverE) { //_[variables_]) {
00081     double value = electron->hadronicOverEm();
00082     std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("HoverE");
00083     if (value>maxcut[icut]) return 0.;
00084   } // if use
00085  
00086   // Eseed/Pout
00087   if (useEoverPOut) { 
00088         double value = electron->eSeedClusterOverPout();
00089     std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("EoverPOutMax");
00090     std::vector<double> mincut = cuts_.getParameter<std::vector<double> >("EoverPOutMin");
00091     if (value<mincut[icut] || value>maxcut[icut]) return 0.;
00092   } 
00093 
00094   // DeltaPhiIn*Charge
00095   if (useDeltaPhiInCharge) { 
00096     double value1 = electron->deltaPhiSuperClusterTrackAtVtx();
00097     double value2 = electron->charge();
00098     double value  = value1*value2;
00099     std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("deltaPhiInChargeMax");
00100     std::vector<double> mincut = cuts_.getParameter<std::vector<double> >("deltaPhiInChargeMin");
00101     if (value<mincut[icut] || value>maxcut[icut]) return 0.;
00102   } 
00103   
00104   return 1.;
00105 
00106 }