1 |
csander |
1.1 |
// -*- C++ -*-
|
2 |
|
|
//
|
3 |
|
|
// Package: AnalysisSkeleton
|
4 |
|
|
// Class: AnalysisSkeleton
|
5 |
|
|
//
|
6 |
|
|
/**\class AnalysisSkeleton AnalysisSkeleton.cc MyAnalysis/AnalysisSkeleton/src/AnalysisSkeleton.cc
|
7 |
|
|
|
8 |
|
|
Description: [one line class summary]
|
9 |
|
|
|
10 |
|
|
Implementation:
|
11 |
|
|
[Notes on implementation]
|
12 |
|
|
*/
|
13 |
|
|
//
|
14 |
|
|
// Original Author: Christian Sander,,,
|
15 |
|
|
// Created: Wed Jun 30 13:55:44 CEST 2010
|
16 |
|
|
// $Id$
|
17 |
|
|
//
|
18 |
|
|
//
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
// system include files
|
22 |
|
|
#include <memory>
|
23 |
|
|
|
24 |
|
|
// user include files
|
25 |
|
|
#include "FWCore/Framework/interface/Frameworkfwd.h"
|
26 |
|
|
#include "FWCore/Utilities/interface/EDMException.h"
|
27 |
|
|
#include "FWCore/ServiceRegistry/interface/Service.h"
|
28 |
|
|
#include "CommonTools/UtilAlgos/interface/TFileService.h"
|
29 |
|
|
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
30 |
|
|
#include "FWCore/Framework/interface/EDAnalyzer.h"
|
31 |
|
|
|
32 |
|
|
#include "FWCore/Framework/interface/Event.h"
|
33 |
|
|
#include "FWCore/Framework/interface/MakerMacros.h"
|
34 |
|
|
|
35 |
|
|
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
36 |
|
|
|
37 |
|
|
#include "DataFormats/PatCandidates/interface/Jet.h"
|
38 |
|
|
#include "DataFormats/PatCandidates/interface/MET.h"
|
39 |
|
|
#include "DataFormats/PatCandidates/interface/Electron.h"
|
40 |
|
|
#include "DataFormats/PatCandidates/interface/Muon.h"
|
41 |
|
|
#include "DataFormats/PatCandidates/interface/Photon.h"
|
42 |
|
|
|
43 |
|
|
#include "DataFormats/VertexReco/interface/Vertex.h"
|
44 |
|
|
#include "DataFormats/VertexReco/interface/VertexFwd.h"
|
45 |
|
|
|
46 |
|
|
#include "TH1F.h"
|
47 |
|
|
#include "TFile.h"
|
48 |
|
|
|
49 |
|
|
//
|
50 |
|
|
// class declaration
|
51 |
|
|
//
|
52 |
|
|
using namespace edm;
|
53 |
|
|
using namespace std;
|
54 |
|
|
using namespace reco;
|
55 |
|
|
|
56 |
|
|
class AnalysisSkeleton : public edm::EDAnalyzer {
|
57 |
|
|
public:
|
58 |
|
|
explicit AnalysisSkeleton(const edm::ParameterSet&);
|
59 |
|
|
~AnalysisSkeleton();
|
60 |
|
|
bool goodElectron(const pat::Electron* ele);
|
61 |
|
|
bool goodMuon(const pat::Muon* mu);
|
62 |
|
|
bool goodJet(const pat::Jet* jet);
|
63 |
|
|
|
64 |
|
|
private:
|
65 |
|
|
virtual void beginJob() ;
|
66 |
|
|
virtual void analyze(const edm::Event&, const edm::EventSetup&);
|
67 |
|
|
virtual void endJob() ;
|
68 |
|
|
|
69 |
|
|
// ----------member data ---------------------------
|
70 |
|
|
};
|
71 |
|
|
|
72 |
|
|
//
|
73 |
|
|
// constants, enums and typedefs
|
74 |
|
|
//
|
75 |
|
|
|
76 |
|
|
//
|
77 |
|
|
// static data member definitions
|
78 |
|
|
//
|
79 |
|
|
edm::InputTag jets_;
|
80 |
|
|
edm::InputTag met_;
|
81 |
|
|
edm::InputTag electrons_;
|
82 |
|
|
edm::InputTag muons_;
|
83 |
|
|
edm::InputTag photons_;
|
84 |
|
|
edm::InputTag vertex_;
|
85 |
|
|
|
86 |
|
|
double elec_pt_cut_;
|
87 |
|
|
double elec_eta_cut_;
|
88 |
|
|
double elec_mva_cut_;
|
89 |
|
|
double elec_d0_cut_;
|
90 |
|
|
|
91 |
|
|
double muon_pt_cut_;
|
92 |
|
|
double muon_eta_cut_;
|
93 |
|
|
int muon_nHits_cut_;
|
94 |
|
|
double muon_nChi2_cut_;
|
95 |
|
|
double muon_d0_cut_;
|
96 |
|
|
|
97 |
|
|
double jet_pt_cut_;
|
98 |
|
|
double jet_eta_cut_;
|
99 |
|
|
double jet_minFem_cut_;
|
100 |
|
|
double jet_maxFem_cut_;
|
101 |
|
|
int jet_minN90_cut_;
|
102 |
|
|
double jet_maxfHPD_cut_;
|
103 |
|
|
bool jet_useJetID_;
|
104 |
|
|
|
105 |
|
|
math::XYZPoint bs;
|
106 |
|
|
|
107 |
|
|
TH1F* h_met;
|
108 |
|
|
TH1F* h_jetpt;
|
109 |
|
|
TH1F* h_jetphi;
|
110 |
|
|
TH1F* h_jeteta;
|
111 |
|
|
//
|
112 |
|
|
// constructors and destructor
|
113 |
|
|
//
|
114 |
|
|
AnalysisSkeleton::AnalysisSkeleton(const edm::ParameterSet& pset)
|
115 |
|
|
|
116 |
|
|
{
|
117 |
|
|
//now do what ever initialization is needed
|
118 |
|
|
jets_ = pset.getParameter<edm::InputTag> ("jetCollection");
|
119 |
|
|
met_ = pset.getParameter<edm::InputTag> ("metCollection");
|
120 |
|
|
electrons_ = pset.getParameter<edm::InputTag> ("electronCollection");
|
121 |
|
|
muons_ = pset.getParameter<edm::InputTag> ("muonCollection");
|
122 |
|
|
photons_ = pset.getParameter<edm::InputTag> ("photonCollection");
|
123 |
|
|
vertex_ = pset.getParameter<edm::InputTag> ("vertexCollection");
|
124 |
|
|
|
125 |
|
|
muon_pt_cut_ = pset.getParameter<double> ("muon_pt_cut");
|
126 |
|
|
muon_eta_cut_ = pset.getParameter<double> ("muon_eta_cut");
|
127 |
|
|
muon_nHits_cut_ = pset.getParameter<int> ("muon_nHits_cut");
|
128 |
|
|
muon_nChi2_cut_ = pset.getParameter<double> ("muon_nChi2_cut");
|
129 |
|
|
muon_d0_cut_ = pset.getParameter<double> ("muon_d0_cut");
|
130 |
|
|
|
131 |
|
|
elec_pt_cut_ = pset.getParameter<double> ("elec_pt_cut");
|
132 |
|
|
elec_eta_cut_ = pset.getParameter<double> ("elec_eta_cut");
|
133 |
|
|
elec_mva_cut_ = pset.getParameter<double> ("elec_mva_cut");
|
134 |
|
|
elec_d0_cut_ = pset.getParameter<double> ("elec_d0_cut");
|
135 |
|
|
|
136 |
|
|
jet_pt_cut_ = pset.getParameter<double> ("jet_pt_cut");
|
137 |
|
|
jet_eta_cut_ = pset.getParameter<double> ("jet_eta_cut");
|
138 |
|
|
jet_minFem_cut_ = pset.getParameter<double> ("jet_minFem_cut");
|
139 |
|
|
jet_maxFem_cut_ = pset.getParameter<double> ("jet_maxFem_cut");
|
140 |
|
|
jet_minN90_cut_ = pset.getParameter<int> ("jet_minN90_cut");
|
141 |
|
|
jet_maxfHPD_cut_ = pset.getParameter<double> ("jet_maxfHPD_cut");
|
142 |
|
|
jet_useJetID_ = pset.getParameter<bool> ("jet_useJetID");
|
143 |
|
|
}
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
AnalysisSkeleton::~AnalysisSkeleton()
|
147 |
|
|
{
|
148 |
|
|
|
149 |
|
|
// do anything here that needs to be done at destruction time
|
150 |
|
|
// (e.g. close files, deallocate resources etc.)
|
151 |
|
|
|
152 |
|
|
}
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
//
|
156 |
|
|
// member functions
|
157 |
|
|
//
|
158 |
|
|
|
159 |
|
|
// ------------ method called to for each event ------------
|
160 |
|
|
void
|
161 |
|
|
AnalysisSkeleton::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
|
162 |
|
|
{
|
163 |
|
|
|
164 |
|
|
//// Load all the PAT collections
|
165 |
|
|
|
166 |
|
|
//CaloJets
|
167 |
|
|
Handle<edm::View<pat::Jet> > Jets;
|
168 |
|
|
bool isFound = iEvent.getByLabel(jets_, Jets);
|
169 |
|
|
if (!isFound)
|
170 |
|
|
return;
|
171 |
|
|
edm::View<pat::Jet> Jets_rec = *Jets;
|
172 |
|
|
|
173 |
|
|
//MET
|
174 |
|
|
Handle<edm::View<pat::MET> > Met;
|
175 |
|
|
isFound = iEvent.getByLabel(met_, Met);
|
176 |
|
|
if (!isFound)
|
177 |
|
|
return;
|
178 |
|
|
edm::View<pat::MET> Met_rec = *Met;
|
179 |
|
|
|
180 |
|
|
//Electrons
|
181 |
|
|
Handle<edm::View<pat::Electron> > Electrons;
|
182 |
|
|
isFound = iEvent.getByLabel(electrons_, Electrons);
|
183 |
|
|
if (!isFound)
|
184 |
|
|
return;
|
185 |
|
|
edm::View<pat::Electron> Electrons_rec = *Electrons;
|
186 |
|
|
|
187 |
|
|
//Muons
|
188 |
|
|
Handle<edm::View<pat::Muon> > Muons;
|
189 |
|
|
isFound = iEvent.getByLabel(muons_, Muons);
|
190 |
|
|
if (!isFound)
|
191 |
|
|
return;
|
192 |
|
|
edm::View<pat::Muon> Muons_rec = *Muons;
|
193 |
|
|
|
194 |
|
|
//Photons
|
195 |
|
|
Handle<edm::View<pat::Photon> > Photons;
|
196 |
|
|
isFound = iEvent.getByLabel(photons_, Photons);
|
197 |
|
|
if (!isFound)
|
198 |
|
|
return;
|
199 |
|
|
edm::View<pat::Photon> Photons_rec = *Photons;
|
200 |
|
|
|
201 |
|
|
//Vertex
|
202 |
|
|
edm::Handle<reco::VertexCollection> vertices;
|
203 |
|
|
isFound = iEvent.getByLabel(vertex_, vertices);
|
204 |
|
|
if (!isFound)
|
205 |
|
|
return;
|
206 |
|
|
|
207 |
|
|
for (reco::VertexCollection::const_iterator vertex = vertices->begin(); vertex != vertices->end(); ++vertex) {
|
208 |
|
|
bs = vertex->position();
|
209 |
|
|
break;
|
210 |
|
|
}
|
211 |
|
|
|
212 |
|
|
//// Fill the histograms
|
213 |
|
|
|
214 |
|
|
for (edm::View<pat::Jet>::const_iterator it = Jets_rec.begin(); it != Jets_rec.end(); ++it) {
|
215 |
|
|
if (goodJet(&(*it))) {
|
216 |
|
|
h_jetpt->Fill(it->pt());
|
217 |
|
|
h_jeteta->Fill(it->eta());
|
218 |
|
|
h_jetphi->Fill(it->phi());
|
219 |
|
|
}
|
220 |
|
|
}
|
221 |
|
|
|
222 |
|
|
for (edm::View<pat::MET>::const_iterator it = Met_rec.begin(); it != Met_rec.end(); ++it) {
|
223 |
|
|
h_met->Fill(it->pt());
|
224 |
|
|
break;
|
225 |
|
|
}
|
226 |
|
|
|
227 |
|
|
}
|
228 |
|
|
|
229 |
|
|
|
230 |
|
|
// ------------ method called once each job just before starting event loop ------------
|
231 |
|
|
void
|
232 |
|
|
AnalysisSkeleton::beginJob()
|
233 |
|
|
{
|
234 |
|
|
edm::Service<TFileService> fs;
|
235 |
|
|
if (!fs) {
|
236 |
|
|
throw edm::Exception(edm::errors::Configuration, "TFile Service is not registered in cfg file");
|
237 |
|
|
}
|
238 |
|
|
h_met = fs->make<TH1F> ("met", "Met (Type I)", 100, 0., 1000.);
|
239 |
|
|
h_met->Sumw2();
|
240 |
|
|
h_jetpt = fs->make<TH1F> ("jetpt", "Jet Pt", 100, 0., 1000.);
|
241 |
|
|
h_jetpt->Sumw2();
|
242 |
|
|
h_jeteta = fs->make<TH1F> ("jeteta", "Jet Eta", 100, -5., 5.);
|
243 |
|
|
h_jeteta->Sumw2();
|
244 |
|
|
h_jetphi = fs->make<TH1F> ("jetphi", "Jet Phi", 100, -TMath::Pi(), -TMath::Pi());
|
245 |
|
|
h_jetphi->Sumw2();
|
246 |
|
|
}
|
247 |
|
|
|
248 |
|
|
// ------------ method called once each job just after ending the event loop ------------
|
249 |
|
|
void
|
250 |
|
|
AnalysisSkeleton::endJob() {
|
251 |
|
|
}
|
252 |
|
|
|
253 |
|
|
bool AnalysisSkeleton::goodElectron(const pat::Electron* ele) {
|
254 |
|
|
if (ele->pt() < elec_pt_cut_)
|
255 |
|
|
return false;
|
256 |
|
|
if (fabs(ele->eta()) > elec_eta_cut_)
|
257 |
|
|
return false;
|
258 |
|
|
if (ele->mva() < elec_mva_cut_)
|
259 |
|
|
return false;
|
260 |
|
|
if (fabs(ele->gsfTrack()->dxy(bs)) > elec_d0_cut_)
|
261 |
|
|
return false;
|
262 |
|
|
return true;
|
263 |
|
|
}
|
264 |
|
|
|
265 |
|
|
bool AnalysisSkeleton::goodMuon(const pat::Muon* mu) {
|
266 |
|
|
if (mu->pt() < muon_pt_cut_)
|
267 |
|
|
return false;
|
268 |
|
|
if (fabs(mu->eta()) > muon_eta_cut_)
|
269 |
|
|
return false;
|
270 |
|
|
if (!mu->isGlobalMuon())
|
271 |
|
|
return false;
|
272 |
|
|
if (mu->innerTrack()->numberOfValidHits() < muon_nHits_cut_)
|
273 |
|
|
return false;
|
274 |
|
|
if (mu->globalTrack()->normalizedChi2() > muon_nChi2_cut_)
|
275 |
|
|
return false;
|
276 |
|
|
if (fabs(mu->innerTrack()->dxy(bs)) > muon_d0_cut_)
|
277 |
|
|
return false;
|
278 |
|
|
return true;
|
279 |
|
|
}
|
280 |
|
|
|
281 |
|
|
bool AnalysisSkeleton::goodJet(const pat::Jet* jet) {
|
282 |
|
|
if (jet->pt() < jet_pt_cut_)
|
283 |
|
|
return false;
|
284 |
|
|
if (fabs(jet->eta()) > jet_eta_cut_)
|
285 |
|
|
return false;
|
286 |
|
|
if (jet->emEnergyFraction() < jet_minFem_cut_ && fabs(jet->eta()) < 2.6 && jet_useJetID_)
|
287 |
|
|
return false;
|
288 |
|
|
if (jet->emEnergyFraction() > jet_maxFem_cut_ && fabs(jet->eta()) < 2.6 && jet_useJetID_)
|
289 |
|
|
return false;
|
290 |
|
|
if (jet->jetID().n90Hits < jet_minN90_cut_ && jet_useJetID_)
|
291 |
|
|
return false;
|
292 |
|
|
if (jet->jetID().fHPD > jet_maxfHPD_cut_ && jet_useJetID_)
|
293 |
|
|
return false;
|
294 |
|
|
return true;
|
295 |
|
|
}
|
296 |
|
|
|
297 |
|
|
//define this as a plug-in
|
298 |
|
|
DEFINE_FWK_MODULE(AnalysisSkeleton);
|