CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/RecoEgamma/ElectronIdentification/src/ElectronLikelihood.cc

Go to the documentation of this file.
00001 #include "FWCore/Utilities/interface/Exception.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00004 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00005 
00006 #include "RecoEgamma/ElectronIdentification/interface/ElectronLikelihood.h"
00007 #include <iostream>
00008 
00009 
00010 ElectronLikelihood::ElectronLikelihood (const ElectronLikelihoodCalibration *calibration,
00011                                         LikelihoodSwitches eleIDSwitches,
00012                                         std::string signalWeightSplitting,
00013                                         std::string backgroundWeightSplitting,
00014                                         bool splitSignalPdfs,
00015                                         bool splitBackgroundPdfs) :
00016   _EB0lt15lh (new LikelihoodPdfProduct ("electronID_EB0_ptLt15_likelihood",0,0)) ,
00017   _EB1lt15lh (new LikelihoodPdfProduct ("electronID_EB1_ptLt15_likelihood",1,0)) ,
00018   _EElt15lh (new LikelihoodPdfProduct ("electronID_EE_ptLt15_likelihood",2,0)) ,
00019   _EB0gt15lh (new LikelihoodPdfProduct ("electronID_EB0_ptGt15_likelihood",0,1)) ,
00020   _EB1gt15lh (new LikelihoodPdfProduct ("electronID_EB1_ptGt15_likelihood",1,1)) ,
00021   _EEgt15lh (new LikelihoodPdfProduct ("electronID_EE_ptGt15_likelihood",2,1)) ,
00022   m_eleIDSwitches (eleIDSwitches) ,
00023   m_signalWeightSplitting (signalWeightSplitting), 
00024   m_backgroundWeightSplitting (backgroundWeightSplitting),
00025   m_splitSignalPdfs (splitSignalPdfs), 
00026   m_splitBackgroundPdfs (splitBackgroundPdfs)  
00027 {
00028   Setup (calibration,
00029          signalWeightSplitting, backgroundWeightSplitting,
00030          splitSignalPdfs, splitBackgroundPdfs) ;
00031 }
00032 
00033 
00034 
00035 // --------------------------------------------------------
00036 
00037 
00038 
00039 ElectronLikelihood::~ElectronLikelihood () {
00040   delete _EB0lt15lh ;
00041   delete _EB1lt15lh ;
00042   delete _EElt15lh ;
00043   delete _EB0gt15lh ;
00044   delete _EB1gt15lh ;
00045   delete _EEgt15lh ;
00046 }
00047 
00048 
00049 
00050 // --------------------------------------------------------
00051 
00052 
00053 void 
00054 ElectronLikelihood::Setup (const ElectronLikelihoodCalibration *calibration,
00055                            std::string signalWeightSplitting,
00056                            std::string backgroundWeightSplitting,
00057                            bool splitSignalPdfs,
00058                            bool splitBackgroundPdfs) 
00059 {
00060 
00061   // ECAL BARREL0 (|eta|<1.0) LIKELIHOOD - Pt < 15 GeV region
00062   _EB0lt15lh->initFromDB (calibration) ;
00063 
00064   _EB0lt15lh->addSpecies ("electrons") ;
00065   _EB0lt15lh->addSpecies ("hadrons") ;
00066 
00067   if(signalWeightSplitting.compare("class")==0) {
00068     _EB0lt15lh->setSplitFrac ("electrons", "class0") ;
00069     _EB0lt15lh->setSplitFrac ("electrons", "class1") ;
00070   }
00071   else {
00072     throw cms::Exception("BadConfig") << "Only class (non-showering / showering)"
00073                                       << " and fullclass (golden / bigbrem / narrow / showering)" 
00074                                       << " splitting is implemented right now";
00075   }
00076 
00077   if (m_eleIDSwitches.m_useDeltaPhi)     _EB0lt15lh->addPdf ("electrons", "dPhi",          splitSignalPdfs) ;   
00078   if (m_eleIDSwitches.m_useDeltaEta)     _EB0lt15lh->addPdf ("electrons", "dEta",          splitSignalPdfs) ;
00079   if (m_eleIDSwitches.m_useEoverP)       _EB0lt15lh->addPdf ("electrons", "EoP",           splitSignalPdfs) ;
00080   if (m_eleIDSwitches.m_useHoverE)       _EB0lt15lh->addPdf ("electrons", "HoE",           splitSignalPdfs) ;
00081   if (m_eleIDSwitches.m_useSigmaEtaEta)  _EB0lt15lh->addPdf ("electrons", "sigmaIEtaIEta", splitSignalPdfs) ;
00082   if (m_eleIDSwitches.m_useSigmaPhiPhi)  _EB0lt15lh->addPdf ("electrons", "sigmaIPhiIPhi", splitSignalPdfs) ;
00083   if (m_eleIDSwitches.m_useFBrem)        _EB0lt15lh->addPdf ("electrons", "fBrem",         splitSignalPdfs) ;
00084   if (m_eleIDSwitches.m_useOneOverEMinusOneOverP)        _EB0lt15lh->addPdf ("electrons", "OneOverEMinusOneOverP",         splitSignalPdfs) ;
00085 
00086   if(backgroundWeightSplitting.compare("class")==0) {
00087     _EB0lt15lh->setSplitFrac ("hadrons", "class0") ;
00088     _EB0lt15lh->setSplitFrac ("hadrons", "class1") ;
00089   }
00090   else {
00091     throw cms::Exception("BadConfig") << "Only class (0 brem clusters / >=1 brem clusters)"
00092                                       << " splitting is implemented right now";
00093   }
00094 
00095   if (m_eleIDSwitches.m_useDeltaPhi)     _EB0lt15lh->addPdf ("hadrons", "dPhi",          splitBackgroundPdfs) ;   
00096   if (m_eleIDSwitches.m_useDeltaEta)     _EB0lt15lh->addPdf ("hadrons", "dEta",          splitBackgroundPdfs) ;
00097   if (m_eleIDSwitches.m_useEoverP)       _EB0lt15lh->addPdf ("hadrons", "EoP",           splitBackgroundPdfs) ;
00098   if (m_eleIDSwitches.m_useHoverE)       _EB0lt15lh->addPdf ("hadrons", "HoE",           splitBackgroundPdfs) ;
00099   if (m_eleIDSwitches.m_useSigmaEtaEta)  _EB0lt15lh->addPdf ("hadrons", "sigmaIEtaIEta", splitBackgroundPdfs) ;
00100   if (m_eleIDSwitches.m_useSigmaPhiPhi)  _EB0lt15lh->addPdf ("hadrons", "sigmaIPhiIPhi", splitBackgroundPdfs) ;
00101   if (m_eleIDSwitches.m_useFBrem)        _EB0lt15lh->addPdf ("hadrons", "fBrem",         splitBackgroundPdfs) ;
00102   if (m_eleIDSwitches.m_useOneOverEMinusOneOverP)        _EB0lt15lh->addPdf ("hadrons", "OneOverEMinusOneOverP",         splitBackgroundPdfs) ;
00103 
00104   // ECAL BARREL0 (|eta|<1.0) LIKELIHOOD - Pt >= 15 GeV region
00105   _EB0gt15lh->initFromDB (calibration) ;
00106 
00107   _EB0gt15lh->addSpecies ("electrons") ;  
00108   _EB0gt15lh->addSpecies ("hadrons") ;
00109 
00110   if(signalWeightSplitting.compare("class")==0) {
00111     _EB0gt15lh->setSplitFrac ("electrons", "class0") ;
00112     _EB0gt15lh->setSplitFrac ("electrons", "class1") ;
00113   }
00114   else {
00115     throw cms::Exception("BadConfig") << "Only class (0 brem clusters / >=1 brem clusters)"
00116                                       << " splitting is implemented right now";
00117   }
00118 
00119   if (m_eleIDSwitches.m_useDeltaPhi)     _EB0gt15lh->addPdf ("electrons", "dPhi",          splitSignalPdfs) ;   
00120   if (m_eleIDSwitches.m_useDeltaEta)     _EB0gt15lh->addPdf ("electrons", "dEta",          splitSignalPdfs) ;
00121   if (m_eleIDSwitches.m_useEoverP)       _EB0gt15lh->addPdf ("electrons", "EoP",           splitSignalPdfs) ;
00122   if (m_eleIDSwitches.m_useHoverE)       _EB0gt15lh->addPdf ("electrons", "HoE",           splitSignalPdfs) ;
00123   if (m_eleIDSwitches.m_useSigmaEtaEta)  _EB0gt15lh->addPdf ("electrons", "sigmaIEtaIEta", splitSignalPdfs) ;
00124   if (m_eleIDSwitches.m_useSigmaPhiPhi)  _EB0gt15lh->addPdf ("electrons", "sigmaIPhiIPhi", splitSignalPdfs) ;
00125   if (m_eleIDSwitches.m_useFBrem)        _EB0gt15lh->addPdf ("electrons", "fBrem",         splitSignalPdfs) ;
00126   if (m_eleIDSwitches.m_useOneOverEMinusOneOverP)        _EB0gt15lh->addPdf ("electrons", "OneOverEMinusOneOverP",         splitSignalPdfs) ;
00127 
00128   if(backgroundWeightSplitting.compare("class")==0) {
00129     _EB0gt15lh->setSplitFrac ("hadrons", "class0") ;
00130     _EB0gt15lh->setSplitFrac ("hadrons", "class1") ;
00131   }
00132   else {
00133     throw cms::Exception("BadConfig") << "Only class (0 brem clusters / >=1 brem clusters)"
00134                                       << " splitting is implemented right now";
00135   }
00136 
00137   if (m_eleIDSwitches.m_useDeltaPhi)     _EB0gt15lh->addPdf ("hadrons", "dPhi",          splitBackgroundPdfs) ;   
00138   if (m_eleIDSwitches.m_useDeltaEta)     _EB0gt15lh->addPdf ("hadrons", "dEta",          splitBackgroundPdfs) ;
00139   if (m_eleIDSwitches.m_useEoverP)       _EB0gt15lh->addPdf ("hadrons", "EoP",           splitBackgroundPdfs) ;
00140   if (m_eleIDSwitches.m_useHoverE)       _EB0gt15lh->addPdf ("hadrons", "HoE",           splitBackgroundPdfs) ;
00141   if (m_eleIDSwitches.m_useSigmaEtaEta)  _EB0gt15lh->addPdf ("hadrons", "sigmaIEtaIEta", splitBackgroundPdfs) ;
00142   if (m_eleIDSwitches.m_useSigmaPhiPhi)  _EB0gt15lh->addPdf ("hadrons", "sigmaIPhiIPhi", splitBackgroundPdfs) ;
00143   if (m_eleIDSwitches.m_useFBrem)        _EB0gt15lh->addPdf ("hadrons", "fBrem",         splitBackgroundPdfs) ;
00144   if (m_eleIDSwitches.m_useOneOverEMinusOneOverP)        _EB0gt15lh->addPdf ("hadrons", "OneOverEMinusOneOverP",         splitBackgroundPdfs) ;
00145 
00146 
00147   // ECAL BARREL1 (|eta|>1.0) LIKELIHOOD - Pt < 15 GeV region
00148   _EB1lt15lh->initFromDB (calibration) ;
00149 
00150   _EB1lt15lh->addSpecies ("electrons") ;
00151   _EB1lt15lh->addSpecies ("hadrons") ;
00152 
00153   if(signalWeightSplitting.compare("class")==0) {
00154     _EB1lt15lh->setSplitFrac ("electrons", "class0") ;
00155     _EB1lt15lh->setSplitFrac ("electrons", "class1") ;
00156   }
00157   else {
00158     throw cms::Exception("BadConfig") << "Only class (non-showering / showering)"
00159                                       << " and fullclass (golden / bigbrem / narrow / showering)" 
00160                                       << " splitting is implemented right now";
00161   }
00162 
00163   if (m_eleIDSwitches.m_useDeltaPhi)     _EB1lt15lh->addPdf ("electrons", "dPhi",          splitSignalPdfs) ;   
00164   if (m_eleIDSwitches.m_useDeltaEta)     _EB1lt15lh->addPdf ("electrons", "dEta",          splitSignalPdfs) ;
00165   if (m_eleIDSwitches.m_useEoverP)       _EB1lt15lh->addPdf ("electrons", "EoP",           splitSignalPdfs) ;
00166   if (m_eleIDSwitches.m_useHoverE)       _EB1lt15lh->addPdf ("electrons", "HoE",           splitSignalPdfs) ;
00167   if (m_eleIDSwitches.m_useSigmaEtaEta)  _EB1lt15lh->addPdf ("electrons", "sigmaIEtaIEta", splitSignalPdfs) ;
00168   if (m_eleIDSwitches.m_useSigmaPhiPhi)  _EB1lt15lh->addPdf ("electrons", "sigmaIPhiIPhi", splitSignalPdfs) ;
00169   if (m_eleIDSwitches.m_useFBrem)        _EB1lt15lh->addPdf ("electrons", "fBrem",         splitSignalPdfs) ;
00170   if (m_eleIDSwitches.m_useOneOverEMinusOneOverP)        _EB1lt15lh->addPdf ("electrons", "OneOverEMinusOneOverP",         splitSignalPdfs) ;
00171 
00172   if(backgroundWeightSplitting.compare("class")==0) {
00173     _EB1lt15lh->setSplitFrac ("hadrons", "class0") ;
00174     _EB1lt15lh->setSplitFrac ("hadrons", "class1") ;
00175   }
00176   else {
00177     throw cms::Exception("BadConfig") << "Only class (0 brem clusters / >=1 brem clusters)"
00178                                       << " splitting is implemented right now";
00179   }
00180 
00181   if (m_eleIDSwitches.m_useDeltaPhi)     _EB1lt15lh->addPdf ("hadrons", "dPhi",          splitBackgroundPdfs) ;   
00182   if (m_eleIDSwitches.m_useDeltaEta)     _EB1lt15lh->addPdf ("hadrons", "dEta",          splitBackgroundPdfs) ;
00183   if (m_eleIDSwitches.m_useEoverP)       _EB1lt15lh->addPdf ("hadrons", "EoP",           splitBackgroundPdfs) ;
00184   if (m_eleIDSwitches.m_useHoverE)       _EB1lt15lh->addPdf ("hadrons", "HoE",           splitBackgroundPdfs) ;
00185   if (m_eleIDSwitches.m_useSigmaEtaEta)  _EB1lt15lh->addPdf ("hadrons", "sigmaIEtaIEta", splitBackgroundPdfs) ;
00186   if (m_eleIDSwitches.m_useSigmaPhiPhi)  _EB1lt15lh->addPdf ("hadrons", "sigmaIPhiIPhi", splitBackgroundPdfs) ;
00187   if (m_eleIDSwitches.m_useFBrem)        _EB1lt15lh->addPdf ("hadrons", "fBrem",         splitBackgroundPdfs) ;
00188   if (m_eleIDSwitches.m_useOneOverEMinusOneOverP)        _EB1lt15lh->addPdf ("hadrons", "OneOverEMinusOneOverP",         splitBackgroundPdfs) ;
00189 
00190   // ECAL BARREL1 (|eta|>1.0) LIKELIHOOD - Pt >= 15 GeV region
00191   _EB1gt15lh->initFromDB (calibration) ;
00192 
00193   _EB1gt15lh->addSpecies ("electrons") ;  
00194   _EB1gt15lh->addSpecies ("hadrons") ;
00195 
00196   if(signalWeightSplitting.compare("class")==0) {
00197     _EB1gt15lh->setSplitFrac ("electrons", "class0") ;
00198     _EB1gt15lh->setSplitFrac ("electrons", "class1") ;
00199   }
00200   else {
00201     throw cms::Exception("BadConfig") << "Only class (0 brem clusters / >=1 brem clusters)"
00202                                       << " splitting is implemented right now";
00203   }
00204 
00205   if (m_eleIDSwitches.m_useDeltaPhi)     _EB1gt15lh->addPdf ("electrons", "dPhi",          splitSignalPdfs) ;   
00206   if (m_eleIDSwitches.m_useDeltaEta)     _EB1gt15lh->addPdf ("electrons", "dEta",          splitSignalPdfs) ;
00207   if (m_eleIDSwitches.m_useEoverP)       _EB1gt15lh->addPdf ("electrons", "EoP",           splitSignalPdfs) ;
00208   if (m_eleIDSwitches.m_useHoverE)       _EB1gt15lh->addPdf ("electrons", "HoE",           splitSignalPdfs) ;
00209   if (m_eleIDSwitches.m_useSigmaEtaEta)  _EB1gt15lh->addPdf ("electrons", "sigmaIEtaIEta", splitSignalPdfs) ;
00210   if (m_eleIDSwitches.m_useSigmaPhiPhi)  _EB1gt15lh->addPdf ("electrons", "sigmaIPhiIPhi", splitSignalPdfs) ;
00211   if (m_eleIDSwitches.m_useFBrem)        _EB1gt15lh->addPdf ("electrons", "fBrem",         splitSignalPdfs) ;
00212   if (m_eleIDSwitches.m_useOneOverEMinusOneOverP)        _EB1gt15lh->addPdf ("electrons", "OneOverEMinusOneOverP",         splitSignalPdfs) ;
00213 
00214   if(backgroundWeightSplitting.compare("class")==0) {
00215     _EB1gt15lh->setSplitFrac ("hadrons", "class0") ;
00216     _EB1gt15lh->setSplitFrac ("hadrons", "class1") ;
00217   }
00218   else {
00219     throw cms::Exception("BadConfig") << "Only class (0 brem clusters / >=1 brem clusters)"
00220                                       << " splitting is implemented right now";
00221   }
00222 
00223   if (m_eleIDSwitches.m_useDeltaPhi)     _EB1gt15lh->addPdf ("hadrons", "dPhi",          splitBackgroundPdfs) ;   
00224   if (m_eleIDSwitches.m_useDeltaEta)     _EB1gt15lh->addPdf ("hadrons", "dEta",          splitBackgroundPdfs) ;
00225   if (m_eleIDSwitches.m_useEoverP)       _EB1gt15lh->addPdf ("hadrons", "EoP",           splitBackgroundPdfs) ;
00226   if (m_eleIDSwitches.m_useHoverE)       _EB1gt15lh->addPdf ("hadrons", "HoE",           splitBackgroundPdfs) ;
00227   if (m_eleIDSwitches.m_useSigmaEtaEta)  _EB1gt15lh->addPdf ("hadrons", "sigmaIEtaIEta", splitBackgroundPdfs) ;
00228   if (m_eleIDSwitches.m_useSigmaPhiPhi)  _EB1gt15lh->addPdf ("hadrons", "sigmaIPhiIPhi", splitBackgroundPdfs) ;
00229   if (m_eleIDSwitches.m_useFBrem)        _EB1gt15lh->addPdf ("hadrons", "fBrem",         splitBackgroundPdfs) ;
00230   if (m_eleIDSwitches.m_useOneOverEMinusOneOverP)        _EB1gt15lh->addPdf ("hadrons", "OneOverEMinusOneOverP",         splitBackgroundPdfs) ;
00231 
00232   // ECAL ENDCAP LIKELIHOOD - Pt < 15 GeV
00233   _EElt15lh->initFromDB (calibration) ;
00234 
00235   _EElt15lh->addSpecies ("electrons") ;
00236   _EElt15lh->addSpecies ("hadrons") ;
00237 
00238   if(signalWeightSplitting.compare("class")==0) {
00239     _EElt15lh->setSplitFrac ("electrons", "class0") ;
00240     _EElt15lh->setSplitFrac ("electrons", "class1") ;
00241   }
00242   else {
00243     throw cms::Exception("BadConfig") << "Only class (0 brem clusters / >=1 brem clusters)"
00244                                       << " splitting is implemented right now";
00245   }
00246 
00247   if (m_eleIDSwitches.m_useDeltaPhi)     _EElt15lh->addPdf ("electrons", "dPhi",          splitSignalPdfs) ;   
00248   if (m_eleIDSwitches.m_useDeltaEta)     _EElt15lh->addPdf ("electrons", "dEta",          splitSignalPdfs) ;
00249   if (m_eleIDSwitches.m_useEoverP)       _EElt15lh->addPdf ("electrons", "EoP",           splitSignalPdfs) ;
00250   if (m_eleIDSwitches.m_useHoverE)       _EElt15lh->addPdf ("electrons", "HoE",           splitSignalPdfs) ;
00251   if (m_eleIDSwitches.m_useSigmaEtaEta)  _EElt15lh->addPdf ("electrons", "sigmaIEtaIEta", splitSignalPdfs) ;
00252   if (m_eleIDSwitches.m_useSigmaPhiPhi)  _EElt15lh->addPdf ("electrons", "sigmaIPhiIPhi", splitSignalPdfs) ;
00253   if (m_eleIDSwitches.m_useFBrem)        _EElt15lh->addPdf ("electrons", "fBrem",         splitSignalPdfs) ;
00254   if (m_eleIDSwitches.m_useOneOverEMinusOneOverP)        _EElt15lh->addPdf ("electrons", "OneOverEMinusOneOverP",         splitSignalPdfs) ;
00255 
00256   if(backgroundWeightSplitting.compare("class")==0) {
00257     _EElt15lh->setSplitFrac ("hadrons", "class0") ;
00258     _EElt15lh->setSplitFrac ("hadrons", "class1") ;
00259   }
00260   else {
00261     throw cms::Exception("BadConfig") << "Only class (0 brem clusters / >=1 brem clusters)"
00262                                       << " splitting is implemented right now";
00263   }
00264 
00265   if (m_eleIDSwitches.m_useDeltaPhi)     _EElt15lh->addPdf ("hadrons", "dPhi",          splitBackgroundPdfs) ;   
00266   if (m_eleIDSwitches.m_useDeltaEta)     _EElt15lh->addPdf ("hadrons", "dEta",          splitBackgroundPdfs) ;
00267   if (m_eleIDSwitches.m_useEoverP)       _EElt15lh->addPdf ("hadrons", "EoP",           splitBackgroundPdfs) ;
00268   if (m_eleIDSwitches.m_useHoverE)       _EElt15lh->addPdf ("hadrons", "HoE",           splitBackgroundPdfs) ;
00269   if (m_eleIDSwitches.m_useSigmaEtaEta)  _EElt15lh->addPdf ("hadrons", "sigmaIEtaIEta", splitBackgroundPdfs) ;
00270   if (m_eleIDSwitches.m_useSigmaPhiPhi)  _EElt15lh->addPdf ("hadrons", "sigmaIPhiIPhi", splitBackgroundPdfs) ;
00271   if (m_eleIDSwitches.m_useFBrem)        _EElt15lh->addPdf ("hadrons", "fBrem",         splitBackgroundPdfs) ;
00272   if (m_eleIDSwitches.m_useOneOverEMinusOneOverP)        _EElt15lh->addPdf ("hadrons", "OneOverEMinusOneOverP",         splitBackgroundPdfs) ;
00273 
00274   // ECAL ENDCAP LIKELIHOOD - Pt >= 15 GeV
00275   _EEgt15lh->initFromDB (calibration) ;
00276 
00277   _EEgt15lh->addSpecies ("electrons") ;
00278   _EEgt15lh->addSpecies ("hadrons") ;
00279 
00280   if(signalWeightSplitting.compare("class")==0) {
00281     _EEgt15lh->setSplitFrac ("electrons", "class0") ;
00282     _EEgt15lh->setSplitFrac ("electrons", "class1") ;
00283   }
00284   else {
00285     throw cms::Exception("BadConfig") << "Only class (0 brem clusters / >=1 brem clusters)"
00286                                       << " splitting is implemented right now";
00287   }
00288 
00289   if (m_eleIDSwitches.m_useDeltaPhi)     _EEgt15lh->addPdf ("electrons", "dPhi",          splitSignalPdfs) ;   
00290   if (m_eleIDSwitches.m_useDeltaEta)     _EEgt15lh->addPdf ("electrons", "dEta",          splitSignalPdfs) ;
00291   if (m_eleIDSwitches.m_useEoverP)       _EEgt15lh->addPdf ("electrons", "EoP",           splitSignalPdfs) ;
00292   if (m_eleIDSwitches.m_useHoverE)       _EEgt15lh->addPdf ("electrons", "HoE",           splitSignalPdfs) ;
00293   if (m_eleIDSwitches.m_useSigmaEtaEta)  _EEgt15lh->addPdf ("electrons", "sigmaIEtaIEta", splitSignalPdfs) ;
00294   if (m_eleIDSwitches.m_useSigmaPhiPhi)  _EEgt15lh->addPdf ("electrons", "sigmaIPhiIPhi", splitSignalPdfs) ;
00295   if (m_eleIDSwitches.m_useFBrem)        _EEgt15lh->addPdf ("electrons", "fBrem",         splitSignalPdfs) ;
00296   if (m_eleIDSwitches.m_useOneOverEMinusOneOverP)        _EEgt15lh->addPdf ("electrons", "OneOverEMinusOneOverP",         splitSignalPdfs) ;
00297 
00298   if(backgroundWeightSplitting.compare("class")==0) {
00299     _EEgt15lh->setSplitFrac ("hadrons", "class0") ;
00300     _EEgt15lh->setSplitFrac ("hadrons", "class1") ;
00301   }
00302   else {
00303     throw cms::Exception("BadConfig") << "Only class (0 brem clusters / >=1 brem clusters)"
00304                                       << " splitting is implemented right now";
00305   }
00306 
00307   if (m_eleIDSwitches.m_useDeltaPhi)     _EEgt15lh->addPdf ("hadrons", "dPhi",          splitBackgroundPdfs) ;   
00308   if (m_eleIDSwitches.m_useDeltaEta)     _EEgt15lh->addPdf ("hadrons", "dEta",          splitBackgroundPdfs) ;
00309   if (m_eleIDSwitches.m_useEoverP)       _EEgt15lh->addPdf ("hadrons", "EoP",           splitBackgroundPdfs) ;
00310   if (m_eleIDSwitches.m_useHoverE)       _EEgt15lh->addPdf ("hadrons", "HoE",           splitBackgroundPdfs) ;
00311   if (m_eleIDSwitches.m_useSigmaEtaEta)  _EEgt15lh->addPdf ("hadrons", "sigmaIEtaIEta", splitBackgroundPdfs) ;
00312   if (m_eleIDSwitches.m_useSigmaPhiPhi)  _EEgt15lh->addPdf ("hadrons", "sigmaIPhiIPhi", splitBackgroundPdfs) ;
00313   if (m_eleIDSwitches.m_useFBrem)        _EEgt15lh->addPdf ("hadrons", "fBrem",         splitBackgroundPdfs) ;
00314   if (m_eleIDSwitches.m_useOneOverEMinusOneOverP)        _EEgt15lh->addPdf ("hadrons", "OneOverEMinusOneOverP",         splitBackgroundPdfs) ;
00315 }
00316 
00317 
00318 
00319 // --------------------------------------------------------
00320 
00321 
00322 
00323 void 
00324 ElectronLikelihood::getInputVar (const reco::GsfElectron &electron, 
00325                                  std::vector<float> &measurements, 
00326                                  const EcalClusterLazyTools& _myEcalCluster) const 
00327 {
00328   EcalClusterLazyTools myEcalCluster = _myEcalCluster;
00329   // the variables entering the likelihood
00330   if (m_eleIDSwitches.m_useDeltaPhi) measurements.push_back ( electron.deltaPhiSuperClusterTrackAtVtx () ) ;
00331   if (m_eleIDSwitches.m_useDeltaEta) measurements.push_back ( electron.deltaEtaSuperClusterTrackAtVtx () ) ;
00332   if (m_eleIDSwitches.m_useEoverP) measurements.push_back ( electron.eSuperClusterOverP () ) ;
00333   if (m_eleIDSwitches.m_useHoverE) measurements.push_back ( electron.hadronicOverEm () ) ;
00334   std::vector<float> vCov = myEcalCluster.localCovariances(*(electron.superCluster()->seed())) ;
00335   if (m_eleIDSwitches.m_useSigmaEtaEta) measurements.push_back ( sqrt (vCov[0]) );
00336   if (m_eleIDSwitches.m_useSigmaPhiPhi) measurements.push_back ( sqrt (vCov[2]) );
00337   if(m_eleIDSwitches.m_useFBrem) measurements.push_back( electron.fbrem() );
00338   // 1/E - 1/P calculated consistently with the variables used to make the PDFs
00339   reco::GsfTrackRef trkRef = electron.get<reco::GsfTrackRef>();
00340   float OneOverEMinusOneOverP = 1.0/(electron.eSuperClusterOverP() * trkRef->p()) - 1.0/trkRef->p();
00341   if(m_eleIDSwitches.m_useOneOverEMinusOneOverP) measurements.push_back( OneOverEMinusOneOverP );
00342 
00343 }
00344 
00345 
00346 
00347 // --------------------------------------------------------
00348 
00349 
00350 
00351 float 
00352 ElectronLikelihood::result (const reco::GsfElectron &electron, 
00353                             const EcalClusterLazyTools& myEcalCluster) const 
00354 {
00355 
00356   //=======================================================
00357   // used classification:
00358   // nbrem clusters = 0         =>  0
00359   // nbrem clusters >= 1        =>  1
00360   //=======================================================
00361 
00362   std::vector<float> measurements ;
00363   getInputVar (electron, measurements, myEcalCluster) ;
00364 
00365   // Split using only the number of brem clusters
00366   int bitVal=(electron.numberOfBrems()==0) ? 0 : 1 ;
00367   
00368   char className[20];
00369   if(m_signalWeightSplitting.compare("class")==0) {
00370     snprintf(className, 20, "class%d", bitVal);
00371   } else {
00372     throw cms::Exception("BadConfig") << "Only class (0 brem clusters / >=1 brem clusters)"
00373                                       << " splitting is implemented right now";
00374   }
00375 
00376   reco::SuperClusterRef sclusRef = electron.superCluster() ;
00377   EcalSubdetector subdet = EcalSubdetector (sclusRef->hitsAndFractions()[0].first.subdetId ()) ;
00378   float thisPt =  electron.pt();
00379 
00380   if (subdet==EcalBarrel && fabs(electron.eta())<=1.0 && thisPt<15.)
00381     return _EB0lt15lh->getRatio ("electrons",measurements,std::string (className)) ;
00382   else if (subdet==EcalBarrel && fabs(electron.eta())<=1.0 && thisPt>=15.)
00383     return _EB0gt15lh->getRatio ("electrons",measurements,std::string (className)) ;
00384   else if (subdet==EcalBarrel && fabs(electron.eta())>1.0 && thisPt<15.)
00385     return _EB1lt15lh->getRatio ("electrons",measurements,std::string (className)) ;
00386   else if (subdet==EcalBarrel && fabs(electron.eta())>1.0 && thisPt>=15.)
00387     return _EB1gt15lh->getRatio ("electrons",measurements,std::string (className)) ;
00388   else if (subdet==EcalEndcap && thisPt<15.)
00389     return _EElt15lh->getRatio ("electrons",measurements,std::string (className)) ;
00390   else if (subdet==EcalEndcap && thisPt>=15.)
00391     return _EEgt15lh->getRatio ("electrons",measurements,std::string (className)) ;
00392   else return -999. ;
00393 }
00394 
00395 float 
00396 ElectronLikelihood::resultLog (const reco::GsfElectron &electron, 
00397                                const EcalClusterLazyTools& myEcalCluster) const 
00398 {
00399 
00400   //=======================================================
00401   // used classification:
00402   // nbrem clusters = 0         =>  0
00403   // nbrem clusters >= 1        =>  1
00404   //=======================================================
00405 
00406   std::vector<float> measurements ;
00407   getInputVar (electron, measurements, myEcalCluster) ;
00408 
00409   // Split using only the number of brem clusters
00410   int bitVal=(electron.numberOfBrems()==0) ? 0 : 1 ;
00411   
00412   char className[20];
00413   if(m_signalWeightSplitting.compare("class")==0) {
00414     snprintf(className, 20, "class%d", bitVal);
00415   } else {
00416     throw cms::Exception("BadConfig") << "Only class (0 brem clusters / >=1 brem clusters)"
00417                                       << " splitting is implemented right now";
00418   }
00419 
00420   reco::SuperClusterRef sclusRef = electron.superCluster() ;
00421   EcalSubdetector subdet = EcalSubdetector (sclusRef->hitsAndFractions()[0].first.subdetId ()) ;
00422   float thisPt =  electron.pt();
00423 
00424   float lh=-999.;
00425 
00426   if (subdet==EcalBarrel && fabs(electron.eta())<=1.0 && thisPt<15.)
00427     lh = _EB0lt15lh->getRatio ("electrons",measurements,std::string (className)) ;
00428   else if (subdet==EcalBarrel && fabs(electron.eta())<=1.0 && thisPt>=15.)
00429     lh = _EB0gt15lh->getRatio ("electrons",measurements,std::string (className)) ;
00430   else if (subdet==EcalBarrel && fabs(electron.eta())>1.0 && thisPt<15.)
00431     lh = _EB1lt15lh->getRatio ("electrons",measurements,std::string (className)) ;
00432   else if (subdet==EcalBarrel && fabs(electron.eta())>1.0 && thisPt>=15.)
00433     lh = _EB1gt15lh->getRatio ("electrons",measurements,std::string (className)) ;
00434   else if (subdet==EcalEndcap && thisPt<15.)
00435     lh = _EElt15lh->getRatio ("electrons",measurements,std::string (className)) ;
00436   else if (subdet==EcalEndcap && thisPt>=15.)
00437     lh = _EEgt15lh->getRatio ("electrons",measurements,std::string (className)) ;
00438   else lh = -999. ;
00439 
00440   if(lh<=0) return -20.;
00441   else if(lh==1) return 20.;
00442   else return log(lh/(1.0-lh));
00443 
00444 }
00445