From eb506abc4a612e050ca1b8cc640330366a7d344e Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Fri, 21 Sep 2018 13:43:58 +0200 Subject: [PATCH 1/6] use modern pointer --- .../PFRecoTauDiscriminationAgainstElectronMVA6.cc | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc index cc3760b6f70c8..94872dac66370 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc @@ -29,10 +29,10 @@ class PFRecoTauDiscriminationAgainstElectronMVA6 : public PFTauDiscriminationPro public: explicit PFRecoTauDiscriminationAgainstElectronMVA6(const edm::ParameterSet& cfg) : PFTauDiscriminationProducerBase(cfg), - mva_(nullptr), + mva_(), category_output_() { - mva_ = new AntiElectronIDMVA6(cfg); + mva_ = std::make_unique(cfg); usePhiAtEcalEntranceExtrapolation_ = cfg.getParameter("usePhiAtEcalEntranceExtrapolation"); srcGsfElectrons_ = cfg.getParameter("srcGsfElectrons"); @@ -51,18 +51,13 @@ class PFRecoTauDiscriminationAgainstElectronMVA6 : public PFTauDiscriminationPro void endEvent(edm::Event&) override; - ~PFRecoTauDiscriminationAgainstElectronMVA6() override - { - delete mva_; - } + ~PFRecoTauDiscriminationAgainstElectronMVA6() override {} private: bool isInEcalCrack(double) const; std::string moduleLabel_; - - AntiElectronIDMVA6* mva_; - float* mvaInput_; + std::unique_ptr mva_; edm::InputTag srcGsfElectrons_; edm::EDGetTokenT GsfElectrons_token; From 456cae499e544e90bdaa3c716f31aef8ed19cf96 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Fri, 21 Sep 2018 15:15:55 +0200 Subject: [PATCH 2/6] Constraints on input values against unphysical outliers --- RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc index d44240810966b..5211b72fb306e 100644 --- a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc +++ b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc @@ -393,10 +393,10 @@ double AntiElectronIDMVA6::MVAValue(Float_t TauPt, Var_woGwGSF_Barrel_[0] = std::max(float(-0.1), ElecEtotOverPin); Var_woGwGSF_Barrel_[1] = std::log(ElecChi2NormGSF); Var_woGwGSF_Barrel_[2] = ElecGSFNumHits; - Var_woGwGSF_Barrel_[3] = std::log(ElecGSFTrackResol); + Var_woGwGSF_Barrel_[3] = std::log(std::max(float(0.1), ElecGSFTrackResol)); Var_woGwGSF_Barrel_[4] = ElecGSFTracklnPt; Var_woGwGSF_Barrel_[5] = ElecNumHitsDiffOverSum; - Var_woGwGSF_Barrel_[6] = std::log(ElecChi2NormKF); + Var_woGwGSF_Barrel_[6] = std::log(std::max(float(0.1), ElecChi2NormKF)); Var_woGwGSF_Barrel_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.)); Var_woGwGSF_Barrel_[8] = std::min(ElecEecalOverPout, float(20.)); Var_woGwGSF_Barrel_[9] = ElecDeltaEta; @@ -417,12 +417,12 @@ double AntiElectronIDMVA6::MVAValue(Float_t TauPt, mvaValue = mva_woGwGSF_BL_->GetClassifier(Var_woGwGSF_Barrel_); } else { Var_woGwGSF_Endcap_[0] = std::max(float(-0.1), ElecEtotOverPin); - Var_woGwGSF_Endcap_[1] = std::log(ElecChi2NormGSF); + Var_woGwGSF_Endcap_[1] = std::log(std::max(float(0.1), ElecChi2NormGSF)); Var_woGwGSF_Endcap_[2] = ElecGSFNumHits; - Var_woGwGSF_Endcap_[3] = std::log(ElecGSFTrackResol); + Var_woGwGSF_Endcap_[3] = std::log(std::max(float(0.1), ElecGSFTrackResol)); Var_woGwGSF_Endcap_[4] = ElecGSFTracklnPt; Var_woGwGSF_Endcap_[5] = ElecNumHitsDiffOverSum; - Var_woGwGSF_Endcap_[6] = std::log(ElecChi2NormKF); + Var_woGwGSF_Endcap_[6] = std::log(std::max(float(0.1), ElecChi2NormKF)); Var_woGwGSF_Endcap_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.)); Var_woGwGSF_Endcap_[8] = std::min(ElecEecalOverPout, float(20.)); Var_woGwGSF_Endcap_[9] = ElecDeltaEta; @@ -445,12 +445,12 @@ double AntiElectronIDMVA6::MVAValue(Float_t TauPt, else if ( TauSignalPFGammaCandsIn > 0 && TauHasGsf > 0.5 ) { if ( std::abs(TauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ) { Var_wGwGSF_Barrel_[0] = std::max(float(-0.1), ElecEtotOverPin); - Var_wGwGSF_Barrel_[1] = std::log(ElecChi2NormGSF); + Var_wGwGSF_Barrel_[1] = std::log(std::max(float(0.1), ElecChi2NormGSF)); Var_wGwGSF_Barrel_[2] = ElecGSFNumHits; - Var_wGwGSF_Barrel_[3] = std::log(ElecGSFTrackResol); + Var_wGwGSF_Barrel_[3] = std::log(std::max(float(0.1), ElecGSFTrackResol)); Var_wGwGSF_Barrel_[4] = ElecGSFTracklnPt; Var_wGwGSF_Barrel_[5] = ElecNumHitsDiffOverSum; - Var_wGwGSF_Barrel_[6] = std::log(ElecChi2NormKF); + Var_wGwGSF_Barrel_[6] = std::log(std::max(float(0.1), ElecChi2NormKF)); Var_wGwGSF_Barrel_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.)); Var_wGwGSF_Barrel_[8] = std::min(ElecEecalOverPout, float(20.)); Var_wGwGSF_Barrel_[9] = ElecDeltaEta; @@ -479,12 +479,12 @@ double AntiElectronIDMVA6::MVAValue(Float_t TauPt, mvaValue = mva_wGwGSF_BL_->GetClassifier(Var_wGwGSF_Barrel_); } else { Var_wGwGSF_Endcap_[0] = std::max(float(-0.1), ElecEtotOverPin); - Var_wGwGSF_Endcap_[1] = std::log(ElecChi2NormGSF); + Var_wGwGSF_Endcap_[1] = std::log(std::max(float(0.1), ElecChi2NormGSF)); Var_wGwGSF_Endcap_[2] = ElecGSFNumHits; - Var_wGwGSF_Endcap_[3] = std::log(ElecGSFTrackResol); + Var_wGwGSF_Endcap_[3] = std::log(std::max(float(0.1), ElecGSFTrackResol)); Var_wGwGSF_Endcap_[4] = ElecGSFTracklnPt; Var_wGwGSF_Endcap_[5] = ElecNumHitsDiffOverSum; - Var_wGwGSF_Endcap_[6] = std::log(ElecChi2NormKF); + Var_wGwGSF_Endcap_[6] = std::log(std::max(float(0.1), ElecChi2NormKF)); Var_wGwGSF_Endcap_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.)); Var_wGwGSF_Endcap_[8] = std::min(ElecEecalOverPout, float(20.)); Var_wGwGSF_Endcap_[9] = ElecDeltaEta; From 9fc628046dbc4e620dfd32a35ae5a092577995e6 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Fri, 21 Sep 2018 16:14:41 +0200 Subject: [PATCH 3/6] usePhiAtEcalEntranceExtrapolation becomes an internal parameter of the AntiElectronMVA algo --- .../RecoTau/interface/AntiElectronIDMVA6.h | 12 +++++++----- .../PATTauDiscriminationAgainstElectronMVA6.cc | 6 ++---- ...RecoTauDiscriminationAgainstElectronMVA6.cc | 6 ++---- RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc | 18 ++++++++++-------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/RecoTauTag/RecoTau/interface/AntiElectronIDMVA6.h b/RecoTauTag/RecoTau/interface/AntiElectronIDMVA6.h index cc2d246e9d619..afbaf54f57861 100644 --- a/RecoTauTag/RecoTau/interface/AntiElectronIDMVA6.h +++ b/RecoTauTag/RecoTau/interface/AntiElectronIDMVA6.h @@ -123,15 +123,15 @@ class AntiElectronIDMVA6 // this function can be called for all categories double MVAValue(const reco::PFTau& thePFTau, - const reco::GsfElectron& theGsfEle, bool usePhiAtEcalEntranceExtrapolation); + const reco::GsfElectron& theGsfEle); // this function can be called for category 1 only !! - double MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEcalEntranceExtrapolation); + double MVAValue(const reco::PFTau& thePFTau); // this function can be called for all categories double MVAValue(const pat::Tau& theTau, - const pat::Electron& theEle, bool usePhiAtEcalEntranceExtrapolation); + const pat::Electron& theEle); // this function can be called for category 1 only !! - double MVAValue(const pat::Tau& theTau, bool usePhiAtEcalEntranceExtrapolation); + double MVAValue(const pat::Tau& theTau); // track extrapolation to ECAL entrance (used to re-calculate varibales that might not be available on miniAOD) bool atECalEntrance(const reco::Candidate* part, math::XYZPoint &pos); @@ -153,7 +153,9 @@ class AntiElectronIDMVA6 std::string mvaName_NoEleMatch_wGwoGSF_EC_; std::string mvaName_woGwGSF_EC_; std::string mvaName_wGwGSF_EC_; - + + bool usePhiAtEcalEntranceExtrapolation_; + Float_t* Var_NoEleMatch_woGwoGSF_Barrel_; Float_t* Var_NoEleMatch_wGwoGSF_Barrel_; Float_t* Var_woGwGSF_Barrel_; diff --git a/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc index 4ad8e257209ae..8416a6e21ce21 100644 --- a/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc @@ -31,7 +31,6 @@ class PATTauDiscriminationAgainstElectronMVA6 : public PATTauDiscriminationProdu { mva_ = std::make_unique(cfg); - usePhiAtEcalEntranceExtrapolation_ = cfg.getParameter("usePhiAtEcalEntranceExtrapolation"); srcElectrons = cfg.getParameter("srcElectrons"); electronToken = consumes(srcElectrons); verbosity_ = ( cfg.exists("verbosity") ) ? @@ -61,7 +60,6 @@ class PATTauDiscriminationAgainstElectronMVA6 : public PATTauDiscriminationProdu edm::Handle taus_; std::unique_ptr category_output_; - bool usePhiAtEcalEntranceExtrapolation_; int verbosity_; }; @@ -104,7 +102,7 @@ double PATTauDiscriminationAgainstElectronMVA6::discriminate(const TauRef& theTa double deltaREleTau = deltaR(theElectron.p4(), theTauRef->p4()); deltaRDummy = deltaREleTau; if( deltaREleTau < 0.3 ){ - double mva_match = mva_->MVAValue(*theTauRef, theElectron, usePhiAtEcalEntranceExtrapolation_); + double mva_match = mva_->MVAValue(*theTauRef, theElectron); bool hasGsfTrack = false; pat::PackedCandidate const* packedLeadTauCand = dynamic_cast(theTauRef->leadChargedHadrCand().get()); if( abs(packedLeadTauCand->pdgId()) == 11 ) @@ -142,7 +140,7 @@ double PATTauDiscriminationAgainstElectronMVA6::discriminate(const TauRef& theTa } // end of loop over electrons if ( !isGsfElectronMatched ) { - mvaValue = mva_->MVAValue(*theTauRef, usePhiAtEcalEntranceExtrapolation_); + mvaValue = mva_->MVAValue(*theTauRef); bool hasGsfTrack = false; pat::PackedCandidate const* packedLeadTauCand = dynamic_cast(theTauRef->leadChargedHadrCand().get()); if( abs(packedLeadTauCand->pdgId()) == 11 ) hasGsfTrack = true; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc index 94872dac66370..18837554a129b 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc @@ -34,7 +34,6 @@ class PFRecoTauDiscriminationAgainstElectronMVA6 : public PFTauDiscriminationPro { mva_ = std::make_unique(cfg); - usePhiAtEcalEntranceExtrapolation_ = cfg.getParameter("usePhiAtEcalEntranceExtrapolation"); srcGsfElectrons_ = cfg.getParameter("srcGsfElectrons"); GsfElectrons_token = consumes(srcGsfElectrons_); @@ -65,7 +64,6 @@ class PFRecoTauDiscriminationAgainstElectronMVA6 : public PFTauDiscriminationPro edm::Handle taus_; std::unique_ptr category_output_; - bool usePhiAtEcalEntranceExtrapolation_; int verbosity_; }; @@ -144,7 +142,7 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& double deltaREleTau = deltaR(theGsfElectron->p4(), thePFTauRef->p4()); deltaRDummy = deltaREleTau; if ( deltaREleTau < 0.3 ) { - double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron, usePhiAtEcalEntranceExtrapolation_); + double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron); bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().isNonnull(); if ( !hasGsfTrack ) hasGsfTrack = theGsfElectron->gsfTrack().isNonnull(); @@ -181,7 +179,7 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& } // end of loop over electrons if ( !isGsfElectronMatched ) { - mvaValue = mva_->MVAValue(*thePFTauRef, usePhiAtEcalEntranceExtrapolation_); + mvaValue = mva_->MVAValue(*thePFTauRef); bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().isNonnull(); //// Veto taus that go to Ecal crack diff --git a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc index 5211b72fb306e..a36af2efeaece 100644 --- a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc +++ b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc @@ -46,6 +46,8 @@ AntiElectronIDMVA6::AntiElectronIDMVA6(const edm::ParameterSet& cfg) mvaName_woGwGSF_EC_ = cfg.getParameter("mvaName_woGwGSF_EC"); mvaName_wGwGSF_EC_ = cfg.getParameter("mvaName_wGwGSF_EC"); + usePhiAtEcalEntranceExtrapolation_ = cfg.getParameter("usePhiAtEcalEntranceExtrapolation"); + Var_NoEleMatch_woGwoGSF_Barrel_ = new Float_t[10]; Var_NoEleMatch_wGwoGSF_Barrel_ = new Float_t[18]; Var_woGwGSF_Barrel_ = new Float_t[24]; @@ -516,7 +518,7 @@ double AntiElectronIDMVA6::MVAValue(Float_t TauPt, } double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, - const reco::GsfElectron& theGsfEle, bool usePhiAtEcalEntranceExtrapolation) + const reco::GsfElectron& theGsfEle) { // === tau variables === @@ -619,7 +621,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, Float_t TauPhi = thePFTau.phi(); float sumPhiTimesEnergy = 0.; float sumEnergyPhi = 0.; - if ( !usePhiAtEcalEntranceExtrapolation ){ + if ( !usePhiAtEcalEntranceExtrapolation_ ){ for (auto const& pfc : signalPFCands){ sumPhiTimesEnergy += pfc->positionAtECALEntrance().phi()*pfc->energy(); sumEnergyPhi += pfc->energy(); @@ -732,7 +734,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, ElecMvaInDeltaEta); } -double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEcalEntranceExtrapolation) +double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau) { // === tau variables === float TauEtaAtEcalEntrance = -99.; @@ -834,7 +836,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc Float_t TauPhi = thePFTau.phi(); float sumPhiTimesEnergy = 0.; float sumEnergyPhi = 0.; - if ( !usePhiAtEcalEntranceExtrapolation ){ + if ( !usePhiAtEcalEntranceExtrapolation_ ){ for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); pfCandidate != signalPFCands.end(); ++pfCandidate ) { sumPhiTimesEnergy += (*pfCandidate)->positionAtECALEntrance().phi()*(*pfCandidate)->energy(); @@ -902,7 +904,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc 0.); } -double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau, const pat::Electron& theEle, bool usePhiAtEcalEntranceExtrapolation) +double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau, const pat::Electron& theEle) { // === tau variables === float TauEtaAtEcalEntrance = theTau.etaAtEcalEntrance(); @@ -984,7 +986,7 @@ double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau, const pat::Electron& Int_t TauSignalPFGammaCandsOut = GammasPtOutSigCone.size(); Float_t TauVisMassIn = (pfGammaSum + pfChargedSum).mass(); Float_t TauPhi = -99.; - if ( usePhiAtEcalEntranceExtrapolation ) { + if ( usePhiAtEcalEntranceExtrapolation_ ) { float sumPhiTimesEnergy = 0.; float sumEnergy = 0.; const reco::CandidatePtrVector signalCands = theTau.signalCands(); @@ -1098,7 +1100,7 @@ double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau, const pat::Electron& ElecMvaInDeltaEta); } -double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau, bool usePhiAtEcalEntranceExtrapolation) +double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau) { // === tau variables === float TauEtaAtEcalEntrance = theTau.etaAtEcalEntrance(); @@ -1172,7 +1174,7 @@ double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau, bool usePhiAtEcalEnt Int_t TauSignalPFGammaCandsOut = GammasPtOutSigCone.size(); Float_t TauVisMassIn = (pfGammaSum + pfChargedSum).mass(); Float_t TauPhi = -99.; - if ( usePhiAtEcalEntranceExtrapolation ) { + if ( usePhiAtEcalEntranceExtrapolation_ ) { float sumPhiTimesEnergy = 0.; float sumEnergy = 0.; const reco::CandidatePtrVector signalCands = theTau.signalCands(); From 25bb91c724ce2c28f4cac6c3a646d860cbd79c43 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Fri, 28 Sep 2018 16:07:23 +0200 Subject: [PATCH 4/6] looser protection boundaries --- RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc index a36af2efeaece..d07ad825dd0c0 100644 --- a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc +++ b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc @@ -393,12 +393,12 @@ double AntiElectronIDMVA6::MVAValue(Float_t TauPt, else if ( TauSignalPFGammaCandsIn == 0 && TauHasGsf > 0.5 ) { if ( std::abs(TauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ) { Var_woGwGSF_Barrel_[0] = std::max(float(-0.1), ElecEtotOverPin); - Var_woGwGSF_Barrel_[1] = std::log(ElecChi2NormGSF); + Var_woGwGSF_Barrel_[1] = std::log(std::max(float(0.01), ElecChi2NormGSF)); Var_woGwGSF_Barrel_[2] = ElecGSFNumHits; - Var_woGwGSF_Barrel_[3] = std::log(std::max(float(0.1), ElecGSFTrackResol)); + Var_woGwGSF_Barrel_[3] = std::log(std::max(float(0.01), ElecGSFTrackResol)); Var_woGwGSF_Barrel_[4] = ElecGSFTracklnPt; Var_woGwGSF_Barrel_[5] = ElecNumHitsDiffOverSum; - Var_woGwGSF_Barrel_[6] = std::log(std::max(float(0.1), ElecChi2NormKF)); + Var_woGwGSF_Barrel_[6] = std::log(std::max(float(0.01), ElecChi2NormKF)); Var_woGwGSF_Barrel_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.)); Var_woGwGSF_Barrel_[8] = std::min(ElecEecalOverPout, float(20.)); Var_woGwGSF_Barrel_[9] = ElecDeltaEta; @@ -419,12 +419,12 @@ double AntiElectronIDMVA6::MVAValue(Float_t TauPt, mvaValue = mva_woGwGSF_BL_->GetClassifier(Var_woGwGSF_Barrel_); } else { Var_woGwGSF_Endcap_[0] = std::max(float(-0.1), ElecEtotOverPin); - Var_woGwGSF_Endcap_[1] = std::log(std::max(float(0.1), ElecChi2NormGSF)); + Var_woGwGSF_Endcap_[1] = std::log(std::max(float(0.01), ElecChi2NormGSF)); Var_woGwGSF_Endcap_[2] = ElecGSFNumHits; - Var_woGwGSF_Endcap_[3] = std::log(std::max(float(0.1), ElecGSFTrackResol)); + Var_woGwGSF_Endcap_[3] = std::log(std::max(float(0.01), ElecGSFTrackResol)); Var_woGwGSF_Endcap_[4] = ElecGSFTracklnPt; Var_woGwGSF_Endcap_[5] = ElecNumHitsDiffOverSum; - Var_woGwGSF_Endcap_[6] = std::log(std::max(float(0.1), ElecChi2NormKF)); + Var_woGwGSF_Endcap_[6] = std::log(std::max(float(0.01), ElecChi2NormKF)); Var_woGwGSF_Endcap_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.)); Var_woGwGSF_Endcap_[8] = std::min(ElecEecalOverPout, float(20.)); Var_woGwGSF_Endcap_[9] = ElecDeltaEta; @@ -447,12 +447,12 @@ double AntiElectronIDMVA6::MVAValue(Float_t TauPt, else if ( TauSignalPFGammaCandsIn > 0 && TauHasGsf > 0.5 ) { if ( std::abs(TauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ) { Var_wGwGSF_Barrel_[0] = std::max(float(-0.1), ElecEtotOverPin); - Var_wGwGSF_Barrel_[1] = std::log(std::max(float(0.1), ElecChi2NormGSF)); + Var_wGwGSF_Barrel_[1] = std::log(std::max(float(0.01), ElecChi2NormGSF)); Var_wGwGSF_Barrel_[2] = ElecGSFNumHits; - Var_wGwGSF_Barrel_[3] = std::log(std::max(float(0.1), ElecGSFTrackResol)); + Var_wGwGSF_Barrel_[3] = std::log(std::max(float(0.01), ElecGSFTrackResol)); Var_wGwGSF_Barrel_[4] = ElecGSFTracklnPt; Var_wGwGSF_Barrel_[5] = ElecNumHitsDiffOverSum; - Var_wGwGSF_Barrel_[6] = std::log(std::max(float(0.1), ElecChi2NormKF)); + Var_wGwGSF_Barrel_[6] = std::log(std::max(float(0.01), ElecChi2NormKF)); Var_wGwGSF_Barrel_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.)); Var_wGwGSF_Barrel_[8] = std::min(ElecEecalOverPout, float(20.)); Var_wGwGSF_Barrel_[9] = ElecDeltaEta; @@ -481,12 +481,12 @@ double AntiElectronIDMVA6::MVAValue(Float_t TauPt, mvaValue = mva_wGwGSF_BL_->GetClassifier(Var_wGwGSF_Barrel_); } else { Var_wGwGSF_Endcap_[0] = std::max(float(-0.1), ElecEtotOverPin); - Var_wGwGSF_Endcap_[1] = std::log(std::max(float(0.1), ElecChi2NormGSF)); + Var_wGwGSF_Endcap_[1] = std::log(std::max(float(0.01), ElecChi2NormGSF)); Var_wGwGSF_Endcap_[2] = ElecGSFNumHits; - Var_wGwGSF_Endcap_[3] = std::log(std::max(float(0.1), ElecGSFTrackResol)); + Var_wGwGSF_Endcap_[3] = std::log(std::max(float(0.01), ElecGSFTrackResol)); Var_wGwGSF_Endcap_[4] = ElecGSFTracklnPt; Var_wGwGSF_Endcap_[5] = ElecNumHitsDiffOverSum; - Var_wGwGSF_Endcap_[6] = std::log(std::max(float(0.1), ElecChi2NormKF)); + Var_wGwGSF_Endcap_[6] = std::log(std::max(float(0.01), ElecChi2NormKF)); Var_wGwGSF_Endcap_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.)); Var_wGwGSF_Endcap_[8] = std::min(ElecEecalOverPout, float(20.)); Var_wGwGSF_Endcap_[9] = ElecDeltaEta; From 9004ee7dda849781a8c7895b9ba897ea1b64fa58 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Fri, 28 Sep 2018 16:47:27 +0200 Subject: [PATCH 5/6] fix name of input param --- .../python/PATTauDiscriminationAgainstElectronMVA6_cfi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoTauTag/RecoTau/python/PATTauDiscriminationAgainstElectronMVA6_cfi.py b/RecoTauTag/RecoTau/python/PATTauDiscriminationAgainstElectronMVA6_cfi.py index ba1d78326e0a5..2d8db274ceec3 100644 --- a/RecoTauTag/RecoTau/python/PATTauDiscriminationAgainstElectronMVA6_cfi.py +++ b/RecoTauTag/RecoTau/python/PATTauDiscriminationAgainstElectronMVA6_cfi.py @@ -4,7 +4,7 @@ patTauDiscriminationAgainstElectronMVA6 = cms.EDProducer("PATTauDiscriminationAgainstElectronMVA6", # tau collection to discriminate - PFTauProducer = cms.InputTag('slimmedTaus'), + PATTauProducer = cms.InputTag('slimmedTaus'), # Require leading pion ensures that: # 1) these is at least one track above threshold (0.5 GeV) in the signal cone From 5e9f4f98b43521a40a46337655f63fc2748008d6 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Thu, 4 Oct 2018 10:47:00 +0200 Subject: [PATCH 6/6] Range-based loops --- ...PATTauDiscriminationAgainstElectronMVA6.cc | 7 +- ...ecoTauDiscriminationAgainstElectronMVA6.cc | 38 ++--- RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc | 160 +++++++++--------- 3 files changed, 96 insertions(+), 109 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc index 8416a6e21ce21..050d9abb814a9 100644 --- a/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc @@ -87,8 +87,8 @@ double PATTauDiscriminationAgainstElectronMVA6::discriminate(const TauRef& theTa if( (*theTauRef).leadChargedHadrCand().isNonnull()) { int numSignalPFGammaCandsInSigCone = 0; const reco::CandidatePtrVector signalGammaCands = theTauRef->signalGammaCands(); - for( reco::CandidatePtrVector::const_iterator gamma = signalGammaCands.begin(); gamma != signalGammaCands.end(); ++gamma ){ - double dR = deltaR((*gamma)->p4(), theTauRef->leadChargedHadrCand()->p4()); + for ( const auto & gamma : signalGammaCands ) { + double dR = deltaR(gamma->p4(), theTauRef->leadChargedHadrCand()->p4()); double signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, theTauRef->pt()))); // gammas inside the tau signal cone if (dR < signalrad) { @@ -96,8 +96,7 @@ double PATTauDiscriminationAgainstElectronMVA6::discriminate(const TauRef& theTa } } // loop over the electrons - for( unsigned int ie = 0; ie < Electrons->size(); ++ie ){ - const pat::Electron& theElectron = Electrons->at(ie); + for ( const auto & theElectron : *Electrons ) { if ( theElectron.pt() > 10. ) { // CV: only take electrons above some minimal energy/Pt into account... double deltaREleTau = deltaR(theElectron.p4(), theTauRef->p4()); deltaRDummy = deltaREleTau; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc index 18837554a129b..4356026a6ea32 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc @@ -91,10 +91,9 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& float sumEtaTimesEnergy = 0.; float sumEnergy = 0.; const std::vector& signalPFCands = thePFTauRef->signalPFCands(); - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); - pfCandidate != signalPFCands.end(); ++pfCandidate ) { - sumEtaTimesEnergy += ((*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy()); - sumEnergy += (*pfCandidate)->energy(); + for ( const auto & pfCandidate : signalPFCands ) { + sumEtaTimesEnergy += (pfCandidate->positionAtECALEntrance().eta()*pfCandidate->energy()); + sumEnergy += pfCandidate->energy(); } if ( sumEnergy > 0. ) { tauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy; @@ -102,17 +101,16 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& float leadChargedPFCandEtaAtEcalEntrance = -99.; float leadChargedPFCandPt = -99.; - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); - pfCandidate != signalPFCands.end(); ++pfCandidate ) { + for ( const auto & pfCandidate : signalPFCands ) { const reco::Track* track = nullptr; - if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get(); - else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get(); + if ( pfCandidate->trackRef().isNonnull() ) track = pfCandidate->trackRef().get(); + else if ( pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->innerTrack().isNonnull() ) track = pfCandidate->muonRef()->innerTrack().get(); + else if ( pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->globalTrack().isNonnull() ) track = pfCandidate->muonRef()->globalTrack().get(); + else if ( pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->outerTrack().isNonnull() ) track = pfCandidate->muonRef()->outerTrack().get(); + else if ( pfCandidate->gsfTrackRef().isNonnull() ) track = pfCandidate->gsfTrackRef().get(); if ( track ) { if ( track->pt() > leadChargedPFCandPt ) { - leadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta(); + leadChargedPFCandEtaAtEcalEntrance = pfCandidate->positionAtECALEntrance().eta(); leadChargedPFCandPt = track->pt(); } } @@ -123,10 +121,9 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& int numSignalPFGammaCandsInSigCone = 0; const std::vector& signalPFGammaCands = thePFTauRef->signalPFGammaCands(); - for ( std::vector::const_iterator pfGamma = signalPFGammaCands.begin(); - pfGamma != signalPFGammaCands.end(); ++pfGamma ) { + for ( const auto & pfGamma : signalPFGammaCands ) { - double dR = deltaR((*pfGamma)->p4(), thePFTauRef->leadPFChargedHadrCand()->p4()); + double dR = deltaR(pfGamma->p4(), thePFTauRef->leadPFChargedHadrCand()->p4()); double signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTauRef->pt()))); // pfGammas inside the tau signal cone @@ -136,16 +133,15 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& } // loop over the electrons - for ( reco::GsfElectronCollection::const_iterator theGsfElectron = gsfElectrons_->begin(); - theGsfElectron != gsfElectrons_->end(); ++theGsfElectron ) { - if ( theGsfElectron->pt() > 10. ) { // CV: only take electrons above some minimal energy/Pt into account... - double deltaREleTau = deltaR(theGsfElectron->p4(), thePFTauRef->p4()); + for ( const auto & theGsfElectron : *gsfElectrons_ ) { + if ( theGsfElectron.pt() > 10. ) { // CV: only take electrons above some minimal energy/Pt into account... + double deltaREleTau = deltaR(theGsfElectron.p4(), thePFTauRef->p4()); deltaRDummy = deltaREleTau; if ( deltaREleTau < 0.3 ) { - double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron); + double mva_match = mva_->MVAValue(*thePFTauRef, theGsfElectron); bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().isNonnull(); if ( !hasGsfTrack ) - hasGsfTrack = theGsfElectron->gsfTrack().isNonnull(); + hasGsfTrack = theGsfElectron.gsfTrack().isNonnull(); //// Veto taus that go to Ecal crack if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) { diff --git a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc index d07ad825dd0c0..eafd4d0e53218 100644 --- a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc +++ b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc @@ -526,10 +526,9 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, float sumEtaTimesEnergy = 0.; float sumEnergy = 0.; const std::vector& signalPFCands = thePFTau.signalPFCands(); - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); - pfCandidate != signalPFCands.end(); ++pfCandidate ) { - sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy(); - sumEnergy += (*pfCandidate)->energy(); + for ( const auto & pfCandidate : signalPFCands ) { + sumEtaTimesEnergy += pfCandidate->positionAtECALEntrance().eta()*pfCandidate->energy(); + sumEnergy += pfCandidate->energy(); } if ( sumEnergy > 0. ) { TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy; @@ -537,17 +536,16 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, float TauLeadChargedPFCandEtaAtEcalEntrance = -99.; float TauLeadChargedPFCandPt = -99.; - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); - pfCandidate != signalPFCands.end(); ++pfCandidate ) { + for ( const auto & pfCandidate : signalPFCands ) { const reco::Track* track = nullptr; - if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get(); - else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get(); + if ( pfCandidate->trackRef().isNonnull() ) track = pfCandidate->trackRef().get(); + else if ( pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->innerTrack().isNonnull() ) track = pfCandidate->muonRef()->innerTrack().get(); + else if ( pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->globalTrack().isNonnull() ) track = pfCandidate->muonRef()->globalTrack().get(); + else if ( pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->outerTrack().isNonnull() ) track = pfCandidate->muonRef()->outerTrack().get(); + else if ( pfCandidate->gsfTrackRef().isNonnull() ) track = pfCandidate->gsfTrackRef().get(); if ( track ) { if ( track->pt() > TauLeadChargedPFCandPt ) { - TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta(); + TauLeadChargedPFCandEtaAtEcalEntrance = pfCandidate->positionAtECALEntrance().eta(); TauLeadChargedPFCandPt = track->pt(); } } @@ -571,8 +569,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, reco::Candidate::LorentzVector pfGammaSum(0,0,0,0); reco::Candidate::LorentzVector pfChargedSum(0,0,0,0); - for ( unsigned i = 0 ; i < thePFTau.signalPFGammaCands().size(); ++i ) { - reco::PFCandidatePtr gamma = thePFTau.signalPFGammaCands().at(i); + for ( const auto & gamma : thePFTau.signalPFGammaCands() ) { float dR = deltaR(gamma->p4(), thePFTau.leadPFChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); @@ -603,8 +600,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, } } - for ( unsigned i = 0 ; i < thePFTau.signalPFChargedHadrCands().size(); ++i ) { - reco::PFCandidatePtr charged = thePFTau.signalPFChargedHadrCands().at(i); + for ( const auto & charged : thePFTau.signalPFChargedHadrCands() ) { float dR = deltaR(charged->p4(), thePFTau.leadPFChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); @@ -621,16 +617,16 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, Float_t TauPhi = thePFTau.phi(); float sumPhiTimesEnergy = 0.; float sumEnergyPhi = 0.; - if ( !usePhiAtEcalEntranceExtrapolation_ ){ - for (auto const& pfc : signalPFCands){ + if ( !usePhiAtEcalEntranceExtrapolation_ ) { + for ( const auto & pfc : signalPFCands ) { sumPhiTimesEnergy += pfc->positionAtECALEntrance().phi()*pfc->energy(); sumEnergyPhi += pfc->energy(); } } else{ TauPhi= -99.; - for (unsigned int o = 0; o < signalPFCands.size(); ++o ) { - reco::Candidate const* signalCand = signalPFCands[o].get(); + for ( const auto & signalPFCand : signalPFCands ) { + reco::Candidate const* signalCand = signalPFCand.get(); float phi = thePFTau.phi(); math::XYZPoint aPos; if ( atECalEntrance(signalCand, aPos) ) phi = aPos.Phi(); @@ -741,10 +737,9 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau) float sumEtaTimesEnergy = 0.; float sumEnergy = 0.; const std::vector& signalPFCands = thePFTau.signalPFCands(); - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); - pfCandidate != signalPFCands.end(); ++pfCandidate ) { - sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy(); - sumEnergy += (*pfCandidate)->energy(); + for ( const auto & pfCandidate : signalPFCands ) { + sumEtaTimesEnergy += pfCandidate->positionAtECALEntrance().eta()*pfCandidate->energy(); + sumEnergy += pfCandidate->energy(); } if ( sumEnergy > 0. ) { TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy; @@ -752,17 +747,16 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau) float TauLeadChargedPFCandEtaAtEcalEntrance = -99.; float TauLeadChargedPFCandPt = -99.; - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); - pfCandidate != signalPFCands.end(); ++pfCandidate ) { + for ( const auto & pfCandidate : signalPFCands ) { const reco::Track* track = nullptr; - if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get(); - else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get(); + if ( pfCandidate->trackRef().isNonnull() ) track = pfCandidate->trackRef().get(); + else if ( pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->innerTrack().isNonnull() ) track = pfCandidate->muonRef()->innerTrack().get(); + else if ( pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->globalTrack().isNonnull() ) track = pfCandidate->muonRef()->globalTrack().get(); + else if ( pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->outerTrack().isNonnull() ) track = pfCandidate->muonRef()->outerTrack().get(); + else if ( pfCandidate->gsfTrackRef().isNonnull() ) track = pfCandidate->gsfTrackRef().get(); if ( track ) { if ( track->pt() > TauLeadChargedPFCandPt ) { - TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta(); + TauLeadChargedPFCandEtaAtEcalEntrance = pfCandidate->positionAtECALEntrance().eta(); TauLeadChargedPFCandPt = track->pt(); } } @@ -786,8 +780,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau) reco::Candidate::LorentzVector pfGammaSum(0,0,0,0); reco::Candidate::LorentzVector pfChargedSum(0,0,0,0); - for ( unsigned i = 0 ; i < thePFTau.signalPFGammaCands().size(); ++i ) { - reco::PFCandidatePtr gamma = thePFTau.signalPFGammaCands().at(i); + for ( const auto & gamma : thePFTau.signalPFGammaCands() ) { float dR = deltaR(gamma->p4(), thePFTau.leadPFChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); @@ -818,8 +811,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau) } } - for ( unsigned i = 0 ; i < thePFTau.signalPFChargedHadrCands().size(); ++i ) { - reco::PFCandidatePtr charged = thePFTau.signalPFChargedHadrCands().at(i); + for ( const auto & charged : thePFTau.signalPFChargedHadrCands() ) { float dR = deltaR(charged->p4(), thePFTau.leadPFChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); @@ -837,16 +829,15 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau) float sumPhiTimesEnergy = 0.; float sumEnergyPhi = 0.; if ( !usePhiAtEcalEntranceExtrapolation_ ){ - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); - pfCandidate != signalPFCands.end(); ++pfCandidate ) { - sumPhiTimesEnergy += (*pfCandidate)->positionAtECALEntrance().phi()*(*pfCandidate)->energy(); - sumEnergyPhi += (*pfCandidate)->energy(); + for ( const auto & pfCandidate : signalPFCands ) { + sumPhiTimesEnergy += pfCandidate->positionAtECALEntrance().phi()*pfCandidate->energy(); + sumEnergyPhi += pfCandidate->energy(); } } else{ TauPhi= -99.; - for (unsigned int o = 0; o < signalPFCands.size(); o++ ) { - reco::Candidate const* signalCand = signalPFCands[o].get(); + for ( const auto & signalPFCand : signalPFCands ) { + reco::Candidate const* signalCand = signalPFCand.get(); float phi = thePFTau.phi(); math::XYZPoint aPos; if ( atECalEntrance(signalCand, aPos) == true ) phi = aPos.Phi(); @@ -932,53 +923,53 @@ double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau, const pat::Electron& reco::Candidate::LorentzVector pfChargedSum(0,0,0,0); const reco::CandidatePtrVector signalGammaCands = theTau.signalGammaCands(); - for ( reco::CandidatePtrVector::const_iterator gamma = signalGammaCands.begin(); gamma != signalGammaCands.end(); ++gamma ){ - float dR = deltaR((*gamma)->p4(), theTau.leadChargedHadrCand()->p4()); + for ( const auto & gamma : signalGammaCands ) { + float dR = deltaR(gamma->p4(), theTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, theTau.pt()))); // pfGammas inside the tau signal cone if (dR < signalrad) { if ( theTau.leadChargedHadrCand().isNonnull() ) { - GammasdEtaInSigCone.push_back((*gamma)->eta() - theTau.leadChargedHadrCand()->eta()); - GammasdPhiInSigCone.push_back((*gamma)->phi() - theTau.leadChargedHadrCand()->phi()); + GammasdEtaInSigCone.push_back(gamma->eta() - theTau.leadChargedHadrCand()->eta()); + GammasdPhiInSigCone.push_back(gamma->phi() - theTau.leadChargedHadrCand()->phi()); //A.-C. please check whether this change is safe against future trainings //GammasdPhiInSigCone.push_back(deltaPhi((*gamma)->phi(), theTau.leadChargedHadrCand()->phi())); } else { - GammasdEtaInSigCone.push_back((*gamma)->eta() - theTau.eta()); - GammasdPhiInSigCone.push_back((*gamma)->phi() - theTau.phi()); + GammasdEtaInSigCone.push_back(gamma->eta() - theTau.eta()); + GammasdPhiInSigCone.push_back(gamma->phi() - theTau.phi()); //A.-C. please check whether this change is safe against future trainings - //GammasdPhiInSigCone.push_back(deltaPhi((*gamma)->phi(), theTau.phi())); + //GammasdPhiInSigCone.push_back(deltaPhi(gamma->phi(), theTau.phi())); } - GammasPtInSigCone.push_back((*gamma)->pt()); - pfGammaSum += (*gamma)->p4(); + GammasPtInSigCone.push_back(gamma->pt()); + pfGammaSum += gamma->p4(); } // pfGammas outside the tau signal cone else { if ( theTau.leadChargedHadrCand().isNonnull() ) { - GammasdEtaOutSigCone.push_back((*gamma)->eta() - theTau.leadChargedHadrCand()->eta()); - GammasdPhiOutSigCone.push_back((*gamma)->phi() - theTau.leadChargedHadrCand()->phi()); + GammasdEtaOutSigCone.push_back(gamma->eta() - theTau.leadChargedHadrCand()->eta()); + GammasdPhiOutSigCone.push_back(gamma->phi() - theTau.leadChargedHadrCand()->phi()); //A.-C. please check whether this change is safe against future trainings - //GammasdPhiOutSigCone.push_back(deltaPhi((*gamma)->phi(), theTau.leadChargedHadrCand()->phi())); + //GammasdPhiOutSigCone.push_back(deltaPhi(gamma->phi(), theTau.leadChargedHadrCand()->phi())); } else { - GammasdEtaOutSigCone.push_back((*gamma)->eta() - theTau.eta()); - GammasdPhiOutSigCone.push_back((*gamma)->phi() - theTau.phi()); + GammasdEtaOutSigCone.push_back(gamma->eta() - theTau.eta()); + GammasdPhiOutSigCone.push_back(gamma->phi() - theTau.phi()); //A.-C. please chaekc whether this change is safe against future trainings - //GammasdPhiOutSigCone.push_back(deltaPhi((*gamma)->phi(), theTau.phi())); + //GammasdPhiOutSigCone.push_back(deltaPhi(gamma->phi(), theTau.phi())); } - GammasPtOutSigCone.push_back((*gamma)->pt()); + GammasPtOutSigCone.push_back(gamma->pt()); } } const reco::CandidatePtrVector signalChargedCands = theTau.signalChargedHadrCands(); - for ( reco::CandidatePtrVector::const_iterator charged = signalChargedCands.begin(); charged != signalChargedCands.end(); ++charged ){ - float dR = deltaR((*charged)->p4(), theTau.leadChargedHadrCand()->p4()); + for ( const auto & charged : signalChargedCands ) { + float dR = deltaR(charged->p4(), theTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, theTau.pt()))); // charged particles inside the tau signal cone if (dR < signalrad) { - pfChargedSum += (*charged)->p4(); + pfChargedSum += charged->p4(); } } @@ -990,8 +981,8 @@ double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau, const pat::Electron& float sumPhiTimesEnergy = 0.; float sumEnergy = 0.; const reco::CandidatePtrVector signalCands = theTau.signalCands(); - for (unsigned int o = 0; o < signalCands.size(); o++ ) { - reco::Candidate const* signalCand = signalCands[o].get(); + for ( const auto & signalCandPtr : signalCands ) { + reco::Candidate const* signalCand = signalCandPtr.get(); float phi = theTau.phi(); math::XYZPoint aPos; if ( atECalEntrance(signalCand, aPos) == true ) phi = aPos.Phi(); @@ -1128,45 +1119,45 @@ double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau) reco::Candidate::LorentzVector pfChargedSum(0,0,0,0); const reco::CandidatePtrVector signalGammaCands = theTau.signalGammaCands(); - for ( reco::CandidatePtrVector::const_iterator gamma = signalGammaCands.begin(); gamma != signalGammaCands.end(); ++gamma ) { - float dR = deltaR((*gamma)->p4(), theTau.leadChargedHadrCand()->p4()); + for ( const auto & gamma : signalGammaCands ) { + float dR = deltaR(gamma->p4(), theTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, theTau.pt()))); // pfGammas inside the tau signal cone if (dR < signalrad) { if ( theTau.leadChargedHadrCand().isNonnull() ) { - GammasdEtaInSigCone.push_back((*gamma)->eta() - theTau.leadChargedHadrCand()->eta()); - GammasdPhiInSigCone.push_back((*gamma)->phi() - theTau.leadChargedHadrCand()->phi()); + GammasdEtaInSigCone.push_back(gamma->eta() - theTau.leadChargedHadrCand()->eta()); + GammasdPhiInSigCone.push_back(gamma->phi() - theTau.leadChargedHadrCand()->phi()); } else { - GammasdEtaInSigCone.push_back((*gamma)->eta() - theTau.eta()); - GammasdPhiInSigCone.push_back((*gamma)->phi() - theTau.phi()); + GammasdEtaInSigCone.push_back(gamma->eta() - theTau.eta()); + GammasdPhiInSigCone.push_back(gamma->phi() - theTau.phi()); } - GammasPtInSigCone.push_back((*gamma)->pt()); - pfGammaSum += (*gamma)->p4(); + GammasPtInSigCone.push_back(gamma->pt()); + pfGammaSum += gamma->p4(); } // pfGammas outside the tau signal cone else { if ( theTau.leadChargedHadrCand().isNonnull() ) { - GammasdEtaOutSigCone.push_back((*gamma)->eta() - theTau.leadChargedHadrCand()->eta()); - GammasdPhiOutSigCone.push_back((*gamma)->phi() - theTau.leadChargedHadrCand()->phi()); + GammasdEtaOutSigCone.push_back(gamma->eta() - theTau.leadChargedHadrCand()->eta()); + GammasdPhiOutSigCone.push_back(gamma->phi() - theTau.leadChargedHadrCand()->phi()); } else { - GammasdEtaOutSigCone.push_back((*gamma)->eta() - theTau.eta()); - GammasdPhiOutSigCone.push_back((*gamma)->phi() - theTau.phi()); + GammasdEtaOutSigCone.push_back(gamma->eta() - theTau.eta()); + GammasdPhiOutSigCone.push_back(gamma->phi() - theTau.phi()); } - GammasPtOutSigCone.push_back((*gamma)->pt()); + GammasPtOutSigCone.push_back(gamma->pt()); } } const reco::CandidatePtrVector signalChargedCands = theTau.signalChargedHadrCands(); - for ( reco::CandidatePtrVector::const_iterator charged = signalChargedCands.begin(); charged != signalChargedCands.end(); ++charged ) { - float dR = deltaR((*charged)->p4(), theTau.leadChargedHadrCand()->p4()); + for ( const auto & charged : signalChargedCands ) { + float dR = deltaR(charged->p4(), theTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, theTau.pt()))); // charged particles inside the tau signal cone if (dR < signalrad) { - pfChargedSum += (*charged)->p4(); + pfChargedSum += charged->p4(); } } @@ -1178,8 +1169,8 @@ double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau) float sumPhiTimesEnergy = 0.; float sumEnergy = 0.; const reco::CandidatePtrVector signalCands = theTau.signalCands(); - for (unsigned int o = 0; o < signalCands.size(); o++ ) { - reco::Candidate const* signalCand = signalCands[o].get(); + for ( const auto & signalCandPtr : signalCands ) { + reco::Candidate const* signalCand = signalCandPtr.get(); float phi = theTau.phi(); math::XYZPoint aPos; if ( atECalEntrance(signalCand, aPos) == true ) phi = aPos.Phi(); @@ -1258,9 +1249,10 @@ namespace { std::array cPhi; // IN: define locations of the 18 phi-cracks cPhi[0] = 2.97025; - for ( unsigned iCrack = 1; iCrack <= 17; ++iCrack ) - cPhi[iCrack] = cPhi[0] - 2.*iCrack*pi/18; - return cPhi; + for ( unsigned iCrack = 1; iCrack <= 17; ++iCrack ) { + cPhi[iCrack] = cPhi[0] - 2.*iCrack*pi/18; + } + return cPhi; } const std::array cPhi = fill_cPhi();