Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18244 from cms-tau-pog/CMSSW_9_1_X_tau-pog_miniAO…
…D-tauMVAs Developments to provide facilitated access to new TauID information (all high level changes)
- Loading branch information
Showing
17 changed files
with
395 additions
and
226 deletions.
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
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.