1 |
vuko |
1.1 |
// -*- C++ -*-
|
2 |
|
|
//
|
3 |
|
|
// Package: WZAnalyzer
|
4 |
|
|
// Class: WZAnalyzer
|
5 |
|
|
//
|
6 |
vuko |
1.2 |
/**\class WZAnalyzer WZAnalyzer.cc Vuko/WZAnalysis/src/WZAnalyzer.cc
|
7 |
vuko |
1.1 |
|
8 |
|
|
Description: <one line class summary>
|
9 |
|
|
|
10 |
|
|
Implementation:
|
11 |
|
|
<Notes on implementation>
|
12 |
|
|
*/
|
13 |
|
|
//
|
14 |
|
|
// Original Author: Vuko Brigljevic
|
15 |
|
|
// Created: Fri Nov 9 11:07:27 CET 2007
|
16 |
kkaadze |
1.61 |
// $Id: WZAnalyzer.cc,v 1.60 2008/06/08 17:23:09 vuko Exp $
|
17 |
vuko |
1.1 |
//
|
18 |
|
|
//
|
19 |
|
|
|
20 |
|
|
|
21 |
senka |
1.19 |
|
22 |
vuko |
1.1 |
// system include files
|
23 |
|
|
#include <memory>
|
24 |
|
|
|
25 |
|
|
// user include files
|
26 |
|
|
#include "FWCore/Framework/interface/Frameworkfwd.h"
|
27 |
|
|
#include "FWCore/Framework/interface/EDAnalyzer.h"
|
28 |
|
|
|
29 |
|
|
#include "FWCore/Framework/interface/Event.h"
|
30 |
|
|
#include "FWCore/Framework/interface/MakerMacros.h"
|
31 |
|
|
|
32 |
|
|
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
33 |
|
|
|
34 |
vuko |
1.2 |
#include "Vuko/WZAnalysis/interface/WZAnalyzer.h"
|
35 |
vuko |
1.1 |
#include "DataFormats/Candidate/interface/OverlapChecker.h"
|
36 |
|
|
|
37 |
vuko |
1.2 |
#include "Vuko/WZAnalysis/interface/ElectronProperties.h"
|
38 |
vuko |
1.3 |
#include "Vuko/WZAnalysis/interface/MuonProperties.h"
|
39 |
kkaadze |
1.55 |
#include "Vuko/WZAnalysis/interface/AnglesUtil.h"
|
40 |
smorovic |
1.6 |
#include "DataFormats/Common/interface/TriggerResults.h"
|
41 |
vuko |
1.1 |
|
42 |
|
|
//--- muon AOD:
|
43 |
|
|
#include "DataFormats/JetReco/interface/CaloJetCollection.h"
|
44 |
|
|
#include "DataFormats/EgammaCandidates/interface/Electron.h"
|
45 |
|
|
#include "DataFormats/EgammaCandidates/interface/ElectronFwd.h"
|
46 |
|
|
#include "DataFormats/MuonReco/interface/MuonFwd.h"
|
47 |
|
|
#include "DataFormats/MuonReco/interface/Muon.h"
|
48 |
senka |
1.28 |
#include "DataFormats/MuonReco/interface/MuIsoDeposit.h"
|
49 |
vuko |
1.1 |
#include "DataFormats/EgammaReco/interface/BasicCluster.h"
|
50 |
|
|
#include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
|
51 |
|
|
#include "DataFormats/EgammaCandidates/interface/PixelMatchGsfElectron.h"
|
52 |
|
|
|
53 |
senka |
1.9 |
#include "DataFormats/METReco/interface/CaloMET.h"
|
54 |
|
|
|
55 |
vuko |
1.1 |
|
56 |
|
|
#include "TFile.h"
|
57 |
|
|
#include "TH1F.h"
|
58 |
|
|
#include "TH2F.h"
|
59 |
|
|
#include "TTree.h"
|
60 |
smorovic |
1.52 |
//#include "TVector3.h"
|
61 |
vuko |
1.1 |
|
62 |
|
|
#include <map>
|
63 |
|
|
|
64 |
|
|
//
|
65 |
|
|
// constants, enums and typedefs
|
66 |
|
|
//
|
67 |
|
|
|
68 |
|
|
//
|
69 |
|
|
// static data member definitions
|
70 |
|
|
//
|
71 |
|
|
|
72 |
|
|
//
|
73 |
|
|
// constructors and destructor
|
74 |
|
|
//
|
75 |
|
|
WZAnalyzer::WZAnalyzer(const edm::ParameterSet& iConfig)
|
76 |
|
|
|
77 |
|
|
{
|
78 |
|
|
//now do what ever initialization is needed
|
79 |
kkaadze |
1.58 |
// Recreate = iConfig.getUntrackedParameter<bool>("SecondRound");
|
80 |
|
|
treeNumber = iConfig.getUntrackedParameter<int>("treeNumber");
|
81 |
senka |
1.16 |
fOutputFileName = iConfig.getUntrackedParameter<string>("HistOutFile");
|
82 |
vuko |
1.10 |
theMCTruthCollection = iConfig.getParameter<edm::InputTag>("genParticles");
|
83 |
|
|
|
84 |
senka |
1.12 |
// theMCTruthCollection = iConfig.getParameter<edm::InputTag>("genParticleCollection");
|
85 |
|
|
|
86 |
vuko |
1.1 |
theLooseMuonCollection = iConfig.getParameter<edm::InputTag>("LooseMuons");
|
87 |
|
|
theGoodMuonCollection = iConfig.getParameter<edm::InputTag>("GoodMuons");
|
88 |
|
|
theLooseElectronCollection = iConfig.getParameter<edm::InputTag>("LooseElectrons");
|
89 |
beaucero |
1.56 |
theAllElectronCollection = iConfig.getParameter<edm::InputTag>("AllElectrons");
|
90 |
vuko |
1.1 |
theTightLeptonCollection = iConfig.getParameter<edm::InputTag>("TightLeptons");
|
91 |
|
|
// theMediumElectronCollection = iConfig.getParameter<edm::InputTag>("LooseElectrons");
|
92 |
|
|
// theTightElectronCollection = iConfig.getParameter<edm::InputTag>("TightElectrons");
|
93 |
|
|
// Z's
|
94 |
|
|
theZeeCollection = iConfig.getParameter<edm::InputTag>("ZtoEE");
|
95 |
|
|
theZmumuCollection = iConfig.getParameter<edm::InputTag>("ZtoMuMu");
|
96 |
vuko |
1.3 |
theZllCollection = iConfig.getParameter<edm::InputTag>("ZtoLL");
|
97 |
vuko |
1.10 |
|
98 |
|
|
theJetCollection = iConfig.getParameter<edm::InputTag>("Jets");
|
99 |
vuko |
1.26 |
|
100 |
|
|
theWeightCollection = iConfig.getParameter<edm::InputTag>("EventWeight");
|
101 |
smorovic |
1.38 |
alpgenIDTag = iConfig.getParameter<edm::InputTag>("AlpgenIDTag");
|
102 |
|
|
|
103 |
smorovic |
1.39 |
getAlpgenID = false;
|
104 |
|
|
getAlpgenID = iConfig.getParameter<bool>("getAlpgenID");
|
105 |
|
|
|
106 |
smorovic |
1.6 |
storeHLTresults=false;
|
107 |
|
|
storeHLTresults = iConfig.getParameter<bool>("storeHLTresults");
|
108 |
vuko |
1.1 |
|
109 |
vuko |
1.26 |
getEventWeight = false;
|
110 |
|
|
getEventWeight = iConfig.getParameter<bool>("getEventWeight");
|
111 |
|
|
|
112 |
smorovic |
1.23 |
triggerResultsTag = iConfig.getParameter<edm::InputTag>("TriggerResults");
|
113 |
smorovic |
1.6 |
firstTriggerResult = true;
|
114 |
smorovic |
1.52 |
|
115 |
|
|
findBackJets = false;
|
116 |
|
|
findBackJets = iConfig.getParameter<bool>("findBackJets");
|
117 |
vuko |
1.1 |
}
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
WZAnalyzer::~WZAnalyzer()
|
121 |
|
|
{
|
122 |
|
|
|
123 |
|
|
// do anything here that needs to be done at desctruction time
|
124 |
|
|
// (e.g. close files, deallocate resources etc.)
|
125 |
|
|
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
//
|
130 |
|
|
// member functions
|
131 |
|
|
//
|
132 |
|
|
|
133 |
|
|
// ------------ method called to for each event ------------
|
134 |
|
|
void
|
135 |
|
|
WZAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
|
136 |
|
|
{
|
137 |
|
|
using namespace edm;
|
138 |
|
|
using namespace reco;
|
139 |
|
|
using namespace std;
|
140 |
|
|
|
141 |
vuko |
1.11 |
///////////////////////////////////////
|
142 |
|
|
//
|
143 |
|
|
/// EVENT INITIALISATION
|
144 |
|
|
///
|
145 |
|
|
|
146 |
smorovic |
1.41 |
//read run number and event ID number
|
147 |
|
|
RunNumber = iEvent.id().run();
|
148 |
|
|
EventID = iEvent.id().event();
|
149 |
|
|
|
150 |
vuko |
1.11 |
// Reset a few things
|
151 |
|
|
for (map<string,wzana::LeptonProperties* >::iterator iter = leptonProperties.begin();
|
152 |
|
|
iter!=leptonProperties.end(); iter++)
|
153 |
|
|
{
|
154 |
|
|
iter->second->ResetValues();
|
155 |
|
|
}
|
156 |
|
|
|
157 |
|
|
|
158 |
vuko |
1.1 |
const Candidate * theZCandidate = 0;
|
159 |
|
|
const Candidate * theWlepton = 0;
|
160 |
|
|
|
161 |
vuko |
1.11 |
|
162 |
|
|
////////////////////////////////////////
|
163 |
|
|
// Get lists
|
164 |
|
|
|
165 |
vuko |
1.1 |
// Z->mumu
|
166 |
|
|
Handle<CandidateCollection> zmumuCands;
|
167 |
|
|
iEvent.getByLabel( theZmumuCollection , zmumuCands);
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
// Z->ee
|
171 |
|
|
Handle<CandidateCollection> zeeCands;
|
172 |
|
|
iEvent.getByLabel( theZeeCollection , zeeCands);
|
173 |
|
|
|
174 |
vuko |
1.3 |
// Z->ee
|
175 |
|
|
Handle<CandidateCollection> zllCands;
|
176 |
|
|
iEvent.getByLabel( theZllCollection , zllCands);
|
177 |
|
|
|
178 |
vuko |
1.1 |
// loose electrons
|
179 |
|
|
Handle<CandidateCollection> looseElectronCands;
|
180 |
|
|
iEvent.getByLabel( theLooseElectronCollection , looseElectronCands);
|
181 |
|
|
|
182 |
beaucero |
1.56 |
// All electrons
|
183 |
|
|
Handle<CandidateCollection> allElectronCands;
|
184 |
|
|
iEvent.getByLabel( theAllElectronCollection , allElectronCands);
|
185 |
vuko |
1.1 |
|
186 |
|
|
// loose muons
|
187 |
|
|
Handle<CandidateCollection> looseMuonCands;
|
188 |
|
|
iEvent.getByLabel( theLooseMuonCollection , looseMuonCands);
|
189 |
|
|
|
190 |
|
|
// good muons
|
191 |
|
|
Handle<CandidateCollection> goodMuonCands;
|
192 |
|
|
iEvent.getByLabel( theGoodMuonCollection , goodMuonCands);
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
// tight leptons
|
196 |
|
|
Handle<CandidateCollection> tightLeptonCands;
|
197 |
|
|
iEvent.getByLabel( theTightLeptonCollection , tightLeptonCands);
|
198 |
|
|
|
199 |
vuko |
1.10 |
// jets
|
200 |
vuko |
1.14 |
|
201 |
|
|
Handle<CaloJetCollection> jetCands;
|
202 |
vuko |
1.10 |
iEvent.getByLabel( theJetCollection , jetCands);
|
203 |
|
|
|
204 |
vuko |
1.26 |
|
205 |
|
|
// event weights (CSA07 soups...)
|
206 |
|
|
eventWeight = -1;
|
207 |
|
|
|
208 |
|
|
Handle< double> weightHandle;
|
209 |
smorovic |
1.31 |
Handle<int> genProcessID;
|
210 |
smorovic |
1.36 |
Handle<int> alpgenProcessID;
|
211 |
smorovic |
1.31 |
Handle<double> genEventScale;
|
212 |
|
|
|
213 |
vuko |
1.26 |
if (getEventWeight) {
|
214 |
smorovic |
1.40 |
|
215 |
vuko |
1.26 |
iEvent.getByLabel (theWeightCollection, weightHandle);
|
216 |
|
|
if (weightHandle.isValid()) {
|
217 |
|
|
eventWeight = * weightHandle;
|
218 |
|
|
}
|
219 |
smorovic |
1.40 |
|
220 |
smorovic |
1.31 |
iEvent.getByLabel( "genEventProcID", genProcessID );
|
221 |
smorovic |
1.32 |
if (genProcessID.isValid()) {
|
222 |
|
|
processID = *genProcessID;
|
223 |
smorovic |
1.31 |
}
|
224 |
smorovic |
1.40 |
|
225 |
smorovic |
1.39 |
if (processID==4 && getAlpgenID) {
|
226 |
smorovic |
1.38 |
iEvent.getByLabel( alpgenIDTag , alpgenProcessID );
|
227 |
|
|
if (alpgenProcessID.isValid()) {
|
228 |
|
|
alpgenID = *alpgenProcessID;
|
229 |
|
|
}
|
230 |
|
|
} else alpgenID=0;
|
231 |
|
|
|
232 |
|
|
|
233 |
smorovic |
1.31 |
iEvent.getByLabel( "genEventScale", genEventScale );
|
234 |
smorovic |
1.32 |
if (genEventScale.isValid()) {
|
235 |
|
|
eventScale = *genEventScale;
|
236 |
smorovic |
1.31 |
}
|
237 |
vuko |
1.26 |
}
|
238 |
beaucero |
1.42 |
|
239 |
|
|
|
240 |
smorovic |
1.6 |
// get hold of TriggerResults
|
241 |
senka |
1.27 |
Handle<TriggerResults> HLTR; //moja promjena: ovo prebaceno 2 reda nize!
|
242 |
senka |
1.44 |
if (storeHLTresults) {
|
243 |
|
|
// Handle<TriggerResults> HLTR;
|
244 |
|
|
iEvent.getByLabel(triggerResultsTag,HLTR);
|
245 |
|
|
if (firstTriggerResult) {
|
246 |
|
|
firstTriggerResult = false;
|
247 |
|
|
trigNames.init((edm::TriggerResults&)*HLTR);
|
248 |
|
|
numTriggers = trigNames.size();
|
249 |
|
|
}
|
250 |
|
|
}
|
251 |
|
|
|
252 |
smorovic |
1.6 |
|
253 |
senka |
1.44 |
// MET corrected (P_muons, P_muons_calo_deposit)
|
254 |
|
|
|
255 |
|
|
reco::Particle::LorentzVector MET=computeMET(iEvent, iSetup, looseMuonCands);
|
256 |
|
|
// MET_energy=MET.energy();
|
257 |
|
|
MET_energy=MET.energy(); // this is Et!!
|
258 |
|
|
MET_pt=MET.pt();
|
259 |
|
|
MET_px=MET.px();
|
260 |
|
|
MET_py=MET.py();
|
261 |
|
|
MET_eta=MET.eta();
|
262 |
vuko |
1.50 |
MET_phi=MET.phi();
|
263 |
senka |
1.44 |
|
264 |
kkaadze |
1.61 |
//Correct MET due to SC energy scale corrections
|
265 |
kkaadze |
1.55 |
reco::Particle::LorentzVector MET_SCCorr = correctMETforSCCorrection(MET, looseElectronCands);
|
266 |
|
|
MET_Et_SCCorr = MET_SCCorr.energy();
|
267 |
|
|
MET_pt_SCCorr = MET_SCCorr.pt();
|
268 |
|
|
MET_phi_SCCorr = MET_SCCorr.phi();
|
269 |
|
|
|
270 |
kkaadze |
1.61 |
//Correct MET due to electron energy scale corrections
|
271 |
kkaadze |
1.55 |
reco::Particle::LorentzVector MET_ElCorr = correctMETforElCorrection(MET, looseElectronCands);
|
272 |
|
|
MET_Et_ElCorr = MET_ElCorr.energy();
|
273 |
|
|
MET_pt_ElCorr = MET_ElCorr.pt();
|
274 |
|
|
MET_phi_ElCorr = MET_ElCorr.phi();
|
275 |
|
|
|
276 |
senka |
1.28 |
|
277 |
|
|
// selected muons
|
278 |
vuko |
1.1 |
|
279 |
beaucero |
1.35 |
// cout << "\t # loose mu : " << looseMuonCands->size()
|
280 |
|
|
// << "\t # tight mu : " << goodMuonCands->size()
|
281 |
|
|
// << "\t # loose e : " << looseElectronCands->size()
|
282 |
beaucero |
1.56 |
// << "\t # tight e : " << allElectronCands->size()
|
283 |
beaucero |
1.35 |
// << "\t # tight l : " << tightLeptonCands->size()
|
284 |
|
|
// << "\t # Z->mumu : " << zmumuCands->size()
|
285 |
|
|
// << "\t # Z->ee : " << zeeCands->size()
|
286 |
|
|
// << "\t # Z->ll : " << zllCands->size()
|
287 |
|
|
// << endl;
|
288 |
vuko |
1.1 |
|
289 |
senka |
1.27 |
N_looseMuons=0;
|
290 |
|
|
N_looseElectrons=0;
|
291 |
kkaadze |
1.61 |
N_allElectrons=0;
|
292 |
senka |
1.27 |
N_looseMuons = looseMuonCands->size();
|
293 |
|
|
N_looseElectrons = looseElectronCands->size();
|
294 |
kkaadze |
1.61 |
N_allElectrons = allElectronCands->size();
|
295 |
vuko |
1.49 |
NCaloJets = jetCands->size();
|
296 |
kkaadze |
1.61 |
|
297 |
vuko |
1.1 |
//
|
298 |
vuko |
1.7 |
// Find best Z (in Z->ll collection (merged Z->ee & Z->mumu)
|
299 |
vuko |
1.1 |
//
|
300 |
|
|
::OverlapChecker overlap;
|
301 |
|
|
|
302 |
vuko |
1.3 |
|
303 |
|
|
float dzmass_min = 100.;
|
304 |
|
|
|
305 |
senka |
1.27 |
n=1; // number of non overlaping Zs
|
306 |
vuko |
1.3 |
for(CandidateCollection::const_iterator z1 = zllCands->begin();
|
307 |
|
|
z1 != zllCands->end(); ++ z1 ) {
|
308 |
vuko |
1.21 |
|
309 |
|
|
// Check that two leptons used to build the Z are not overlapping
|
310 |
|
|
if (overlap(*(z1->daughter(0)),*(z1->daughter(1))) ) {
|
311 |
smorovic |
1.32 |
continue;
|
312 |
vuko |
1.21 |
}
|
313 |
|
|
|
314 |
vuko |
1.3 |
float dzmass = fabs( z1->mass() - 91.188);
|
315 |
|
|
if (dzmass < dzmass_min) {
|
316 |
vuko |
1.7 |
theZCandidate = &(*z1);
|
317 |
vuko |
1.3 |
dzmass_min = dzmass;
|
318 |
|
|
}
|
319 |
|
|
//
|
320 |
|
|
//Get back Electrons from Z and W
|
321 |
|
|
for(CandidateCollection::const_iterator z2 = z1;
|
322 |
|
|
z2 != zllCands->end(); ++ z2 ) {
|
323 |
|
|
if (z1 != z2) {
|
324 |
|
|
if (overlap(*z1,*z2)) {
|
325 |
|
|
} else {
|
326 |
senka |
1.27 |
n++;
|
327 |
vuko |
1.3 |
}
|
328 |
|
|
}
|
329 |
|
|
}
|
330 |
|
|
}
|
331 |
|
|
|
332 |
|
|
|
333 |
vuko |
1.1 |
zFlavour = 0;
|
334 |
|
|
wlFlavour = 0;
|
335 |
beaucero |
1.35 |
zMass = -10;
|
336 |
|
|
zPt = -10;
|
337 |
|
|
zEta = -10;
|
338 |
|
|
zPhi = -10;
|
339 |
vuko |
1.50 |
nWlElCand = 0;
|
340 |
|
|
nWlMuCand = 0;
|
341 |
vuko |
1.1 |
|
342 |
senka |
1.9 |
dPhi_WlZ_reco=-15.;
|
343 |
|
|
dPhi_WZ_reco=-15.;
|
344 |
kkaadze |
1.55 |
|
345 |
|
|
dPhi_Wl_MET = -15.;
|
346 |
|
|
dPhi_Wl_MET_SCCorr = -15.;
|
347 |
|
|
dPhi_Wl_MET_ElCorr = -15.;
|
348 |
beaucero |
1.56 |
wlCharge =-10;
|
349 |
|
|
wlEta = -10;
|
350 |
|
|
wlPhi = -10;
|
351 |
|
|
wlTransMass = -10;
|
352 |
|
|
wlTransMass_SCCorr = -10;
|
353 |
|
|
wlTransMass_ElCorr = -10;
|
354 |
kkaadze |
1.62 |
forElectronFakeRate = -10;
|
355 |
|
|
forMuonFakeRate = -10;
|
356 |
kkaadze |
1.61 |
|
357 |
senka |
1.15 |
//---------------
|
358 |
|
|
// matching(iEvent,looseMuonCands, 13);
|
359 |
|
|
// matching(iEvent,looseElectronCands, 11);
|
360 |
|
|
// MatchedGenParticle(&(*looseMuonCands)[0]);
|
361 |
|
|
//-------------------
|
362 |
|
|
|
363 |
vuko |
1.1 |
int nwl_candidates=0;
|
364 |
|
|
if (theZCandidate) {
|
365 |
|
|
|
366 |
|
|
|
367 |
|
|
zMass = theZCandidate->mass();
|
368 |
|
|
zFlavour = abs(theZCandidate->daughter(0)->pdgId());
|
369 |
|
|
zPt = theZCandidate->pt();
|
370 |
|
|
zEta = theZCandidate->eta();
|
371 |
|
|
zPhi = theZCandidate->phi();
|
372 |
|
|
|
373 |
vuko |
1.18 |
// Sanity check: can we identify the Z daughters with leptons from the loose lists
|
374 |
|
|
|
375 |
|
|
Handle<CandidateCollection> looseLeptonCands;
|
376 |
|
|
if (zFlavour == 11) {
|
377 |
|
|
looseLeptonCands = looseElectronCands;
|
378 |
|
|
} else if (zFlavour == 13) {
|
379 |
|
|
looseLeptonCands = looseMuonCands;
|
380 |
|
|
}
|
381 |
|
|
for (int i=0; i<2; i++) {
|
382 |
|
|
int noverlaps=0;
|
383 |
|
|
for(CandidateCollection::const_iterator l = looseLeptonCands->begin();
|
384 |
|
|
l != looseLeptonCands->end(); l++) {
|
385 |
|
|
if (overlap(*(theZCandidate->daughter(i)), *l) ) {
|
386 |
|
|
noverlaps++;
|
387 |
|
|
}
|
388 |
|
|
}
|
389 |
|
|
}
|
390 |
|
|
|
391 |
senka |
1.15 |
matching(iEvent,looseMuonCands, 13);
|
392 |
|
|
matching(iEvent,looseElectronCands, 11);
|
393 |
|
|
|
394 |
vuko |
1.4 |
if (zFlavour == 11) {
|
395 |
senka |
1.17 |
//--------------
|
396 |
vuko |
1.18 |
leptonProperties["ZEl1"]->FillProperties(theZCandidate->daughter(0), iEvent, iSetup,
|
397 |
|
|
MatchedGenParticle(theZCandidate->daughter(0)),dR(theZCandidate->daughter(0)));
|
398 |
|
|
leptonProperties["ZEl2"]->FillProperties(theZCandidate->daughter(1), iEvent, iSetup,
|
399 |
|
|
MatchedGenParticle(theZCandidate->daughter(1)),dR(theZCandidate->daughter(1)));
|
400 |
senka |
1.17 |
} else if (zFlavour == 13) {
|
401 |
|
|
//--------------
|
402 |
senka |
1.19 |
const reco::Candidate * mcpart = MatchedGenParticle(theZCandidate->daughter(0));
|
403 |
senka |
1.17 |
//--------------
|
404 |
vuko |
1.18 |
leptonProperties["Zmu1"]->FillProperties(theZCandidate->daughter(0), iEvent, iSetup,
|
405 |
|
|
MatchedGenParticle(theZCandidate->daughter(0)),dR(theZCandidate->daughter(0)));
|
406 |
vuko |
1.53 |
leptonProperties["Zmul"]->FillProperties(theZCandidate->daughter(0), iEvent, iSetup,
|
407 |
|
|
MatchedGenParticle(theZCandidate->daughter(0)),dR(theZCandidate->daughter(0)));
|
408 |
vuko |
1.18 |
leptonProperties["Zmu2"]->FillProperties(theZCandidate->daughter(1), iEvent, iSetup,
|
409 |
|
|
MatchedGenParticle(theZCandidate->daughter(1)),dR(theZCandidate->daughter(1)));
|
410 |
kkaadze |
1.61 |
|
411 |
vuko |
1.4 |
}
|
412 |
kkaadze |
1.61 |
|
413 |
vuko |
1.1 |
float max_pt = 0.;
|
414 |
kkaadze |
1.61 |
|
415 |
|
|
// Find W lepton
|
416 |
|
|
|
417 |
|
|
|
418 |
vuko |
1.1 |
// Now find lepton that will be associated to W
|
419 |
|
|
// among leptons not used for the Z reconstruction
|
420 |
|
|
for(CandidateCollection::const_iterator lepton = tightLeptonCands->begin();
|
421 |
|
|
lepton != tightLeptonCands->end(); lepton++) {
|
422 |
kkaadze |
1.61 |
|
423 |
|
|
|
424 |
vuko |
1.1 |
if ( overlap(*theZCandidate, *lepton) ) continue; // Ignore if lepton used for the Z
|
425 |
kkaadze |
1.61 |
|
426 |
vuko |
1.1 |
nwl_candidates++;
|
427 |
vuko |
1.50 |
if (abs(lepton->pdgId()) == 11) {
|
428 |
|
|
nWlElCand++;
|
429 |
|
|
} else if (abs(lepton->pdgId()) == 13) {
|
430 |
|
|
nWlMuCand++;
|
431 |
|
|
}
|
432 |
vuko |
1.1 |
|
433 |
|
|
// If more than one candidate: choose leading pt
|
434 |
|
|
if (lepton->pt() > max_pt) {
|
435 |
|
|
theWlepton = &(*lepton);
|
436 |
|
|
max_pt = lepton->pt();
|
437 |
|
|
}
|
438 |
kkaadze |
1.61 |
|
439 |
vuko |
1.1 |
if(lepton->hasMasterClone()) {
|
440 |
beaucero |
1.35 |
// cout << "SHOUT: TIGHT LEPTON IS SHALLOW COPY !!! (SHOULD NOT BE!) \n";
|
441 |
vuko |
1.1 |
}
|
442 |
|
|
//
|
443 |
|
|
}
|
444 |
|
|
if (theWlepton) {
|
445 |
|
|
wlFlavour = theWlepton->pdgId();
|
446 |
|
|
wlCharge = theWlepton->charge();
|
447 |
|
|
wlPt = theWlepton->pt();
|
448 |
|
|
wlEta = theWlepton->eta();
|
449 |
|
|
wlPhi = theWlepton->phi();
|
450 |
beaucero |
1.56 |
wlTransMass= kinem::TransvMass(theWlepton->pt(),MET.pt(),
|
451 |
|
|
theWlepton->px(), MET.px(),
|
452 |
|
|
theWlepton->py(),MET.py());
|
453 |
kkaadze |
1.61 |
|
454 |
vuko |
1.3 |
if (abs(wlFlavour) == 11) {
|
455 |
senka |
1.17 |
leptonProperties["Wel"]->FillProperties(theWlepton, iEvent, iSetup, MatchedGenParticle(theWlepton),dR(theWlepton));
|
456 |
vuko |
1.3 |
} else if (abs(wlFlavour) == 13) {
|
457 |
senka |
1.17 |
leptonProperties["Wmu"]->FillProperties(theWlepton, iEvent, iSetup, MatchedGenParticle(theWlepton),dR(theWlepton));
|
458 |
vuko |
1.3 |
}
|
459 |
kkaadze |
1.61 |
|
460 |
beaucero |
1.56 |
dPhi_WlZ_reco=kinem::delta_phi(theWlepton->phi(),theZCandidate->phi());
|
461 |
|
|
dPhi_WZ_reco=kinem::delta_phi((theWlepton->p4()+MET).phi(),theZCandidate->phi());
|
462 |
kkaadze |
1.61 |
|
463 |
kkaadze |
1.55 |
dPhi_Wl_MET = kinem::delta_phi(theWlepton->phi(),MET.phi());
|
464 |
beaucero |
1.56 |
dPhi_Wl_MET_SCCorr = kinem::delta_phi(theWlepton->phi(),MET_SCCorr.phi());
|
465 |
|
|
wlTransMass_SCCorr= kinem::TransvMass(theWlepton->pt(),MET_SCCorr.pt(),
|
466 |
kkaadze |
1.61 |
theWlepton->px(), MET_SCCorr.px(),
|
467 |
|
|
theWlepton->py(),MET_SCCorr.py());
|
468 |
beaucero |
1.56 |
dPhi_Wl_MET_ElCorr = kinem::delta_phi(theWlepton->phi(),MET_ElCorr.phi());
|
469 |
|
|
wlTransMass_ElCorr= kinem::TransvMass(theWlepton->pt(),MET_ElCorr.pt(),
|
470 |
kkaadze |
1.61 |
theWlepton->px(), MET_ElCorr.px(),
|
471 |
|
|
theWlepton->py(),MET_ElCorr.py());
|
472 |
vuko |
1.1 |
}
|
473 |
kkaadze |
1.55 |
|
474 |
vuko |
1.1 |
}
|
475 |
smorovic |
1.6 |
|
476 |
kkaadze |
1.61 |
|
477 |
kkaadze |
1.62 |
// Piece of code to select events with only one muon candidate for e-fakerate : KETI
|
478 |
kkaadze |
1.61 |
else { // if ( !theZCandidate ) {
|
479 |
|
|
matching(iEvent,looseMuonCands, 13);
|
480 |
|
|
matching(iEvent,allElectronCands, 11);
|
481 |
kkaadze |
1.62 |
matching(iEvent,looseElectronCands, 11);
|
482 |
kkaadze |
1.61 |
|
483 |
|
|
const CandidateCollection* electronCands = allElectronCands.product();
|
484 |
kkaadze |
1.62 |
const CandidateCollection* looseElCands = looseElectronCands.product();
|
485 |
kkaadze |
1.61 |
const CandidateCollection* muonCands = looseMuonCands.product();
|
486 |
kkaadze |
1.62 |
|
487 |
|
|
//Look at event with only one Global Muon and at least one GSF electron after Amb Resolver (for electron FakeRate)
|
488 |
|
|
//On Tree level all Muon selection nees to be applied in order this to be Good Muon
|
489 |
|
|
if ( N_looseMuons == 1 && allElectronCands->size() > 0 ) {
|
490 |
|
|
forElectronFakeRate = 1;
|
491 |
|
|
//Muon is supposly W candidate ( BUT not necessarily )
|
492 |
kkaadze |
1.61 |
leptonProperties["Wmu"] ->FillProperties(&(*muonCands)[0], iEvent, iSetup,
|
493 |
|
|
MatchedGenParticle( &(*muonCands)[0]), dR(&(*muonCands)[0]));
|
494 |
kkaadze |
1.62 |
theWlepton = &(*looseMuonCands->begin());
|
495 |
|
|
wlTransMass= kinem::TransvMass(theWlepton->pt(),MET.pt(),
|
496 |
|
|
theWlepton->px(), MET.px(),
|
497 |
|
|
theWlepton->py(),MET.py());
|
498 |
|
|
|
499 |
|
|
//Fill Lepton Properties for first electron as ZEl1
|
500 |
|
|
leptonProperties["ZEl1"] ->FillProperties(&(*electronCands)[0], iEvent, iSetup,
|
501 |
|
|
MatchedGenParticle( &(*electronCands)[0]), dR(&(*electronCands)[0]));
|
502 |
|
|
//If Second GSF electrons is also found ( meaning, both b jets decayed sami-leptonicaly )
|
503 |
|
|
//Fill lepton Properies as ZEl2
|
504 |
|
|
if ( allElectronCands->size() > 1 ) {
|
505 |
|
|
leptonProperties["ZEl2"] ->FillProperties(&(*electronCands)[1], iEvent, iSetup,
|
506 |
|
|
MatchedGenParticle( &(*electronCands)[1]), dR(&(*electronCands)[1]));
|
507 |
|
|
}
|
508 |
|
|
}
|
509 |
|
|
//Look at event with only one electron satisfying WZLoose Selection and at least one global Muon
|
510 |
|
|
if ( N_looseElectrons == 1 && looseMuonCands->size() > 0 ) {
|
511 |
|
|
forMuonFakeRate = 1;
|
512 |
|
|
//Electron can be assumed from W ( as it has passed Loose selection )
|
513 |
|
|
leptonProperties["Wel"]->FillProperties(&(*looseElCands)[0], iEvent, iSetup,
|
514 |
|
|
MatchedGenParticle( &(*looseElCands)[0]), dR(&(*looseElCands)[0]));
|
515 |
|
|
theWlepton = &(*looseElectronCands->begin());
|
516 |
|
|
wlTransMass= kinem::TransvMass(theWlepton->pt(),MET.pt(),
|
517 |
|
|
theWlepton->px(), MET.px(),
|
518 |
|
|
theWlepton->py(),MET.py());
|
519 |
|
|
|
520 |
|
|
// Fill Lepton Properties for first muon as Zmu1
|
521 |
|
|
leptonProperties["Zmu1"] ->FillProperties(&(*muonCands)[0], iEvent, iSetup,
|
522 |
|
|
MatchedGenParticle( &(*muonCands)[0]), dR(&(*muonCands)[0]));
|
523 |
|
|
//If second muons is also found, fill Lepton Properties for second muon as Zmu2
|
524 |
|
|
if ( looseMuonCands->size() > 1 ) {
|
525 |
|
|
leptonProperties["Zmu2"] ->FillProperties(&(*muonCands)[1], iEvent, iSetup,
|
526 |
kkaadze |
1.61 |
MatchedGenParticle( &(*muonCands)[1]), dR(&(*muonCands)[1]));
|
527 |
|
|
}
|
528 |
|
|
}
|
529 |
|
|
}
|
530 |
|
|
|
531 |
kkaadze |
1.62 |
/*
|
532 |
|
|
// if ( allElectronCands->size() > 2 ) {
|
533 |
|
|
// leptonProperties["Wel"]->FillProperties(&(*electronCands)[2], iEvent, iSetup,
|
534 |
|
|
// MatchedGenParticle( &(*electronCands)[2]), dR(&(*electronCands)[2]));
|
535 |
|
|
// }
|
536 |
|
|
|
537 |
|
|
// if ( looseMuonCands->size() > 1 ) {
|
538 |
|
|
// leptonProperties["Wmu"] ->FillProqperties(&(*muonCands)[2], iEvent, iSetup,
|
539 |
|
|
// MatchedGenParticle( &(*muonCands)[2]), dR(&(*muonCands)[2]));
|
540 |
|
|
// }
|
541 |
|
|
|
542 |
|
|
*/
|
543 |
kkaadze |
1.61 |
|
544 |
vuko |
1.10 |
// Handle <reco::GenParticleCandidateCollection> mccands;
|
545 |
|
|
Handle<CandidateCollection> mccands;
|
546 |
|
|
iEvent.getByLabel( theMCTruthCollection,mccands );
|
547 |
smorovic |
1.6 |
|
548 |
vuko |
1.11 |
collectMCsummary(mccands);
|
549 |
smorovic |
1.6 |
|
550 |
smorovic |
1.8 |
if (storeHLTresults) {
|
551 |
|
|
|
552 |
smorovic |
1.6 |
//def: 1:single electron 2:single relaxed 3:double electron 4: double relaxed 5,6,7,8: muon e+mu: 9
|
553 |
smorovic |
1.8 |
|
554 |
smorovic |
1.6 |
triggerBitmask=0;
|
555 |
smorovic |
1.52 |
triggerBitmaskQCD=0;
|
556 |
smorovic |
1.8 |
|
557 |
smorovic |
1.6 |
for (size_t i=0; i<numTriggers; ++i) {
|
558 |
|
|
|
559 |
|
|
if (!HLTR->wasrun(i)) {
|
560 |
|
|
continue;
|
561 |
|
|
}
|
562 |
|
|
if (HLTR->error(i) ) {
|
563 |
|
|
continue;
|
564 |
|
|
}
|
565 |
|
|
if (HLTR->accept(i)) {
|
566 |
|
|
//if (triggerNames[i].compare("mcpath")!=0)
|
567 |
|
|
//TRaccept=true;
|
568 |
|
|
}else {
|
569 |
|
|
continue;
|
570 |
|
|
}
|
571 |
smorovic |
1.34 |
if (trigNames.triggerName(i).compare("HLT1Electron")==0) triggerBitmask |= 1;
|
572 |
|
|
if (trigNames.triggerName(i).compare("HLT1ElectronRelaxed")==0) triggerBitmask |= 2;
|
573 |
|
|
if (trigNames.triggerName(i).compare("HLT2Electron")==0) triggerBitmask |= 4;
|
574 |
|
|
if (trigNames.triggerName(i).compare("HLT2ElectronRelaxed")==0) triggerBitmask |= 8;
|
575 |
|
|
|
576 |
|
|
if (trigNames.triggerName(i).compare("HLT1MuonIso")==0) triggerBitmask |= 16;
|
577 |
|
|
if (trigNames.triggerName(i).compare("HLT1MuonNonIso")==0) triggerBitmask |= 32;
|
578 |
|
|
if (trigNames.triggerName(i).compare("HLT2MuonNonIso")==0) triggerBitmask |= 64;
|
579 |
|
|
if (trigNames.triggerName(i).compare("HLT2MuonZ")==0) triggerBitmask |= 128;
|
580 |
smorovic |
1.6 |
|
581 |
smorovic |
1.34 |
if (trigNames.triggerName(i).compare("HLTXElectronMuon")==0) triggerBitmask |= 256;
|
582 |
|
|
if (trigNames.triggerName(i).compare("HLTXElectronMuonRelaxed")==0) triggerBitmask |= 512;
|
583 |
smorovic |
1.47 |
|
584 |
|
|
if (trigNames.triggerName(i).compare("CandHLT2MuonIso")==0) triggerBitmask |= 1024;
|
585 |
smorovic |
1.52 |
|
586 |
|
|
//for QCD control sample
|
587 |
vuko |
1.60 |
if (trigNames.triggerName(i).compare("HLT1Jet")==0) triggerBitmaskQCD |= 1;
|
588 |
|
|
if (trigNames.triggerName(i).compare("HLT2Jet")==0) triggerBitmaskQCD |= 2;
|
589 |
|
|
if (trigNames.triggerName(i).compare("HLT3Jet")==0) triggerBitmaskQCD |= 4;
|
590 |
|
|
if (trigNames.triggerName(i).compare("HLT4Jet")==0) triggerBitmaskQCD |= 8;
|
591 |
|
|
if (trigNames.triggerName(i).compare("HLT2JetAco")==0) triggerBitmaskQCD |= 16;
|
592 |
smorovic |
1.52 |
if (trigNames.triggerName(i).compare("HLTXMuonJets")==0) triggerBitmaskQCD |= 32;
|
593 |
|
|
if (trigNames.triggerName(i).compare("HLT1MET")==0) triggerBitmaskQCD |= 64;
|
594 |
vuko |
1.60 |
if (trigNames.triggerName(i).compare("HLT1Jet1METAco")==0) triggerBitmaskQCD |= 128;
|
595 |
|
|
if (trigNames.triggerName(i).compare("HLT1Jet1MET")==0) triggerBitmaskQCD |= 256;
|
596 |
|
|
if (trigNames.triggerName(i).compare("HLT2Jet1MET")==0) triggerBitmaskQCD |= 512;
|
597 |
|
|
if (trigNames.triggerName(i).compare("HLT3Jet1MET")==0) triggerBitmaskQCD |= 1024;
|
598 |
|
|
if (trigNames.triggerName(i).compare("HLT4Jet1MET")==0) triggerBitmaskQCD |= 2048;
|
599 |
smorovic |
1.52 |
if (trigNames.triggerName(i).compare("HLT1MET1HT")==0) triggerBitmaskQCD |= 4096;
|
600 |
vuko |
1.60 |
if (trigNames.triggerName(i).compare("HLTS2JetAco")==0) triggerBitmaskQCD |= 8192;
|
601 |
kkaadze |
1.61 |
if (trigNames.triggerName(i).compare("HLT1JetPE1")==0) triggerBitmaskQCD |= 16384;
|
602 |
|
|
if (trigNames.triggerName(i).compare("HLT1JetPE3")==0) triggerBitmaskQCD |= 32768;
|
603 |
|
|
if (trigNames.triggerName(i).compare("HLT1JetPE5")==0) triggerBitmaskQCD |= 65536;
|
604 |
|
|
if (trigNames.triggerName(i).compare("CandHLT1jetPE7")==0) triggerBitmaskQCD |= 131072;
|
605 |
|
|
|
606 |
smorovic |
1.6 |
}
|
607 |
|
|
}
|
608 |
vuko |
1.10 |
|
609 |
|
|
// Jet properties
|
610 |
|
|
|
611 |
|
|
float max_et = 0.;
|
612 |
vuko |
1.14 |
float max2_et = 0.;
|
613 |
|
|
const Candidate * leadingJet = 0;
|
614 |
|
|
const Candidate * secondJet = 0;
|
615 |
smorovic |
1.29 |
|
616 |
|
|
bool matchedLept[3]={false,false,false};
|
617 |
|
|
|
618 |
vuko |
1.14 |
// for(CandidateCollection::const_iterator jet = jetCands->begin();
|
619 |
smorovic |
1.41 |
NbJets = 0;
|
620 |
beaucero |
1.42 |
NbJetsWithLeptons = 0;
|
621 |
smorovic |
1.41 |
|
622 |
vuko |
1.14 |
for(CaloJetCollection::const_iterator jet = jetCands->begin();
|
623 |
vuko |
1.10 |
jet != jetCands->end(); jet++) {
|
624 |
smorovic |
1.29 |
|
625 |
|
|
//ignore jets which are within dR 0.15 to a WZ lepton
|
626 |
|
|
{
|
627 |
smorovic |
1.52 |
|
628 |
|
|
float dPhi[3]={-1.0,-1.0,-1.0};
|
629 |
|
|
float dEta[3]={-1.0,-1.0,-1.0};
|
630 |
|
|
bool skipJet=false;
|
631 |
|
|
|
632 |
|
|
for (int ct=0;ct<2;ct++) {
|
633 |
|
|
if (theZCandidate)
|
634 |
|
|
if (theZCandidate->daughter(ct)->pt()>0
|
635 |
beaucero |
1.56 |
&& (abs(theZCandidate->daughter(ct)->pdgId())==13
|
636 |
|
|
|| abs(theZCandidate->daughter(ct)->pdgId())==11) ) {
|
637 |
|
|
dPhi[ct]=kinem::delta_phi(theZCandidate->daughter(ct)->phi(),jet->phi());
|
638 |
|
|
dEta[ct]=fabs(theZCandidate->daughter(ct)->eta() - jet->eta());
|
639 |
smorovic |
1.52 |
}
|
640 |
|
|
}
|
641 |
|
|
if (theWlepton)
|
642 |
|
|
if (theWlepton->pt()>0 && (abs(theWlepton->pdgId())==13 || abs(theWlepton->pdgId())==11 )) {
|
643 |
beaucero |
1.56 |
dPhi[2]=kinem::delta_phi(theWlepton->phi(),jet->phi());
|
644 |
|
|
dEta[2]=fabs(theWlepton->eta() - jet->eta());
|
645 |
smorovic |
1.52 |
}
|
646 |
|
|
for (int k=0;k<3;k++) {
|
647 |
beaucero |
1.56 |
if (matchedLept[k] || dEta[k]<0.0) continue;
|
648 |
smorovic |
1.29 |
|
649 |
|
|
float deltaR=sqrt(dPhi[k]*dPhi[k]+dEta[k]*dEta[k]);
|
650 |
|
|
if (deltaR<0.15) {
|
651 |
|
|
skipJet=true;
|
652 |
|
|
matchedLept[k]=true;
|
653 |
|
|
break;
|
654 |
|
|
}
|
655 |
|
|
}
|
656 |
beaucero |
1.42 |
if(jet->pt() > 10 && fabs(jet->eta())<2.5 )NbJetsWithLeptons++;
|
657 |
vuko |
1.49 |
|
658 |
|
|
if (skipJet || fabs(jet->eta()) > 3.) continue;
|
659 |
|
|
|
660 |
beaucero |
1.42 |
if(jet->pt() > 10 && fabs(jet->eta())<2.5 )NbJets++;
|
661 |
smorovic |
1.29 |
}
|
662 |
|
|
|
663 |
vuko |
1.49 |
if (jet->et() > max_et ) {
|
664 |
|
|
if (leadingJet) {
|
665 |
|
|
secondJet = leadingJet;
|
666 |
|
|
max2_et = max_et;
|
667 |
|
|
}
|
668 |
|
|
leadingJet = &(*jet);
|
669 |
|
|
max_et = jet->et();
|
670 |
|
|
|
671 |
|
|
} else {
|
672 |
|
|
if (jet->et() > max2_et ) {
|
673 |
|
|
secondJet = &(*jet);
|
674 |
|
|
max2_et = jet->et();
|
675 |
|
|
}
|
676 |
|
|
}
|
677 |
vuko |
1.10 |
}
|
678 |
smorovic |
1.52 |
|
679 |
vuko |
1.10 |
if (leadingJet) {
|
680 |
smorovic |
1.52 |
jet1Et = leadingJet->et();
|
681 |
|
|
jet1Phi = leadingJet->phi();
|
682 |
|
|
jet1Eta = leadingJet->eta();
|
683 |
vuko |
1.10 |
|
684 |
|
|
} else {
|
685 |
smorovic |
1.52 |
jet1Et = -10;
|
686 |
|
|
jet1Phi = 0.;
|
687 |
|
|
jet1Eta = 0.;
|
688 |
vuko |
1.10 |
}
|
689 |
vuko |
1.14 |
if (secondJet) {
|
690 |
smorovic |
1.52 |
jet2Et = secondJet->et();
|
691 |
|
|
jet2Phi = secondJet->phi();
|
692 |
|
|
jet2Eta = secondJet->eta();
|
693 |
vuko |
1.14 |
} else {
|
694 |
smorovic |
1.52 |
jet2Et = -10;
|
695 |
|
|
jet2Phi = 0.;
|
696 |
|
|
jet2Eta = 0.;
|
697 |
vuko |
1.14 |
|
698 |
|
|
}
|
699 |
senka |
1.9 |
|
700 |
senka |
1.12 |
// matching:
|
701 |
|
|
|
702 |
|
|
matching(iEvent,looseMuonCands, 13);
|
703 |
|
|
matching(iEvent,looseElectronCands, 11);
|
704 |
|
|
|
705 |
senka |
1.13 |
getMother(&(*mccands)[1]);
|
706 |
vuko |
1.10 |
|
707 |
smorovic |
1.41 |
numberOfElectronTrees = 0;
|
708 |
|
|
|
709 |
|
|
//count number of electron treee entries which will be added
|
710 |
|
|
for(CandidateCollection::const_iterator el = looseElectronCands->begin();
|
711 |
|
|
el != looseElectronCands->end(); ++ el ) {
|
712 |
smorovic |
1.43 |
if (el->pt()>10 && fabs(el->eta())<2.5) {
|
713 |
smorovic |
1.41 |
numberOfElectronTrees++;
|
714 |
|
|
}
|
715 |
|
|
}
|
716 |
|
|
|
717 |
kkaadze |
1.61 |
cout << "Before filling the tree number = " << treeNumber << endl;
|
718 |
vuko |
1.1 |
wzTree->Fill();
|
719 |
|
|
|
720 |
vuko |
1.20 |
// Fill electrons in a tree
|
721 |
|
|
for(CandidateCollection::const_iterator el = looseElectronCands->begin();
|
722 |
|
|
el != looseElectronCands->end(); ++ el ) {
|
723 |
kkaadze |
1.62 |
|
724 |
vuko |
1.20 |
electronUse = 0;
|
725 |
kkaadze |
1.62 |
|
726 |
vuko |
1.20 |
if (theZCandidate) {
|
727 |
|
|
if (overlap(*theZCandidate, *el) ) {
|
728 |
|
|
electronUse = 23;
|
729 |
|
|
} else if (theWlepton) {
|
730 |
|
|
if (overlap(*theWlepton, *el) ) {
|
731 |
|
|
electronUse = 24;
|
732 |
|
|
}
|
733 |
smorovic |
1.41 |
}
|
734 |
vuko |
1.20 |
}
|
735 |
beaucero |
1.42 |
if (el->pt()>10 && fabs(el->eta())<2.5) {
|
736 |
|
|
leptonProperties["electron"]->FillProperties(&(*el),
|
737 |
|
|
iEvent, iSetup,
|
738 |
|
|
MatchedGenParticle(&(*el)),dR(&(*el)));
|
739 |
kkaadze |
1.62 |
|
740 |
smorovic |
1.52 |
if (findBackJets) {
|
741 |
kkaadze |
1.62 |
|
742 |
smorovic |
1.52 |
backJet_found=0;
|
743 |
|
|
backJet_Et=0;
|
744 |
|
|
backJet_Eta=0;
|
745 |
|
|
backJet_Phi=0;
|
746 |
|
|
backJet_maxEInEmTowers=0;
|
747 |
|
|
backJet_maxEInHadTowers=0;
|
748 |
|
|
backJet_energyFractionHadronic=0;
|
749 |
|
|
backJet_emEnergyFraction=0;
|
750 |
|
|
backJet_hadEnergyInHB=0;
|
751 |
|
|
backJet_hadEnergyInHO=0;
|
752 |
|
|
backJet_hadEnergyInHE=0;
|
753 |
|
|
backJet_hadEnergyInHF=0;
|
754 |
|
|
backJet_emEnergyInEB=0;
|
755 |
|
|
backJet_emEnergyInEE=0;
|
756 |
|
|
backJet_emEnergyInHF=0;
|
757 |
|
|
backJet_towersArea=0;
|
758 |
|
|
backJet_n90=0;
|
759 |
|
|
backJet_n60=0;
|
760 |
|
|
backJet_NbTracks = 0;
|
761 |
|
|
backJet_match=0;
|
762 |
|
|
backJet_matchPt=0;
|
763 |
|
|
backJet_match_dR=-1.0;
|
764 |
|
|
|
765 |
|
|
float oldDeltaPhi = -1.0;
|
766 |
|
|
|
767 |
|
|
edm::Handle<reco::TrackCollection> BarrelKFTracks;
|
768 |
|
|
iEvent.getByLabel("ctfWithMaterialTracks",BarrelKFTracks);
|
769 |
|
|
|
770 |
|
|
for (CaloJetCollection::const_iterator jet = jetCands->begin();
|
771 |
|
|
jet != jetCands->end(); jet++) {
|
772 |
|
|
|
773 |
|
|
int NbTracksInJets = 0;
|
774 |
|
|
for( reco::TrackCollection::const_iterator KFT = BarrelKFTracks->begin();KFT !=BarrelKFTracks->end(); ++ KFT ){
|
775 |
beaucero |
1.56 |
double DPhi = kinem::delta_phi(KFT->phi(),jet->phi());
|
776 |
kkaadze |
1.62 |
double dR=sqrt( (KFT->eta() - jet->eta())*(KFT->eta() - jet->eta()) + DPhi*DPhi );
|
777 |
|
|
|
778 |
|
|
if (KFT->pt()>2.0 && dR<0.3) NbTracksInJets++;
|
779 |
|
|
//cout << "pass track eta:" << KFT->eta() << " pt " << KFT->pt() << " dr " << dR << endl;
|
780 |
smorovic |
1.52 |
}
|
781 |
|
|
|
782 |
|
|
if (NbTracksInJets<=3) continue;
|
783 |
beaucero |
1.56 |
float dPhi = fabs(kinem::delta_phi(jet->phi(),el->phi()) - kinem::PI);
|
784 |
smorovic |
1.52 |
if (dPhi<0.7 && (dPhi<oldDeltaPhi || oldDeltaPhi<0.0)) {
|
785 |
|
|
oldDeltaPhi=dPhi;
|
786 |
|
|
|
787 |
|
|
backJet_found=1;
|
788 |
|
|
backJet_Et=jet->et();
|
789 |
|
|
backJet_Eta=jet->eta();
|
790 |
|
|
backJet_Phi=jet->phi();
|
791 |
|
|
backJet_maxEInEmTowers=jet->maxEInEmTowers();
|
792 |
|
|
backJet_maxEInHadTowers=jet->maxEInHadTowers();
|
793 |
|
|
backJet_energyFractionHadronic=jet->energyFractionHadronic();
|
794 |
|
|
backJet_emEnergyFraction=jet->emEnergyFraction();
|
795 |
|
|
backJet_hadEnergyInHB=jet->hadEnergyInHB();
|
796 |
|
|
backJet_hadEnergyInHO=jet->hadEnergyInHO();
|
797 |
|
|
backJet_hadEnergyInHE=jet->hadEnergyInHE();
|
798 |
|
|
backJet_hadEnergyInHF=jet->hadEnergyInHF();
|
799 |
|
|
backJet_emEnergyInEB=jet->emEnergyInEB();
|
800 |
|
|
backJet_emEnergyInEE=jet->emEnergyInEE();
|
801 |
|
|
backJet_emEnergyInHF=jet->emEnergyInHF();
|
802 |
|
|
backJet_towersArea=jet->towersArea();
|
803 |
|
|
backJet_n90=jet->n90();
|
804 |
|
|
backJet_n60=jet->n60();
|
805 |
|
|
//fill variables
|
806 |
|
|
backJet_NbTracks = NbTracksInJets;
|
807 |
|
|
//find monte carlo electrons close to the jet
|
808 |
|
|
float eDR = -1.0;
|
809 |
|
|
}
|
810 |
|
|
}
|
811 |
|
|
}
|
812 |
beaucero |
1.42 |
electronTree->Fill();
|
813 |
|
|
}
|
814 |
|
|
|
815 |
vuko |
1.20 |
}
|
816 |
|
|
|
817 |
kkaadze |
1.62 |
// Here we need to create a new tree that would store p_fake information for further study
|
818 |
|
|
// What this code must do:
|
819 |
|
|
|
820 |
|
|
|
821 |
smorovic |
1.52 |
EventCounter++;
|
822 |
vuko |
1.1 |
}
|
823 |
|
|
|
824 |
|
|
|
825 |
|
|
// ------------ method called once each job just before starting event loop ------------
|
826 |
|
|
void
|
827 |
|
|
WZAnalyzer::beginJob(const edm::EventSetup&)
|
828 |
|
|
{
|
829 |
|
|
|
830 |
|
|
using namespace wzana;
|
831 |
vuko |
1.60 |
theFile = new TFile( fOutputFileName.c_str(), "RECREATE" ) ;
|
832 |
kkaadze |
1.58 |
// theFile = new TFile( "wz.root","UPDATE") ;
|
833 |
vuko |
1.60 |
|
834 |
|
|
//cout << "Tree Number " << treeNumber << endl;
|
835 |
kkaadze |
1.61 |
if ( treeNumber == 0 ) {
|
836 |
|
|
wzTree = new TTree("WZTree","WZ Tree ");
|
837 |
|
|
electronTree = new TTree("ElTree","electron information");
|
838 |
|
|
} else if ( treeNumber == 1 ) {
|
839 |
vuko |
1.60 |
wzTree = new TTree("WZTree1","WZ number 1");
|
840 |
|
|
electronTree = new TTree("ElTree1","electron information");
|
841 |
|
|
} else if ( treeNumber == 2 ) {
|
842 |
|
|
wzTree = new TTree("WZTree2","WZ number 2");
|
843 |
|
|
electronTree = new TTree("ElTree2","electron information");
|
844 |
kkaadze |
1.58 |
} else if ( treeNumber == 3 ){
|
845 |
vuko |
1.60 |
wzTree = new TTree("WZTree3","WZ number 3");
|
846 |
|
|
electronTree = new TTree("ElTree3","electron information");
|
847 |
kkaadze |
1.58 |
} else if (treeNumber == 4 ) {
|
848 |
vuko |
1.60 |
wzTree = new TTree("WZTree4","WZ number 4");
|
849 |
|
|
electronTree = new TTree("ElTree4","electron information");
|
850 |
kkaadze |
1.58 |
} else if ( treeNumber == 5 ) {
|
851 |
vuko |
1.60 |
wzTree = new TTree("WZTree5","WZ number 5");
|
852 |
|
|
electronTree = new TTree("ElTree5","electron information");
|
853 |
kkaadze |
1.58 |
} else if ( treeNumber == 6 ) {
|
854 |
vuko |
1.60 |
wzTree = new TTree("WZTree6","WZ number 6");
|
855 |
|
|
electronTree = new TTree("ElTree6","electron information");
|
856 |
kkaadze |
1.58 |
} else if ( treeNumber == 7 ) {
|
857 |
vuko |
1.60 |
wzTree = new TTree("WZTree7","WZ number 7");
|
858 |
|
|
electronTree = new TTree("ElTree7","electron information");
|
859 |
kkaadze |
1.58 |
} else if ( treeNumber == 8 ) {
|
860 |
vuko |
1.60 |
wzTree = new TTree("WZTree8","WZ number 8");
|
861 |
|
|
electronTree = new TTree("ElTree8","electron information");
|
862 |
kkaadze |
1.58 |
} else { //( treeNumber == 9 ) {
|
863 |
vuko |
1.60 |
wzTree = new TTree("WZTree9","WZ number 9");
|
864 |
|
|
electronTree = new TTree("ElTree9","electron information");
|
865 |
kkaadze |
1.58 |
}
|
866 |
vuko |
1.1 |
|
867 |
vuko |
1.60 |
|
868 |
vuko |
1.20 |
|
869 |
smorovic |
1.52 |
// jetTree = new TTree("JetTree","jet deltaR information");
|
870 |
|
|
|
871 |
vuko |
1.20 |
leptonProperties["electron"] = new ElectronProperties();
|
872 |
vuko |
1.1 |
|
873 |
vuko |
1.3 |
leptonProperties["Wel"] = new ElectronProperties();
|
874 |
|
|
leptonProperties["ZEl1"] = new ElectronProperties();
|
875 |
|
|
leptonProperties["ZEl2"] = new ElectronProperties();
|
876 |
|
|
|
877 |
|
|
leptonProperties["Wmu"] = new MuonProperties();
|
878 |
|
|
leptonProperties["Zmu1"] = new MuonProperties();
|
879 |
|
|
leptonProperties["Zmu2"] = new MuonProperties();
|
880 |
vuko |
1.1 |
|
881 |
vuko |
1.54 |
leptonProperties["Zmul"] = new MuonProperties(); // SAME COMMENT AS BELOW: TEMPORARY FIX
|
882 |
vuko |
1.20 |
|
883 |
vuko |
1.60 |
|
884 |
vuko |
1.3 |
leptonProperties["Wel"]->CreateBranches(wzTree, "WEl_");
|
885 |
vuko |
1.4 |
leptonProperties["ZEl1"]->CreateBranches(wzTree, "ZEl1_");
|
886 |
|
|
leptonProperties["ZEl2"]->CreateBranches(wzTree, "ZEl2_");
|
887 |
vuko |
1.60 |
|
888 |
vuko |
1.54 |
leptonProperties["Wmu"]->CreateBranches(wzTree, "Wmu_");
|
889 |
vuko |
1.60 |
|
890 |
vuko |
1.54 |
leptonProperties["Zmu1"]->CreateBranches(wzTree, "Zmu1_");
|
891 |
vuko |
1.60 |
|
892 |
vuko |
1.54 |
leptonProperties["Zmul"]->CreateBranches(wzTree, "Zmul_");
|
893 |
|
|
leptonProperties["Zmu2"]->CreateBranches(wzTree, "Zmu2_");
|
894 |
|
|
leptonProperties["electron"]->CreateBranches(electronTree);
|
895 |
vuko |
1.60 |
|
896 |
|
|
initialiseTree();
|
897 |
senka |
1.9 |
|
898 |
smorovic |
1.6 |
|
899 |
|
|
//prepare HLT TriggerResults branch
|
900 |
|
|
if (storeHLTresults) {
|
901 |
vuko |
1.60 |
wzTree->Branch("WZ_hltBitmask",&triggerBitmask,"WZ_hltBitmask/I");
|
902 |
|
|
wzTree->Branch("QCD_hltBitmask",&triggerBitmaskQCD,"QCD_hltBitmask/I");
|
903 |
smorovic |
1.6 |
}
|
904 |
senka |
1.9 |
|
905 |
|
|
// MET branch
|
906 |
senka |
1.44 |
wzTree->Branch("MET_Et",&MET_energy,"MET_Et/F");
|
907 |
senka |
1.9 |
wzTree->Branch("MET_pt",&MET_pt,"MET_pt/F");
|
908 |
|
|
wzTree->Branch("MET_eta",&MET_eta,"MET_eta/F");
|
909 |
vuko |
1.50 |
wzTree->Branch("MET_phi",&MET_phi,"MET_eta/F");
|
910 |
senka |
1.9 |
wzTree->Branch("dPhi_WlZ_reco",&dPhi_WlZ_reco,"dPhi_WlZ_reco/F");
|
911 |
|
|
wzTree->Branch("dPhi_WZ_reco",&dPhi_WZ_reco,"dPhi_WZ_reco/F");
|
912 |
kkaadze |
1.55 |
wzTree->Branch("dPhi_Wl_MET",&dPhi_Wl_MET,"dPhi_Wl_MET/F");
|
913 |
vuko |
1.60 |
|
914 |
kkaadze |
1.55 |
// MET branch after corrections
|
915 |
|
|
wzTree->Branch("MET_Et_SCCorr",&MET_Et_SCCorr,"MET_Et_SCCorr/F");
|
916 |
|
|
wzTree->Branch("MET_pt_SCCorr",&MET_pt_SCCorr,"MET_pt_SCCorr/F");
|
917 |
|
|
wzTree->Branch("MET_phi_SCCorr",&MET_phi_SCCorr,"MET_phi_SCCorr/F");
|
918 |
|
|
wzTree->Branch("dPhi_Wl_MET_SCCorr",&dPhi_Wl_MET_SCCorr,"dPhi_Wl_MET_SCCorr/F");
|
919 |
vuko |
1.60 |
|
920 |
kkaadze |
1.55 |
wzTree->Branch("MET_Et_ElCorr",&MET_Et_ElCorr,"MET_Et_SCCorr/F");
|
921 |
|
|
wzTree->Branch("MET_pt_ElCorr",&MET_pt_ElCorr,"MET_pt_SCCorr/F");
|
922 |
|
|
wzTree->Branch("MET_phi_ElCorr",&MET_phi_ElCorr,"MET_phi_SCCorr/F");
|
923 |
|
|
wzTree->Branch("dPhi_Wl_MET_ElCorr",&dPhi_Wl_MET_ElCorr,"dPhi_Wl_MET_ElCorr/F");
|
924 |
vuko |
1.60 |
|
925 |
beaucero |
1.56 |
wzTree->Branch("WlTransMass", &wlTransMass, "WlTransMass/F");
|
926 |
|
|
wzTree->Branch("WlTransMass_SCCorr", &wlTransMass_SCCorr, "WlTransMass_SCCorr/F");
|
927 |
|
|
wzTree->Branch("WlTransMass_ElCorr", &wlTransMass_ElCorr, "WlTransMass_ElCorr/F");
|
928 |
vuko |
1.60 |
|
929 |
|
|
|
930 |
senka |
1.27 |
// # of non overlaping Zs
|
931 |
|
|
wzTree->Branch("N_nonOverlaping_Z",&n,"N_nonOverlaping_Z/I");
|
932 |
|
|
wzTree->Branch("N_looseMuons",&N_looseMuons,"N_looseMuons/I");
|
933 |
|
|
wzTree->Branch("N_looseElectrons",&N_looseElectrons,"N_looseElectrons/I");
|
934 |
kkaadze |
1.61 |
wzTree->Branch("N_allElectrons",&N_allElectrons,"N_allElectrons/I");
|
935 |
senka |
1.27 |
|
936 |
kkaadze |
1.61 |
//for electron fakerate study
|
937 |
kkaadze |
1.62 |
wzTree->Branch("forElectronFakeRate",&forElectronFakeRate, "forElectronFakeRate/I");
|
938 |
|
|
wzTree->Branch("forMuonFakeRate",&forMuonFakeRate, "forMuonFakeRate/I");
|
939 |
kkaadze |
1.61 |
|
940 |
smorovic |
1.52 |
EventCounter=0;
|
941 |
vuko |
1.1 |
}
|
942 |
|
|
|
943 |
|
|
// ------------ method called once each job just after ending the event loop ------------
|
944 |
|
|
void
|
945 |
|
|
WZAnalyzer::endJob() {
|
946 |
vuko |
1.60 |
// cout << "In the end job with treeNumber = " << treeNumber << endl;
|
947 |
vuko |
1.1 |
theFile->Write();
|
948 |
|
|
theFile->Close();
|
949 |
vuko |
1.60 |
|
950 |
vuko |
1.1 |
}
|
951 |
|
|
|
952 |
|
|
|
953 |
|
|
void WZAnalyzer::initialiseTree() {
|
954 |
vuko |
1.26 |
// Event properties
|
955 |
|
|
wzTree->Branch("weight", &eventWeight, "weight/F");
|
956 |
smorovic |
1.31 |
wzTree->Branch("processID", &processID, "processID/I");
|
957 |
smorovic |
1.36 |
wzTree->Branch("alpgenID", &alpgenID, "alpgenID/I");
|
958 |
smorovic |
1.48 |
wzTree->Branch("genEventScale", &eventScale, "genEventScale/F");
|
959 |
smorovic |
1.41 |
wzTree->Branch("RunNumber", &RunNumber, "RunNumber/I");
|
960 |
|
|
wzTree->Branch("EventID", &EventID, "EventID/I");
|
961 |
vuko |
1.26 |
|
962 |
vuko |
1.1 |
// Z properties
|
963 |
|
|
wzTree->Branch("Zmass", &zMass, "Zmass/F");
|
964 |
|
|
wzTree->Branch("ZId", &zFlavour, "Zid/I");
|
965 |
|
|
wzTree->Branch("ZPt", &zPt, "ZPt/F");
|
966 |
|
|
wzTree->Branch("ZEta", &zEta, "ZEta/F");
|
967 |
|
|
wzTree->Branch("ZPhi", &zPhi, "ZPhi/F");
|
968 |
|
|
|
969 |
|
|
// W Properties
|
970 |
|
|
wzTree->Branch("WlId", &wlFlavour, "Wlid/I");
|
971 |
|
|
wzTree->Branch("WlCharge", &wlCharge, "WlCharge/I");
|
972 |
|
|
wzTree->Branch("WlPt", &wlPt, "WlPt/F");
|
973 |
vuko |
1.50 |
|
974 |
|
|
wzTree->Branch("nwlelcand", &nWlElCand, "nwlelcand/I");
|
975 |
|
|
wzTree->Branch("nwlmucand", &nWlMuCand, "nwlmucand/I");
|
976 |
|
|
|
977 |
smorovic |
1.8 |
|
978 |
|
|
wzTree->Branch("MC_leptonZ1_pt", &MCleptZ1_pt,"MC_leptonZ1_pt/F");
|
979 |
|
|
wzTree->Branch("MC_leptonZ2_pt", &MCleptZ2_pt,"MC_leptonZ2_pt/F");
|
980 |
|
|
wzTree->Branch("MC_leptonW_pt", &MCleptW_pt, "MC_leptonW_pt/F");
|
981 |
|
|
|
982 |
|
|
wzTree->Branch("MC_leptonZ1_eta", &MCleptZ1_eta,"MC_leptonZ1_eta/F");
|
983 |
|
|
wzTree->Branch("MC_leptonZ2_eta", &MCleptZ2_eta,"MC_leptonZ2_eta/F");
|
984 |
|
|
wzTree->Branch("MC_leptonW_eta", &MCleptW_eta, "MC_leptonW_eta/F");
|
985 |
|
|
|
986 |
|
|
wzTree->Branch("MC_leptonZ1_phi", &MCleptZ1_phi,"MC_leptonZ1_phi/F");
|
987 |
|
|
wzTree->Branch("MC_leptonZ2_phi", &MCleptZ2_phi,"MC_leptonZ2_phi/F");
|
988 |
|
|
wzTree->Branch("MC_leptonW_phi", &MCleptW_phi, "MC_leptonW_phi/F");
|
989 |
|
|
|
990 |
|
|
wzTree->Branch("MC_leptonZ1_pdgid", &MCleptZ1_pdgid,"MC_leptonZ1_pdgid/I");
|
991 |
|
|
wzTree->Branch("MC_leptonZ2_pdgid", &MCleptZ2_pdgid,"MC_leptonZ2_pdgid/I");
|
992 |
|
|
wzTree->Branch("MC_leptonW_pdgid", &MCleptW_pdgid, "MC_leptonW_pdgid/I");
|
993 |
vuko |
1.14 |
|
994 |
|
|
/*
|
995 |
|
|
wzTree->Branch("MC_leptonW_origin", &MCleptW_pdgid, "MC_leptonW_origin/I");
|
996 |
|
|
wzTree->Branch("MC_leptonZ1_origin", &MCleptW_pdgid, "MC_leptonZ1_origin/I");
|
997 |
|
|
wzTree->Branch("MC_leptonZ2_origin", &MCleptW_pdgid, "MC_leptonZ2_origin/I");
|
998 |
|
|
*/
|
999 |
|
|
|
1000 |
smorovic |
1.8 |
wzTree->Branch("MC_TauDecayType_fromZ1", &MC_tauDecayTypeZ1,"MC_TauDecayType_fromZ1/I");
|
1001 |
|
|
wzTree->Branch("MC_TauDecayType_fromZ2", &MC_tauDecayTypeZ2,"MC_TauDecayType_fromZ2/I");
|
1002 |
|
|
wzTree->Branch("MC_TauDecayType_fromW", &MC_tauDecayTypeW, "MC_TauDecayType_fromW/I");
|
1003 |
vuko |
1.10 |
|
1004 |
beaucero |
1.56 |
// Jet properties
|
1005 |
smorovic |
1.41 |
wzTree->Branch("NbJets", &NbJets, "NbJets/I");
|
1006 |
vuko |
1.49 |
wzTree->Branch("NCaloJets", &NCaloJets,"NCaloJets/I");
|
1007 |
smorovic |
1.41 |
|
1008 |
vuko |
1.10 |
wzTree->Branch("Jet1Et", &jet1Et, "Jet1Et/F");
|
1009 |
|
|
wzTree->Branch("Jet1Phi", &jet1Phi, "Jet1Phi/F");
|
1010 |
|
|
wzTree->Branch("Jet1Eta", &jet1Eta, "Jet1Eta/F");
|
1011 |
|
|
|
1012 |
|
|
wzTree->Branch("Jet2Et", &jet2Et, "Jet2Et/F");
|
1013 |
|
|
wzTree->Branch("Jet2Phi", &jet2Phi, "Jet2Phi/F");
|
1014 |
|
|
wzTree->Branch("Jet2Eta", &jet2Eta, "Jet2Eta/F");
|
1015 |
smorovic |
1.41 |
wzTree->Branch("ElectronTreesInEvent", &numberOfElectronTrees, "ElectronTreesInEvent/I");
|
1016 |
smorovic |
1.52 |
wzTree->Branch("EventCounter", &EventCounter, "EventCounter/I");
|
1017 |
vuko |
1.20 |
//
|
1018 |
|
|
electronTree->Branch("used", &electronUse, "used/I");
|
1019 |
smorovic |
1.40 |
electronTree->Branch("weight", &eventWeight, "weight/F");
|
1020 |
|
|
electronTree->Branch("processID", &processID, "processID/I");
|
1021 |
|
|
electronTree->Branch("alpgenID", &alpgenID, "alpgenID/I");
|
1022 |
smorovic |
1.48 |
electronTree->Branch("genEventScale", &eventScale, "genEventScale/F");
|
1023 |
smorovic |
1.41 |
electronTree->Branch("ElectronTreesInEvent", &numberOfElectronTrees, "ElectronTreesInEvent/I");
|
1024 |
|
|
|
1025 |
|
|
electronTree->Branch("RunNumber", &RunNumber, "RunNumber/I");
|
1026 |
|
|
electronTree->Branch("EventID", &EventID, "EventID/I");
|
1027 |
smorovic |
1.52 |
electronTree->Branch("EventCounter", &EventCounter, "EventCounter/I");
|
1028 |
beaucero |
1.42 |
electronTree->Branch("NbJetsWithLeptons", &NbJetsWithLeptons, "NbJetsWithLeptons/I");
|
1029 |
smorovic |
1.52 |
|
1030 |
|
|
if (findBackJets) {
|
1031 |
|
|
electronTree->Branch("MET_Et",&MET_energy,"MET_Et/F");
|
1032 |
|
|
electronTree->Branch("MET_pt",&MET_pt,"MET_pt/F");
|
1033 |
|
|
electronTree->Branch("MET_eta",&MET_eta,"MET_eta/F");
|
1034 |
beaucero |
1.56 |
electronTree->Branch("MET_phi",&MET_phi,"MET_phi/F");
|
1035 |
smorovic |
1.52 |
|
1036 |
|
|
electronTree->Branch("backJet_found",&backJet_found,"backJet_found/I");
|
1037 |
|
|
electronTree->Branch("backJet_Et",&backJet_Et,"backJet_Et/F");
|
1038 |
|
|
electronTree->Branch("backJet_Eta",&backJet_Eta,"backJet_Eta/F");
|
1039 |
|
|
electronTree->Branch("backJet_Phi",&backJet_Phi,"backJet_Phi/F");
|
1040 |
|
|
electronTree->Branch("backJet_maxEInEmTowers",&backJet_maxEInEmTowers,"backJet_maxEInEmTowers/F");
|
1041 |
|
|
electronTree->Branch("backJet_maxEInHadTowers",&backJet_maxEInHadTowers,"backJet_maxEInHadTowers/F");
|
1042 |
|
|
electronTree->Branch("backJet_energyFractionHadronic",&backJet_energyFractionHadronic,"backJet_energyFractionHadronic/F");
|
1043 |
|
|
electronTree->Branch("backJet_emEnergyFraction",&backJet_emEnergyFraction,"backJet_emEnergyFraction/F");
|
1044 |
|
|
electronTree->Branch("backJet_hadEnergyInHB",&backJet_hadEnergyInHB,"backJet_hadEnergyInHB/F");
|
1045 |
|
|
electronTree->Branch("backJet_hadEnergyInHO",&backJet_hadEnergyInHO,"backJet_hadEnergyInHO/F");
|
1046 |
|
|
electronTree->Branch("backJet_hadEnergyInHE",&backJet_hadEnergyInHE,"backJet_hadEnergyInHE/F");
|
1047 |
|
|
electronTree->Branch("backJet_hadEnergyInHF",&backJet_hadEnergyInHF,"backJet_hadEnergyInHF/F");
|
1048 |
|
|
electronTree->Branch("backJet_emEnergyInEB",&backJet_emEnergyInEB,"backJet_emEnergyInEB/F");
|
1049 |
|
|
electronTree->Branch("backJet_emEnergyInEE",&backJet_emEnergyInEE,"backJet_emEnergyInEE/F");
|
1050 |
|
|
electronTree->Branch("backJet_emEnergyInHF",&backJet_emEnergyInHF,"backJet_emEnergyInHF/F");
|
1051 |
|
|
electronTree->Branch("backJet_towersArea",&backJet_towersArea,"backJet_towersArea/F");
|
1052 |
|
|
electronTree->Branch("backJet_n90",&backJet_n90,"backJet_n90/F");
|
1053 |
|
|
electronTree->Branch("backJet_n60",&backJet_n60,"backJet_n60/F");
|
1054 |
|
|
|
1055 |
|
|
electronTree->Branch("backJet_NbTracks",&backJet_NbTracks,"backJet_NbTracks/I");
|
1056 |
|
|
|
1057 |
|
|
electronTree->Branch("backJet_match",&backJet_match,"backJet_match/I");
|
1058 |
|
|
electronTree->Branch("backJet_matchPt",&backJet_matchPt,"backJet_matchPt/F");
|
1059 |
|
|
electronTree->Branch("backJet_match_dR",&backJet_match_dR,"backJet_match_dR/F");
|
1060 |
|
|
|
1061 |
|
|
|
1062 |
|
|
|
1063 |
|
|
}
|
1064 |
vuko |
1.50 |
|
1065 |
|
|
electronTree->Branch("WZ_hltBitmask",&triggerBitmask,"WZ_hltBitmask/I");
|
1066 |
smorovic |
1.52 |
electronTree->Branch("QCD_hltBitmask",&triggerBitmaskQCD,"QCD_hltBitmask/I");
|
1067 |
smorovic |
1.8 |
}
|
1068 |
vuko |
1.1 |
|
1069 |
senka |
1.9 |
|
1070 |
senka |
1.28 |
//////////////////////////////////////////
|
1071 |
|
|
// MET & MET corrections
|
1072 |
|
|
// MET=MET-sum_p(muons)-sum_p(muons calos depositions)
|
1073 |
|
|
|
1074 |
|
|
reco::Particle::LorentzVector WZAnalyzer::computeMET(const edm::Event& iEvent, const edm::EventSetup& iSetup, Handle<reco::CandidateCollection> MuonCands) {
|
1075 |
senka |
1.9 |
|
1076 |
|
|
using namespace edm;
|
1077 |
|
|
using namespace reco;
|
1078 |
|
|
using namespace std;
|
1079 |
senka |
1.44 |
|
1080 |
beaucero |
1.45 |
double px_MET=0, py_MET=0, Ex_MET=0, Ey_MET=0;
|
1081 |
senka |
1.44 |
double px,py,pz,pt,Et,Ex,Ey;
|
1082 |
|
|
double px_muons=0;
|
1083 |
|
|
double py_muons=0;
|
1084 |
|
|
double Ex_muons=0;
|
1085 |
|
|
double Ey_muons=0;
|
1086 |
|
|
double Et_muons=0;
|
1087 |
|
|
double Et_ecal;
|
1088 |
|
|
double Et_hcal;
|
1089 |
|
|
double Et_ho;
|
1090 |
|
|
double Et_cal;
|
1091 |
|
|
double Ex_ecal;
|
1092 |
|
|
double Ex_hcal;
|
1093 |
|
|
double Ex_ho;
|
1094 |
|
|
double Ey_ecal;
|
1095 |
|
|
double Ey_hcal;
|
1096 |
|
|
double Ey_ho;
|
1097 |
|
|
double eta_cal;
|
1098 |
|
|
double phi_cal;
|
1099 |
|
|
double tg_theta_pola_ecal;
|
1100 |
|
|
double tg_theta_pola_hcal;
|
1101 |
|
|
double tg_theta_pola_ho;
|
1102 |
|
|
double tg_theta_ecal;
|
1103 |
|
|
double tg_theta_hcal;
|
1104 |
|
|
double tg_theta_ho;
|
1105 |
|
|
double E_ecal;
|
1106 |
|
|
double E_hcal;
|
1107 |
|
|
double E_ho;
|
1108 |
|
|
double me=0.0005;
|
1109 |
|
|
double sin_theta_ecal, sin_theta_hcal, sin_theta_ho, cos_theta_ecal,cos_theta_hcal,cos_theta_ho;
|
1110 |
|
|
double p_ecal, p_hcal,p_ho, pt_ecal,pt_hcal,pt_ho, px_ecal,px_hcal,px_ho, py_ecal,py_hcal,py_ho, pz_ecal,pz_hcal,pz_ho;
|
1111 |
|
|
double Ex_cal=0;
|
1112 |
|
|
double Ey_cal=0;
|
1113 |
|
|
double px_cal=0;
|
1114 |
|
|
double py_cal=0;
|
1115 |
|
|
double Ex_kon=0;
|
1116 |
|
|
double Ey_kon=0;
|
1117 |
|
|
|
1118 |
|
|
reco::Particle::LorentzVector Muon_p_4v(0,0,0,0); // sum of muons 4-vectors in (px,py,0,Et), since MET looks like that
|
1119 |
|
|
reco::Particle::LorentzVector Muon_p_cal_4v(0,0,0,0);
|
1120 |
senka |
1.9 |
|
1121 |
|
|
Handle<CaloMETCollection> mets;
|
1122 |
|
|
iEvent.getByLabel("met", mets);
|
1123 |
vuko |
1.25 |
// cout << "# METs=" << mets->size() << endl;
|
1124 |
senka |
1.44 |
|
1125 |
vuko |
1.25 |
if (mets->size() != 1) {
|
1126 |
senka |
1.44 |
cout << "ALARM: # METS is not 1: !" << endl;
|
1127 |
vuko |
1.25 |
return reco::Particle::LorentzVector(0.,0.,0.,0.);
|
1128 |
|
|
}
|
1129 |
senka |
1.44 |
|
1130 |
vuko |
1.14 |
for (CaloMETCollection::const_iterator met = mets->begin();
|
1131 |
|
|
met!= mets->end(); met++) {
|
1132 |
senka |
1.44 |
px_MET=met->px();
|
1133 |
|
|
py_MET=met->py();
|
1134 |
|
|
Ex_MET=met->et()*TMath::Cos(met->phi());
|
1135 |
|
|
Ey_MET=met->et()*TMath::Sin(met->phi());
|
1136 |
|
|
|
1137 |
vuko |
1.14 |
}
|
1138 |
senka |
1.44 |
|
1139 |
|
|
// sum of p of muons
|
1140 |
|
|
for (unsigned int i=0; i<MuonCands->size();i++){
|
1141 |
|
|
px=(*MuonCands)[i].px();
|
1142 |
|
|
py=(*MuonCands)[i].py();
|
1143 |
|
|
pz=(*MuonCands)[i].pz();
|
1144 |
|
|
pt=(*MuonCands)[i].pt();
|
1145 |
|
|
Et=(*MuonCands)[i].et();
|
1146 |
|
|
Ex=Et*TMath::Cos((*MuonCands)[i].phi());
|
1147 |
|
|
Ey=Et*TMath::Sin((*MuonCands)[i].phi());
|
1148 |
|
|
px_muons=px_muons+px;
|
1149 |
|
|
py_muons=py_muons+py;
|
1150 |
|
|
Ex_muons=Ex_muons+Ex;
|
1151 |
|
|
Ey_muons=Ey_muons+Ey;
|
1152 |
|
|
|
1153 |
|
|
}
|
1154 |
|
|
Et_muons=TMath::Sqrt(Ex_muons*Ex_muons+Ey_muons*Ey_muons);
|
1155 |
|
|
Muon_p_4v=reco::Particle::LorentzVector(px_muons,py_muons,0,Et_muons);
|
1156 |
|
|
|
1157 |
|
|
// sum of p of muons left in calorimeters
|
1158 |
|
|
for (unsigned int i=0; i<MuonCands->size();i++){
|
1159 |
|
|
cout<<"" << endl;
|
1160 |
|
|
const reco::Muon* muons=dynamic_cast<const reco::Muon *> (&(*MuonCands)[i]);
|
1161 |
|
|
Et_ecal=muons->getCalEnergy().emS9;
|
1162 |
|
|
Et_hcal=muons->getCalEnergy().hadS9;
|
1163 |
|
|
Et_ho=muons->getCalEnergy().hoS9;
|
1164 |
|
|
eta_cal=muons->eta();
|
1165 |
|
|
phi_cal=muons->phi();
|
1166 |
|
|
tg_theta_pola_ecal=TMath::Exp(-eta_cal);
|
1167 |
|
|
tg_theta_pola_hcal=TMath::Exp(-eta_cal);
|
1168 |
|
|
tg_theta_pola_ho=TMath::Exp(-eta_cal);
|
1169 |
|
|
tg_theta_ecal=2*tg_theta_pola_ecal/(1-tg_theta_pola_ecal*tg_theta_pola_ecal);
|
1170 |
|
|
tg_theta_hcal=2*tg_theta_pola_hcal/(1-tg_theta_pola_hcal*tg_theta_pola_hcal);
|
1171 |
|
|
tg_theta_ho=2*tg_theta_pola_ho/(1-tg_theta_pola_ho*tg_theta_pola_ho);
|
1172 |
|
|
E_ecal=TMath::Abs(Et_ecal*TMath::Sqrt(1+tg_theta_ecal*tg_theta_ecal)/tg_theta_ecal);
|
1173 |
|
|
E_hcal=TMath::Abs(Et_hcal*TMath::Sqrt(1+tg_theta_hcal*tg_theta_hcal)/tg_theta_hcal);
|
1174 |
|
|
E_ho=TMath::Abs(Et_ho*TMath::Sqrt(1+tg_theta_ho*tg_theta_ho)/tg_theta_ho);
|
1175 |
|
|
Ex_ecal=Et_ecal*TMath::Cos(phi_cal);
|
1176 |
|
|
Ex_hcal=Et_hcal*TMath::Cos(phi_cal);
|
1177 |
|
|
Ex_ho=Et_ho*TMath::Cos(phi_cal);
|
1178 |
|
|
Ey_ecal=Et_ecal*TMath::Sin(phi_cal);
|
1179 |
|
|
Ey_hcal=Et_hcal*TMath::Sin(phi_cal);
|
1180 |
|
|
Ey_ho=Et_ho*TMath::Sin(phi_cal);
|
1181 |
|
|
sin_theta_ecal=tg_theta_ecal/TMath::Sqrt(1+tg_theta_ecal*tg_theta_ecal);
|
1182 |
|
|
sin_theta_hcal=tg_theta_hcal/TMath::Sqrt(1+tg_theta_hcal*tg_theta_hcal);
|
1183 |
|
|
sin_theta_ho=tg_theta_ho/TMath::Sqrt(1+tg_theta_ho*tg_theta_ho);
|
1184 |
|
|
cos_theta_ecal=TMath::Sqrt(1-sin_theta_ecal*sin_theta_ecal);
|
1185 |
|
|
cos_theta_hcal=TMath::Sqrt(1-sin_theta_hcal*sin_theta_hcal);
|
1186 |
|
|
cos_theta_ho=TMath::Sqrt(1-sin_theta_ho*sin_theta_ho);
|
1187 |
|
|
if (E_ecal<me){
|
1188 |
|
|
p_ecal=0;
|
1189 |
|
|
}
|
1190 |
|
|
else {
|
1191 |
|
|
p_ecal=TMath::Sqrt(E_ecal*E_ecal-me*me);
|
1192 |
|
|
}
|
1193 |
|
|
if (E_hcal<me){
|
1194 |
|
|
p_hcal=0;
|
1195 |
|
|
}
|
1196 |
|
|
else {
|
1197 |
|
|
p_hcal=TMath::Sqrt(E_hcal*E_hcal-me*me);
|
1198 |
|
|
}
|
1199 |
|
|
if (E_ho<me){
|
1200 |
|
|
p_ho=0;
|
1201 |
|
|
}
|
1202 |
|
|
else {
|
1203 |
|
|
p_ho=TMath::Sqrt(E_ho*E_ho-me*me);
|
1204 |
|
|
}
|
1205 |
senka |
1.28 |
|
1206 |
senka |
1.44 |
pz_ecal=p_ecal*cos_theta_ecal;
|
1207 |
|
|
pz_hcal=p_hcal*cos_theta_hcal;
|
1208 |
|
|
pz_ho=p_ho*cos_theta_ho;
|
1209 |
|
|
pt_ecal=TMath::Abs(p_ecal*sin_theta_ecal);
|
1210 |
senka |
1.33 |
|
1211 |
senka |
1.44 |
pt_hcal=TMath::Abs(p_hcal*sin_theta_hcal);
|
1212 |
|
|
|
1213 |
|
|
pt_ho=TMath::Abs(p_ho*sin_theta_ho);
|
1214 |
|
|
|
1215 |
|
|
px_ecal=pt_ecal*TMath::Cos(phi_cal);
|
1216 |
|
|
px_hcal=pt_hcal*TMath::Cos(phi_cal);
|
1217 |
|
|
px_ho=pt_ho*TMath::Cos(phi_cal);
|
1218 |
|
|
py_ecal=pt_ecal*TMath::Sin(phi_cal);
|
1219 |
|
|
py_hcal=pt_hcal*TMath::Sin(phi_cal);
|
1220 |
|
|
py_ho=pt_ho*TMath::Sin(phi_cal);
|
1221 |
senka |
1.28 |
|
1222 |
senka |
1.44 |
|
1223 |
|
|
Ex_cal=Ex_cal+Ex_ecal+Ex_hcal+Ex_ho;
|
1224 |
|
|
Ey_cal=Ey_cal+Ey_ecal+Ey_hcal+Ey_ho;
|
1225 |
|
|
|
1226 |
|
|
px_cal=px_cal+px_ecal+px_hcal+px_ho;
|
1227 |
|
|
py_cal=py_cal+py_ecal+py_hcal+py_ho;
|
1228 |
|
|
|
1229 |
senka |
1.28 |
|
1230 |
senka |
1.44 |
}
|
1231 |
|
|
Et_cal=TMath::Sqrt(Ex_cal*Ex_cal+Ey_cal*Ey_cal);
|
1232 |
|
|
Muon_p_cal_4v=reco::Particle::LorentzVector(px_cal,py_cal,0, Et_cal);
|
1233 |
senka |
1.33 |
|
1234 |
senka |
1.44 |
Ex_kon=Ex_MET-Ex_muons+Ex_cal;
|
1235 |
|
|
Ey_kon=Ey_MET-Ey_muons+Ey_cal;
|
1236 |
senka |
1.28 |
|
1237 |
senka |
1.44 |
reco::Particle::LorentzVector MET= reco::Particle::LorentzVector(px_MET-px_muons+px_cal,py_MET-py_muons+py_cal,0,TMath::Sqrt(Ex_kon*Ex_kon+Ey_kon*Ey_kon)); // substract p from muons and p of calo muon deposit from MET
|
1238 |
senka |
1.28 |
|
1239 |
|
|
return MET;
|
1240 |
senka |
1.9 |
|
1241 |
|
|
}
|
1242 |
|
|
|
1243 |
kkaadze |
1.55 |
//MET Corrections from difference between corrected and uncorretced SC
|
1244 |
|
|
reco::Particle::LorentzVector WZAnalyzer::correctMETforSCCorrection(reco::Particle::LorentzVector MET_p_4v, Handle<reco::CandidateCollection> ElectronCands) {
|
1245 |
|
|
|
1246 |
|
|
double SCRawEnergy = 0;
|
1247 |
|
|
double SCEnergy = 0;
|
1248 |
|
|
double deltaE = 0;
|
1249 |
|
|
double deltaET = 0;
|
1250 |
|
|
double deltaEx = 0;
|
1251 |
|
|
double deltaEy = 0;
|
1252 |
|
|
|
1253 |
|
|
reco::Particle::LorentzVector SCCorr_p_4v(0,0,0,0); // sum of correction fraction of ET in (px,py,0,Et)
|
1254 |
|
|
|
1255 |
|
|
//Loop over electron candidates and obtain the difference between uncorr and corr SC
|
1256 |
|
|
for (unsigned int i =0; i<ElectronCands->size(); ++i) {
|
1257 |
|
|
const reco::PixelMatchGsfElectron * electron = 0;
|
1258 |
|
|
if ( (*ElectronCands)[i].hasMasterClone() ) {
|
1259 |
|
|
reco::CandidateBaseRef master = (*ElectronCands)[i].masterClone();
|
1260 |
|
|
electron = dynamic_cast<const reco::PixelMatchGsfElectron *>(&(*master));
|
1261 |
|
|
} else {
|
1262 |
|
|
electron = dynamic_cast<const reco::PixelMatchGsfElectron *>(&(*ElectronCands)[i]);
|
1263 |
|
|
}
|
1264 |
|
|
const reco::SuperCluster& ElSC = *(electron->superCluster());
|
1265 |
|
|
SCRawEnergy = ElSC.rawEnergy();
|
1266 |
|
|
SCEnergy = ElSC.energy();
|
1267 |
|
|
//b.c. both uncrected and corrected SC clusters are oriented the same way, difference between vectors is just magnitudinal.
|
1268 |
|
|
deltaE = SCEnergy - SCRawEnergy;
|
1269 |
|
|
deltaET = deltaE/cosh(ElSC.eta());
|
1270 |
|
|
deltaEx += deltaET*cos(ElSC.phi());
|
1271 |
|
|
deltaEy += deltaET*sin(ElSC.phi());
|
1272 |
|
|
}
|
1273 |
|
|
|
1274 |
|
|
deltaET = 0;
|
1275 |
|
|
deltaET = sqrt(deltaEx*deltaEx + deltaEy*deltaEy);
|
1276 |
|
|
SCCorr_p_4v = reco::Particle::LorentzVector(deltaEx, deltaEy, 0, deltaET);
|
1277 |
|
|
// return SCCorr_p_4v;
|
1278 |
|
|
return (MET_p_4v - SCCorr_p_4v);
|
1279 |
|
|
}
|
1280 |
|
|
|
1281 |
|
|
|
1282 |
|
|
//MET Corrections from difference between el energy and rawenergy of SC
|
1283 |
|
|
reco::Particle::LorentzVector WZAnalyzer::correctMETforElCorrection(reco::Particle::LorentzVector MET_p_4v, Handle<reco::CandidateCollection> ElectronCands) {
|
1284 |
|
|
|
1285 |
|
|
double px = 0;
|
1286 |
|
|
double py = 0;
|
1287 |
|
|
double pz = 0;
|
1288 |
|
|
double Ex = 0;
|
1289 |
|
|
double Ey = 0;
|
1290 |
|
|
double Et = 0;
|
1291 |
|
|
double SCRawEnergy = 0;
|
1292 |
|
|
double SCPt = 0;
|
1293 |
|
|
double SCEt = 0;
|
1294 |
|
|
double SCpx = 0;
|
1295 |
|
|
double SCpy = 0;
|
1296 |
|
|
double SCEx = 0;
|
1297 |
|
|
double SCEy = 0;
|
1298 |
|
|
|
1299 |
|
|
const reco::PixelMatchGsfElectron * electron = 0;
|
1300 |
|
|
|
1301 |
|
|
reco::Particle::LorentzVector El_p_4v(0,0,0,0); // in (px,py,0,Et)
|
1302 |
|
|
reco::Particle::LorentzVector SC_p_4v(0,0,0,0);
|
1303 |
|
|
|
1304 |
|
|
//Loop over electron candidates and obtain the difference between uncorr and corr SC
|
1305 |
|
|
for (unsigned int i =0; i<ElectronCands->size(); ++i) {
|
1306 |
|
|
|
1307 |
|
|
px += (*ElectronCands)[i].px();
|
1308 |
|
|
py += (*ElectronCands)[i].py();
|
1309 |
|
|
pz += (*ElectronCands)[i].pz();
|
1310 |
|
|
Ex += (*ElectronCands)[i].et()*cos((*ElectronCands)[i].phi());
|
1311 |
|
|
Ey += (*ElectronCands)[i].et()*sin((*ElectronCands)[i].phi());
|
1312 |
|
|
|
1313 |
|
|
if ( (*ElectronCands)[i].hasMasterClone() ) {
|
1314 |
|
|
reco::CandidateBaseRef master = (*ElectronCands)[i].masterClone();
|
1315 |
|
|
electron = dynamic_cast<const reco::PixelMatchGsfElectron *>(&(*master));
|
1316 |
|
|
} else {
|
1317 |
|
|
electron = dynamic_cast<const reco::PixelMatchGsfElectron *>(&(*ElectronCands)[i]);
|
1318 |
|
|
}
|
1319 |
|
|
const reco::SuperCluster& ElSC = *(electron->superCluster());
|
1320 |
|
|
SCRawEnergy = ElSC.rawEnergy();
|
1321 |
|
|
SCPt = SCRawEnergy/cosh(ElSC.eta());
|
1322 |
|
|
SCEt = SCRawEnergy/cosh(ElSC.eta());
|
1323 |
|
|
SCpx += SCPt*cos(ElSC.phi());
|
1324 |
|
|
SCpy += SCPt*sin(ElSC.phi());
|
1325 |
|
|
SCEx += SCEt*cos(ElSC.phi());
|
1326 |
|
|
SCEy += SCEt*sin(ElSC.phi());
|
1327 |
|
|
}
|
1328 |
|
|
|
1329 |
|
|
Et = sqrt(Ex*Ex + Ey*Ey);
|
1330 |
|
|
El_p_4v = reco::Particle::LorentzVector(px,py,0,Et);
|
1331 |
|
|
|
1332 |
|
|
SCEt = sqrt(SCEx*SCEx + SCEy * SCEy);
|
1333 |
|
|
SC_p_4v = reco::Particle::LorentzVector(SCpx,SCpy,0,SCEt);
|
1334 |
|
|
|
1335 |
|
|
reco::Particle::LorentzVector ElCorr_p_4v = El_p_4v - SC_p_4v;
|
1336 |
|
|
return (MET_p_4v - ElCorr_p_4v);
|
1337 |
|
|
}
|
1338 |
|
|
|
1339 |
|
|
|
1340 |
|
|
|
1341 |
senka |
1.12 |
////////////////////////
|
1342 |
|
|
// matching
|
1343 |
|
|
//
|
1344 |
|
|
|
1345 |
|
|
class MatchingInfo {
|
1346 |
|
|
public:
|
1347 |
|
|
|
1348 |
|
|
MatchingInfo(float dr, int gen, int reco) : deltaR(dr), genMuon(gen),recoMuon(reco) {}
|
1349 |
|
|
|
1350 |
|
|
bool operator<(const MatchingInfo m) { return deltaR < m.deltaR;}
|
1351 |
|
|
|
1352 |
|
|
float deltaR;
|
1353 |
|
|
int genMuon;
|
1354 |
|
|
int recoMuon;
|
1355 |
|
|
|
1356 |
|
|
};
|
1357 |
|
|
|
1358 |
|
|
|
1359 |
|
|
bool betterMatch(MatchingInfo m1, MatchingInfo m2)
|
1360 |
|
|
{ return m1.deltaR < m2.deltaR;}
|
1361 |
|
|
|
1362 |
|
|
|
1363 |
|
|
// method that gives the vector<MatchingInfo> matching_Infos containing (dR,i,j); i=genParticle index, j=ParticleCollection index:
|
1364 |
|
|
|
1365 |
|
|
void WZAnalyzer::matching(const edm::Event& iEvent, Handle<reco::CandidateCollection> cands, int pdgid){
|
1366 |
|
|
|
1367 |
|
|
using namespace edm;
|
1368 |
|
|
using namespace reco;
|
1369 |
|
|
using namespace std;
|
1370 |
|
|
|
1371 |
|
|
//-------------------------
|
1372 |
|
|
Handle<CandidateCollection> mccands;
|
1373 |
|
|
iEvent.getByLabel( theMCTruthCollection,mccands );
|
1374 |
|
|
|
1375 |
|
|
vector <GenParticleCandidate*> genparticles;
|
1376 |
|
|
|
1377 |
|
|
for(CandidateCollection::const_iterator p = mccands->begin();
|
1378 |
|
|
p != mccands->end(); p++) {
|
1379 |
|
|
|
1380 |
|
|
// reco::Candidate* p_tmp = &(*p);
|
1381 |
|
|
reco::GenParticleCandidate* ptr = (reco::GenParticleCandidate*) &(*p);
|
1382 |
|
|
|
1383 |
|
|
if ( (ptr)->status() == 1
|
1384 |
|
|
/*&& (ptr)->momentum().perp() > 2.*/ ) { // stable particles with pt>2 only
|
1385 |
|
|
if ( abs((ptr)->pdgId()) == pdgid ) {
|
1386 |
|
|
genparticles.push_back((ptr));
|
1387 |
|
|
//cout << "electron MCT\n";
|
1388 |
|
|
}
|
1389 |
|
|
}
|
1390 |
|
|
}
|
1391 |
|
|
|
1392 |
|
|
|
1393 |
|
|
int n1=0;
|
1394 |
|
|
vector<MatchingInfo> matching_Infos;
|
1395 |
|
|
for ( unsigned int i=0; i<genparticles.size(); i++ ) // po svim MC muonima
|
1396 |
|
|
{
|
1397 |
|
|
|
1398 |
|
|
for (unsigned int j = 0; j < cands->size(); j++)// po svim reco muonima
|
1399 |
|
|
{
|
1400 |
|
|
|
1401 |
|
|
double d_eta2=(*cands)[j].eta()-(genparticles)[i]->eta();
|
1402 |
smorovic |
1.57 |
//double d_phi=fabs((*cands)[j].phi()-(genparticles)[i]->phi());
|
1403 |
|
|
double d_phi= kinem::delta_phi((*cands)[j].phi(),(genparticles)[i]->phi()) ;
|
1404 |
senka |
1.12 |
double dR_byhand= sqrt(d_eta2*d_eta2+d_phi*d_phi);
|
1405 |
|
|
double dR=dR_byhand;
|
1406 |
|
|
|
1407 |
|
|
if (dR<0.15){
|
1408 |
|
|
n1++;
|
1409 |
|
|
matching_Infos.push_back(MatchingInfo(dR,i,j));
|
1410 |
|
|
}
|
1411 |
|
|
|
1412 |
|
|
}
|
1413 |
|
|
}
|
1414 |
senka |
1.24 |
|
1415 |
senka |
1.12 |
sort(matching_Infos.begin(),matching_Infos.end(),betterMatch); // sorting (dR,i,j)
|
1416 |
senka |
1.24 |
|
1417 |
|
|
if (genparticles.size()!=0 && cands->size()!=0){
|
1418 |
|
|
// Now exclude combinations using same gen or rec muons
|
1419 |
|
|
for (std::vector<MatchingInfo>::iterator it=matching_Infos.begin();
|
1420 |
|
|
it != matching_Infos.end(); it++) {
|
1421 |
|
|
for (std::vector<MatchingInfo>::iterator it2=matching_Infos.begin();
|
1422 |
|
|
it2!=it; it2++) {
|
1423 |
|
|
if ( (it->genMuon == it2->genMuon) || (it->recoMuon == it2->recoMuon) ) {
|
1424 |
|
|
matching_Infos.erase(it);
|
1425 |
|
|
it=matching_Infos.begin();
|
1426 |
|
|
break;
|
1427 |
|
|
}
|
1428 |
|
|
}
|
1429 |
|
|
}
|
1430 |
|
|
}
|
1431 |
|
|
|
1432 |
vuko |
1.14 |
// Now put result in vector of pairs
|
1433 |
|
|
|
1434 |
|
|
leptonMatching[pdgid].clear();
|
1435 |
|
|
|
1436 |
|
|
for (vector<MatchingInfo>::iterator match=matching_Infos.begin();
|
1437 |
senka |
1.16 |
match !=matching_Infos.end(); match++) { // po tablici dr,i,j
|
1438 |
vuko |
1.14 |
|
1439 |
|
|
pair<const GenParticleCandidate*, const reco::Candidate *> pair;
|
1440 |
senka |
1.16 |
// vector<pair,float > matchedParticles;
|
1441 |
vuko |
1.14 |
pair.first = genparticles[match->genMuon];
|
1442 |
|
|
pair.second = & (*cands)[match->recoMuon];
|
1443 |
senka |
1.16 |
|
1444 |
|
|
matchedParticles cestice(genparticles[match->genMuon] ,& (*cands)[match->recoMuon] , match->deltaR);
|
1445 |
|
|
|
1446 |
|
|
leptonMatching[pdgid].push_back(cestice);
|
1447 |
senka |
1.24 |
|
1448 |
vuko |
1.14 |
}
|
1449 |
senka |
1.24 |
|
1450 |
senka |
1.12 |
}
|
1451 |
|
|
|
1452 |
senka |
1.9 |
|
1453 |
senka |
1.13 |
// get mother of particle
|
1454 |
|
|
// returns mother = 1 if mother is Z boson
|
1455 |
|
|
// returns mother = 2 if mother is W boson
|
1456 |
|
|
// returns mother = 4 if mother is b
|
1457 |
|
|
// returns mother = 0 else
|
1458 |
|
|
|
1459 |
vuko |
1.14 |
WZAnalyzer::LeptonOrigin WZAnalyzer::getMother(const reco::Candidate* genParticle){
|
1460 |
|
|
|
1461 |
|
|
int pdg_id=genParticle->pdgId();
|
1462 |
vuko |
1.25 |
// cout << "particle id : " << pdg_id << endl;
|
1463 |
senka |
1.13 |
|
1464 |
|
|
while (genParticle = genParticle->mother() ) { //izvrsava se sve dok ne dodje do nule tj. dok ne trazi majku od protona
|
1465 |
vuko |
1.25 |
// cout << "Going up: ";
|
1466 |
|
|
// cout << "Mother id : " << genParticle->pdgId() << endl;
|
1467 |
senka |
1.24 |
if (abs(genParticle->pdgId())!=abs(pdg_id)) {
|
1468 |
vuko |
1.25 |
// cout<< " good mother " <<endl;
|
1469 |
senka |
1.13 |
if (abs(genParticle->pdgId())==23){ // mother is Z
|
1470 |
vuko |
1.14 |
return zboson;
|
1471 |
senka |
1.13 |
}
|
1472 |
|
|
if (abs(genParticle->pdgId())==24) { // mother is W
|
1473 |
vuko |
1.14 |
return wboson;
|
1474 |
senka |
1.13 |
}
|
1475 |
|
|
// if (abs(genParticle->pdgId())==23 || abs(genParticle->pdgId())==24) { // mother is W or Z
|
1476 |
|
|
// WZ_matched=1;
|
1477 |
|
|
// mother=3;
|
1478 |
|
|
// }
|
1479 |
|
|
if ((((abs(genParticle->pdgId()))/100)%10 ==5)||(((abs(genParticle->pdgId()))/1000)%10 ==5 )) { // mother is b
|
1480 |
vuko |
1.14 |
return bdecay;
|
1481 |
senka |
1.13 |
}
|
1482 |
vuko |
1.14 |
if ((((abs(genParticle->pdgId()))/100)%10 ==4)||(((abs(genParticle->pdgId()))/1000)%10 ==4 )) { // mother is c
|
1483 |
|
|
return cdecay;
|
1484 |
|
|
}
|
1485 |
|
|
return other;
|
1486 |
senka |
1.13 |
}
|
1487 |
vuko |
1.20 |
}
|
1488 |
|
|
|
1489 |
|
|
return other;
|
1490 |
senka |
1.13 |
}
|
1491 |
|
|
|
1492 |
senka |
1.15 |
const reco::Candidate * WZAnalyzer::MatchedGenParticle(const reco::Candidate * daughter){
|
1493 |
|
|
::OverlapChecker overlap;
|
1494 |
|
|
matched_genParticle=0;
|
1495 |
senka |
1.16 |
|
1496 |
|
|
for (map< int,
|
1497 |
|
|
std::vector< matchedParticles > > ::iterator iter = leptonMatching.begin();
|
1498 |
|
|
iter!=leptonMatching.end(); iter++) // entire map
|
1499 |
|
|
{
|
1500 |
kkaadze |
1.61 |
cout << " loop over map " << endl;
|
1501 |
|
|
cout << iter->second.size() << endl;
|
1502 |
vuko |
1.20 |
for (unsigned int j=0; j<iter->second.size(); j++){ // entire vector<class<>>
|
1503 |
kkaadze |
1.61 |
cout << " nesto " << endl;
|
1504 |
senka |
1.16 |
const reco::Candidate * nesto=iter->second[j].pair.second;
|
1505 |
|
|
if (overlap(*nesto,*daughter)){
|
1506 |
|
|
matched_genParticle=iter->second[j].pair.first;
|
1507 |
|
|
}
|
1508 |
|
|
}
|
1509 |
|
|
}
|
1510 |
|
|
return matched_genParticle;
|
1511 |
|
|
}
|
1512 |
|
|
|
1513 |
|
|
|
1514 |
|
|
float WZAnalyzer::dR(const reco::Candidate * daughter){
|
1515 |
vuko |
1.18 |
|
1516 |
senka |
1.16 |
::OverlapChecker overlap;
|
1517 |
vuko |
1.18 |
|
1518 |
senka |
1.19 |
float delta_r = -10;
|
1519 |
senka |
1.15 |
for (map< int,
|
1520 |
senka |
1.16 |
std::vector< matchedParticles > > ::iterator iter = leptonMatching.begin();
|
1521 |
senka |
1.15 |
iter!=leptonMatching.end(); iter++) // entire map
|
1522 |
|
|
{
|
1523 |
vuko |
1.20 |
for (unsigned int j=0; j<iter->second.size(); j++){ // entire vector<class<>>
|
1524 |
senka |
1.16 |
const reco::Candidate * nesto=iter->second[j].pair.second;
|
1525 |
senka |
1.15 |
if (overlap(*nesto,*daughter)){
|
1526 |
senka |
1.16 |
delta_r=iter->second[j].delta_R;
|
1527 |
senka |
1.15 |
}
|
1528 |
|
|
}
|
1529 |
|
|
}
|
1530 |
senka |
1.16 |
return delta_r;
|
1531 |
senka |
1.15 |
}
|
1532 |
|
|
|
1533 |
vuko |
1.11 |
|
1534 |
senka |
1.16 |
|
1535 |
vuko |
1.10 |
void WZAnalyzer::collectMCsummary(Handle <reco::CandidateCollection> mccands) {
|
1536 |
senka |
1.12 |
|
1537 |
vuko |
1.11 |
using namespace reco;
|
1538 |
|
|
|
1539 |
smorovic |
1.8 |
//collections
|
1540 |
senka |
1.24 |
|
1541 |
smorovic |
1.8 |
MCleptZ1_pdgid = -1;
|
1542 |
|
|
MCleptZ2_pdgid = -1;
|
1543 |
|
|
MCleptW_pdgid = -1;
|
1544 |
|
|
|
1545 |
|
|
MCleptZ1_pt = -1;
|
1546 |
|
|
MCleptZ2_pt = -1;
|
1547 |
|
|
MCleptW_pt = -1;
|
1548 |
|
|
|
1549 |
|
|
MCleptZ1_eta = -1;
|
1550 |
|
|
MCleptZ2_eta = -1;
|
1551 |
|
|
MCleptW_eta = -1;
|
1552 |
|
|
|
1553 |
|
|
MCleptZ1_phi = -1;
|
1554 |
|
|
MCleptZ2_phi = -1;
|
1555 |
|
|
MCleptW_phi = -1;
|
1556 |
senka |
1.12 |
|
1557 |
smorovic |
1.8 |
vector<reco::GenParticleCandidate*> Tau;
|
1558 |
|
|
vector<reco::GenParticleCandidate*> StableMuons;
|
1559 |
|
|
vector<reco::GenParticleCandidate*> StableElectrons;
|
1560 |
senka |
1.24 |
|
1561 |
smorovic |
1.32 |
|
1562 |
|
|
|
1563 |
vuko |
1.11 |
for(CandidateCollection::const_iterator p = mccands->begin();
|
1564 |
|
|
p != mccands->end(); p++) {
|
1565 |
vuko |
1.1 |
|
1566 |
vuko |
1.11 |
// reco::Candidate* p_tmp = &(*p);
|
1567 |
|
|
reco::GenParticleCandidate* ptr = (reco::GenParticleCandidate*) &(*p);
|
1568 |
smorovic |
1.8 |
|
1569 |
|
|
if ( (ptr)->status() == 1
|
1570 |
|
|
/*&& (ptr)->momentum().perp() > 2.*/ ) { // stable particles with pt>2 only
|
1571 |
|
|
if ( abs((ptr)->pdgId()) == 11 ) {
|
1572 |
senka |
1.12 |
|
1573 |
smorovic |
1.8 |
StableElectrons.push_back((ptr));
|
1574 |
|
|
//cout << "electron MCT\n";
|
1575 |
|
|
}
|
1576 |
|
|
else if ( abs((ptr)->pdgId()) == 13 ) {
|
1577 |
senka |
1.12 |
|
1578 |
smorovic |
1.8 |
StableMuons.push_back((ptr)) ;
|
1579 |
|
|
//cout << "muon MCT\n";
|
1580 |
|
|
}
|
1581 |
|
|
}
|
1582 |
|
|
else if ((ptr)->status() == 2) {
|
1583 |
|
|
if ( abs((ptr)->pdgId()) == 15 ) {//tau
|
1584 |
|
|
Tau.push_back((ptr));
|
1585 |
|
|
}
|
1586 |
|
|
}
|
1587 |
|
|
}
|
1588 |
senka |
1.12 |
|
1589 |
vuko |
1.25 |
// std::cout << "# Electrons : " << StableElectrons.size()
|
1590 |
|
|
// << "# Muons : " << StableMuons.size() << std::endl
|
1591 |
|
|
// << "# Tau : " << Tau.size() << std::endl;
|
1592 |
senka |
1.12 |
|
1593 |
smorovic |
1.8 |
|
1594 |
|
|
vector<reco::GenParticleCandidate*> * StableLeptons[3] = {&StableElectrons, &StableMuons, &Tau};
|
1595 |
|
|
|
1596 |
smorovic |
1.32 |
vector<reco::GenParticleCandidate*> TauChildLeptons;
|
1597 |
|
|
|
1598 |
|
|
|
1599 |
|
|
//erase electrons and muons from tau from GenparticleCandidate Vector and put to Tau Vector
|
1600 |
|
|
for (int i=1; i>=0; i--) {
|
1601 |
|
|
for ( vector<reco::GenParticleCandidate*>::iterator lepton = StableLeptons[i]->begin();
|
1602 |
|
|
lepton != StableLeptons[i]->end();lepton++) {
|
1603 |
|
|
|
1604 |
|
|
reco::GenParticleCandidate* mcParticleRef = *lepton;
|
1605 |
|
|
|
1606 |
|
|
int parentItr=0;
|
1607 |
|
|
while ( mcParticleRef->mother()!=0 && parentItr<2) {
|
1608 |
|
|
|
1609 |
|
|
parentItr++;
|
1610 |
|
|
|
1611 |
|
|
mcParticleRef = (reco::GenParticleCandidate*) mcParticleRef->mother();
|
1612 |
|
|
if (mcParticleRef==0) break;
|
1613 |
|
|
|
1614 |
|
|
//if tau
|
1615 |
|
|
if (abs((mcParticleRef)->pdgId())==15 ) {
|
1616 |
|
|
//put into collection
|
1617 |
|
|
TauChildLeptons.push_back(*lepton);
|
1618 |
|
|
StableLeptons[i]->erase(lepton);
|
1619 |
|
|
lepton--;
|
1620 |
|
|
break;
|
1621 |
|
|
}
|
1622 |
|
|
}
|
1623 |
|
|
}
|
1624 |
|
|
}
|
1625 |
|
|
|
1626 |
|
|
|
1627 |
smorovic |
1.8 |
bool firstZlept = true;
|
1628 |
vuko |
1.51 |
// int MC_tauDecayTypeZ1 = 0;
|
1629 |
|
|
// int MC_tauDecayTypeZ2 = 0;
|
1630 |
|
|
// int MC_tauDecayTypeW = 0;
|
1631 |
|
|
MC_tauDecayTypeZ1 = 0;
|
1632 |
|
|
MC_tauDecayTypeZ2 = 0;
|
1633 |
|
|
MC_tauDecayTypeW = 0;
|
1634 |
smorovic |
1.32 |
|
1635 |
|
|
|
1636 |
smorovic |
1.8 |
for (int i=2; i>=0; i--) {
|
1637 |
|
|
while (StableLeptons[i]->size() > 0) {
|
1638 |
|
|
float maxPt = 0;
|
1639 |
|
|
vector<reco::GenParticleCandidate*>::iterator index = StableLeptons[i]->end();
|
1640 |
|
|
|
1641 |
|
|
for ( vector<reco::GenParticleCandidate*>::iterator lepton = StableLeptons[i]->begin();
|
1642 |
|
|
lepton != StableLeptons[i]->end(); lepton++ ) {
|
1643 |
smorovic |
1.32 |
|
1644 |
smorovic |
1.8 |
if ((*lepton)->pt() > maxPt) {
|
1645 |
|
|
maxPt = (*lepton)->pt();
|
1646 |
|
|
index = lepton;
|
1647 |
|
|
}
|
1648 |
|
|
}
|
1649 |
|
|
bool Zchild = false;
|
1650 |
|
|
bool Wchild = false;
|
1651 |
smorovic |
1.32 |
bool isTau = false;
|
1652 |
|
|
|
1653 |
|
|
|
1654 |
smorovic |
1.8 |
reco::GenParticleCandidate* mcParticleRef = *index;
|
1655 |
|
|
|
1656 |
smorovic |
1.32 |
if (abs((*index)->pdgId()) == 15) isTau = true;
|
1657 |
|
|
|
1658 |
smorovic |
1.8 |
//find W/Z mother
|
1659 |
smorovic |
1.32 |
int parentItr=0;
|
1660 |
|
|
while ( mcParticleRef->mother()!=0 && parentItr<2) {
|
1661 |
|
|
|
1662 |
smorovic |
1.8 |
if (parentItr>=2) break;
|
1663 |
|
|
parentItr++;
|
1664 |
|
|
mcParticleRef = (reco::GenParticleCandidate*) mcParticleRef->mother();
|
1665 |
smorovic |
1.32 |
if (mcParticleRef==0) break;
|
1666 |
smorovic |
1.8 |
|
1667 |
|
|
if (abs((mcParticleRef)->pdgId())==23 ) {
|
1668 |
|
|
Zchild=true;
|
1669 |
|
|
break;
|
1670 |
|
|
}
|
1671 |
|
|
if (abs((mcParticleRef)->pdgId())==24 ) {
|
1672 |
|
|
Wchild=true;
|
1673 |
|
|
break;
|
1674 |
|
|
}
|
1675 |
|
|
}
|
1676 |
|
|
|
1677 |
smorovic |
1.32 |
|
1678 |
smorovic |
1.8 |
if (maxPt >0) {
|
1679 |
smorovic |
1.32 |
int * MCtauDecayTypePtr = 0;
|
1680 |
|
|
|
1681 |
smorovic |
1.8 |
if (Wchild) {
|
1682 |
|
|
MCleptW_pdgid=(*index)->pdgId();
|
1683 |
|
|
MCleptW_pt=(float)(*index)->pt();
|
1684 |
|
|
MCleptW_eta=(float)(*index)->eta();
|
1685 |
|
|
MCleptW_phi=(float)(*index)->phi();
|
1686 |
smorovic |
1.32 |
if (isTau) {
|
1687 |
|
|
MCtauDecayTypePtr = &MC_tauDecayTypeW;
|
1688 |
|
|
MC_tauDecayTypeW =3;//default to hadronic decay
|
1689 |
|
|
}
|
1690 |
|
|
|
1691 |
smorovic |
1.8 |
}
|
1692 |
|
|
if (Zchild) {
|
1693 |
|
|
if (firstZlept) {
|
1694 |
|
|
firstZlept=false;
|
1695 |
|
|
MCleptZ1_pdgid=(*index)->pdgId();
|
1696 |
|
|
MCleptZ1_pt=(float)(*index)->pt();
|
1697 |
|
|
MCleptZ1_eta=(float)(*index)->eta();
|
1698 |
|
|
MCleptZ1_phi=(float)(*index)->phi();
|
1699 |
smorovic |
1.32 |
if (isTau) {
|
1700 |
|
|
MCtauDecayTypePtr = &MC_tauDecayTypeZ1;
|
1701 |
|
|
MC_tauDecayTypeZ1 =3;
|
1702 |
|
|
}
|
1703 |
|
|
|
1704 |
smorovic |
1.8 |
}
|
1705 |
|
|
else {
|
1706 |
|
|
MCleptZ2_pdgid=(*index)->pdgId();
|
1707 |
|
|
MCleptZ2_pt=(float)(*index)->pt();
|
1708 |
|
|
MCleptZ2_eta=(float)(*index)->eta();
|
1709 |
|
|
MCleptZ2_phi=(float)(*index)->phi();
|
1710 |
smorovic |
1.32 |
if (isTau) {
|
1711 |
|
|
MCtauDecayTypePtr = &MC_tauDecayTypeZ2;
|
1712 |
|
|
MC_tauDecayTypeZ2 =3;
|
1713 |
|
|
}
|
1714 |
|
|
|
1715 |
|
|
}
|
1716 |
|
|
}
|
1717 |
|
|
//check type of tau decay
|
1718 |
|
|
if (MCtauDecayTypePtr) {
|
1719 |
|
|
for( vector<reco::GenParticleCandidate*>::iterator p = TauChildLeptons.begin();p != TauChildLeptons.end(); p++) {
|
1720 |
|
|
int pitr = 0;
|
1721 |
|
|
reco::GenParticleCandidate* mcParticleRef = *p;
|
1722 |
|
|
while (mcParticleRef->mother() && pitr<2) {
|
1723 |
|
|
pitr++;
|
1724 |
|
|
mcParticleRef =(reco::GenParticleCandidate*) mcParticleRef->mother();
|
1725 |
|
|
if (mcParticleRef==0) break;
|
1726 |
|
|
if (mcParticleRef == *index) {
|
1727 |
|
|
if (abs((*p)->pdgId()) == 11) *MCtauDecayTypePtr = 1;
|
1728 |
|
|
if (abs((*p)->pdgId()) == 13) *MCtauDecayTypePtr = 2;
|
1729 |
|
|
}
|
1730 |
|
|
}
|
1731 |
smorovic |
1.8 |
}
|
1732 |
smorovic |
1.32 |
}
|
1733 |
smorovic |
1.8 |
}
|
1734 |
smorovic |
1.32 |
StableLeptons[i]->erase(index);
|
1735 |
smorovic |
1.8 |
}
|
1736 |
|
|
}
|
1737 |
|
|
}
|
1738 |
vuko |
1.1 |
//define this as a plug-in
|
1739 |
vuko |
1.2 |
// DEFINE_FWK_MODULE(WZAnalyzer);
|
1740 |
smorovic |
1.32 |
|