Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New trainings for mvaTauID + one backport from CMSSW_10_0_X #21977

Merged
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2acbc55
Add new payloads for MVAIso 2017v1
mbluj Oct 25, 2017
7b92b26
bugfix
mbluj Oct 25, 2017
0ed49f8
Add protection against a missing tauId source(s)
mbluj Oct 26, 2017
1c6de2e
use nullptr rather than 0 for a null pointer
mbluj Oct 26, 2017
d226a9e
Add protection againist missing (calo) tauId sources
mbluj Oct 26, 2017
143a4df
add a switch allowing/disallowing skipping missing tauId products in …
mbluj Oct 26, 2017
b0948e5
code-checks
mbluj Oct 26, 2017
72ca8c5
changing LogWarning printout such that it is not raised for each tau …
roger-wolf Nov 17, 2017
6b2d8cc
Add function modyfing makePatTausTask to include MVAIso tau-Id 2017v1…
mbluj Jan 25, 2018
a997d05
fix input parameters
mbluj Jan 25, 2018
e8f62d5
Add MVAIso tau-Id with 2017v1 training to miniAOD sequences
mbluj Jan 25, 2018
3f87478
Merge pull request #71 from mbluj/CMSSW_9_4_X_tauIdForMiniAODv2
roger-wolf Jan 26, 2018
fc152ec
renaming python script for updating tauID to be used e.g. for the re-…
roger-wolf Jan 29, 2018
b81d07a
renaming python script for updating tauID to be used e.g. for the re-…
roger-wolf Jan 29, 2018
03d4028
replacing add statements by constructor arguments as requested by reco
roger-wolf Jan 29, 2018
3ab9cbb
and updating the link to re-miniAOD...
roger-wolf Jan 29, 2018
f8cf5c0
splitting hpsPFTauMVAIsolation2Task in sub-tasks
roger-wolf Feb 3, 2018
551345e
defining new era run2_miniAOD_94XFall17
roger-wolf Feb 3, 2018
99d14f7
this should have become obsolete now
roger-wolf Feb 3, 2018
54259b4
now also the proper payloads are picked up when running with era run2…
roger-wolf Feb 6, 2018
dfc35f4
commented line on request by TauPOG
roger-wolf Feb 9, 2018
7dd4c2d
consistent switch of tauID MVA training and extention of tauID WPs by…
roger-wolf Feb 9, 2018
7ac37bb
Add VVLoose WP patTaus in more economical and safe way
mbluj Feb 9, 2018
6b0ac66
cleanup of era replacements
roger-wolf Feb 14, 2018
65c5a30
adapting file to master -- removing of commented lines
roger-wolf Feb 15, 2018
d0977c8
removing final redundancies in module calls
roger-wolf Feb 15, 2018
b5f1c48
resolving merge conflicts, caused by whitespace...
roger-wolf Feb 15, 2018
4554941
Merged CMSSW_9_4_X_tau-pog_newTauID-MCv1 from repository cms-tau-pog …
mbluj Feb 16, 2018
a0f95ce
move definition of the MVAIsoVVLoose tau-Id from miniAOD_tools.py to …
mbluj Feb 16, 2018
47d0d03
put the new 'run2_miniAOD_94XFall17' era in the same place as it is i…
mbluj Feb 16, 2018
262f483
Add a leading underscore to name of an extended task
mbluj Feb 16, 2018
b5834c0
Restore removed modifier only for specific eras for backward compatib…
mbluj Feb 19, 2018
baffd68
move modifers to correct location
mbluj Feb 19, 2018
e30e6ef
adding new working point for eras run2_miniAOD_80XLegacy and run2_min…
roger-wolf Feb 21, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import FWCore.ParameterSet.Config as cms

run2_miniAOD_94XFall17 = cms.Modifier()
2 changes: 1 addition & 1 deletion Configuration/StandardSequences/python/Eras.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self):
'phase2_hgcal', 'phase2_muon', 'phase2_timing',
'phase2_timing_layer','phase2_hcal',
'trackingLowPU', 'trackingPhase1', 'trackingPhase1QuadProp', 'ctpps_2016', 'trackingPhase2PU140',
'tracker_apv_vfp30_2016', 'run2_miniAOD_80XLegacy', 'run2_nanoAOD_92X',
'tracker_apv_vfp30_2016', 'run2_miniAOD_80XLegacy', 'run2_miniAOD_94XFall17', 'run2_nanoAOD_92X',
'hcalHardcodeConditions', 'hcalSkipPacker']
internalUseModChains = ['run2_2017_noTrackingModifier']

