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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 23 of file PATTauIDEmbedder.cc.

Constructor & Destructor Documentation

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

Definition at line 28 of file PATTauIDEmbedder.cc.

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

29 {
30  src_ = consumes<pat::TauCollection>(cfg.getParameter<edm::InputTag>("src"));
31  // read the different tau ID names
32  edm::ParameterSet idps = cfg.getParameter<edm::ParameterSet>("tauIDSources");
33  std::vector<std::string> names = idps.getParameterNamesForType<edm::InputTag>();
34  for (std::vector<std::string>::const_iterator it = names.begin(), ed = names.end(); it != ed; ++it) {
35  tauIDSrcs_.push_back(NameTag(*it, idps.getParameter<edm::InputTag>(*it)));
36  }
37  // but in any case at least once
38  if (tauIDSrcs_.empty()) throw cms::Exception("Configuration") <<
39  "PATTauProducer: id addTauID is true, you must specify:\n" <<
40  "\tPSet tauIDSources = { \n" <<
41  "\t\tInputTag <someName> = <someTag> // as many as you want \n " <<
42  "\t}\n";
43  patTauIDTokens_ = edm::vector_transform(tauIDSrcs_, [this](NameTag const & tag){return mayConsume<pat::PATTauDiscriminator>(tag.second);});
44 
45  produces<std::vector<pat::Tau> >();
46 }
std::vector< edm::EDGetTokenT< pat::PATTauDiscriminator > > patTauIDTokens_
T getParameter(std::string const &) const
static const HistoName names[]
std::vector< NameTag > tauIDSrcs_
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
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:194
edm::EDGetTokenT< pat::TauCollection > src_
std::pair< std::string, edm::InputTag > NameTag
PATTauIDEmbedder::~PATTauIDEmbedder ( )
inlineoverride

Definition at line 15 of file PATTauIDEmbedder.cc.

References produce().

15 {};

Member Function Documentation

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

Definition at line 48 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().

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

Member Data Documentation

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

Definition at line 25 of file PATTauIDEmbedder.cc.

Referenced by PATTauIDEmbedder(), and produce().

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

Definition at line 22 of file PATTauIDEmbedder.cc.

Referenced by PATTauIDEmbedder(), and produce().

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

Definition at line 24 of file PATTauIDEmbedder.cc.

Referenced by PATTauIDEmbedder(), and produce().