CMS 3D CMS Logo

AssociationMapOneToOne2Association.h
Go to the documentation of this file.
1 #ifndef CommonTools_UtilAlgos_AssociationMapOneToOne2Association_h
2 #define CommonTools_UtilAlgos_AssociationMapOneToOne2Association_h
3 /* \class AssociationMapOneToOne2Association
4  *
5  * \author Luca Lista, INFN
6  *
7  * \version $Id: AssociationMapOneToOne2Association.h,v 1.2 2010/02/20 20:55:14 wmtan Exp $
8  */
9 
15 
16 template <typename CKey, typename CVal>
18 public:
20 
21 private:
24  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
26 };
27 
33 
34 template <typename CKey, typename CVal>
36  : am_(consumes<am_t>(cfg.template getParameter<edm::InputTag>("src"))) {
37  produces<as_t>();
38 }
39 
40 template <typename CKey, typename CVal>
42  edm::Event& evt,
43  const edm::EventSetup&) const {
44  using namespace edm;
45  using namespace std;
46  Handle<am_t> am;
47  evt.getByToken(am_, am);
48 
49  unique_ptr<as_t> as(new as_t);
50  typename as_t::Filler filler(*as);
51  filler.fill();
52  size_t size = am->size();
53  vector<int> indices;
54  indices.reserve(size);
55  for (typename am_t::const_iterator i = am->begin(); i != am->end(); ++i) {
56  indices.push_back(i->val.key());
57  }
58  filler.insert(am->refProd().key, indices.begin(), indices.end());
59  evt.put(std::move(as));
60 }
61 
62 #endif
size
Write out results.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:536
AssociationMapOneToOne2Association(const edm::ParameterSet &)
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
edm::AssociationMap< edm::OneToOne< CKey, CVal > > am_t
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
HLT enums.
def move(src, dest)
Definition: eostools.py:511