Expand Down
31 changes: 28 additions & 3 deletions PhysicsTools/PatAlgos/plugins/PATTauProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ PATTauProducer::PATTauProducer(const edm::ParameterSet & iConfig):
isolator_(iConfig.exists("userIsolation") ? iConfig.getParameter<edm::ParameterSet>("userIsolation") : edm::ParameterSet(), consumesCollector(), false) ,
useUserData_(iConfig.exists("userData"))
{
firstOccurence_=true;
// initialize the configurables
baseTauToken_ = consumes<edm::View<reco::BaseTau> >(iConfig.getParameter<edm::InputTag>( "tauSource" ));
tauTransverseImpactParameterSrc_ = iConfig.getParameter<edm::InputTag>( "tauTransverseImpactParameterSource" );
Expand Down Expand Up @@ -87,6 +88,7 @@ PATTauProducer::PATTauProducer(const edm::ParameterSet & iConfig):
}
caloTauIDTokens_ = edm::vector_transform(tauIDSrcs_, [this](NameTag const & tag){return mayConsume<reco::CaloTauDiscriminator>(tag.second);});
pfTauIDTokens_ = edm::vector_transform(tauIDSrcs_, [this](NameTag const & tag){return mayConsume<reco::PFTauDiscriminator>(tag.second);});
skipMissingTauID_ = iConfig.getParameter<bool>( "skipMissingTauID" );
// IsoDeposit configurables
if (iConfig.exists("isoDeposits")) {
edm::ParameterSet depconf = iConfig.getParameter<edm::ParameterSet>("isoDeposits");
Expand Down Expand Up @@ -305,6 +307,7 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup

// prepare ID extraction
if ( addTauID_ ) {
std::string missingDiscriminators;
std::vector<pat::Tau::IdPair> ids(tauIDSrcs_.size());
for ( size_t i = 0; i < tauIDSrcs_.size(); ++i ) {
if ( typeid(*tausRef) == typeid(reco::PFTau) ) {
Expand All @@ -315,6 +318,13 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup
edm::Handle<reco::PFTauDiscriminator> pfTauIdDiscr;
iEvent.getByToken(pfTauIDTokens_[i], pfTauIdDiscr);

if(skipMissingTauID_ && !pfTauIdDiscr.isValid()){
if(!missingDiscriminators.empty()){
missingDiscriminators+=", ";
}
missingDiscriminators+=tauIDSrcs_[i].first;
continue;
}
ids[i].first = tauIDSrcs_[i].first;
ids[i].second = getTauIdDiscriminator(pfTauCollection, idx, pfTauIdDiscr);
} else if ( typeid(*tausRef) == typeid(reco::CaloTau) ) {
Expand All @@ -325,14 +335,27 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup
edm::Handle<reco::CaloTauDiscriminator> caloTauIdDiscr;
iEvent.getByToken(caloTauIDTokens_[i], caloTauIdDiscr);

if(skipMissingTauID_ && !caloTauIdDiscr.isValid()){
if(!missingDiscriminators.empty()){
missingDiscriminators+=", ";
}
missingDiscriminators+=tauIDSrcs_[i].first;
continue;
}
ids[i].first = tauIDSrcs_[i].first;
ids[i].second = getTauIdDiscriminator(caloTauCollection, idx, caloTauIdDiscr);
} else {
throw cms::Exception("Type Mismatch") <<
"PATTauProducer: unsupported datatype '" << typeid(*tausRef).name() << "' for tauSource\n";
}
}

if(!missingDiscriminators.empty() && firstOccurence_){
edm::LogWarning("DataSource") << "The following tau discriminators have not been found in the event:\n"
<< missingDiscriminators <<"\n"
<< "They will not be embedded into the pat::Tau object.\n"
<< "Note: this message will be printed only at first occurence.";
firstOccurence_=false;
}
aTau.setTauIDs(ids);
}

Expand Down Expand Up @@ -367,7 +390,7 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup
sumPhiTimesEnergy += icand->positionAtECALEntrance().phi()*icand->energy();
sumEtaTimesEnergy += icand->positionAtECALEntrance().eta()*icand->energy();
sumEnergy += icand->energy();
const reco::Track* track = 0;
const reco::Track* track = nullptr;
if ( icand->trackRef().isNonnull() ) track = icand->trackRef().get();
else if ( icand->muonRef().isNonnull() && icand->muonRef()->innerTrack().isNonnull() ) track = icand->muonRef()->innerTrack().get();
else if ( icand->muonRef().isNonnull() && icand->muonRef()->globalTrack().isNonnull() ) track = icand->muonRef()->globalTrack().get();
Expand Down Expand Up @@ -522,7 +545,9 @@ void PATTauProducer::fillDescriptions(edm::ConfigurationDescriptions & descripti
tauIDSourcesPSet.setAllowAnything();
iDesc.addNode( edm::ParameterDescription<edm::InputTag>("tauIDSource", edm::InputTag(), true) xor
edm::ParameterDescription<edm::ParameterSetDescription>("tauIDSources", tauIDSourcesPSet, true)
)->setComment("input with electron ID variables");
)->setComment("input with tau ID variables");
// (Dis)allow to skip missing tauId sources
iDesc.add<bool>("skipMissingTauID", false)->setComment("allow to skip a tau ID variable when not present in the event");

// IsoDeposit configurables
edm::ParameterSetDescription isoDepositsPSet;
Expand Down
9 changes: 5 additions & 4 deletions PhysicsTools/PatAlgos/plugins/PATTauProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ namespace pat {
public:

explicit PATTauProducer(const edm::ParameterSet & iConfig);
~PATTauProducer();
~PATTauProducer() override;

virtual void produce(edm::Event & iEvent, const edm::EventSetup& iSetup) override;
void produce(edm::Event & iEvent, const edm::EventSetup& iSetup) override;

static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);

private:

bool firstOccurence_; // used to print LogWarnings only at first occurnece in the event loop

// configurables
edm::EDGetTokenT<edm::View<reco::BaseTau> > baseTauToken_;
edm::EDGetTokenT<PFTauTIPAssociationByRef> tauTransverseImpactParameterToken_;
Expand Down Expand Up @@ -93,7 +94,7 @@ namespace pat {
std::vector<NameTag> tauIDSrcs_;
std::vector<edm::EDGetTokenT<reco::CaloTauDiscriminator> > caloTauIDTokens_;
std::vector<edm::EDGetTokenT<reco::PFTauDiscriminator> > pfTauIDTokens_;

bool skipMissingTauID_;
// tools
GreaterByPt<Tau> pTTauComparator_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,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),
Expand All @@ -151,3 +151,9 @@
resolutions = cms.PSet()
)

