forked from ksbeerna/TopTriggerEfficiencyProvider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DemoAnalyzer.cc
170 lines (131 loc) · 5 KB
/
DemoAnalyzer.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
// -*- C++ -*-
//
// Package: DemoAnalyzer
// Class: DemoAnalyzer
//
/**\class DemoAnalyzer DemoAnalyzer.cc MyAnalysers/DemoAnalyzer/src/DemoAnalyzer.cc
Description: Analyzer to demonstrate the use of the TopTriggerEfficiencyProvider class
Implementation:
[Notes on implementation]
*/
//
// Original Author: Kelly Beernaert
// Created: Thu Nov 8 12:01:23 CET 2012
// $Id: DemoAnalyzer.cc,v 1.3 2012/12/12 11:14:42 bbetchar Exp $
//
//
// system include files
#include <memory>
// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "./TopTriggerEfficiencyProvider.h"
#include <DataFormats/PatCandidates/interface/Jet.h>
#include <DataFormats/JetReco/interface/PFJet.h>
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
#include "DataFormats/Common/interface/View.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
//
// class declaration
//
class DemoAnalyzer : public edm::EDAnalyzer {
public:
explicit DemoAnalyzer(const edm::ParameterSet&);
~DemoAnalyzer();
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
private:
virtual void beginJob() ;
virtual void analyze(const edm::Event&, const edm::EventSetup&);
virtual void endJob() ;
virtual void beginRun(edm::Run const&, edm::EventSetup const&);
virtual void endRun(edm::Run const&, edm::EventSetup const&);
virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
// ----------member data ---------------------------
};
//
// constants, enums and typedefs
//
//
// static data member definitions
//
//
// constructors and destructor
//
DemoAnalyzer::DemoAnalyzer(const edm::ParameterSet& iConfig)
{
//now do what ever initialization is needed
}
DemoAnalyzer::~DemoAnalyzer()
{
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
}
//
// member functions
//
// ------------ method called for each event ------------
void
DemoAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
{
using namespace edm;
edm::Handle< std::vector<reco::GsfElectron> > electron;
iEvent.getByLabel("gsfElectrons", electron);
edm::Handle< std::vector<reco::PFJet> > jet;
iEvent.getByLabel("ak5PFJets", jet);
edm::Handle<std::vector<reco::Vertex> > vertex;
iEvent.getByLabel("offlinePrimaryVertices", vertex);
TopTriggerEfficiencyProvider *weight_provider = new TopTriggerEfficiencyProvider();
weight_provider->setLumi(TopTriggerEfficiencyProvider::RunB,3.1);
weight_provider->setLumi(TopTriggerEfficiencyProvider::RunA,0);
weight_provider->setLumi(TopTriggerEfficiencyProvider::RunC,6.01);
weight_provider->setLumi(TopTriggerEfficiencyProvider::RunD,0);
if(jet->size() < 4 || electron->size() == 0){return;}
//use kinematics of 4th leading jet (once JER and JES corrections applied)
std::vector<double> weight = weight_provider->get_weight((*electron)[0].pt(), (*electron)[0].eta(), (*jet)[3].pt(), (*jet)[3].eta(), vertex->size(), jet->size(), false, TopTriggerEfficiencyProvider::NOMINAL);
std::cout << "weight is "<<(weight)[0] << " +/- "<<(weight)[1]<< std::endl;
}
// ------------ method called once each job just before starting event loop ------------
void
DemoAnalyzer::beginJob()
{
}
// ------------ method called once each job just after ending the event loop ------------
void
DemoAnalyzer::endJob()
{
}
// ------------ method called when starting to processes a run ------------
void
DemoAnalyzer::beginRun(edm::Run const&, edm::EventSetup const&)
{
}
// ------------ method called when ending the processing of a run ------------
void
DemoAnalyzer::endRun(edm::Run const&, edm::EventSetup const&)
{
}
// ------------ method called when starting to processes a luminosity block ------------
void
DemoAnalyzer::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
{
}
// ------------ method called when ending the processing of a luminosity block ------------
void
DemoAnalyzer::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
{
}
// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
void
DemoAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
//The following says we do not know what parameters are allowed so do no validation
// Please change this to state exactly what you do use, even if it is no parameters
edm::ParameterSetDescription desc;
desc.setUnknown();
descriptions.addDefault(desc);
}
//define this as a plug-in
DEFINE_FWK_MODULE(DemoAnalyzer);