From 31cdc5eb71e453c51e7a5b798022e1552800608c Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Thu, 26 Oct 2017 17:20:50 +0200 Subject: [PATCH] add a switch allowing/disallowing skipping missing tauId products in the event --- PhysicsTools/PatAlgos/plugins/PATTauProducer.cc | 9 ++++++--- PhysicsTools/PatAlgos/plugins/PATTauProducer.h | 2 +- .../PatAlgos/python/producersLayer1/tauProducer_cfi.py | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc b/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc index 9dccbe8f70709..5e0105425375f 100755 --- a/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc @@ -87,6 +87,7 @@ PATTauProducer::PATTauProducer(const edm::ParameterSet & iConfig): } caloTauIDTokens_ = edm::vector_transform(tauIDSrcs_, [this](NameTag const & tag){return mayConsume(tag.second);}); pfTauIDTokens_ = edm::vector_transform(tauIDSrcs_, [this](NameTag const & tag){return mayConsume(tag.second);}); + skipMissingTauID_ = iConfig.getParameter( "skipMissingTauID" ); // IsoDeposit configurables if (iConfig.exists("isoDeposits")) { edm::ParameterSet depconf = iConfig.getParameter("isoDeposits"); @@ -315,7 +316,7 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup edm::Handle pfTauIdDiscr; iEvent.getByToken(pfTauIDTokens_[i], pfTauIdDiscr); - if(!pfTauIdDiscr.isValid()){ + if(skipMissingTauID_ && !pfTauIdDiscr.isValid()){ edm::LogWarning("DataSource") << "Tau discriminator '" << tauIDSrcs_[i].first << "' has not been found in the event. It will not be embedded into the pat::Tau object."; continue; @@ -330,7 +331,7 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup edm::Handle caloTauIdDiscr; iEvent.getByToken(caloTauIDTokens_[i], caloTauIdDiscr); - if(!caloTauIdDiscr.isValid()){ + if(skipMissingTauID_ && !caloTauIdDiscr.isValid()){ edm::LogWarning("DataSource") << "Tau discriminator '" << tauIDSrcs_[i].first << "' has not been found in the event. It will not be embedded into the pat::Tau object."; continue; @@ -532,7 +533,9 @@ void PATTauProducer::fillDescriptions(edm::ConfigurationDescriptions & descripti tauIDSourcesPSet.setAllowAnything(); iDesc.addNode( edm::ParameterDescription("tauIDSource", edm::InputTag(), true) xor edm::ParameterDescription("tauIDSources", tauIDSourcesPSet, true) - )->setComment("input with electron ID variables"); + )->setComment("input with tau ID variables"); + // (Dis)allow to skip missing tauId sources + iDesc.add("skipMissingTauID", false)->setComment("allow to skip a tau ID variable when not present in the event"); // IsoDeposit configurables edm::ParameterSetDescription isoDepositsPSet; diff --git a/PhysicsTools/PatAlgos/plugins/PATTauProducer.h b/PhysicsTools/PatAlgos/plugins/PATTauProducer.h index f1dc6866de901..7b813e9d85d27 100644 --- a/PhysicsTools/PatAlgos/plugins/PATTauProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATTauProducer.h @@ -93,7 +93,7 @@ namespace pat { std::vector tauIDSrcs_; std::vector > caloTauIDTokens_; std::vector > pfTauIDTokens_; - + bool skipMissingTauID_; // tools GreaterByPt pTTauComparator_; diff --git a/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py b/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py index 685426d273232..84723dd535a1b 100644 --- a/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py +++ b/PhysicsTools/PatAlgos/python/producersLayer1/tauProducer_cfi.py @@ -134,7 +134,7 @@ againstElectronTightMVA6 = cms.InputTag("hpsPFTauDiscriminationByMVA6TightElectronRejection"), againstElectronVTightMVA6 = cms.InputTag("hpsPFTauDiscriminationByMVA6VTightElectronRejection"), ), - + skipMissingTauID = cms.bool(False), #Allow to skip a tau ID variable when not present in the event" # mc matching configurables addGenMatch = cms.bool(True), embedGenMatch = cms.bool(True),