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;
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
pat::helper::AnyNumberAssociationAdaptor::Collection
edm::View< reco::Candidate > Collection
Definition: AnythingToValueMap.cc:14
pat::helper::AnyNumberAssociationAdaptor::tokenAVf_
edm::EDGetTokenT< AssoVec< float >::type > tokenAVf_
Definition: AnythingToValueMap.cc:115
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
pat::helper::AnyNumberAssociationAdaptor::run_
bool run_(const edm::EDGetTokenT< T > &token, const edm::Event &iEvent, const Collection &coll, std::vector< value_type > &ret)
Definition: AnythingToValueMap.cc:120
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
pat::helper::AnyNumberAssociationAdaptor::ValueMapFloat
Definition: AnythingToValueMap.cc:94
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
pat::helper::AnyNumberAssociationAdaptor::run
bool run(const edm::Event &iEvent, const Collection &coll, std::vector< value_type > &ret)
Definition: AnythingToValueMap.cc:36
pat::helper::AnyNumberAssociationAdaptor::ValueMapBool
Definition: AnythingToValueMap.cc:96
pat::helper::AnyNumberAssociationAdaptor::label_
std::string label_
Definition: AnythingToValueMap.cc:109
pat::helper::AnyNumberAssociationAdaptor::in_
edm::InputTag in_
Definition: AnythingToValueMap.cc:108
patZpeak.handle
handle
Definition: patZpeak.py:23
pat::helper::AnyNumberAssociationAdaptor::AssoVec::type
edm::AssociationVector< reco::CandidateBaseRefProd, typename std::vector< T > > type
Definition: AnythingToValueMap.cc:17
edm::View::refAt
RefToBase< value_type > refAt(size_type i) const
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
AssociationMap.h
pat::helper
Definition: ParametrizationHelper.h:8
pat::helper::ManyThingsToValueMaps
Definition: AnythingToValueMap.h:66
pat::helper::AnyNumberAssociationAdaptor::AssoVecFloat
Definition: AnythingToValueMap.cc:98
pat::helper::AnyNumberAssociationAdaptor::ValueMapDouble
Definition: AnythingToValueMap.cc:93
edm::Handle
Definition: AssociativeIterator.h:50
pat::helper::AnyNumberAssociationAdaptor::AssoVecInt
Definition: AnythingToValueMap.cc:99
pat::helper::AnyNumberAssociationAdaptor::ValueMapInt
Definition: AnythingToValueMap.cc:95
MakerMacros.h
pat::helper::AnyNumberAssociationAdaptor::tokenVMf_
edm::EDGetTokenT< edm::ValueMap< float > > tokenVMf_
Definition: AnythingToValueMap.cc:111
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
pat::helper::AnyNumberAssociationAdaptor::tokenVMd_
edm::EDGetTokenT< edm::ValueMap< double > > tokenVMd_
Definition: AnythingToValueMap.cc:110
pat::helper::AnyNumberAssociationAdaptor::AssoVec
Definition: AnythingToValueMap.cc:16
pat::helper::AnyNumberAssociationAdaptor::type_
Type type_
Definition: AnythingToValueMap.cc:107
pat::helper::AnyNumberAssociationAdaptor::AnyNumberAssociationAdaptor
AnyNumberAssociationAdaptor(const edm::InputTag &in, const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
Definition: AnythingToValueMap.cc:20
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::View::size
size_type size() const
pat::helper::AnyNumberAssociationAdaptor::label
const std::string & label()
Definition: AnythingToValueMap.cc:34
edm::AssociationVector
Definition: AssociationVector.h:67
pat::helper::AnyNumberAssociationAdaptor::tokenAVi_
edm::EDGetTokenT< AssoVec< int >::type > tokenAVi_
Definition: AnythingToValueMap.cc:116
edm::View
Definition: CaloClusterFwd.h:14
pat::helper::AnyNumberAssociationAdaptor::tokenAVd_
edm::EDGetTokenT< AssoVec< double >::type > tokenAVd_
Definition: AnythingToValueMap.cc:114
edm::ParameterSet
Definition: ParameterSet.h:36
pat::helper::AnyNumberAssociationAdaptor::tokenVMi_
edm::EDGetTokenT< edm::ValueMap< int > > tokenVMi_
Definition: AnythingToValueMap.cc:112
pat::helper::AnyNumbersToValueMaps
ManyThingsToValueMaps< AnyNumberAssociationAdaptor > AnyNumbersToValueMaps
Definition: AnythingToValueMap.cc:136
recoMuon::in
Definition: RecoMuonEnumerators.h:6
helper
Definition: helper.py:1
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
pat::helper::AnyNumberAssociationAdaptor::AssoVecDouble
Definition: AnythingToValueMap.cc:97
pat::helper::AnyNumberAssociationAdaptor::Nothing
Definition: AnythingToValueMap.cc:100
pat::helper::AnyNumberAssociationAdaptor
Definition: AnythingToValueMap.cc:11
pat
Definition: HeavyIon.h:7
pat::helper::AnyNumberAssociationAdaptor::Type
Type
Definition: AnythingToValueMap.cc:91
instance
static PFTauRenderPlugin instance
Definition: PFTauRenderPlugin.cc:70
ValueMap.h
pat::helper::AnyNumberAssociationAdaptor::tokenVMb_
edm::EDGetTokenT< edm::ValueMap< bool > > tokenVMb_
Definition: AnythingToValueMap.cc:113
AnythingToValueMap.h
type
type
Definition: HCALResponse.h:21
edm::ValueMap
Definition: ValueMap.h:107
OneToValue.h
pat::helper::AnyNumberAssociationAdaptor::value_type
float value_type
Definition: AnythingToValueMap.cc:13
edm::RefToBase< Candidate >
AssociationVector.h
pat::helper::AnyNumberAssociationAdaptor::Uninitialized
Definition: AnythingToValueMap.cc:92
ConsumesCollector.h
Candidate.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316