CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
pat::helper::ManyThingsToValueMaps< Adaptor, Collection, value_type > Class Template Reference

#include <AnythingToValueMap.h>

Inheritance diagram for pat::helper::ManyThingsToValueMaps< Adaptor, Collection, value_type >:
edm::stream::EDProducer<>

Public Types

typedef edm::ValueMap< value_type > Map
 
typedef Map::Filler MapFiller
 
- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Public Member Functions

 ManyThingsToValueMaps (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~ManyThingsToValueMaps () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Attributes

std::vector< Adaptor > adaptors_
 
bool failSilently_
 
std::vector< edm::InputTaginputs_
 
edm::EDGetTokenT< Collection > src_
 

Detailed Description

template<class Adaptor, class Collection = typename Adaptor::Collection, typename value_type = typename Adaptor::value_type>
class pat::helper::ManyThingsToValueMaps< Adaptor, Collection, value_type >

Definition at line 66 of file AnythingToValueMap.h.

Member Typedef Documentation

◆ Map

template<class Adaptor , class Collection = typename Adaptor::Collection, typename value_type = typename Adaptor::value_type>
typedef edm::ValueMap<value_type> pat::helper::ManyThingsToValueMaps< Adaptor, Collection, value_type >::Map

Definition at line 68 of file AnythingToValueMap.h.

◆ MapFiller

template<class Adaptor , class Collection = typename Adaptor::Collection, typename value_type = typename Adaptor::value_type>
typedef Map::Filler pat::helper::ManyThingsToValueMaps< Adaptor, Collection, value_type >::MapFiller

Definition at line 69 of file AnythingToValueMap.h.

Constructor & Destructor Documentation

◆ ManyThingsToValueMaps()

template<class Adaptor , class Collection = typename Adaptor::Collection, typename value_type = typename Adaptor::value_type>
pat::helper::ManyThingsToValueMaps< Adaptor, Collection, value_type >::ManyThingsToValueMaps ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 70 of file AnythingToValueMap.h.

References pat::helper::ManyThingsToValueMaps< Adaptor, Collection, value_type >::adaptors_, and pat::helper::ManyThingsToValueMaps< Adaptor, Collection, value_type >::inputs_.

71  : failSilently_(iConfig.getUntrackedParameter<bool>("failSilently", false)),
72  src_(consumes<Collection>(iConfig.getParameter<edm::InputTag>("collection"))),
73  inputs_(iConfig.getParameter<std::vector<edm::InputTag> >("associations")) {
74  for (std::vector<edm::InputTag>::const_iterator it = inputs_.begin(), ed = inputs_.end(); it != ed; ++it) {
75  adaptors_.push_back(Adaptor(*it, iConfig, consumesCollector()));
76  produces<Map>(adaptors_.back().label());
77  }
78  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
T getUntrackedParameter(std::string const &, T const &) const
std::vector< edm::InputTag > inputs_
edm::EDGetTokenT< Collection > src_

◆ ~ManyThingsToValueMaps()

template<class Adaptor , class Collection = typename Adaptor::Collection, typename value_type = typename Adaptor::value_type>
pat::helper::ManyThingsToValueMaps< Adaptor, Collection, value_type >::~ManyThingsToValueMaps ( )
inlineoverride

Definition at line 79 of file AnythingToValueMap.h.

79 {}

Member Function Documentation

◆ produce()

template<class Adaptor , class Collection , typename value_type >
void pat::helper::ManyThingsToValueMaps< Adaptor, Collection, value_type >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 91 of file AnythingToValueMap.h.

References Exception, trigObjTnPSource_cfi::filler, patZpeak::handle, iEvent, genParticles_cff::map, eostools::move(), and runTheMatrix::ret.

92  {
94  iEvent.getByToken(src_, handle);
95  if (handle.failedToGet() && failSilently_)
96  return;
97 
98  std::vector<value_type> ret;
99  ret.reserve(handle->size());
100 
101  for (typename std::vector<Adaptor>::iterator it = adaptors_.begin(), ed = adaptors_.end(); it != ed; ++it) {
102  ret.clear();
103  if (it->run(iEvent, *handle, ret)) {
104  auto map = std::make_unique<Map>();
105  MapFiller filler(*map);
106  filler.insert(handle, ret.begin(), ret.end());
107  filler.fill();
108  iEvent.put(std::move(map), it->label());
109  } else {
110  if (!failSilently_)
111  throw cms::Exception("ManyThingsToValueMaps") << "Error in adapter " << it->label() << "\n";
112  }
113  }
114  }
ret
prodAgent to be discontinued
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< Collection > src_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ adaptors_

template<class Adaptor , class Collection = typename Adaptor::Collection, typename value_type = typename Adaptor::value_type>
std::vector<Adaptor> pat::helper::ManyThingsToValueMaps< Adaptor, Collection, value_type >::adaptors_
private

◆ failSilently_

template<class Adaptor , class Collection = typename Adaptor::Collection, typename value_type = typename Adaptor::value_type>
bool pat::helper::ManyThingsToValueMaps< Adaptor, Collection, value_type >::failSilently_
private

Definition at line 84 of file AnythingToValueMap.h.

◆ inputs_

template<class Adaptor , class Collection = typename Adaptor::Collection, typename value_type = typename Adaptor::value_type>
std::vector<edm::InputTag> pat::helper::ManyThingsToValueMaps< Adaptor, Collection, value_type >::inputs_
private

◆ src_

template<class Adaptor , class Collection = typename Adaptor::Collection, typename value_type = typename Adaptor::value_type>
edm::EDGetTokenT<Collection> pat::helper::ManyThingsToValueMaps< Adaptor, Collection, value_type >::src_
private

Definition at line 85 of file AnythingToValueMap.h.