CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/RecoEgamma/ElectronIdentification/src/CutBasedElectronID.cc

Go to the documentation of this file.
00001 #include "RecoEgamma/ElectronIdentification/interface/CutBasedElectronID.h"
00002 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00003 #include "DataFormats/VertexReco/interface/Vertex.h"
00004 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00005 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00006 //#include "RecoEgamma/EgammaTools/interface/ConversionFinder.h"
00007 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00008 
00009 #include <algorithm>
00010 
00011 void CutBasedElectronID::setup(const edm::ParameterSet& conf) {
00012 
00013   // Get all the parameters
00014   baseSetup(conf);
00015 
00016   type_ = conf.getParameter<std::string>("electronIDType");
00017   quality_ = conf.getParameter<std::string>("electronQuality");
00018   version_ = conf.getParameter<std::string>("electronVersion");
00019   verticesCollection_ = conf.getParameter<edm::InputTag>("verticesCollection");
00020   
00021   if (type_ == "classbased" and (version_ == "V06")) {
00022     newCategories_ = conf.getParameter<bool>("additionalCategories");
00023   }
00024 
00025   if (type_ == "classbased" and (version_ == "V03" or version_ == "V04" or version_ == "V05" or version_ == "")) {
00026     wantBinning_ = conf.getParameter<bool>("etBinning");
00027     newCategories_ = conf.getParameter<bool>("additionalCategories");
00028   }
00029 
00030   if (type_ == "robust" || type_ == "classbased") {
00031     std::string stringCut = type_+quality_+"EleIDCuts"+version_;
00032     cuts_ = conf.getParameter<edm::ParameterSet>(stringCut);
00033   }
00034   else {
00035     throw cms::Exception("Configuration")
00036       << "Invalid electronType parameter in CutBasedElectronID: must be robust or classbased\n";
00037   }
00038 }
00039 
00040 double CutBasedElectronID::result(const reco::GsfElectron* electron ,
00041                                   const edm::Event& e ,
00042                                   const edm::EventSetup& es) {
00043 
00044   if (type_ == "classbased")
00045     return cicSelection(electron, e, es);
00046   else if (type_ == "robust")
00047     return robustSelection(electron, e, es);
00048 
00049   return 0;
00050 
00051 }
00052 
00053 int CutBasedElectronID::classify(const reco::GsfElectron* electron) {
00054 
00055   double eta = fabs(electron->superCluster()->eta());
00056   double eOverP = electron->eSuperClusterOverP();
00057   double fBrem = electron->fbrem();
00058 
00059   int cat = -1;
00060   if (version_ == "V00" || version_ == "V01") {
00061     if((electron->isEB() && fBrem<0.06) || (electron->isEE() && fBrem<0.1))
00062       cat=1;
00063     else if (eOverP < 1.2 && eOverP > 0.8)
00064       cat=0;
00065     else
00066       cat=2;
00067 
00068     return cat;
00069 
00070   } else if (version_ == "V02") {
00071     if (electron->isEB()) {       // BARREL
00072       if(fBrem < 0.12)
00073         cat=1;
00074       else if (eOverP < 1.2 && eOverP > 0.9)
00075         cat=0;
00076       else
00077         cat=2;
00078     } else {                     // ENDCAP
00079       if(fBrem < 0.2)
00080         cat=1;
00081       else if (eOverP < 1.22 && eOverP > 0.82)
00082         cat=0;
00083       else
00084         cat=2;
00085     }
00086 
00087     return cat;
00088 
00089   } else {
00090     if (electron->isEB()) {
00091       if ((fBrem >= 0.12) and (eOverP > 0.9) and (eOverP < 1.2))
00092         cat = 0;
00093       else if (((eta >  .445   and eta <  .45  ) or
00094                 (eta >  .79    and eta <  .81  ) or
00095                 (eta > 1.137   and eta < 1.157 ) or
00096                 (eta > 1.47285 and eta < 1.4744)) and newCategories_)
00097         cat = 6;
00098       else if (electron->trackerDrivenSeed() and !electron->ecalDrivenSeed() and newCategories_)
00099         cat = 8;
00100       else if (fBrem < 0.12)
00101         cat = 1;
00102       else
00103         cat = 2;
00104     } else {
00105       if ((fBrem >= 0.2) and (eOverP > 0.82) and (eOverP < 1.22))
00106         cat = 3;
00107       else if (eta > 1.5 and eta <  1.58 and newCategories_)
00108         cat = 7;
00109       else if (electron->trackerDrivenSeed() and !electron->ecalDrivenSeed() and newCategories_)
00110         cat = 8;
00111       else if (fBrem < 0.2)
00112         cat = 4;
00113       else
00114         cat = 5;
00115     }
00116 
00117     return cat;
00118   }
00119 
00120   return -1;
00121 }
00122 
00123 double CutBasedElectronID::cicSelection(const reco::GsfElectron* electron,
00124                                         const edm::Event& e,
00125                                         const edm::EventSetup& es) {
00126 
00127   double scTheta = (2*atan(exp(-electron->superCluster()->eta())));
00128   double scEt = electron->superCluster()->energy()*sin(scTheta);
00129 
00130   double eta = fabs(electron->superCluster()->eta());
00131 
00132   double eOverP = electron->eSuperClusterOverP();
00133   double eSeedOverPin = electron->eSeedClusterOverP();
00134   double fBrem = electron->fbrem();
00135   double hOverE = electron->hadronicOverEm();
00136   double sigmaee = electron->sigmaIetaIeta(); //sqrt(vLocCov[0]);
00137   double deltaPhiIn = electron->deltaPhiSuperClusterTrackAtVtx();
00138   double deltaEtaIn = electron->deltaEtaSuperClusterTrackAtVtx();
00139 
00140   double ip = 0;
00141   int mishits = electron->gsfTrack()->trackerExpectedHitsInner().numberOfHits();
00142   double tkIso = electron->dr03TkSumPt();
00143   double ecalIso = electron->dr04EcalRecHitSumEt();
00144   double hcalIso = electron->dr04HcalTowerSumEt();
00145 
00146   if (version_ == "V00") {
00147     sigmaee = electron->sigmaEtaEta();//sqrt(vCov[0]);
00148     if (electron->isEE())
00149       sigmaee = sigmaee - 0.02*(fabs(eta) - 2.3);   //correct sigmaetaeta dependence on eta in endcap
00150   }
00151 
00152   if (version_ != "V01" or version_ != "V00") {
00153     edm::Handle<reco::VertexCollection> vtxH;
00154     e.getByLabel(verticesCollection_, vtxH);
00155     if (vtxH->size() != 0) {
00156       reco::VertexRef vtx(vtxH, 0);
00157       ip = fabs(electron->gsfTrack()->dxy(math::XYZPoint(vtx->x(),vtx->y(),vtx->z())));
00158     } else
00159       ip = fabs(electron->gsfTrack()->dxy());
00160 
00161     if (electron->isEB()) {
00162       sigmaee = electron->sigmaIetaIeta(); //sqrt(vCov[0]);
00163     }
00164   }
00165 
00166   std::vector<double> cut;
00167 
00168   int cat = classify(electron);
00169   int eb;
00170 
00171   if (electron->isEB())
00172     eb = 0;
00173   else
00174     eb = 1;
00175 
00176   // LOOSE and TIGHT Selections
00177   if (type_ == "classbased" && (version_ == "V01" || version_ == "V00")) {
00178 
00179     if ((eOverP < 0.8) && (fBrem < 0.2))
00180       return 0.;
00181 
00182     cut = cuts_.getParameter<std::vector<double> >("hOverE");
00183     if (hOverE > cut[cat+4*eb])
00184       return 0.;
00185 
00186     cut = cuts_.getParameter<std::vector<double> >("sigmaEtaEta");
00187     if (sigmaee > cut[cat+4*eb])
00188       return 0.;
00189 
00190     cut = cuts_.getParameter<std::vector<double> >("deltaPhiIn");
00191     if (eOverP < 1.5) {
00192       if (fabs(deltaPhiIn) > cut[cat+4*eb])
00193         return 0.;
00194     } else {
00195       if (fabs(deltaPhiIn) > cut[3+4*eb])
00196         return 0.;
00197     }
00198 
00199     cut = cuts_.getParameter<std::vector<double> >("deltaEtaIn");
00200     if (fabs(deltaEtaIn) > cut[cat+4*eb])
00201       return 0.;
00202 
00203     cut = cuts_.getParameter<std::vector<double> >("eSeedOverPin");
00204     if (eSeedOverPin < cut[cat+4*eb])
00205       return 0.;
00206 
00207     if (quality_ == "tight")
00208       if (eOverP < 0.9*(1-fBrem))
00209         return 0.;
00210 
00211     return 1.;
00212   }
00213 
00214   if (type_ == "classbased" and version_ == "V02") {
00215     double result = 0.;
00216 
00217     int bin = 0;
00218 
00219     if (scEt < 20.)
00220       bin = 2;
00221     else if (scEt > 30.)
00222       bin = 0;
00223     else
00224       bin = 1;
00225 
00226     if (fBrem > 0)
00227       eSeedOverPin = eSeedOverPin + fBrem;
00228 
00229     if (bin != 2) {
00230       tkIso = tkIso*pow(40./scEt, 2);
00231       ecalIso = ecalIso*pow(40./scEt, 2);
00232       hcalIso = hcalIso*pow(40./scEt, 2);
00233     }
00234 
00235     std::vector<double> cutTk = cuts_.getParameter<std::vector<double> >("cutisotk");
00236     std::vector<double> cutEcal = cuts_.getParameter<std::vector<double> >("cutisoecal");
00237     std::vector<double> cutHcal = cuts_.getParameter<std::vector<double> >("cutisohcal");
00238     if ((tkIso > cutTk[cat+3*eb+bin*6]) ||
00239         (ecalIso > cutEcal[cat+3*eb+bin*6]) ||
00240         (hcalIso > cutHcal[cat+3*eb+bin*6]))
00241       result = 0.;
00242     else
00243       result = 2.;
00244 
00245     if (fBrem > -2) {
00246       std::vector<double> cuthoe = cuts_.getParameter<std::vector<double> >("cuthoe");
00247       std::vector<double> cutsee = cuts_.getParameter<std::vector<double> >("cutsee");
00248       std::vector<double> cutdphi = cuts_.getParameter<std::vector<double> >("cutdphiin");
00249       std::vector<double> cutdeta = cuts_.getParameter<std::vector<double> >("cutdetain");
00250       std::vector<double> cuteopin = cuts_.getParameter<std::vector<double> >("cuteseedopcor");
00251       std::vector<double> cutet = cuts_.getParameter<std::vector<double> >("cutet");
00252       std::vector<double> cutip = cuts_.getParameter<std::vector<double> >("cutip");
00253       std::vector<double> cutmishits = cuts_.getParameter<std::vector<double> >("cutmishits");
00254       if ((hOverE < cuthoe[cat+3*eb+bin*6]) and
00255           (sigmaee < cutsee[cat+3*eb+bin*6]) and
00256           (fabs(deltaPhiIn) < cutdphi[cat+3*eb+bin*6]) and
00257           (fabs(deltaEtaIn) < cutdeta[cat+3*eb+bin*6]) and
00258           (eSeedOverPin > cuteopin[cat+3*eb+bin*6]) and
00259           (ip < cutip[cat+3*eb+bin*6]) and
00260           (mishits < cutmishits[cat+3*eb+bin*6]))
00261         result = result + 1.;
00262     }
00263     return result;
00264   }
00265 
00266   if (version_ == "V03" or version_ == "V04" or version_ == "V05") {
00267     double result = 0.;
00268 
00269     int bin = 0;
00270 
00271     if (wantBinning_) {
00272       if (scEt < 20.)
00273         bin = 2;
00274       else if (scEt > 30.)
00275         bin = 0;
00276       else
00277         bin = 1;
00278     }
00279 
00280     if (fBrem > 0)
00281       eSeedOverPin = eSeedOverPin + fBrem;
00282 
00283     float iso_sum = tkIso + ecalIso + hcalIso;
00284     float iso_sum_corrected = iso_sum*pow(40./scEt, 2);
00285 
00286     std::vector<double> cutIsoSum = cuts_.getParameter<std::vector<double> >("cutiso_sum");
00287     std::vector<double> cutIsoSumCorr = cuts_.getParameter<std::vector<double> >("cutiso_sumoet");
00288     if ((iso_sum < cutIsoSum[cat+bin*9]) and
00289         (iso_sum_corrected < cutIsoSumCorr[cat+bin*9]))
00290       result += 2.;
00291 
00292     if (fBrem > -2) {
00293       std::vector<double> cuthoe = cuts_.getParameter<std::vector<double> >("cuthoe");
00294       std::vector<double> cutsee = cuts_.getParameter<std::vector<double> >("cutsee");
00295       std::vector<double> cutdphi = cuts_.getParameter<std::vector<double> >("cutdphiin");
00296       std::vector<double> cutdeta = cuts_.getParameter<std::vector<double> >("cutdetain");
00297       std::vector<double> cuteopin = cuts_.getParameter<std::vector<double> >("cuteseedopcor");
00298       std::vector<double> cutet = cuts_.getParameter<std::vector<double> >("cutet");
00299 
00300       if ((hOverE < cuthoe[cat+bin*9]) and
00301           (sigmaee < cutsee[cat+bin*9]) and
00302           (fabs(deltaPhiIn) < cutdphi[cat+bin*9]) and
00303           (fabs(deltaEtaIn) < cutdeta[cat+bin*9]) and
00304           (eSeedOverPin > cuteopin[cat+bin*9]) and
00305           (scEt > cutet[cat+bin*9]))
00306         result += 1.;
00307     }
00308 
00309     std::vector<double> cutip = cuts_.getParameter<std::vector<double> >("cutip_gsf");
00310     if (ip < cutip[cat+bin*9])
00311       result += 8;
00312     
00313     std::vector<double> cutmishits = cuts_.getParameter<std::vector<double> >("cutfmishits");
00314     std::vector<double> cutdcotdist = cuts_.getParameter<std::vector<double> >("cutdcotdist");
00315     
00316     float dist = (electron->convDist() == -9999.? 9999:electron->convDist());
00317     float dcot = (electron->convDcot() == -9999.? 9999:electron->convDcot());
00318 
00319     float dcotdistcomb = ((0.04 - std::max(fabs(dist), fabs(dcot))) > 0?(0.04 - std::max(fabs(dist), fabs(dcot))):0);
00320 
00321     if ((mishits < cutmishits[cat+bin*9]) and
00322         (dcotdistcomb < cutdcotdist[cat+bin*9]))
00323       result += 4;
00324 
00325     return result;
00326   }
00327 
00328   if (type_ == "classbased" && (version_ == "V06" || version_ == "")) { 
00329     std::vector<double> cutIsoSum      = cuts_.getParameter<std::vector<double> >("cutiso_sum");
00330     std::vector<double> cutIsoSumCorr  = cuts_.getParameter<std::vector<double> >("cutiso_sumoet");
00331     std::vector<double> cuthoe         = cuts_.getParameter<std::vector<double> >("cuthoe");
00332     std::vector<double> cutsee         = cuts_.getParameter<std::vector<double> >("cutsee");
00333     std::vector<double> cutdphi        = cuts_.getParameter<std::vector<double> >("cutdphiin");
00334     std::vector<double> cutdeta        = cuts_.getParameter<std::vector<double> >("cutdetain");
00335     std::vector<double> cuteopin       = cuts_.getParameter<std::vector<double> >("cuteseedopcor");
00336     std::vector<double> cutmishits     = cuts_.getParameter<std::vector<double> >("cutfmishits");
00337     std::vector<double> cutdcotdist    = cuts_.getParameter<std::vector<double> >("cutdcotdist");
00338     std::vector<double> cutip          = cuts_.getParameter<std::vector<double> >("cutip_gsf");
00339     std::vector<double> cutIsoSumCorrl = cuts_.getParameter<std::vector<double> >("cutiso_sumoetl");
00340     std::vector<double> cuthoel        = cuts_.getParameter<std::vector<double> >("cuthoel");
00341     std::vector<double> cutseel        = cuts_.getParameter<std::vector<double> >("cutseel");
00342     std::vector<double> cutdphil       = cuts_.getParameter<std::vector<double> >("cutdphiinl");
00343     std::vector<double> cutdetal       = cuts_.getParameter<std::vector<double> >("cutdetainl");
00344     std::vector<double> cutipl         = cuts_.getParameter<std::vector<double> >("cutip_gsfl");
00345     
00346     int result = 0;
00347     
00348     const int ncuts = 10;
00349     std::vector<bool> cut_results(ncuts, false);
00350     
00351     float iso_sum = tkIso + ecalIso + hcalIso;
00352     float scEta = electron->superCluster()->eta();
00353     if(fabs(scEta)>1.5) 
00354       iso_sum += (fabs(scEta)-1.5)*1.09;
00355     
00356     float iso_sumoet = iso_sum*(40./scEt);
00357     
00358     float eseedopincor = eSeedOverPin + fBrem;
00359     if(fBrem < 0)
00360       eseedopincor = eSeedOverPin;
00361 
00362     float dist = (electron->convDist() == -9999.? 9999:electron->convDist());
00363     float dcot = (electron->convDcot() == -9999.? 9999:electron->convDcot());
00364 
00365     float dcotdistcomb = ((0.04 - std::max(fabs(dist), fabs(dcot))) > 0?(0.04 - std::max(fabs(dist), fabs(dcot))):0);
00366 
00367     for (int cut=0; cut<ncuts; cut++) {
00368       switch (cut) {
00369       case 0:
00370         cut_results[cut] = compute_cut(fabs(deltaEtaIn), scEt, cutdetal[cat], cutdeta[cat]);
00371         break;
00372       case 1:
00373         cut_results[cut] = compute_cut(fabs(deltaPhiIn), scEt, cutdphil[cat], cutdphi[cat]);
00374         break;
00375       case 2:
00376         cut_results[cut] = (eseedopincor > cuteopin[cat]);
00377         break;
00378       case 3:
00379         cut_results[cut] = compute_cut(hOverE, scEt, cuthoel[cat], cuthoe[cat]);
00380         break;
00381       case 4:
00382         cut_results[cut] = compute_cut(sigmaee, scEt, cutseel[cat], cutsee[cat]);
00383         break;
00384       case 5:
00385         cut_results[cut] = compute_cut(iso_sumoet, scEt, cutIsoSumCorrl[cat], cutIsoSumCorr[cat]);
00386         break;
00387       case 6:
00388         cut_results[cut] = (iso_sum < cutIsoSum[cat]);
00389         break;
00390       case 7:
00391         cut_results[cut] = compute_cut(fabs(ip), scEt, cutipl[cat], cutip[cat]);
00392         break;
00393       case 8:
00394         cut_results[cut] = (mishits < cutmishits[cat]);
00395         break;
00396       case 9:
00397         cut_results[cut] = (dcotdistcomb < cutdcotdist[cat]);
00398         break;
00399       }
00400     }
00401     
00402     // ID part
00403     if (cut_results[0] & cut_results[1] & cut_results[2] & cut_results[3] & cut_results[4])
00404       result = result + 1;
00405     
00406     // ISO part
00407     if (cut_results[5] & cut_results[6])
00408       result = result + 2;
00409     
00410     // IP part
00411     if (cut_results[7])
00412       result = result + 8;
00413     
00414     // Conversion part
00415     if (cut_results[8] & cut_results[9])
00416       result = result + 4;
00417 
00418     return result;
00419   }
00420 
00421   return -1.;
00422 }
00423 
00424 
00425 bool CutBasedElectronID::compute_cut(double x, double et, double cut_min, double cut_max, bool gtn) {
00426 
00427   float et_min = 10;
00428   float et_max = 40;
00429 
00430   bool accept = false;
00431   float cut = cut_max; //  the cut at et=40 GeV
00432 
00433   if(et < et_max) {
00434     cut = cut_min + (1/et_min - 1/et)*(cut_max - cut_min)/(1/et_min - 1/et_max);
00435   } 
00436   
00437   if(et < et_min) {
00438     cut = cut_min;
00439   } 
00440 
00441   if(gtn) {   // useful for e/p cut which is gt
00442     accept = (x >= cut);
00443   } 
00444   else {
00445     accept = (x <= cut);
00446   }
00447 
00448   //std::cout << x << " " << cut_min << " " << cut << " " << cut_max << " " << et << " " << accept << std::endl;
00449   return accept;
00450 }
00451 
00452 double CutBasedElectronID::robustSelection(const reco::GsfElectron* electron ,
00453                                            const edm::Event& e ,
00454                                            const edm::EventSetup& es) {
00455 
00456   double scTheta = (2*atan(exp(-electron->superCluster()->eta())));
00457   double scEt = electron->superCluster()->energy()*sin(scTheta);
00458   double eta = electron->p4().Eta();
00459   double eOverP = electron->eSuperClusterOverP();
00460   double hOverE = electron->hadronicOverEm();
00461   double sigmaee = electron->sigmaIetaIeta();
00462   double e25Max = electron->e2x5Max();
00463   double e15 = electron->e1x5();
00464   double e55 = electron->e5x5();
00465   double e25Maxoe55 = e25Max/e55;
00466   double e15oe55 = e15/e55 ;
00467   double deltaPhiIn = electron->deltaPhiSuperClusterTrackAtVtx();
00468   double deltaEtaIn = electron->deltaEtaSuperClusterTrackAtVtx();
00469 
00470   double ip = 0;
00471   int mishits = electron->gsfTrack()->trackerExpectedHitsInner().numberOfHits();
00472   double tkIso = electron->dr03TkSumPt();
00473   double ecalIso = electron->dr04EcalRecHitSumEt();
00474   double ecalIsoPed = (electron->isEB())?std::max(0.,ecalIso-1.):ecalIso;
00475   double hcalIso = electron->dr04HcalTowerSumEt();
00476   double hcalIso1 = electron->dr04HcalDepth1TowerSumEt();
00477   double hcalIso2 = electron->dr04HcalDepth2TowerSumEt();
00478 
00479   if (version_ == "V00") {
00480     sigmaee = electron->sigmaEtaEta();
00481      if (electron->isEE())
00482        sigmaee = sigmaee - 0.02*(fabs(eta) - 2.3);   //correct sigmaetaeta dependence on eta in endcap
00483   }
00484 
00485   if (version_ == "V03" or version_ == "V04") {
00486     edm::Handle<reco::BeamSpot> pBeamSpot;
00487     // uses the same name for the vertex collection to avoid adding more new names
00488     e.getByLabel(verticesCollection_, pBeamSpot);
00489     if (pBeamSpot.isValid()) {
00490       const reco::BeamSpot *bspot = pBeamSpot.product();
00491       const math::XYZPoint bspotPosition = bspot->position();
00492       ip = fabs(electron->gsfTrack()->dxy(bspotPosition));
00493     } else
00494       ip = fabs(electron->gsfTrack()->dxy());
00495   }
00496 
00497   if (version_ == "V04" or version_ == "V05") {
00498     ecalIso = electron->dr03EcalRecHitSumEt();
00499     ecalIsoPed = (electron->isEB())?std::max(0.,ecalIso-1.):ecalIso;
00500     hcalIso = electron->dr03HcalTowerSumEt();
00501     hcalIso1 = electron->dr03HcalDepth1TowerSumEt();
00502     hcalIso2 = electron->dr03HcalDepth2TowerSumEt();
00503   }
00504 
00505   if (version_ == "V05") {
00506     edm::Handle<reco::VertexCollection> vtxH;
00507     e.getByLabel(verticesCollection_, vtxH);
00508     if (vtxH->size() != 0) {
00509       reco::VertexRef vtx(vtxH, 0);
00510       ip = fabs(electron->gsfTrack()->dxy(math::XYZPoint(vtx->x(),vtx->y(),vtx->z())));
00511     } else
00512       ip = fabs(electron->gsfTrack()->dxy());
00513   }
00514 
00515   // .....................................................................................
00516   std::vector<double> cut;
00517   // ROBUST Selection
00518   if (type_ == "robust") {
00519 
00520     double result = 0;
00521 
00522     // hoe, sigmaEtaEta, dPhiIn, dEtaIn
00523     if (electron->isEB())
00524       cut = cuts_.getParameter<std::vector<double> >("barrel");
00525     else
00526       cut = cuts_.getParameter<std::vector<double> >("endcap");
00527     // check isolations: if only isolation passes result = 2
00528     if (quality_ == "highenergy") {
00529       if ((tkIso > cut[6] || hcalIso2 > cut[11]) ||
00530           (electron->isEB() && ((ecalIso + hcalIso1) > cut[7]+cut[8]*scEt)) ||
00531           (electron->isEE() && (scEt >= 50.) && ((ecalIso + hcalIso1) > cut[7]+cut[8]*(scEt-50))) ||
00532           (electron->isEE() && (scEt < 50.) && ((ecalIso + hcalIso1) > cut[9]+cut[10]*(scEt-50))))
00533         result = 0;
00534       else
00535         result = 2;
00536     } else {
00537       if ((tkIso > cut[6]) || (ecalIso > cut[7]) || (hcalIso > cut[8]) || (hcalIso1 > cut[9]) || (hcalIso2 > cut[10]) ||
00538           (tkIso/electron->p4().Pt() > cut[11]) || (ecalIso/electron->p4().Pt() > cut[12]) || (hcalIso/electron->p4().Pt() > cut[13]) ||
00539           ((tkIso+ecalIso+hcalIso)>cut[14]) || (((tkIso+ecalIso+hcalIso)/ electron->p4().Pt()) > cut[15]) ||
00540           ((tkIso+ecalIsoPed+hcalIso)>cut[16]) || (((tkIso+ecalIsoPed+hcalIso)/ electron->p4().Pt()) > cut[17])  )
00541         result = 0.;
00542       else
00543         result = 2.;
00544     }
00545 
00546     if ((hOverE < cut[0]) && (sigmaee < cut[1]) && (fabs(deltaPhiIn) < cut[2]) &&
00547         (fabs(deltaEtaIn) < cut[3]) && (e25Maxoe55 > cut[4] && e15oe55 > cut[5]) &&
00548         (sigmaee >= cut[18]) && (eOverP > cut[19] &&  eOverP < cut[20]) )
00549      { result = result + 1 ; }
00550 
00551     if (ip > cut[21])
00552       return result;
00553     if (mishits > cut[22]) // expected missing hits
00554       return result;
00555     // positive cut[23] means to demand a valid hit in 1st layer PXB
00556     if (cut[23] >0 && not (electron->gsfTrack()->hitPattern().hasValidHitInFirstPixelBarrel()))
00557       return result;
00558 
00559     // cut[24]: Dist cut[25]: dcot
00560     float dist = fabs(electron->convDist());
00561     float dcot = fabs(electron->convDcot());
00562     bool isConversion = (cut[24]>99. || cut[25]>99.)?false:(dist < cut[24] && dcot < cut[25]);
00563     if (isConversion)
00564       return result ;
00565     
00566     result += 4 ;
00567 
00568     return result ;
00569    }
00570 
00571   return -1. ;
00572  }