CMS 3D CMS Logo

AssociationVector2ValueMap.h
Go to the documentation of this file.
1 #ifndef CommonTools_UtilAlgos_AssociationVector2ValueMap_h
2 #define CommonTools_UtilAlgos_AssociationVector2ValueMap_h
3 /* \class AssociationVector2ValueMap
4  *
5  * \author Luca Lista, INFN
6  *
7  * \version $Id: AssociationVector2ValueMap.h,v 1.2 2010/02/20 20:55:15 wmtan Exp $
8  */
9 
14 
15 template <typename KeyRefProd, typename CVal>
17 public:
19 
20 private:
22  typedef typename CVal::value_type value_t;
24  typedef typename av_t::CKey collection_t;
25  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
27 };
28 
34 
35 template <typename KeyRefProd, typename CVal>
37  : av_(consumes<av_t>(cfg.template getParameter<edm::InputTag>("src"))) {
38  produces<vm_t>();
39 }
40 
41 template <typename KeyRefProd, typename CVal>
43  edm::Event& evt,
44  const edm::EventSetup&) const {
45  using namespace edm;
46  using namespace std;
47  Handle<av_t> av;
48  evt.getByToken(av_, av);
49 
50  unique_ptr<vm_t> vm(new vm_t);
51  typename vm_t::Filler filler(*vm);
52  filler.fill();
53  size_t size = av->size();
54  vector<value_t> values;
55  values.reserve(size);
56  for (typename av_t::const_iterator i = av->begin(); i != av->end(); ++i) {
57  values.push_back(i->second);
58  }
59  filler.insert(av->keyProduct(), values.begin(), values.end());
60  evt.put(std::move(vm));
61 }
62 
63 #endif
size
Write out results.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
transient_vector_type::const_iterator const_iterator
edm::AssociationVector< KeyRefProd, CVal > av_t
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:540
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
KeyRefProd::product_type CKey
AssociationVector2ValueMap(const edm::ParameterSet &)
HLT enums.
def move(src, dest)
Definition: eostools.py:511
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override