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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

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
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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:136
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
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().