CMS 3D CMS Logo

ElectronIdMVABased.cc
Go to the documentation of this file.
1 //
2 //
3 // Original Author: Zablocki Jakub
4 // Created: Thu Feb 9 10:47:50 CST 2012
5 //
6 //
7 
8 // system include files
9 #include <memory>
10 
11 // user include files
14 
17 
24 //
25 // class declaration
26 //
27 
29 public:
30  explicit ElectronIdMVABased(const edm::ParameterSet&);
31  ~ElectronIdMVABased() override {}
32 
33 private:
34  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
35 
36  // ----------member data ---------------------------
39  const std::vector<std::string> mvaWeightFileEleID;
41  const double thresholdBarrel;
42  const double thresholdEndcap;
43  const double thresholdIsoBarrel;
44  const double thresholdIsoEndcap;
45 
46  const std::unique_ptr<const ElectronMVAEstimator> mvaID_;
47 };
48 
49 // constructor
51  : vertexToken(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexTag"))),
52  electronToken(consumes<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("electronTag"))),
53  thresholdBarrel(iConfig.getParameter<double>("thresholdBarrel")),
54  thresholdEndcap(iConfig.getParameter<double>("thresholdEndcap")),
55  thresholdIsoBarrel(iConfig.getParameter<double>("thresholdIsoDR03Barrel")),
56  thresholdIsoEndcap(iConfig.getParameter<double>("thresholdIsoDR03Endcap")),
58  .vweightsfiles = iConfig.getParameter<std::vector<std::string> >("HZZmvaWeightFile")})) {
59  produces<reco::GsfElectronCollection>();
60 }
61 
62 // ------------ method called on each new Event ------------
64  constexpr double etaEBEE = 1.485;
65 
66  auto mvaElectrons = std::make_unique<reco::GsfElectronCollection>();
67 
69  iEvent.getByToken(vertexToken, vertexCollection);
70  int nVtx = vertexCollection->size();
71 
73  iEvent.getByToken(electronToken, egCollection);
74  const reco::GsfElectronCollection egCandidates = (*egCollection.product());
75  for (reco::GsfElectronCollection::const_iterator egIter = egCandidates.begin(); egIter != egCandidates.end();
76  ++egIter) {
77  double mvaVal = mvaID_->mva(*egIter, nVtx);
78  double isoDr03 = egIter->dr03TkSumPt() + egIter->dr03EcalRecHitSumEt() + egIter->dr03HcalTowerSumEt();
79  double eleEta = fabs(egIter->eta());
80  if (eleEta <= etaEBEE && mvaVal > thresholdBarrel && isoDr03 < thresholdIsoBarrel) {
81  mvaElectrons->push_back(*egIter);
82  reco::GsfElectron::MvaOutput myMvaOutput;
83  myMvaOutput.mva_Isolated = mvaVal;
84  mvaElectrons->back().setMvaOutput(myMvaOutput);
85  } else if (eleEta > etaEBEE && mvaVal > thresholdEndcap && isoDr03 < thresholdIsoEndcap) {
86  mvaElectrons->push_back(*egIter);
87  reco::GsfElectron::MvaOutput myMvaOutput;
88  myMvaOutput.mva_Isolated = mvaVal;
89  mvaElectrons->back().setMvaOutput(myMvaOutput);
90  }
91  }
92 
94 }
95 
96 //define this as a plug-in
edm::StreamID
Definition: StreamID.h:30
ElectronIdMVABased::mvaWeightFileEleID
const std::vector< std::string > mvaWeightFileEleID
Definition: ElectronIdMVABased.cc:39
ElectronIdMVABased::thresholdIsoBarrel
const double thresholdIsoBarrel
Definition: ElectronIdMVABased.cc:43
ElectronMVAEstimator
Definition: ElectronMVAEstimator.h:10
edm::Handle::product
T const * product() const
Definition: Handle.h:70
edm::EDGetTokenT< reco::VertexCollection >
ElectronIdMVABased::mvaID_
const std::unique_ptr< const ElectronMVAEstimator > mvaID_
Definition: ElectronIdMVABased.cc:46
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
ElectronIdMVABased::vertexToken
const edm::EDGetTokenT< reco::VertexCollection > vertexToken
Definition: ElectronIdMVABased.cc:37
reco::GsfElectronCollection
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
Definition: GsfElectronFwd.h:14
electronIdMVABased_cfi.mvaElectrons
mvaElectrons
Definition: electronIdMVABased_cfi.py:3
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
ElectronIdMVABased::electronToken
const edm::EDGetTokenT< reco::GsfElectronCollection > electronToken
Definition: ElectronIdMVABased.cc:38
edm::Handle< reco::VertexCollection >
MakerMacros.h
electronIdMVABased_cfi.thresholdBarrel
thresholdBarrel
Definition: electronIdMVABased_cfi.py:12
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
electronIdMVABased_cfi.thresholdEndcap
thresholdEndcap
Definition: electronIdMVABased_cfi.py:13
ElectronIdMVABased::ElectronIdMVABased
ElectronIdMVABased(const edm::ParameterSet &)
Definition: ElectronIdMVABased.cc:50
reco::GsfElectron::MvaOutput::mva_Isolated
float mva_Isolated
Definition: GsfElectron.h:714
GsfElectron.h
edm::global::EDProducer
Definition: EDProducer.h:32
L1TkPrimaryVertexProducer_cfi.nVtx
nVtx
Definition: L1TkPrimaryVertexProducer_cfi.py:14
GsfElectronFwd.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
ElectronMVAEstimator.h
iEvent
int iEvent
Definition: GenABIO.cc:224
ElectronIdMVABased
Definition: ElectronIdMVABased.cc:28
ElectronIdMVABased::thresholdBarrel
const double thresholdBarrel
Definition: ElectronIdMVABased.cc:41
edm::EventSetup
Definition: EventSetup.h:58
ElectronIdMVABased::thresholdEndcap
const double thresholdEndcap
Definition: ElectronIdMVABased.cc:42
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
VertexFwd.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
ElectronIdMVABased::~ElectronIdMVABased
~ElectronIdMVABased() override
Definition: ElectronIdMVABased.cc:31
Vertex.h
Frameworkfwd.h
spclusmultinvestigator_cfi.vertexCollection
vertexCollection
Definition: spclusmultinvestigator_cfi.py:4
l1t::VertexCollection
std::vector< Vertex > VertexCollection
Definition: Vertex.h:12
reco::GsfElectron::MvaOutput
Definition: GsfElectron.h:712
ElectronIdMVABased::thresholdIsoEndcap
const double thresholdIsoEndcap
Definition: ElectronIdMVABased.cc:44
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ElectronIdMVABased::path_mvaWeightFileEleID
const std::string path_mvaWeightFileEleID
Definition: ElectronIdMVABased.cc:40
ParameterSet.h
EDProducer.h
ElectronIdMVABased::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: ElectronIdMVABased.cc:63
edm::Event
Definition: Event.h:73
edm::errors::Configuration
Definition: EDMException.h:36