CMS 3D CMS Logo

MVAVariableHelper.cc
Go to the documentation of this file.
2 
4 // Specializations for the Electrons
6 
11 
12 template<>
14  : tokens_({
15  cc.consumes<reco::ConversionCollection>(edm::InputTag("allConversions")),
16  cc.consumes<reco::ConversionCollection>(edm::InputTag("reducedEgamma:reducedConversions")),
17  cc.consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot")),
18  cc.consumes<double>(edm::InputTag("fixedGridRhoFastjetAll"))
19  })
20 {}
21 
22 template<>
24  edm::Ptr<reco::GsfElectron> const& particlePtr, const edm::Event& iEvent) const
25 {
27  edm::Handle<reco::BeamSpot> beamSpotHandle;
28  edm::Handle<double> rhoHandle;
29 
30  iEvent.getByToken(tokens_[0], conversionsHandle);
31  if( !conversionsHandle.isValid() ) {
32  iEvent.getByToken(tokens_[1], conversionsHandle);
33  if( !conversionsHandle.isValid() )
34  throw cms::Exception(" Collection not found: ")
35  << " failed to find a standard AOD or miniAOD conversions collection " << std::endl;
36  }
37 
38  iEvent.getByToken(tokens_[2], beamSpotHandle);
39  iEvent.getByToken(tokens_[3], rhoHandle);
40 
41  return ElectronMVAEstimatorRun2::getExtraVars(*particlePtr,
42  conversionsHandle.product(),
43  beamSpotHandle.product(),
44  *rhoHandle);
45 }
46 
47 template<>
49  : indexMap_({
50  {"electronMVAVariableHelper:kfhits" , 0},
51  {"electronMVAVariableHelper:kfchi2" , 1},
52  {"electronMVAVariableHelper:convVtxFitProb", 2},
53  {"fixedGridRhoFastjetAll" , 3}
54  })
55 {}
56 
58 // Specializations for the Photons
60 
62 
63 template<>
65  : tokens_({
66  cc.consumes<edm::ValueMap<float>>(edm::InputTag("photonIDValueMapProducer", "phoPhotonIsolation")),
67  cc.consumes<edm::ValueMap<float>>(edm::InputTag("photonIDValueMapProducer", "phoChargedIsolation")),
68  cc.consumes<edm::ValueMap<float>>(edm::InputTag("photonIDValueMapProducer", "phoWorstChargedIsolation")),
69  cc.consumes<edm::ValueMap<float>>(edm::InputTag("photonIDValueMapProducer", "phoWorstChargedIsolationConeVeto")),
70  cc.consumes<edm::ValueMap<float>>(edm::InputTag("photonIDValueMapProducer", "phoWorstChargedIsolationConeVetoPVConstr")),
71  cc.consumes<edm::ValueMap<float>>(edm::InputTag("egmPhotonIsolation", "gamma-DR030-")),
72  cc.consumes<edm::ValueMap<float>>(edm::InputTag("egmPhotonIsolation", "h+-DR030-")),
73  cc.consumes<double>(edm::InputTag("fixedGridRhoFastjetAll")),
74  cc.consumes<double>(edm::InputTag("fixedGridRhoAll"))
75  })
76 {}
77 
78 template<>
80  edm::Ptr<reco::Photon> const& particlePtr, const edm::Event& iEvent) const
81 {
82  return std::vector<float> {
83  getVariableFromValueMapToken(particlePtr, tokens_[0], iEvent),
84  getVariableFromValueMapToken(particlePtr, tokens_[1], iEvent),
85  getVariableFromValueMapToken(particlePtr, tokens_[2], iEvent),
86  getVariableFromValueMapToken(particlePtr, tokens_[3], iEvent),
87  getVariableFromValueMapToken(particlePtr, tokens_[4], iEvent),
88  getVariableFromValueMapToken(particlePtr, tokens_[5], iEvent),
89  getVariableFromValueMapToken(particlePtr, tokens_[6], iEvent),
92  };
93 }
94 
95 template<>
97  : indexMap_({
98  {"photonIDValueMapProducer:phoPhotonIsolation" , 0},
99  {"photonIDValueMapProducer:phoChargedIsolation" , 1},
100  {"photonIDValueMapProducer:phoWorstChargedIsolation" , 2},
101  {"photonIDValueMapProducer:phoWorstChargedIsolationConeVeto" , 3},
102  {"photonIDValueMapProducer:phoWorstChargedIsolationConeVetoPVConstr", 4},
103  {"egmPhotonIsolation:gamma-DR030-" , 5},
104  {"egmPhotonIsolation:h+-DR030-" , 6},
105  {"fixedGridRhoFastjetAll" , 7},
106  {"fixedGridRhoAll" , 8}
107  })
108 {}
const std::vector< edm::EDGetToken > tokens_
static std::vector< float > getExtraVars(reco::GsfElectron const &ele, reco::ConversionCollection const *conversions, reco::BeamSpot const *beamSpot, double rho)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
Definition: ConversionFwd.h:9
static float getVariableFromValueMapToken(edm::Ptr< ParticleType > const &particlePtr, edm::EDGetToken const &token, edm::Event const &iEvent)
int iEvent
Definition: GenABIO.cc:230
bool isValid() const
Definition: HandleBase.h:74
MVAVariableHelper(edm::ConsumesCollector &&cc)
static float getVariableFromDoubleToken(edm::EDGetToken const &token, const edm::Event &iEvent)
std::vector< edm::EDGetTokenT< int > > tokens_
const std::vector< float > getAuxVariables(edm::Ptr< ParticleType > const &particlePtr, const edm::Event &iEvent) const
T const * product() const
Definition: Handle.h:81