CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes
PATTauIDEmbedder Class Reference
Inheritance diagram for PATTauIDEmbedder:
edm::stream::EDProducer<>

Public Member Functions

 PATTauIDEmbedder (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~PATTauIDEmbedder () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Types

typedef std::pair< std::string, edm::InputTagNameTag
 

Private Attributes

std::vector< edm::EDGetTokenT< pat::PATTauDiscriminator > > patTauIDTokens_
 
edm::EDGetTokenT< pat::TauCollectionsrc_
 
std::vector< NameTagtauIDSrcs_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 10 of file PATTauIDEmbedder.cc.

Member Typedef Documentation

typedef std::pair<std::string, edm::InputTag> PATTauIDEmbedder::NameTag
private

Definition at line 20 of file PATTauIDEmbedder.cc.

Constructor & Destructor Documentation

PATTauIDEmbedder::PATTauIDEmbedder ( const edm::ParameterSet cfg)
explicit

Definition at line 25 of file PATTauIDEmbedder.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNamesForType(), names, patTauIDTokens_, src_, GlobalPosition_Frontier_DevDB_cff::tag, tauIDSrcs_, and edm::vector_transform().

25  {
26  src_ = consumes<pat::TauCollection>(cfg.getParameter<edm::InputTag>("src"));
27  // read the different tau ID names
28  edm::ParameterSet idps = cfg.getParameter<edm::ParameterSet>("tauIDSources");
29  std::vector<std::string> names = idps.getParameterNamesForType<edm::InputTag>();
30  for (std::vector<std::string>::const_iterator it = names.begin(), ed = names.end(); it != ed; ++it) {
31  tauIDSrcs_.push_back(NameTag(*it, idps.getParameter<edm::InputTag>(*it)));
32  }
33  // but in any case at least once
34  if (tauIDSrcs_.empty())
35  throw cms::Exception("Configuration") << "PATTauProducer: id addTauID is true, you must specify:\n"
36  << "\tPSet tauIDSources = { \n"
37  << "\t\tInputTag <someName> = <someTag> // as many as you want \n "
38  << "\t}\n";
40  tauIDSrcs_, [this](NameTag const& tag) { return mayConsume<pat::PATTauDiscriminator>(tag.second); });
41 
42  produces<std::vector<pat::Tau> >();
43 }
std::vector< edm::EDGetTokenT< pat::PATTauDiscriminator > > patTauIDTokens_
T getParameter(std::string const &) const
std::vector< NameTag > tauIDSrcs_
const std::string names[nVars_]
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:168
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
edm::EDGetTokenT< pat::TauCollection > src_
std::pair< std::string, edm::InputTag > NameTag
PATTauIDEmbedder::~PATTauIDEmbedder ( )
inlineoverride

Definition at line 13 of file PATTauIDEmbedder.cc.

References produce().

13 {};

Member Function Documentation

void PATTauIDEmbedder::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 45 of file PATTauIDEmbedder.cc.

References DEFINE_FWK_MODULE, edm::Event::getByToken(), mps_fire::i, eostools::move(), patTauIDTokens_, edm::Event::put(), pat::Tau::setTauIDs(), src_, and tauIDSrcs_.

Referenced by ~PATTauIDEmbedder().

45  {
47  evt.getByToken(src_, inputTaus);
48 
49  auto outputTaus = std::make_unique<std::vector<pat::Tau> >();
50  outputTaus->reserve(inputTaus->size());
51 
52  int tau_idx = 0;
53  for (pat::TauCollection::const_iterator inputTau = inputTaus->begin(); inputTau != inputTaus->end();
54  ++inputTau, ++tau_idx) {
55  pat::Tau outputTau(*inputTau);
56  pat::TauRef inputTauRef(inputTaus, tau_idx);
57  size_t nTauIds = inputTau->tauIDs().size();
58  std::vector<pat::Tau::IdPair> tauIds(nTauIds + tauIDSrcs_.size());
59 
60  for (size_t i = 0; i < nTauIds; ++i) {
61  tauIds[i] = inputTau->tauIDs().at(i);
62  }
63 
65  for (size_t i = 0; i < tauIDSrcs_.size(); ++i) {
66  evt.getByToken(patTauIDTokens_[i], tauDiscr);
67  tauIds[nTauIds + i].first = tauIDSrcs_[i].first;
68  tauIds[nTauIds + i].second = (*tauDiscr)[inputTauRef];
69  }
70 
71  outputTau.setTauIDs(tauIds);
72  outputTaus->push_back(outputTau);
73  }
74 
75  evt.put(std::move(outputTaus));
76 }
std::vector< edm::EDGetTokenT< pat::PATTauDiscriminator > > patTauIDTokens_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
std::vector< NameTag > tauIDSrcs_
Analysis-level tau class.
Definition: Tau.h:53
edm::EDGetTokenT< pat::TauCollection > src_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

std::vector<edm::EDGetTokenT<pat::PATTauDiscriminator> > PATTauIDEmbedder::patTauIDTokens_
private

Definition at line 22 of file PATTauIDEmbedder.cc.

Referenced by PATTauIDEmbedder(), and produce().

edm::EDGetTokenT<pat::TauCollection> PATTauIDEmbedder::src_
private

Definition at line 19 of file PATTauIDEmbedder.cc.

Referenced by PATTauIDEmbedder(), and produce().

std::vector<NameTag> PATTauIDEmbedder::tauIDSrcs_
private

Definition at line 21 of file PATTauIDEmbedder.cc.

Referenced by PATTauIDEmbedder(), and produce().