1 #include "Math/VectorUtil.h"
10 using namespace wp2012;
12 namespace HWWFunctions {
15 if ((cuts_passed & selectionType) == selectionType)
return true;
21 cuts_t cuts_passed =
electronSelection(hww, index, applyAlignmentCorrection, removedEtaCutInEndcap, useGsfTrack);
22 if ( (cuts_passed & selectionType) == selectionType )
return true;
38 if (fabs(hww.
els_p4().at(index).eta()) < 1.479){
41 }
else if (pfiso<0.09) {
69 if ((answer_loose_2012 & PassWP2012CutsNoIso) == PassWP2012CutsNoIso) cuts_passed |= (1ll<<
ELEID_WP2012_LOOSE_NOISO);
116 if (fabs(hww.
els_p4().at(index).eta()) < 2.5) cuts_passed |= (1ll<<
ELEETA_250);
117 if (fabs(hww.
els_p4().at(index).eta()) < 2.4) cuts_passed |= (1ll<<
ELEETA_240);
122 if( hww.
els_p4().at(index).pt() > 10.0 ) cuts_passed |= (1ll<<
ELEPT_010);
144 if (hww.
els_p4().at(index).pt() > 20.0)
return true;
146 if (hww.
els_fbrem().at(index) > 0.15)
return true;
148 if (fabs(hww.
els_etaSC().at(index)) < 1.) {
158 if (hww.
els_p4().at(index).pt() > 20.0)
return true;
160 if (hww.
els_fbrem().at(index) > 0.15)
return true;
162 if (fabs(hww.
els_etaSC().at(index)) < 1.) {
171 if (fabs(hww.
els_etaSC().at(index)) > 1.479 && hww.
els_hOverE().at(index) > 0.1)
return false;
173 if (hww.
els_p4().at(index).pt() > 20.0)
return true;
179 if (hww.
els_fbrem().at(index) > 0.15)
return true;
181 if (fabs(hww.
els_etaSC().at(index)) < 1.) {
196 unsigned int mask = 0;
199 std::vector<double> dEtaInThresholds;
200 std::vector<double> dPhiInThresholds;
201 std::vector<double> sigmaIEtaIEtaThresholds;
202 std::vector<double> hoeThresholds;
203 std::vector<double> ooemoopThresholds;
204 std::vector<double> d0VtxThresholds;
205 std::vector<double> dzVtxThresholds;
206 std::vector<bool> vtxFitThresholds;
207 std::vector<int> mHitsThresholds;
208 std::vector<double> isoHiThresholds;
209 std::vector<double> isoLoThresholds;
212 eidGetWP2012(tightness, dEtaInThresholds, dPhiInThresholds, hoeThresholds, sigmaIEtaIEtaThresholds,
213 ooemoopThresholds, d0VtxThresholds, dzVtxThresholds, vtxFitThresholds, mHitsThresholds,
214 isoHiThresholds, isoLoThresholds);
218 float etaAbs = fabs(hww.
els_etaSC().at(index));
219 float pt = hww.
els_p4().at(index).pt();
223 if (etaAbs <= 1.0) AEff = 0.10;
224 else if (etaAbs > 1.0 && etaAbs <= 1.479) AEff = 0.12;
225 else if (etaAbs > 1.479 && etaAbs <= 2.0) AEff = 0.085;
226 else if (etaAbs > 2.0 && etaAbs <= 2.2) AEff = 0.11;
227 else if (etaAbs > 2.2 && etaAbs <= 2.3) AEff = 0.12;
228 else if (etaAbs > 2.3 && etaAbs <= 2.4) AEff = 0.12;
229 else if (etaAbs > 2.4) AEff = 0.13;
239 float pfiso_n =
std::max(pfiso_em + pfiso_nh - rhoPrime * AEff,
float(0.0));
240 float pfiso = (pfiso_ch + pfiso_n) / pt;
246 bool vtxFitConversion =
isMITConversion(hww, index, 0, 1
e-6, 2.0,
true,
false);
258 if (fabs(d0vtx) < d0VtxThresholds[det]) mask |=
wp2012::D0VTX;
259 if (fabs(dzvtx) < dzVtxThresholds[det]) mask |=
wp2012::DZVTX;
260 if (!vtxFitThresholds[det] || !vtxFitConversion) mask |=
wp2012::VTXFIT;
262 if (pt >= 20.0 && pfiso < isoHiThresholds[det]) mask |=
wp2012::ISO;
263 if (pt < 20.0 && pfiso < isoLoThresholds[det]) mask |=
wp2012::ISO;
273 const float etaAbs = fabs(eta);
276 if (etaAbs <= 1.0 ) {
return 0.19;}
277 else if (etaAbs > 1.0 && etaAbs <= 1.479) {
return 0.25;}
278 else if (etaAbs > 1.479 && etaAbs <= 2.0) {
return 0.12;}
279 else if (etaAbs > 2.0 && etaAbs <= 2.2 ) {
return 0.21;}
280 else if (etaAbs > 2.2 && etaAbs <= 2.3 ) {
return 0.27;}
281 else if (etaAbs > 2.3 && etaAbs <= 2.4 ) {
return 0.44;}
282 else if (etaAbs > 2.4 ) {
return 0.52;}
292 std::vector<double> relisoThresholds;
293 std::vector<double> dEtaInThresholds;
294 std::vector<double> dPhiInThresholds;
295 std::vector<double> hoeThresholds;
296 std::vector<double> sigmaIEtaIEtaThresholds;
298 eidGetVBTF(tightness, dEtaInThresholds, dPhiInThresholds, hoeThresholds,
299 sigmaIEtaIEtaThresholds, relisoThresholds);
310 if (fabs(hww.
els_etaSC().at(index)) < 1.479) {
315 if (fabs(dEtaIn) < dEtaInThresholds[0] &&
316 fabs(dPhiIn) < dPhiInThresholds[0] &&
317 hww.
els_hOverE().at(index) < hoeThresholds[0] &&
323 if (fabs(hww.
els_etaSC().at(index)) > 1.479) {
326 bool passdEtaCut = fabs(dEtaIn) < dEtaInThresholds[1];
327 if(removedEtaCutInEndcap) passdEtaCut =
true;
329 fabs(dPhiIn) < dPhiInThresholds[1] &&
330 hww.
els_hOverE().at(index) < hoeThresholds[1] &&
343 float pt = hww.
els_p4().at(index).Pt();
344 unsigned int nbrem = hww.
els_nSeed().at(index);
346 if ( workingPoint == 0 ) {
349 if ( ( fabs(etaSC) < 1.479 && nbrem == 0 && lhValue > 3.5 ) ||
350 ( fabs(etaSC) < 1.479 && nbrem >= 1 && lhValue > 4.0 ) ||
351 ( fabs(etaSC) > 1.479 && nbrem == 0 && lhValue > 4.0 ) ||
352 ( fabs(etaSC) > 1.479 && nbrem >= 1 && lhValue > 4.0 ))
return true;
353 }
else if (pt > 10.0 && pt <= 20.0) {
354 if ( ( fabs(etaSC) < 1.479 && nbrem == 0 && lhValue > 4.0 ) ||
355 ( fabs(etaSC) < 1.479 && nbrem >= 1 && lhValue > 4.5 ) ||
356 ( fabs(etaSC) > 1.479 && nbrem == 0 && lhValue > 4.0 ) ||
357 ( fabs(etaSC) > 1.479 && nbrem >= 1 && lhValue > 4.0 ))
return true;
361 edm::LogError(
"InvalidInput") <<
"Error! Likelihood WP not supported: "
362 << workingPoint <<
". Please choose 0 for Emanuele 8th September";
380 double pt = hww.
els_p4().at(index).pt();
381 return sum/
max(pt, 20.);
384 float electronIsoValuePF(
HWW& hww,
const unsigned int iel,
unsigned int ivtx,
float coner,
float minptn,
float dzcut,
float footprintdr,
float gammastripveto,
float elestripveto,
int filterId ) {
389 float eleta = hww.
els_p4().at(iel).eta();
393 float pffootprint = 0.;
394 float pfjurveto = 0.;
395 float pfjurvetoq = 0.;
396 for (
unsigned int ipf=0; ipf<hww.
pfcands_p4().size(); ++ipf){
398 float dR = ROOT::Math::VectorUtil::DeltaR( hww.
pfcands_p4().at(ipf), hww.
els_p4().at(iel) );
400 if (dR>coner)
continue;
404 float deta = fabs(pfeta - eleta);
407 if (filterId!=0 && filterId!=pfid)
continue;
413 if (dR<footprintdr && pfid==130) pffootprint+=pfpt;
414 if (deta<gammastripveto && pfid==22) pfjurveto+=pfpt;
421 if (eltkid>=0 && pftkid>=0 && eltkid==pftkid)
continue;
424 if (elgsftkid>=0 && pfgsfid>=0 && elgsftkid==pfgsfid)
continue;
430 if(fabs(
gsftrks_dz_pv(hww, gsfid,ivtx ).first - eldz )<dzcut) {
432 if (deta<elestripveto && pfid==11) pfjurvetoq+=pfpt;
441 if (deta<elestripveto && pfid==11) pfjurvetoq+=pfpt;
448 return (pfciso+pfniso-pffootprint-pfjurveto-pfjurvetoq)/hww.
els_p4().at(iel).pt();
507 float scPositionCorrectionEEP[3] = { 0.52, -0.81, 0.81};
508 float scPositionCorrectionEEM[3] = { -0.02, -0.81, -0.94};
518 corrected_pos =
LorentzVector( initial_pos.x() + scPositionCorrectionEEM[0],
519 initial_pos.y() + scPositionCorrectionEEM[1],
520 initial_pos.z() + scPositionCorrectionEEM[2], 0.0);
523 corrected_pos =
LorentzVector( initial_pos.x() + scPositionCorrectionEEP[0],
524 initial_pos.y() + scPositionCorrectionEEP[1],
525 initial_pos.z() + scPositionCorrectionEEP[2], 0.0);
532 float deta_sc = corrected_pos.Eta() - initial_pos.Eta();
533 float dphi_sc = acos(
cos(corrected_pos.Phi() - initial_pos.Phi()));
534 dEtaIn = deta_sc + hww.
els_dEtaIn().at(index);
545 double dxyPV = hww.
els_d0().at(index)-
552 return (vtx.z()-pv.z()) - ((vtx.x()-pv.x())*p4.x()+(vtx.y()-pv.y())*p4.y())/p4.pt() * p4.z()/p4.pt();
562 double sumPtMax = -1;
564 for (
unsigned int i = 0;
i < hww.
vtxs_sumpt().size(); ++
i ){
571 if (iMax<0)
return 9999.;
576 return (vtx.z()-pv.z()) - ((vtx.x()-pv.x())*p4.x()+(vtx.y()-pv.y())*p4.y())/p4.pt() * p4.z()/p4.pt();
581 double sumPtMax = -1;
583 for (
unsigned int i = 0;
i < hww.
vtxs_sumpt().size(); ++
i ){
590 if (iMax<0)
return 9999.;
591 double dxyPV = hww.
els_d0().at(index)-
601 const float etaAbs = fabs(hww.
els_etaSC().at(index));
602 const float pt = hww.
els_p4().at(index).pt();
615 const float pfiso_n =
std::max(pfiso_em + pfiso_nh - rhoPrime * AEff, 0.0
f);
616 const float pfiso = (pfiso_ch + pfiso_n) / pt;
620 LogDebug(
"electronSelections") <<
"AEff : " << AEff <<
" "
621 <<
"rho : " << rhoPrime <<
" "
622 <<
"pfiso_ch : " << pfiso_ch <<
" "
623 <<
"pfiso_em : " << pfiso_em <<
" "
624 <<
"pfiso_nh : " << pfiso_nh <<
" "
625 <<
"pfiso_n : " << pfiso_n <<
" "
626 <<
"pfiso : " << pfiso <<
" "
627 <<
"pt : " << pt <<
" "
628 <<
"etaAbs : " << etaAbs;
bool electronId_smurf_v2(HWW &, const unsigned int index)
std::vector< float > & els_iso03_pf2012_ch()
float electronIsolation_rel(HWW &, const unsigned int index, bool use_calo_iso)
uint64 electronIdComponent_t
double electron_dzPV_wwV1(HWW &, unsigned int index)
std::vector< float > & els_conv_dcot()
std::vector< int > & pfels_elsidx()
float fastJetEffArea04_v1(HWW &, const float eta)
std::vector< float > & els_tkIso()
std::vector< int > & els_exp_innerlayers()
bool passLikelihoodId_v2(HWW &, unsigned int index, float lhValue, int workingPoint)
bool pass_electronSelectionCompareMask(HWW &, const cuts_t cuts_passed, const cuts_t selectionType)
bool isMITConversion(HWW &, unsigned int elidx, int nWrongHitsMax, float probMin, float dlMin, bool matchCTF, bool requireArbitratedMerged)
std::vector< LorentzVector > & els_vertex_p4()
std::vector< float > & els_hOverE()
std::vector< int > & pfcands_charge()
Sin< T >::type sin(const T &t)
std::vector< float > & els_ecalEnergy()
std::vector< int > & els_nSeed()
std::vector< float > & els_d0()
std::vector< float > & els_iso04_pf2012_nh()
std::vector< int > & els_sccharge()
std::vector< float > & els_iso04_pf2012_em()
std::vector< float > & els_fbrem()
std::vector< LorentzVector > & pfcands_p4()
std::vector< float > & els_conv_dist()
float electronIsoValuePF(HWW &, const unsigned int iel, unsigned int ivtx, float coner=0.4, float minptn=1.0, float dzcut=0.1, float footprintdr=0.07, float gammastripveto=0.025, float elestripveto=-999., int filterId=0)
std::vector< float > & els_iso04_pf2012_ch()
float electronIsoValuePF2012_FastJetEffArea_HWW(HWW &, int index)
electronIdComponent_t electronId_VBTF(HWW &, const unsigned int index, const vbtf_tightness tightness, bool applyAlignementCorrection=false, bool removedEtaCutInEndcap=false)
std::vector< int > & els_gsftrkidx()
std::vector< float > & els_iso03_pf2012_nh()
double electron_dzPV_smurfV3(HWW &, unsigned int index)
cuts_t electronSelection(HWW &, const unsigned int index, bool applyAlignmentCorrection=false, bool removedEtaCutInEndcap=false, bool useGsfTrack=true)
std::vector< float > & els_eOverPIn()
std::vector< int > & els_scindex()
std::vector< int > & pfcands_trkidx()
static const electronIdComponent_t PassWP2012CutsNoIso
std::vector< int > & pfcands_pfelsidx()
std::pair< double, double > gsftrks_dz_pv(HWW &, int itrk, int ipv)
void checkElectronSelections(void)
std::vector< int > & els_trk_charge()
const T & max(const T &a, const T &b)
std::vector< float > & els_ecalIso()
double electron_d0PV_smurfV3(HWW &, unsigned int index)
void eidGetVBTF(const vbtf_tightness tightness, std::vector< double > &cutdeta, std::vector< double > &cutdphi, std::vector< double > &cuthoe, std::vector< double > &cutsee, std::vector< double > &cutreliso)
Cos< T >::type cos(const T &t)
std::vector< int > & pfcands_particleId()
Abs< T >::type abs(const T &t)
std::vector< LorentzVector > & vtxs_position()
double electron_d0PV_wwV1(HWW &, unsigned int index)
std::vector< float > & els_hcalIso()
bool electronId_smurf_v1(HWW &, const unsigned int index)
std::vector< LorentzVector > & els_p4()
std::vector< float > & els_etaSC()
bool pass_electronSelection(HWW &, const unsigned int index, const cuts_t selectionType, bool applyAlignmentCorrection=false, bool removedEtaCutInEndcap=false, bool useGsfTrack=true)
static const electronIdComponent_t PassWP2012CutsNoIsoNoIP
std::vector< int > & els_charge()
bool isFromConversionMIT(HWW &, const unsigned int index)
std::pair< double, double > trks_dz_pv(HWW &, int itrk, int ipv)
std::vector< float > & els_dPhiIn()
float & evt_kt6pf_foregiso_rho()
std::vector< int > & els_type()
double dzPV(const LorentzVector &vtx, const LorentzVector &p4, const LorentzVector &pv)
void eidGetWP2012(const wp2012_tightness tightness, std::vector< double > &cutdeta, std::vector< double > &cutdphi, std::vector< double > &cuthoe, std::vector< double > &cutsee, std::vector< double > &cutooemoop, std::vector< double > &cutd0vtx, std::vector< double > &cutdzvtx, std::vector< bool > &cutvtxfit, std::vector< int > &cutmhit, std::vector< double > &cutrelisohighpt, std::vector< double > &cutrelisolowpt)
bool electronId_smurf_v3(HWW &, const unsigned int index)
std::vector< float > & els_dEtaIn()
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > LorentzVector
electronIdComponent_t electronId_WP2012(HWW &, const unsigned int index, const wp2012_tightness tightness)
std::vector< float > & els_iso03_pf2012_em()
std::vector< LorentzVector > & scs_pos_p4()
bool isChargeFlip3agree(HWW &, int elIndex)
void electronCorrection_pos(HWW &, const unsigned int index, float &dEtaIn, float &dPhiIn)
std::vector< int > & trks_charge()
std::vector< float > & els_sigmaIEtaIEta()
std::vector< float > & vtxs_sumpt()
std::vector< LorentzVector > & els_trk_p4()
math::PtEtaPhiELorentzVectorF LorentzVector
std::vector< int > & els_trkidx()
bool isFromConversionPartnerTrack(HWW &, const unsigned int index)
std::vector< int > & els_fiduciality()
bool isGoodVertex(HWW &hww, int)