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