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::Event&, const edm::EventSetup&) 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  using namespace edm;
44  using namespace std;
45  Handle<av_t> av;
46  evt.getByToken(av_, av);
47 
48  unique_ptr<vm_t> vm(new vm_t);
49  typename vm_t::Filler filler(*vm);
50  filler.fill();
51  size_t size = av->size();
52  vector<value_t> values;
53  values.reserve(size);
54  for (typename av_t::const_iterator i = av->begin(); i != av->end(); ++i) {
55  values.push_back(i->second);
56  }
57  filler.insert(av->keyProduct(), values.begin(), values.end());
58  evt.put(std::move(vm));
59 }
60 
61 #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:539
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
void produce(edm::Event &, const edm::EventSetup &) override
KeyRefProd::product_type CKey
AssociationVector2ValueMap(const edm::ParameterSet &)
HLT enums.
def move(src, dest)
Definition: eostools.py:511