CMS 3D CMS Logo

AnythingToValueMap.cc
Go to the documentation of this file.
8 
9 namespace pat { namespace helper {
11  public:
12  typedef float value_type;
15 
17  type_(Uninitialized), in_(in), label_(in.label() + in.instance()),
18  tokenVMd_(iC.consumes<edm::ValueMap<double> >(in)),
19  tokenVMf_(iC.consumes<edm::ValueMap<float> >(in)),
20  tokenVMi_(iC.consumes<edm::ValueMap<int> >(in)),
21  tokenVMb_(iC.consumes<edm::ValueMap<bool> >(in)),
22  tokenAVd_(iC.consumes<AssoVec<double>::type >(in)),
23  tokenAVf_(iC.consumes<AssoVec<float>::type >(in)),
24  tokenAVi_(iC.consumes<AssoVec<int>::type >(in))
25  { }
26 
27  const std::string & label() { return label_; }
28 
29  bool run(const edm::Event &iEvent, const Collection &coll, std::vector<value_type> &ret) {
30  switch (type_) {
31  case Uninitialized:
32  if (run_<edm::ValueMap<double> >(tokenVMd_, iEvent, coll, ret)) { type_ = ValueMapDouble; return true; }
33  if (run_<edm::ValueMap<float> >(tokenVMf_, iEvent, coll, ret)) { type_ = ValueMapFloat; return true; }
34  if (run_<edm::ValueMap<int> >(tokenVMi_, iEvent, coll, ret)) { type_ = ValueMapInt; return true; }
35  if (run_<edm::ValueMap<bool> >(tokenVMb_, iEvent, coll, ret)) { type_ = ValueMapBool; return true; }
36  if (run_<AssoVec<double>::type >(tokenAVd_, iEvent, coll, ret)) { type_ = AssoVecDouble; return true; }
37  if (run_<AssoVec<float>::type >(tokenAVf_, iEvent, coll, ret)) { type_ = AssoVecFloat; return true; }
38  if (run_<AssoVec<int>::type >(tokenAVi_, iEvent, coll, ret)) { type_ = AssoVecInt; return true; }
39  type_ = Nothing; return false;
40  break;
41  case ValueMapDouble : return run_<edm::ValueMap<double> >(tokenVMd_, iEvent, coll, ret);
42  case ValueMapFloat : return run_<edm::ValueMap<float> >(tokenVMf_, iEvent, coll, ret);
43  case ValueMapInt : return run_<edm::ValueMap<int> >(tokenVMi_, iEvent, coll, ret);
44  case ValueMapBool : return run_<edm::ValueMap<bool> >(tokenVMb_, iEvent, coll, ret);
47  case AssoVecInt : return run_<AssoVec<int>::type >(tokenAVi_, iEvent, coll, ret);
48  case Nothing : return false;
49  }
50  return false;
51  }
52  private:
53  enum Type { Uninitialized = 0,
57  template<typename T> bool run_(const edm::EDGetTokenT<T> & token, const edm::Event &iEvent, const Collection &coll, std::vector<value_type> &ret) ;
68 
69 };
70 
71 template<typename T>
72 bool AnyNumberAssociationAdaptor::run_(const edm::EDGetTokenT<T> & token, const edm::Event &iEvent, const Collection &coll, std::vector<value_type> &ret) {
74  iEvent.getByToken(token, handle);
75  if (handle.failedToGet()) return false;
76 
77  for (size_t i = 0, n = coll.size(); i < n; ++i) {
78  reco::CandidateBaseRef ref = coll.refAt(i);
79  ret.push_back( (*handle)[ref] );
80  }
81  return true;
82 }
83 
85 
86 }} // namespaces
87 
88 
90 using namespace pat::helper;
type
Definition: HCALResponse.h:21
bool run(const edm::Event &iEvent, const Collection &coll, std::vector< value_type > &ret)
Definition: helper.py:1
edm::EDGetTokenT< AssoVec< double >::type > tokenAVd_
bool run_(const edm::EDGetTokenT< T > &token, const edm::Event &iEvent, const Collection &coll, std::vector< value_type > &ret)
static PFTauRenderPlugin instance
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
size_type size() const
edm::EDGetTokenT< edm::ValueMap< float > > tokenVMf_
Definition: HeavyIon.h:7
RefToBase< value_type > refAt(size_type i) const
ManyThingsToValueMaps< AnyNumberAssociationAdaptor > AnyNumbersToValueMaps
int iEvent
Definition: GenABIO.cc:230
edm::AssociationVector< reco::CandidateBaseRefProd, typename std::vector< T > > type
AnyNumberAssociationAdaptor(const edm::InputTag &in, const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
bool failedToGet() const
Definition: HandleBase.h:78
JetCorrectorParametersCollection coll
Definition: classes.h:10
edm::EDGetTokenT< edm::ValueMap< bool > > tokenVMb_
edm::View< reco::Candidate > Collection
HLT enums.
edm::EDGetTokenT< AssoVec< float >::type > tokenAVf_
edm::EDGetTokenT< edm::ValueMap< double > > tokenVMd_
edm::EDGetTokenT< AssoVec< int >::type > tokenAVi_
edm::EDGetTokenT< edm::ValueMap< int > > tokenVMi_