diff --git a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py index c792b95f46fe1..2d457ddb337a0 100644 --- a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py +++ b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py @@ -261,6 +261,18 @@ def customizeHLTfor43549(process): return process +def customizeHLTfor43774(process): + filt_types = ["HLTEgammaGenericFilter","HLTEgammaGenericQuadraticEtaFilter","HLTEgammaGenericQuadraticFilter","HLTElectronGenericFilter"] + absAbleVar = ["DEta","deta","DetaSeed","Dphi","OneOESuperMinusOneOP","OneOESeedMinusOneOP"] + for filt_type in filt_types: + for filt in filters_by_type(process, filt_type): + if filt.varTag.productInstanceLabel in absAbleVar: + filt.useAbs = cms.bool(True) + + return process + + + # CMSSW version specific customizations def customizeHLTforCMSSW(process, menuType="GRun"): @@ -271,5 +283,5 @@ def customizeHLTforCMSSW(process, menuType="GRun"): process = customizeHLTfor43025(process) process = customizeHLTfor43549(process) - + process = customizeHLTfor43774(process) return process diff --git a/HLTrigger/Egamma/plugins/HLTEgammaGenericQuadraticEtaFilter.cc b/HLTrigger/Egamma/plugins/HLTEgammaGenericQuadraticEtaFilter.cc index 673e91a50bbe5..9ab14ecfff3c8 100644 --- a/HLTrigger/Egamma/plugins/HLTEgammaGenericQuadraticEtaFilter.cc +++ b/HLTrigger/Egamma/plugins/HLTEgammaGenericQuadraticEtaFilter.cc @@ -31,6 +31,7 @@ HLTEgammaGenericQuadraticEtaFilter::HLTEgammaGenericQuadraticEtaFilter(const edm energyLowEdges_ = iConfig.getParameter >("energyLowEdges"); lessThan_ = iConfig.getParameter("lessThan"); useEt_ = iConfig.getParameter("useEt"); + useAbs_ = iConfig.getParameter("useAbs"); etaBoundaryEB12_ = iConfig.getParameter("etaBoundaryEB12"); etaBoundaryEE12_ = iConfig.getParameter("etaBoundaryEE12"); @@ -101,6 +102,7 @@ void HLTEgammaGenericQuadraticEtaFilter::fillDescriptions(edm::ConfigurationDesc desc.add >("energyLowEdges", {0.0}); // No energy-dependent cuts by default desc.add("lessThan", true); desc.add("useEt", true); + desc.add("useAbs", false); desc.add("etaBoundaryEB12", 1.0); desc.add("etaBoundaryEE12", 2.0); desc.add >("thrRegularEB1", {4.0}); @@ -175,7 +177,7 @@ bool HLTEgammaGenericQuadraticEtaFilter::hltFilter(edm::Event& iEvent, ref = recoecalcands[i]; reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*depMap).find(ref); - float vali = mapi->val; + float vali = useAbs_ ? std::abs(mapi->val) : mapi->val; float EtaSC = ref->eta(); // Pick the right EA and do rhoCorr diff --git a/HLTrigger/Egamma/plugins/HLTEgammaGenericQuadraticEtaFilter.h b/HLTrigger/Egamma/plugins/HLTEgammaGenericQuadraticEtaFilter.h index d0432ec60c809..764217be0e3de 100644 --- a/HLTrigger/Egamma/plugins/HLTEgammaGenericQuadraticEtaFilter.h +++ b/HLTrigger/Egamma/plugins/HLTEgammaGenericQuadraticEtaFilter.h @@ -36,6 +36,7 @@ class HLTEgammaGenericQuadraticEtaFilter : public HLTFilter { edm::EDGetTokenT varToken_; bool lessThan_; // the cut is "<" or ">" ? bool useEt_; // use E or Et in relative isolation cuts + bool useAbs_; // use the standard abs of the variable (before any rho corr) /* Barrel quadratic threshold function: vali (<= or >=) thrRegularEB_ + (E or Et)*thrOverEEB_ + (E or Et)*(E or Et)*thrOverE2EB_ Endcap quadratic threshold function: diff --git a/HLTrigger/Egamma/plugins/HLTEgammaGenericQuadraticFilter.cc b/HLTrigger/Egamma/plugins/HLTEgammaGenericQuadraticFilter.cc index baf1b8b588cef..5e75615534123 100644 --- a/HLTrigger/Egamma/plugins/HLTEgammaGenericQuadraticFilter.cc +++ b/HLTrigger/Egamma/plugins/HLTEgammaGenericQuadraticFilter.cc @@ -31,6 +31,7 @@ HLTEgammaGenericQuadraticFilter::HLTEgammaGenericQuadraticFilter(const edm::Para energyLowEdges_ = iConfig.getParameter >("energyLowEdges"); lessThan_ = iConfig.getParameter("lessThan"); useEt_ = iConfig.getParameter("useEt"); + useAbs_ = iConfig.getParameter("useAbs"); thrRegularEB_ = iConfig.getParameter >("thrRegularEB"); thrRegularEE_ = iConfig.getParameter >("thrRegularEE"); @@ -89,6 +90,7 @@ void HLTEgammaGenericQuadraticFilter::fillDescriptions(edm::ConfigurationDescrip desc.add >("energyLowEdges", {0.0}); // No energy-dependent cuts by default desc.add("lessThan", true); desc.add("useEt", false); + desc.add("useAbs", false); desc.add >("thrRegularEB", {0.0}); desc.add >("thrRegularEE", {0.0}); desc.add >("thrOverEEB", {-1.0}); @@ -155,7 +157,7 @@ bool HLTEgammaGenericQuadraticFilter::hltFilter(edm::Event& iEvent, ref = recoecalcands[i]; reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*depMap).find(ref); - float vali = mapi->val; + float vali = useAbs_ ? std::abs(mapi->val) : mapi->val; float EtaSC = ref->eta(); // Pick the right EA and do rhoCorr diff --git a/HLTrigger/Egamma/plugins/HLTEgammaGenericQuadraticFilter.h b/HLTrigger/Egamma/plugins/HLTEgammaGenericQuadraticFilter.h index 0cb3e0d652bcd..f410c0fe1cf12 100644 --- a/HLTrigger/Egamma/plugins/HLTEgammaGenericQuadraticFilter.h +++ b/HLTrigger/Egamma/plugins/HLTEgammaGenericQuadraticFilter.h @@ -37,6 +37,7 @@ class HLTEgammaGenericQuadraticFilter : public HLTFilter { bool lessThan_; // the cut is "<" or ">" ? bool useEt_; // use E or Et in relative isolation cuts + bool useAbs_; // use the standard abs of the variable (before any rho corr) /* Barrel quadratic threshold function: vali (<= or >=) thrRegularEB_ + (E or Et)*thrOverEEB_ + (E or Et)*(E or Et)*thrOverE2EB_ Endcap quadratic threshold function: diff --git a/HLTrigger/Egamma/plugins/HLTGenericFilter.cc b/HLTrigger/Egamma/plugins/HLTGenericFilter.cc index f84cf062d304a..31fba72842f6c 100644 --- a/HLTrigger/Egamma/plugins/HLTGenericFilter.cc +++ b/HLTrigger/Egamma/plugins/HLTGenericFilter.cc @@ -33,6 +33,7 @@ HLTGenericFilter::HLTGenericFilter(const edm::ParameterSet& iConfig) : HLTFi energyLowEdges_ = iConfig.template getParameter>("energyLowEdges"); lessThan_ = iConfig.template getParameter("lessThan"); useEt_ = iConfig.template getParameter("useEt"); + useAbs_ = iConfig.template getParameter("useAbs"); thrRegularEB_ = iConfig.template getParameter>("thrRegularEB"); thrRegularEE_ = iConfig.template getParameter>("thrRegularEE"); thrOverEEB_ = iConfig.template getParameter>("thrOverEEB"); @@ -88,6 +89,7 @@ void HLTGenericFilter::fillDescriptions(edm::ConfigurationDescriptions& desc desc.add>("energyLowEdges", {0.0}); // No energy-dependent cuts by default desc.add("lessThan", true); desc.add("useEt", false); + desc.add("useAbs", false); desc.add>("thrRegularEB", {0.0}); desc.add>("thrRegularEE", {0.0}); desc.add>("thrOverEEB", {-1.0}); @@ -177,7 +179,11 @@ bool HLTGenericFilter::hltFilter(edm::Event& iEvent, T1Ref ref = recoCands[i]; typename T1IsolationMap::const_iterator mapi = (*depMap).find(ref); - float vali = mapi->val; + //should we do the abs before or after the rho corr? + //note: its very unlikely to rho correct a variable that wants to be abs + //decided yes as it seems slightly better this way but can not think of a use case either way + float vali = useAbs_ ? std::abs(mapi->val) : mapi->val; + float EtaSC = ref->eta(); // Pick the right EA and do rhoCorr @@ -191,7 +197,6 @@ bool HLTGenericFilter::hltFilter(edm::Event& iEvent, energy = getEt(ref); else energy = getEnergy(ref); - //if (energy < 0.) energy = 0.; // require energy to be positive (needed?) // Pick the right cut threshold double cutRegularEB_ = 9999., cutRegularEE_ = 9999.; diff --git a/HLTrigger/Egamma/plugins/HLTGenericFilter.h b/HLTrigger/Egamma/plugins/HLTGenericFilter.h index 603162b8498af..d7fd3a948828e 100644 --- a/HLTrigger/Egamma/plugins/HLTGenericFilter.h +++ b/HLTrigger/Egamma/plugins/HLTGenericFilter.h @@ -56,6 +56,7 @@ class HLTGenericFilter : public HLTFilter { std::vector energyLowEdges_; // lower bin edges for energy-dependent cuts bool lessThan_; // the cut is "<" or ">" ? bool useEt_; // use E or Et in relative isolation cuts + bool useAbs_; // use the standard abs of the variable (before any rho corr) std::vector thrRegularEB_; // threshold for regular cut (x < thr) - ECAL barrel std::vector thrRegularEE_; // threshold for regular cut (x < thr) - ECAL endcap std::vector thrOverEEB_; // threshold for x/E < thr cut (isolations) - ECAL barrel diff --git a/RecoEgamma/EgammaHLTProducers/plugins/EgammaHLTGsfTrackVarProducer.cc b/RecoEgamma/EgammaHLTProducers/plugins/EgammaHLTGsfTrackVarProducer.cc index ce66e70a0daab..f309f2621b981 100644 --- a/RecoEgamma/EgammaHLTProducers/plugins/EgammaHLTGsfTrackVarProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/plugins/EgammaHLTGsfTrackVarProducer.cc @@ -39,10 +39,29 @@ #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h" class EgammaHLTGsfTrackVarProducer : public edm::global::EDProducer<> { +public: + struct GsfTrackExtrapolations { + GsfTrackExtrapolations() {} + void operator()(const reco::GsfTrack& trk, + const reco::SuperCluster& sc, + const MultiTrajectoryStateTransform& mtsTransform); + TrajectoryStateOnSurface innTSOS; + TrajectoryStateOnSurface outTSOS; + TrajectoryStateOnSurface sclTSOS; + + GlobalVector innMom, outMom; + GlobalPoint sclPos; + }; + public: explicit EgammaHLTGsfTrackVarProducer(const edm::ParameterSet&); void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + void fillAbsAbleVar(float& existVal, const float newVal) const { + if (std::abs(newVal) < std::abs(existVal)) { + existVal = produceAbsValues_ ? std::abs(newVal) : newVal; + } + } private: const edm::EDGetTokenT recoEcalCandToken_; @@ -57,6 +76,7 @@ class EgammaHLTGsfTrackVarProducer : public edm::global::EDProducer<> { const int lowerTrackNrToRemoveCut_; const bool useDefaultValuesForBarrel_; const bool useDefaultValuesForEndcap_; + const bool produceAbsValues_; const edm::EDPutTokenT dEtaMapPutToken_; const edm::EDPutTokenT dEtaSeedMapPutToken_; @@ -67,8 +87,15 @@ class EgammaHLTGsfTrackVarProducer : public edm::global::EDProducer<> { const edm::EDPutTokenT validHitsMapPutToken_; const edm::EDPutTokenT nLayerITMapPutToken_; const edm::EDPutTokenT chi2MapPutToken_; + const edm::EDPutTokenT fbremMapPutToken_; }; +namespace { + + float calRelDelta(float a, float b, float defaultVal = 0.f) { return a != 0.f ? (a - b) / a : defaultVal; } + +} // namespace + EgammaHLTGsfTrackVarProducer::EgammaHLTGsfTrackVarProducer(const edm::ParameterSet& config) : recoEcalCandToken_( consumes(config.getParameter("recoEcalCandidateProducer"))), @@ -81,6 +108,7 @@ EgammaHLTGsfTrackVarProducer::EgammaHLTGsfTrackVarProducer(const edm::ParameterS lowerTrackNrToRemoveCut_{config.getParameter("lowerTrackNrToRemoveCut")}, useDefaultValuesForBarrel_{config.getParameter("useDefaultValuesForBarrel")}, useDefaultValuesForEndcap_{config.getParameter("useDefaultValuesForEndcap")}, + produceAbsValues_{config.getParameter("produceAbsValues")}, dEtaMapPutToken_{produces("Deta").setBranchAlias("deta")}, dEtaSeedMapPutToken_{produces("DetaSeed").setBranchAlias("detaseed")}, dPhiMapPutToken_{produces("Dphi").setBranchAlias("dphi")}, @@ -90,7 +118,8 @@ EgammaHLTGsfTrackVarProducer::EgammaHLTGsfTrackVarProducer(const edm::ParameterS produces("MissingHits").setBranchAlias("missinghits")}, validHitsMapPutToken_{produces("ValidHits").setBranchAlias("validhits")}, nLayerITMapPutToken_{produces("NLayerIT").setBranchAlias("nlayerit")}, - chi2MapPutToken_{produces("Chi2").setBranchAlias("chi2")} {} + chi2MapPutToken_{produces("Chi2").setBranchAlias("chi2")}, + fbremMapPutToken_{produces("fbrem")} {} void EgammaHLTGsfTrackVarProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; @@ -101,6 +130,7 @@ void EgammaHLTGsfTrackVarProducer::fillDescriptions(edm::ConfigurationDescriptio desc.add(("lowerTrackNrToRemoveCut"), -1); desc.add(("useDefaultValuesForBarrel"), false); desc.add(("useDefaultValuesForEndcap"), false); + desc.add(("produceAbsValues"), false); descriptions.add("hltEgammaHLTGsfTrackVarProducer", desc); } @@ -124,6 +154,7 @@ void EgammaHLTGsfTrackVarProducer::produce(edm::StreamID, edm::Event& iEvent, co reco::RecoEcalCandidateIsolationMap validHitsMap(recoEcalCandHandle); reco::RecoEcalCandidateIsolationMap nLayerITMap(recoEcalCandHandle); reco::RecoEcalCandidateIsolationMap chi2Map(recoEcalCandHandle); + reco::RecoEcalCandidateIsolationMap fbremMap(recoEcalCandHandle); for (unsigned int iRecoEcalCand = 0; iRecoEcalCand < recoEcalCandHandle->size(); ++iRecoEcalCand) { reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle, iRecoEcalCand); @@ -156,6 +187,7 @@ void EgammaHLTGsfTrackVarProducer::produce(edm::StreamID, edm::Event& iEvent, co float dPhiInValue = 999999; float oneOverESuperMinusOneOverPValue = 999999; float oneOverESeedMinusOneOverPValue = 999999; + float fbrem = 999999; const int nrTracks = gsfTracks.size(); const bool rmCutsDueToNrTracks = nrTracks <= lowerTrackNrToRemoveCut_ || nrTracks >= upperTrackNrToRemoveCut_; @@ -164,6 +196,9 @@ void EgammaHLTGsfTrackVarProducer::produce(edm::StreamID, edm::Event& iEvent, co ? useDefaultValuesForBarrel_ && nrTracks >= 1 : useDefaultValuesForEndcap_ && nrTracks >= 1; + MultiTrajectoryStateTransform mtsTransform(&trackerGeometry, &magneticField); + GsfTrackExtrapolations gsfTrackExtrapolations; + if (rmCutsDueToNrTracks || useDefaultValues) { nLayerITValue = 100; dEtaInValue = 0; @@ -174,30 +209,23 @@ void EgammaHLTGsfTrackVarProducer::produce(edm::StreamID, edm::Event& iEvent, co chi2Value = 0; oneOverESuperMinusOneOverPValue = 0; oneOverESeedMinusOneOverPValue = 0; + fbrem = 0; } else { for (size_t trkNr = 0; trkNr < gsfTracks.size(); trkNr++) { GlobalPoint scPos(scRef->x(), scRef->y(), scRef->z()); - GlobalPoint trackExtrapToSC; - { - auto innTSOS = - MultiTrajectoryStateTransform::innerStateOnSurface(*gsfTracks[trkNr], trackerGeometry, &magneticField); - auto posTSOS = extrapolator.extrapolate(innTSOS, scPos); - multiTrajectoryStateMode::positionFromModeCartesian(posTSOS, trackExtrapToSC); - } + gsfTrackExtrapolations(*gsfTracks[trkNr], *scRef, mtsTransform); - EleRelPointPair scAtVtx(scRef->position(), trackExtrapToSC, beamSpotPosition); + EleRelPointPair scAtVtx(scRef->position(), gsfTrackExtrapolations.sclPos, beamSpotPosition); + + fbrem = calRelDelta(gsfTrackExtrapolations.innMom.mag(), gsfTrackExtrapolations.outMom.mag(), fbrem); float trkP = gsfTracks[trkNr]->p(); if (scRef->energy() != 0 && trkP != 0) { - if (std::abs(1 / scRef->energy() - 1 / trkP) < oneOverESuperMinusOneOverPValue) { - oneOverESuperMinusOneOverPValue = std::abs(1 / scRef->energy() - 1 / trkP); - } + fillAbsAbleVar(oneOverESuperMinusOneOverPValue, 1 / scRef->energy() - 1 / trkP); } if (scRef->seed().isNonnull() && scRef->seed()->energy() != 0 && trkP != 0) { - if (std::abs(1 / scRef->seed()->energy() - 1 / trkP) < oneOverESeedMinusOneOverPValue) { - oneOverESeedMinusOneOverPValue = std::abs(1 / scRef->seed()->energy() - 1 / trkP); - } + fillAbsAbleVar(oneOverESeedMinusOneOverPValue, 1 / scRef->seed()->energy() - 1 / trkP); } if (gsfTracks[trkNr]->missingInnerHits() < missingHitsValue) { @@ -218,19 +246,9 @@ void EgammaHLTGsfTrackVarProducer::produce(edm::StreamID, edm::Event& iEvent, co chi2Value = gsfTracks[trkNr]->normalizedChi2(); } - if (std::abs(scAtVtx.dEta()) < dEtaInValue) { - // we are allowing them to come from different tracks - dEtaInValue = std::abs(scAtVtx.dEta()); - } - - if (std::abs(scAtVtx.dEta()) < dEtaSeedInValue) { - dEtaSeedInValue = std::abs(scAtVtx.dEta() - scRef->position().eta() + scRef->seed()->position().eta()); - } - - if (std::abs(scAtVtx.dPhi()) < dPhiInValue) { - // we are allowing them to come from different tracks - dPhiInValue = std::abs(scAtVtx.dPhi()); - } + fillAbsAbleVar(dEtaInValue, scAtVtx.dEta()); + fillAbsAbleVar(dEtaSeedInValue, scAtVtx.dEta() - scRef->position().eta() + scRef->seed()->position().eta()); + fillAbsAbleVar(dPhiInValue, scAtVtx.dPhi()); } } @@ -243,6 +261,7 @@ void EgammaHLTGsfTrackVarProducer::produce(edm::StreamID, edm::Event& iEvent, co validHitsMap.insert(recoEcalCandRef, validHitsValue); nLayerITMap.insert(recoEcalCandRef, nLayerITValue); chi2Map.insert(recoEcalCandRef, chi2Value); + fbremMap.insert(recoEcalCandRef, fbrem); } iEvent.emplace(dEtaMapPutToken_, dEtaMap); @@ -254,6 +273,18 @@ void EgammaHLTGsfTrackVarProducer::produce(edm::StreamID, edm::Event& iEvent, co iEvent.emplace(validHitsMapPutToken_, validHitsMap); iEvent.emplace(nLayerITMapPutToken_, nLayerITMap); iEvent.emplace(chi2MapPutToken_, chi2Map); + iEvent.emplace(fbremMapPutToken_, fbremMap); +} + +void EgammaHLTGsfTrackVarProducer::GsfTrackExtrapolations::operator()( + const reco::GsfTrack& trk, const reco::SuperCluster& sc, const MultiTrajectoryStateTransform& mtsTransform) { + innTSOS = mtsTransform.innerStateOnSurface(trk); + outTSOS = mtsTransform.outerStateOnSurface(trk); + sclTSOS = mtsTransform.extrapolatedState(innTSOS, GlobalPoint(sc.x(), sc.y(), sc.z())); + + multiTrajectoryStateMode::momentumFromModeCartesian(innTSOS, innMom); + multiTrajectoryStateMode::positionFromModeCartesian(sclTSOS, sclPos); + multiTrajectoryStateMode::momentumFromModeCartesian(outTSOS, outMom); } #include "FWCore/Framework/interface/MakerMacros.h"