From dc1625ec3df606d3ca8502a274a857caf29780b5 Mon Sep 17 00:00:00 2001 From: anehrkor Date: Fri, 29 May 2015 16:25:34 +0200 Subject: [PATCH] New cleaner module that works also if tau is made up of combination of pf charged hadrons and tracks -> solves rare problem with 3-prongs having charge +/-3. --- .../plugins/RecoTauChargeCleanerPlugin.cc | 59 +++++++++++++++++++ .../RecoTau/python/RecoTauCleanerPlugins.py | 12 ++++ .../RecoTau/python/RecoTauCleaner_cfi.py | 2 +- 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 RecoTauTag/RecoTau/plugins/RecoTauChargeCleanerPlugin.cc diff --git a/RecoTauTag/RecoTau/plugins/RecoTauChargeCleanerPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauChargeCleanerPlugin.cc new file mode 100644 index 0000000000000..75a03751191a9 --- /dev/null +++ b/RecoTauTag/RecoTau/plugins/RecoTauChargeCleanerPlugin.cc @@ -0,0 +1,59 @@ +/* + * Original author: Alexander Nehrkorn (RWTH Aachen) + * + * Description: + * This module rejects tau candidates that do not have unit charge. + * It takes the fact into account that taus do not necessarily need + * to be created from PF charged hadrons only but can be created + * from a combination of PF charged hadrons and tracks. + * + */ + +#include "RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h" +#include "DataFormats/TauReco/interface/PFTau.h" +#include "DataFormats/TauReco/interface/PFTauFwd.h" + +namespace reco { namespace tau { + +class RecoTauChargeCleanerPlugin : public RecoTauCleanerPlugin +{ +public: + explicit RecoTauChargeCleanerPlugin(const edm::ParameterSet&, edm::ConsumesCollector &&iC); + ~RecoTauChargeCleanerPlugin() {} + double operator()(const PFTauRef& tau) const override; + +private: + std::vector nprongs_; + double failResult_; + int charge_; +}; + +RecoTauChargeCleanerPlugin::RecoTauChargeCleanerPlugin(const edm::ParameterSet& pset, edm::ConsumesCollector &&iC) + : RecoTauCleanerPlugin(pset,std::move(iC)), + nprongs_(pset.getParameter >("nprongs")), + failResult_(pset.getParameter("selectionFailValue")), + charge_(pset.getParameter("passForCharge")) +{} + +double RecoTauChargeCleanerPlugin::operator()(const PFTauRef& cand) const +{ + int charge = 0; + unsigned nChargedPFCandidate(0), nTrack(0); + for(unsigned iSignalCand = 0; iSignalCand < cand->signalTauChargedHadronCandidates().size(); iSignalCand++){ + charge += cand->signalTauChargedHadronCandidates().at(iSignalCand).charge(); + if(cand->signalTauChargedHadronCandidates().at(iSignalCand).algoIs(reco::PFRecoTauChargedHadron::kChargedPFCandidate)) nChargedPFCandidate++; + else if(cand->signalTauChargedHadronCandidates().at(iSignalCand).algoIs(reco::PFRecoTauChargedHadron::kTrack)) nTrack++; + } + + for(auto nprong : nprongs_){ + if(nChargedPFCandidate+nTrack == nprong) return abs(charge)-charge_; + } + + return failResult_; +} + +}} + +#include "FWCore/Framework/interface/MakerMacros.h" + +DEFINE_EDM_PLUGIN(RecoTauCleanerPluginFactory, reco::tau::RecoTauChargeCleanerPlugin, "RecoTauChargeCleanerPlugin"); diff --git a/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py b/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py index 09687d9dfa2ac..8dcfc7df1ca76 100644 --- a/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py +++ b/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py @@ -28,6 +28,18 @@ selectionFailValue = cms.double(0), ) +# similar to unitCharge but handles also cases where tau is made up of +# a combination of tracks and pf charged hadrons +charge = cms.PSet( + name = cms.string("Charge"), + plugin = cms.string("RecoTauChargeCleanerPlugin"), + # cleaner is applied to decay modes with the number of prongs given here + nprongs = cms.vuint32(1,3), + # taus with charge != 1 are rejected + passForCharge = cms.int32(1), + selectionFailValue = cms.double(0), +) + # Prefer taus with pt greater 15 ptGt15 = cms.PSet( name = cms.string("PtGt15"), diff --git a/RecoTauTag/RecoTau/python/RecoTauCleaner_cfi.py b/RecoTauTag/RecoTau/python/RecoTauCleaner_cfi.py index 30d65dd479550..d387946755de3 100644 --- a/RecoTauTag/RecoTau/python/RecoTauCleaner_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauCleaner_cfi.py @@ -6,7 +6,7 @@ src = cms.InputTag("combinatoricRecoTaus"), cleaners = cms.VPSet( # Reject taus that have charge == 3 - cleaners.unitCharge, + cleaners.charge, # Reject taus that are not within DR<0.1 of the jet axis #cleaners.matchingConeCut, # Reject taus that fail HPS selections