from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17
for era in [ run2_miniAOD_80XLegacy, run2_miniAOD_94XFall17]:
_extTauIDSources = patTaus.tauIDSources.clone()
_extTauIDSources.byVVLooseIsolationMVArun2v1DBoldDMwLT = cms.InputTag("hpsPFTauDiscriminationByVVLooseIsolationMVArun2v1DBoldDMwLT")
era.toModify(patTaus, tauIDSources = _extTauIDSources)
22 changes: 13 additions & 9 deletions PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,21 +318,25 @@ def miniAOD_customizeCommon(process):
for idmod in photon_ids:
setupAllVIDIdsInModule(process,idmod,setupVIDPhotonSelection,None,False,task)

#---------------------------------------------------------------------------
#Adding Boosted Subjets taus
#-- Adding boosted taus
from RecoTauTag.Configuration.boostedHPSPFTaus_cfi import addBoostedTaus
addBoostedTaus(process)
#---------------------------------------------------------------------------
#Adding tau reco for 80X legacy reMiniAOD
#make a copy of makePatTauTask to avoid labels and substitution problems
_makePatTausTaskWithTauReReco = process.makePatTausTask.copy()
#add PFTau reco modules to cloned makePatTauTask
process.load("RecoTauTag.Configuration.RecoPFTauTag_cff")
_makePatTausTaskWithTauReReco.add(process.PFTauTask)
#replace original task by extended one for the miniAOD_80XLegacy era
process.load("RecoTauTag.Configuration.HPSPFTaus_cff")
#-- Adding customization for 94X 2017 legacy reMniAOD
from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17
_makePatTausTaskWithRetrainedMVATauID = process.makePatTausTask.copy()
_makePatTausTaskWithRetrainedMVATauID.add(process.hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLTTask)
run2_miniAOD_94XFall17.toReplaceWith(
process.makePatTausTask, _makePatTausTaskWithRetrainedMVATauID
)
#-- Adding custimization for 80X 2016 legacy reMiniAOD
from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
_makePatTausTaskWithTauReReco = process.makePatTausTask.copy()
_makePatTausTaskWithTauReReco.add(process.PFTauTask)
run2_miniAOD_80XLegacy.toReplaceWith(
process.makePatTausTask, _makePatTausTaskWithTauReReco)

# Adding puppi jets
if not hasattr(process, 'ak4PFJetsPuppi'): #MM: avoid confilct with substructure call
process.load('RecoJets.JetProducers.ak4PFJetsPuppi_cfi')
Expand Down
Loading