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
Developments to provide facilitated access to new TauID information (all high level changes) #18244
Merged
davidlange6
merged 22 commits into
cms-sw:master
from
cms-tau-pog:CMSSW_9_1_X_tau-pog_miniAOD-tauMVAs
May 2, 2017
Merged
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
dd670c7
Merge branch 'from-CMSSW_9_0_X_2017-02-22-2300' into CMSSW_9_0_X_tau-pog
roger-wolf 229164f
Access to new MVA tauID trainings on full 2016 dataset + internal tes…
roger-wolf f9ea9d1
workaround by Anne-Catherine that allows manual track extrapolation t…
roger-wolf ca50fe2
enable re-embedding of new tauID info into an updated patTau object, …
roger-wolf fb09f6f
adding missing config to Reco cfi
roger-wolf 0432ec5
adding missing file
roger-wolf f4d6d29
Merge branch 'from-CMSSW_9_0_X_2017-02-26-2300' into CMSSW_9_0_X_tau-pog
roger-wolf d550ac3
Merge branch 'CMSSW_9_0_X_tau-pog' into CMSSW_9_0_X_tau-pog_miniAOD-t…
roger-wolf 54a1132
Merge branch 'CMSSW_9_0_X_tau-pog_miniAOD-tauMVAs' into CMSSW_9_1_X_t…
roger-wolf 8917638
repairing the validation of minAOD branching by correct use of TFileS…
roger-wolf 247debd
addressing requests and comment by RECO from last time this PR was made
roger-wolf 7a2c1c4
removing whitespace
roger-wolf 15c4358
Following requests by RECO
roger-wolf 9b6b1f0
Merge branch 'from-CMSSW_9_1_X_2017-04-13-2300' into CMSSW_9_1_X_tau-…
roger-wolf 9c34513
updating relval files to files which have not been deleted...
roger-wolf 2ab25a0
moved plugin to PatAlgos on request by RECO
roger-wolf 6423448
moved plugin to PatAlgos on request by RECO
roger-wolf bce6857
removing parameter w/o single use case -- cleanup requiested by RECO
roger-wolf b966f95
plus removing the obsolete existsAs...
roger-wolf b6bfaa5
Merge branch 'from-CMSSW_9_1_X_2017-04-24-1100' into CMSSW_9_1_X_tau-…
roger-wolf 923271e
logic fixes - pickup Bfield from EventSetup instead of hard-coding...…
roger-wolf 48fa4c5
moving readout of EventRecord for B-field from plugins to class AntiE…
roger-wolf File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#include "FWCore/Framework/interface/stream/EDProducer.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
#include "FWCore/Utilities/interface/InputTag.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "DataFormats/PatCandidates/interface/PATTauDiscriminator.h" | ||
#include "DataFormats/PatCandidates/interface/Tau.h" | ||
#include "FWCore/Utilities/interface/transform.h" | ||
|
||
class PATTauIDEmbedder : public edm::stream::EDProducer<> | ||
{ | ||
public: | ||
|
||
explicit PATTauIDEmbedder(const edm::ParameterSet&); | ||
~PATTauIDEmbedder(){}; | ||
|
||
void produce(edm::Event&, const edm::EventSetup&); | ||
|
||
private: | ||
|
||
//--- configuration parameters | ||
edm::EDGetTokenT<pat::TauCollection> src_; | ||
typedef std::pair<std::string, edm::InputTag> NameTag; | ||
std::vector<NameTag> tauIDSrcs_; | ||
std::vector<edm::EDGetTokenT<pat::PATTauDiscriminator> > patTauIDTokens_; | ||
}; | ||
|
||
PATTauIDEmbedder::PATTauIDEmbedder(const edm::ParameterSet& cfg) | ||
{ | ||
src_ = consumes<pat::TauCollection>(cfg.getParameter<edm::InputTag>("src")); | ||
// read the different tau ID names | ||
edm::ParameterSet idps = cfg.getParameter<edm::ParameterSet>("tauIDSources"); | ||
std::vector<std::string> names = idps.getParameterNamesForType<edm::InputTag>(); | ||
for (std::vector<std::string>::const_iterator it = names.begin(), ed = names.end(); it != ed; ++it) { | ||
tauIDSrcs_.push_back(NameTag(*it, idps.getParameter<edm::InputTag>(*it))); | ||
} | ||
// but in any case at least once | ||
if (tauIDSrcs_.empty()) throw cms::Exception("Configuration") << | ||
"PATTauProducer: id addTauID is true, you must specify:\n" << | ||
"\tPSet tauIDSources = { \n" << | ||
"\t\tInputTag <someName> = <someTag> // as many as you want \n " << | ||
"\t}\n"; | ||
patTauIDTokens_ = edm::vector_transform(tauIDSrcs_, [this](NameTag const & tag){return mayConsume<pat::PATTauDiscriminator>(tag.second);}); | ||
|
||
produces<std::vector<pat::Tau> >(); | ||
} | ||
|
||
void PATTauIDEmbedder::produce(edm::Event& evt, const edm::EventSetup& es) | ||
{ | ||
edm::Handle<pat::TauCollection> inputTaus; | ||
evt.getByToken(src_, inputTaus); | ||
|
||
auto outputTaus = std::make_unique<std::vector<pat::Tau> >(); | ||
outputTaus->reserve(inputTaus->size()); | ||
|
||
int tau_idx = 0; | ||
for(pat::TauCollection::const_iterator inputTau = inputTaus->begin(); inputTau != inputTaus->end(); ++inputTau, ++tau_idx){ | ||
pat::Tau outputTau(*inputTau); | ||
pat::TauRef inputTauRef(inputTaus, tau_idx); | ||
size_t nTauIds = inputTau->tauIDs().size(); | ||
std::vector<pat::Tau::IdPair> tauIds(nTauIds+tauIDSrcs_.size()); | ||
|
||
for(size_t i = 0; i < nTauIds; ++i){ | ||
tauIds[i] = inputTau->tauIDs().at(i); | ||
} | ||
|
||
edm::Handle<pat::PATTauDiscriminator> tauDiscr; | ||
for(size_t i = 0; i < tauIDSrcs_.size(); ++i){ | ||
evt.getByToken(patTauIDTokens_[i], tauDiscr); | ||
tauIds[nTauIds+i].first = tauIDSrcs_[i].first; | ||
tauIds[nTauIds+i].second = (*tauDiscr)[inputTauRef]; | ||
} | ||
|
||
outputTau.setTauIDs(tauIds); | ||
outputTaus->push_back(outputTau); | ||
} | ||
|
||
evt.put(std::move(outputTaus)); | ||
} | ||
|
||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
|
||
DEFINE_FWK_MODULE(PATTauIDEmbedder); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
/store/relval/CMSSW_9_0_0_pre4/RelValTTbar_13/GEN-SIM-RECO/PUpmx25ns_90X_mcRun2_asymptotic_v1-v1/10000/5C714DBC-65EE-E611-BCFB-0CC47A78A426.root | ||
/store/relval/CMSSW_9_0_0_pre4/RelValTTbar_13/GEN-SIM-RECO/PUpmx25ns_90X_mcRun2_asymptotic_v1-v1/10000/A40BB4B4-65EE-E611-A3C2-0CC47A7C3412.root | ||
/store/relval/CMSSW_8_0_0/RelValTTbar_13/GEN-SIM-RECO/PU25ns_80X_mcRun2_asymptotic_v4-v1/10000/42D6DF66-9DDA-E511-9200-0CC47A4D7670.root | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,9 @@ | |
#include "DataFormats/PatCandidates/interface/PATTauDiscriminator.h" | ||
#include "DataFormats/Candidate/interface/Candidate.h" | ||
|
||
#include "MagneticField/Engine/interface/MagneticField.h" | ||
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" | ||
|
||
#include <iostream> | ||
#include <sstream> | ||
#include <fstream> | ||
|
@@ -31,6 +34,7 @@ class PATTauDiscriminationAgainstElectronMVA6 : public PATTauDiscriminationProdu | |
{ | ||
mva_ = std::make_unique<AntiElectronIDMVA6>(cfg); | ||
|
||
usePhiAtEcalEntranceExtrapolation_ = cfg.getParameter<bool>("usePhiAtEcalEntranceExtrapolation"); | ||
srcElectrons = cfg.getParameter<edm::InputTag>("srcElectrons"); | ||
electronToken = consumes<pat::ElectronCollection>(srcElectrons); | ||
verbosity_ = ( cfg.exists("verbosity") ) ? | ||
|
@@ -60,6 +64,8 @@ class PATTauDiscriminationAgainstElectronMVA6 : public PATTauDiscriminationProdu | |
edm::Handle<TauCollection> taus_; | ||
|
||
std::unique_ptr<PATTauDiscriminator> category_output_; | ||
bool usePhiAtEcalEntranceExtrapolation_; | ||
double bField_; | ||
|
||
int verbosity_; | ||
}; | ||
|
@@ -72,6 +78,10 @@ void PATTauDiscriminationAgainstElectronMVA6::beginEvent(const edm::Event& evt, | |
category_output_.reset(new PATTauDiscriminator(TauRefProd(taus_))); | ||
|
||
evt.getByToken(electronToken, Electrons); | ||
|
||
edm::ESHandle<MagneticField> pSetup; | ||
es.get<IdealMagneticFieldRecord>().get(pSetup); | ||
bField_ = pSetup->inTesla(GlobalPoint(0,0,0)).z(); | ||
} | ||
|
||
double PATTauDiscriminationAgainstElectronMVA6::discriminate(const TauRef& theTauRef) const | ||
|
@@ -102,7 +112,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); | ||
double mva_match = mva_->MVAValue(*theTauRef, theElectron, usePhiAtEcalEntranceExtrapolation_, bField_); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not set bField in the mva::beginEvent call ? |
||
bool hasGsfTrack = 0; | ||
pat::PackedCandidate const* packedLeadTauCand = dynamic_cast<pat::PackedCandidate const*>(theTauRef->leadChargedHadrCand().get()); | ||
if( abs(packedLeadTauCand->pdgId()) == 11 ) | ||
|
@@ -140,7 +150,7 @@ double PATTauDiscriminationAgainstElectronMVA6::discriminate(const TauRef& theTa | |
} // end of loop over electrons | ||
|
||
if ( !isGsfElectronMatched ) { | ||
mvaValue = mva_->MVAValue(*theTauRef); | ||
mvaValue = mva_->MVAValue(*theTauRef, usePhiAtEcalEntranceExtrapolation_, bField_); | ||
bool hasGsfTrack = 0; | ||
pat::PackedCandidate const* packedLeadTauCand = dynamic_cast<pat::PackedCandidate const*>(theTauRef->leadChargedHadrCand().get()); | ||
if( abs(packedLeadTauCand->pdgId()) == 11 ) hasGsfTrack = 1; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it still meaningful to set input EDM files from CMSSW_8_0_0 (it looks like going backwards)?
IIUC, this file (RecoTauTag/Configuration/test/ZTT-validation.txt) is used in some private validation testing.
So, I just need a confirmation that this is not made by some mistake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Slava,
i can confirm that the change of files is correct. This is the test file that is still used in PatAlgos/test/. Since I do not want to maintain after vanishing relval files over and over again I moved to this more persistent solution for the time being.
Cheers,
Roger