CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  tokenAVb_(iC.consumes<AssoVec<bool>::type >(in))
26  { }
27 
28  const std::string & label() { return label_; }
29 
30  bool run(const edm::Event &iEvent, const Collection &coll, std::vector<value_type> &ret) {
31  switch (type_) {
32  case Uninitialized:
33  if (run_<edm::ValueMap<double> >(tokenVMd_, iEvent, coll, ret)) { type_ = ValueMapDouble; return true; }
34  if (run_<edm::ValueMap<float> >(tokenVMf_, iEvent, coll, ret)) { type_ = ValueMapFloat; return true; }
35  if (run_<edm::ValueMap<int> >(tokenVMi_, iEvent, coll, ret)) { type_ = ValueMapInt; return true; }
36  if (run_<edm::ValueMap<bool> >(tokenVMb_, iEvent, coll, ret)) { type_ = ValueMapBool; return true; }
37  if (run_<AssoVec<double>::type >(tokenAVd_, iEvent, coll, ret)) { type_ = AssoVecDouble; return true; }
38  if (run_<AssoVec<float>::type >(tokenAVf_, iEvent, coll, ret)) { type_ = AssoVecFloat; return true; }
39  if (run_<AssoVec<int>::type >(tokenAVi_, iEvent, coll, ret)) { type_ = AssoVecInt; return true; }
40  if (run_<AssoVec<bool>::type >(tokenAVb_, iEvent, coll, ret)) { type_ = AssoVecBool; return true; }
41  type_ = Nothing; return false;
42  break;
43  case ValueMapDouble : return run_<edm::ValueMap<double> >(tokenVMd_, iEvent, coll, ret);
44  case ValueMapFloat : return run_<edm::ValueMap<float> >(tokenVMf_, iEvent, coll, ret);
45  case ValueMapInt : return run_<edm::ValueMap<int> >(tokenVMi_, iEvent, coll, ret);
46  case ValueMapBool : return run_<edm::ValueMap<bool> >(tokenVMb_, iEvent, coll, ret);
51  case Nothing : return false;
52  }
53  return false;
54  }
55  private:
56  enum Type { Uninitialized = 0,
60  template<typename T> bool run_(const edm::EDGetTokenT<T> & token, const edm::Event &iEvent, const Collection &coll, std::vector<value_type> &ret) ;
72 
73 };
74 
75 template<typename T>
76 bool AnyNumberAssociationAdaptor::run_(const edm::EDGetTokenT<T> & token, const edm::Event &iEvent, const Collection &coll, std::vector<value_type> &ret) {
78  iEvent.getByToken(token, handle);
79  if (handle.failedToGet()) return false;
80 
81  for (size_t i = 0, n = coll.size(); i < n; ++i) {
82  reco::CandidateBaseRef ref = coll.refAt(i);
83  ret.push_back( (*handle)[ref] );
84  }
85  return true;
86 }
87 
89 
90 }} // namespaces
91 
92 
94 using namespace pat::helper;
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
bool run(const edm::Event &iEvent, const Collection &coll, std::vector< value_type > &ret)
edm::EDGetTokenT< AssoVec< bool >::type > tokenAVb_
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:464
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
size_type size() const
edm::EDGetTokenT< edm::ValueMap< float > > tokenVMf_
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
tuple handle
Definition: patZpeak.py:22
AnyNumberAssociationAdaptor(const edm::InputTag &in, const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
bool failedToGet() const
Definition: HandleBase.h:79
JetCorrectorParametersCollection coll
Definition: classes.h:10
edm::EDGetTokenT< edm::ValueMap< bool > > tokenVMb_
edm::View< reco::Candidate > Collection
edm::EDGetTokenT< AssoVec< float >::type > tokenAVf_
edm::EDGetTokenT< edm::ValueMap< double > > tokenVMd_
edm::EDGetTokenT< AssoVec< int >::type > tokenAVi_
edm::EDGetTokenT< edm::ValueMap< int > > tokenVMi_