CMS 3D CMS Logo

MVAVariableHelper.h
Go to the documentation of this file.
1 #ifndef RecoEgamma_EgammaTools_MVAVariableHelper_H
2 #define RecoEgamma_EgammaTools_MVAVariableHelper_H
3 
8 
9 #include <unordered_map>
10 #include <vector>
11 #include <string>
12 
13 template<class ParticleType>
15 
16  public:
17 
19 
20  int getIndex(std::string const& name) const { return indexMap_.at(name); }
21 
22  private:
23 
24  const std::unordered_map<std::string, int> indexMap_;
25 };
26 
27 template<class ParticleType>
29 
30  public:
31 
33 
34  const std::vector<float> getAuxVariables(edm::Ptr<ParticleType> const& particlePtr,
35  const edm::Event& iEvent) const;
36 
37  private:
38 
39  static float getVariableFromValueMapToken(edm::Ptr<ParticleType> const& particlePtr,
40  edm::EDGetToken const& token, edm::Event const& iEvent) {
42  iEvent.getByToken(token, handle);
43  return (*handle)[particlePtr];
44  }
45 
46  static float getVariableFromDoubleToken(edm::EDGetToken const& token, const edm::Event& iEvent) {
48  iEvent.getByToken(token, handle);
49  return *handle;
50  }
51 
52  const std::vector<edm::EDGetToken> tokens_;
53 };
54 
55 #endif
const std::vector< edm::EDGetToken > tokens_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
int getIndex(std::string const &name) const
static float getVariableFromValueMapToken(edm::Ptr< ParticleType > const &particlePtr, edm::EDGetToken const &token, edm::Event const &iEvent)
int iEvent
Definition: GenABIO.cc:224
const std::unordered_map< std::string, int > indexMap_
static float getVariableFromDoubleToken(edm::EDGetToken const &token, const edm::Event &iEvent)