CMS 3D CMS Logo

AnythingToValueMap.cc
Go to the documentation of this file.
8 
9 namespace pat {
10  namespace helper {
12  public:
13  typedef float value_type;
15  template <typename T>
16  struct AssoVec {
18  };
19 
21  const edm::ParameterSet &iConfig,
24  in_(in),
25  label_(in.label() + in.instance()),
26  tokenVMd_(iC.consumes<edm::ValueMap<double> >(in)),
27  tokenVMf_(iC.consumes<edm::ValueMap<float> >(in)),
28  tokenVMi_(iC.consumes<edm::ValueMap<int> >(in)),
29  tokenVMb_(iC.consumes<edm::ValueMap<bool> >(in)),
30  tokenAVd_(iC.consumes<AssoVec<double>::type>(in)),
31  tokenAVf_(iC.consumes<AssoVec<float>::type>(in)),
32  tokenAVi_(iC.consumes<AssoVec<int>::type>(in)) {}
33 
34  const std::string &label() { return label_; }
35 
36  bool run(const edm::Event &iEvent, const Collection &coll, std::vector<value_type> &ret) {
37  switch (type_) {
38  case Uninitialized:
41  return true;
42  }
43  if (run_<edm::ValueMap<float> >(tokenVMf_, iEvent, coll, ret)) {
45  return true;
46  }
47  if (run_<edm::ValueMap<int> >(tokenVMi_, iEvent, coll, ret)) {
49  return true;
50  }
51  if (run_<edm::ValueMap<bool> >(tokenVMb_, iEvent, coll, ret)) {
53  return true;
54  }
57  return true;
58  }
61  return true;
62  }
63  if (run_<AssoVec<int>::type>(tokenAVi_, iEvent, coll, ret)) {
64  type_ = AssoVecInt;
65  return true;
66  }
67  type_ = Nothing;
68  return false;
69  break;
70  case ValueMapDouble:
71  return run_<edm::ValueMap<double> >(tokenVMd_, iEvent, coll, ret);
72  case ValueMapFloat:
73  return run_<edm::ValueMap<float> >(tokenVMf_, iEvent, coll, ret);
74  case ValueMapInt:
75  return run_<edm::ValueMap<int> >(tokenVMi_, iEvent, coll, ret);
76  case ValueMapBool:
77  return run_<edm::ValueMap<bool> >(tokenVMb_, iEvent, coll, ret);
78  case AssoVecDouble:
80  case AssoVecFloat:
82  case AssoVecInt:
84  case Nothing:
85  return false;
86  }
87  return false;
88  }
89 
90  private:
91  enum Type {
101  };
102  template <typename T>
103  bool run_(const edm::EDGetTokenT<T> &token,
104  const edm::Event &iEvent,
105  const Collection &coll,
106  std::vector<value_type> &ret);
117  };
118 
119  template <typename T>
121  const edm::Event &iEvent,
122  const Collection &coll,
123  std::vector<value_type> &ret) {
125  iEvent.getByToken(token, handle);
126  if (handle.failedToGet())
127  return false;
128 
129  for (size_t i = 0, n = coll.size(); i < n; ++i) {
130  reco::CandidateBaseRef ref = coll.refAt(i);
131  ret.push_back((*handle)[ref]);
132  }
133  return true;
134  }
135 
137 
138  } // namespace helper
139 } // namespace pat
140 
142 using namespace pat::helper;
bool run(const edm::Event &iEvent, const Collection &coll, std::vector< value_type > &ret)
Definition: helper.py:1
RefToBase< value_type > refAt(size_type i) const
bool run_(const edm::EDGetTokenT< T > &token, const edm::Event &iEvent, const Collection &coll, std::vector< value_type > &ret)
static PFTauRenderPlugin instance
ret
prodAgent to be discontinued
edm::EDGetTokenT< edm::ValueMap< float > > tokenVMf_
size_type size() const
Definition: HeavyIon.h:7
ManyThingsToValueMaps< AnyNumberAssociationAdaptor > AnyNumbersToValueMaps
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< AssoVec< int >::type > tokenAVi_
edm::AssociationVector< reco::CandidateBaseRefProd, typename std::vector< T > > type
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
AnyNumberAssociationAdaptor(const edm::InputTag &in, const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
edm::EDGetTokenT< AssoVec< double >::type > tokenAVd_
edm::EDGetTokenT< edm::ValueMap< bool > > tokenVMb_
edm::View< reco::Candidate > Collection
edm::EDGetTokenT< AssoVec< float >::type > tokenAVf_
HLT enums.
edm::EDGetTokenT< edm::ValueMap< double > > tokenVMd_
edm::EDGetTokenT< edm::ValueMap< int > > tokenVMi_