1 #ifndef PhysicsTools_TagAndProbe_interface_AnythingToValueMap_h
2 #define PhysicsTools_TagAndProbe_interface_AnythingToValueMap_h
13 namespace pat {
namespace helper {
15 template<
class Adaptor,
class Collection =
typename Adaptor::Collection,
typename value_type =
typename Adaptor::value_type>
36 template<
class Adaptor,
class Collection,
typename value_type>
42 bool adaptorOk = adaptor_.init(iEvent);
43 if ((!adaptorOk) && failSilently_)
return;
45 std::vector<value_type>
ret;
46 ret.reserve(handle->size());
48 adaptor_.run(*handle, ret);
50 std::auto_ptr<Map> map(
new Map());
52 filler.
insert(handle, ret.begin(), ret.end());
54 iEvent.
put(map, adaptor_.label());
57 template<
class Adaptor,
class Collection =
typename Adaptor::Collection,
typename value_type =
typename Adaptor::value_type>
65 inputs_(iConfig.getParameter<std::vector<edm::
InputTag> >(
"associations"))
67 for (std::vector<edm::InputTag>::const_iterator it =
inputs_.begin(), ed =
inputs_.end(); it != ed; ++it) {
69 produces< Map >(
adaptors_.back().label());
83 template<
class Adaptor,
class Collection,
typename value_type>
89 std::vector<value_type>
ret;
90 ret.reserve(handle->size());
92 for (
typename std::vector<Adaptor>::iterator it = adaptors_.begin(), ed = adaptors_.end(); it != ed; ++it) {
94 if (it->run(iEvent, *handle, ret)) {
95 std::auto_ptr<Map> map(
new Map());
97 filler.
insert(handle, ret.begin(), ret.end());
99 iEvent.
put(map, it->label());
101 if (!failSilently_)
throw cms::Exception(
"ManyThingsToValueMaps") <<
"Error in adapter " << it->label() <<
"\n";
edm::ValueMap< value_type > Map
tuple ret
prodAgent to be discontinued
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
void insert(const H &h, I begin, I end)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< edm::InputTag > inputs_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
AnythingToValueMap(const edm::ParameterSet &iConfig)
edm::EDGetTokenT< Collection > src_
std::vector< Adaptor > adaptors_
edm::ValueMap< value_type > Map
edm::EDGetTokenT< Collection > src_
ManyThingsToValueMaps(const edm::ParameterSet &iConfig)
volatile std::atomic< bool > shutdown_flag false
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)