9 |
|
#include "MitPhysics/Init/interface/ModNames.h" |
10 |
|
#include "MitAna/DataCont/interface/ObjArray.h" |
11 |
|
#include "MitCommon/MathTools/interface/MathUtils.h" |
12 |
+ |
#include "MitPhysics/Utils/interface/MetTools.h" |
13 |
|
#include "MitAna/DataTree/interface/ParticleCol.h" |
14 |
|
#include "TFile.h" |
15 |
|
#include "TTree.h" |
24 |
|
fMetName("NoDefaultNameSet"), |
25 |
|
fCleanJetsName("NoDefaultNameSet"), |
26 |
|
fCleanJetsNoPtCutName("NoDefaultNameSet"), |
26 |
– |
fCaloJetName0("AKt5Jets"), |
27 |
|
fVertexName(ModNames::gkGoodVertexesName), |
28 |
+ |
fPFCandidatesName(Names::gkPFCandidatesBrn), |
29 |
|
fMuons(0), |
30 |
|
fMet(0), |
31 |
|
fVertices(0), |
32 |
< |
fCaloJet0(0) |
32 |
> |
fPFCandidates(0), |
33 |
> |
fNEventsSelected(0) |
34 |
|
{ |
35 |
|
// Constructor. |
36 |
|
} |
50 |
|
// branches. For this module, we request a branch of the MitTree. |
51 |
|
|
52 |
|
// Load Branches |
53 |
< |
ReqBranch(fMuonBranchName, fMuons); |
54 |
< |
ReqBranch(fCaloJetName0, fCaloJet0); |
53 |
> |
ReqBranch(fMuonBranchName, fMuons); |
54 |
> |
ReqBranch(fPFCandidatesName, fPFCandidates); |
55 |
|
|
56 |
|
//Create your histograms here |
57 |
|
|
125 |
|
{ |
126 |
|
// Process entries of the tree. For this module, we just load the branches and |
127 |
|
LoadBranch(fMuonBranchName); |
128 |
< |
LoadBranch(fCaloJetName0); |
129 |
< |
|
128 |
> |
LoadBranch(fPFCandidatesName); |
129 |
> |
|
130 |
|
//Obtain all the good objects from the event cleaning module |
131 |
|
fVertices = GetObjThisEvt<VertexOArr>(fVertexName); |
132 |
|
ObjArray<Muon> *CleanMuons = dynamic_cast<ObjArray<Muon>* >(FindObjThisEvt(ModNames::gkCleanMuonsName)); |
140 |
|
TParameter<Double_t> *NNLOWeight = GetObjThisEvt<TParameter<Double_t> >("NNLOWeight"); |
141 |
|
|
142 |
|
MetCol *met = dynamic_cast<ObjArray<Met>* >(FindObjThisEvt(fMetName)); |
143 |
< |
const Met *caloMet = 0; |
143 |
> |
const Met *stdMet = 0; |
144 |
|
if (met) { |
145 |
< |
caloMet = met->At(0); |
145 |
> |
stdMet = met->At(0); |
146 |
|
} else { |
147 |
|
cout << "Error: Met Collection " << fMetName << " could not be loaded.\n"; |
148 |
|
return; |
181 |
|
//*********************************************************************************************** |
182 |
|
//|Z_vert-Z_l| maximum |
183 |
|
//*********************************************************************************************** |
184 |
+ |
std::vector<double> leptonsDz; |
185 |
|
double zDiffMax = 0.0; |
186 |
|
if(fVertices->GetEntries() > 0) { |
187 |
|
for (UInt_t j=0; j<CleanMuons->GetEntries(); j++) { |
188 |
< |
double pDz = 0.0; |
189 |
< |
for(uint i0 = 0; i0 < fVertices->GetEntries(); i0++) { |
187 |
< |
if(fVertices->At(i0)->NTracks() > 0){ |
188 |
< |
pDz = TMath::Abs(CleanMuons->At(j)->BestTrk()->DzCorrected(*fVertices->At(i0))); |
189 |
< |
break; |
190 |
< |
} |
191 |
< |
} |
192 |
< |
if(pDz > zDiffMax) pDz = zDiffMax; |
188 |
> |
double pDz = CleanMuons->At(j)->BestTrk()->DzCorrected(*fVertices->At(0)); |
189 |
> |
leptonsDz.push_back(pDz); |
190 |
|
} |
191 |
|
for (UInt_t j=0; j<CleanElectrons->GetEntries(); j++) { |
192 |
< |
double pDz = 0.0; |
193 |
< |
for(uint i0 = 0; i0 < fVertices->GetEntries(); i0++) { |
194 |
< |
if(fVertices->At(i0)->NTracks() > 0){ |
195 |
< |
pDz = TMath::Abs(CleanElectrons->At(j)->GsfTrk()->DzCorrected(*fVertices->At(i0))); |
196 |
< |
break; |
197 |
< |
} |
192 |
> |
double pDz = CleanElectrons->At(j)->GsfTrk()->DzCorrected(*fVertices->At(0)); |
193 |
> |
leptonsDz.push_back(pDz); |
194 |
> |
} |
195 |
> |
for(UInt_t t=0; t<leptonsDz.size(); t++) { |
196 |
> |
for(UInt_t i=t+1; i<leptonsDz.size(); i++) { |
197 |
> |
if(TMath::Abs(leptonsDz[t]-leptonsDz[i]) > zDiffMax) zDiffMax = TMath::Abs(leptonsDz[t]-leptonsDz[i]); |
198 |
|
} |
202 |
– |
if(pDz > zDiffMax) pDz = zDiffMax; |
199 |
|
} |
200 |
+ |
leptonsDz.clear(); |
201 |
|
} |
202 |
|
|
203 |
|
//*********************************************************************************************** |
209 |
|
|
210 |
|
double deltaEtaLeptons = CleanLeptons->At(0)->Eta() - CleanLeptons->At(1)->Eta(); |
211 |
|
|
212 |
< |
double deltaPhiDileptonMet = MathUtils::DeltaPhi(caloMet->Phi(), |
212 |
> |
double deltaPhiDileptonMet = MathUtils::DeltaPhi(stdMet->Phi(), |
213 |
|
dilepton->Phi())*180.0 / TMath::Pi(); |
214 |
|
|
215 |
< |
double mtHiggs = TMath::Sqrt(2.0*dilepton->Pt() * caloMet->Pt()* |
215 |
> |
double mtHiggs = TMath::Sqrt(2.0*dilepton->Pt() * stdMet->Pt()* |
216 |
|
(1.0 - cos(deltaPhiDileptonMet * TMath::Pi() / 180.0))); |
217 |
|
|
218 |
|
//angle between MET and closest lepton |
219 |
< |
double deltaPhiMetLepton[2] = {MathUtils::DeltaPhi(caloMet->Phi(), CleanLeptons->At(0)->Phi()), |
220 |
< |
MathUtils::DeltaPhi(caloMet->Phi(), CleanLeptons->At(1)->Phi())}; |
219 |
> |
double deltaPhiMetLepton[2] = {MathUtils::DeltaPhi(stdMet->Phi(), CleanLeptons->At(0)->Phi()), |
220 |
> |
MathUtils::DeltaPhi(stdMet->Phi(), CleanLeptons->At(1)->Phi())}; |
221 |
|
|
222 |
< |
double mTW[2] = {TMath::Sqrt(2.0*CleanLeptons->At(0)->Pt()*caloMet->Pt()* |
222 |
> |
double mTW[2] = {TMath::Sqrt(2.0*CleanLeptons->At(0)->Pt()*stdMet->Pt()* |
223 |
|
(1.0 - cos(deltaPhiMetLepton[0]))), |
224 |
< |
TMath::Sqrt(2.0*CleanLeptons->At(1)->Pt()*caloMet->Pt()* |
224 |
> |
TMath::Sqrt(2.0*CleanLeptons->At(1)->Pt()*stdMet->Pt()* |
225 |
|
(1.0 - cos(deltaPhiMetLepton[1])))}; |
226 |
|
|
227 |
|
double minDeltaPhiMetLepton = (deltaPhiMetLepton[0] < deltaPhiMetLepton[1])? |
228 |
|
deltaPhiMetLepton[0]:deltaPhiMetLepton[1]; |
229 |
|
|
230 |
< |
double METdeltaPhilEt = caloMet->Pt(); |
231 |
< |
if(minDeltaPhiMetLepton < TMath::Pi()/2.) |
232 |
< |
METdeltaPhilEt = METdeltaPhilEt * sin(minDeltaPhiMetLepton); |
230 |
> |
MetTools metTools(CleanMuons, CleanElectrons, fPFCandidates, fVertices->At(0), 0.1, 8.0, 5.0); |
231 |
> |
double pMET[2] = {metTools.GetProjectedMet(CleanLeptons,stdMet), |
232 |
> |
metTools.GetProjectedTrackMet(CleanLeptons)}; |
233 |
> |
|
234 |
> |
double METdeltaPhilEt = TMath::Min(pMET[0],pMET[1]); |
235 |
|
|
236 |
|
//count the number of central Jets for vetoing and b-tagging |
237 |
|
vector<Jet*> sortedJetsAll; |
242 |
|
CleanJetsNoPtCut->At(i)->Py(), |
243 |
|
CleanJetsNoPtCut->At(i)->Pz(), |
244 |
|
CleanJetsNoPtCut->At(i)->E() ); |
245 |
< |
|
246 |
< |
int nCloseStdJet = -1; |
247 |
< |
double deltaRMin = 999.; |
248 |
< |
for(UInt_t nj=0; nj<fCaloJet0->GetEntries(); nj++){ |
249 |
< |
const CaloJet *jet = fCaloJet0->At(nj); |
250 |
< |
Double_t deltaR = MathUtils::DeltaR(jet_a->Mom(),jet->Mom()); |
251 |
< |
if(deltaR < deltaRMin) { |
252 |
< |
nCloseStdJet = nj; |
253 |
< |
deltaRMin = deltaR; |
254 |
< |
} |
256 |
< |
} |
257 |
< |
if(nCloseStdJet >= 0 && deltaRMin < 0.5){ |
258 |
< |
jet_a->SetMatchedMCFlavor(fCaloJet0->At(nCloseStdJet)->MatchedMCFlavor()); |
259 |
< |
jet_a->SetCombinedSecondaryVertexBJetTagsDisc(fCaloJet0->At(nCloseStdJet)->CombinedSecondaryVertexBJetTagsDisc()); |
260 |
< |
jet_a->SetCombinedSecondaryVertexMVABJetTagsDisc(fCaloJet0->At(nCloseStdJet)->CombinedSecondaryVertexMVABJetTagsDisc()); |
261 |
< |
jet_a->SetJetProbabilityBJetTagsDisc(fCaloJet0->At(nCloseStdJet)->JetProbabilityBJetTagsDisc()); |
262 |
< |
jet_a->SetJetBProbabilityBJetTagsDisc(fCaloJet0->At(nCloseStdJet)->JetBProbabilityBJetTagsDisc()); |
263 |
< |
jet_a->SetTrackCountingHighEffBJetTagsDisc(fCaloJet0->At(nCloseStdJet)->TrackCountingHighEffBJetTagsDisc()); |
264 |
< |
jet_a->SetTrackCountingHighPurBJetTagsDisc(fCaloJet0->At(nCloseStdJet)->TrackCountingHighPurBJetTagsDisc()); |
265 |
< |
jet_a->SetSimpleSecondaryVertexBJetTagsDisc(fCaloJet0->At(nCloseStdJet)->SimpleSecondaryVertexBJetTagsDisc()); |
266 |
< |
jet_a->SetSimpleSecondaryVertexHighEffBJetTagsDisc(fCaloJet0->At(nCloseStdJet)->SimpleSecondaryVertexHighEffBJetTagsDisc()); |
267 |
< |
jet_a->SetSimpleSecondaryVertexHighPurBJetTagsDisc(fCaloJet0->At(nCloseStdJet)->SimpleSecondaryVertexHighPurBJetTagsDisc()); |
268 |
< |
} |
269 |
< |
else { |
270 |
< |
jet_a->SetMatchedMCFlavor(CleanJetsNoPtCut->At(i)->MatchedMCFlavor()); |
271 |
< |
jet_a->SetCombinedSecondaryVertexBJetTagsDisc(CleanJetsNoPtCut->At(i)->CombinedSecondaryVertexBJetTagsDisc()); |
272 |
< |
jet_a->SetCombinedSecondaryVertexMVABJetTagsDisc(CleanJetsNoPtCut->At(i)->CombinedSecondaryVertexMVABJetTagsDisc()); |
273 |
< |
jet_a->SetJetProbabilityBJetTagsDisc(CleanJetsNoPtCut->At(i)->JetProbabilityBJetTagsDisc()); |
274 |
< |
jet_a->SetJetBProbabilityBJetTagsDisc(CleanJetsNoPtCut->At(i)->JetBProbabilityBJetTagsDisc()); |
275 |
< |
jet_a->SetTrackCountingHighEffBJetTagsDisc(CleanJetsNoPtCut->At(i)->TrackCountingHighEffBJetTagsDisc()); |
276 |
< |
jet_a->SetTrackCountingHighPurBJetTagsDisc(CleanJetsNoPtCut->At(i)->TrackCountingHighPurBJetTagsDisc()); |
277 |
< |
jet_a->SetSimpleSecondaryVertexBJetTagsDisc(CleanJetsNoPtCut->At(i)->SimpleSecondaryVertexBJetTagsDisc()); |
278 |
< |
jet_a->SetSimpleSecondaryVertexHighEffBJetTagsDisc(CleanJetsNoPtCut->At(i)->SimpleSecondaryVertexHighEffBJetTagsDisc()); |
279 |
< |
jet_a->SetSimpleSecondaryVertexHighPurBJetTagsDisc(CleanJetsNoPtCut->At(i)->SimpleSecondaryVertexHighPurBJetTagsDisc()); |
280 |
< |
} |
245 |
> |
jet_a->SetMatchedMCFlavor(CleanJetsNoPtCut->At(i)->MatchedMCFlavor()); |
246 |
> |
jet_a->SetCombinedSecondaryVertexBJetTagsDisc(CleanJetsNoPtCut->At(i)->CombinedSecondaryVertexBJetTagsDisc()); |
247 |
> |
jet_a->SetCombinedSecondaryVertexMVABJetTagsDisc(CleanJetsNoPtCut->At(i)->CombinedSecondaryVertexMVABJetTagsDisc()); |
248 |
> |
jet_a->SetJetProbabilityBJetTagsDisc(CleanJetsNoPtCut->At(i)->JetProbabilityBJetTagsDisc()); |
249 |
> |
jet_a->SetJetBProbabilityBJetTagsDisc(CleanJetsNoPtCut->At(i)->JetBProbabilityBJetTagsDisc()); |
250 |
> |
jet_a->SetTrackCountingHighEffBJetTagsDisc(CleanJetsNoPtCut->At(i)->TrackCountingHighEffBJetTagsDisc()); |
251 |
> |
jet_a->SetTrackCountingHighPurBJetTagsDisc(CleanJetsNoPtCut->At(i)->TrackCountingHighPurBJetTagsDisc()); |
252 |
> |
jet_a->SetSimpleSecondaryVertexBJetTagsDisc(CleanJetsNoPtCut->At(i)->SimpleSecondaryVertexBJetTagsDisc()); |
253 |
> |
jet_a->SetSimpleSecondaryVertexHighEffBJetTagsDisc(CleanJetsNoPtCut->At(i)->SimpleSecondaryVertexHighEffBJetTagsDisc()); |
254 |
> |
jet_a->SetSimpleSecondaryVertexHighPurBJetTagsDisc(CleanJetsNoPtCut->At(i)->SimpleSecondaryVertexHighPurBJetTagsDisc()); |
255 |
|
sortedJetsAll.push_back(jet_a); |
256 |
|
} |
257 |
|
|
258 |
|
for(UInt_t i=0; i<CleanJets->GetEntries(); i++){ |
259 |
|
if(TMath::Abs(CleanJets->At(i)->Eta()) < 5.0 && |
260 |
< |
CleanJets->At(i)->Pt() > 25.0){ |
260 |
> |
CleanJets->At(i)->Pt() > 30.0){ |
261 |
|
Jet* jet_b = new Jet(CleanJets->At(i)->Px(), |
262 |
|
CleanJets->At(i)->Py(), |
263 |
|
CleanJets->At(i)->Pz(), |
295 |
|
double maxBtag = -99999.; |
296 |
|
double imaxBtag = -1; |
297 |
|
for(UInt_t i=0; i<sortedJetsLowPt.size(); i++){ |
298 |
+ |
if(sortedJetsLowPt[i]->Pt() <= 7) continue; |
299 |
|
if(sortedJetsLowPt[i]->TrackCountingHighEffBJetTagsDisc() > maxBtag){ |
300 |
|
maxBtag = sortedJetsLowPt[i]->TrackCountingHighEffBJetTagsDisc(); |
301 |
|
imaxBtag = i; |
322 |
|
bool passCut[nCuts] = {false, false, false, false, false, |
323 |
|
false, false, false, false, false}; |
324 |
|
|
325 |
< |
if(CleanLeptons->At(0)->Pt() > 20.0 && |
326 |
< |
CleanLeptons->At(1)->Pt() >= 20.0) passCut[0] = true; |
325 |
> |
Bool_t PreselPtCut = kTRUE; |
326 |
> |
if(CleanLeptons->At(0)->Pt() <= 20) PreselPtCut = kFALSE; |
327 |
> |
if(CleanLeptons->At(1)->Pt() <= 10) PreselPtCut = kFALSE; |
328 |
> |
if(CleanLeptons->At(1)->ObjType() == kElectron && CleanLeptons->At(1)->Pt() <= 15) PreselPtCut = kFALSE; |
329 |
> |
if(PreselPtCut == kTRUE) passCut[0] = true; |
330 |
|
|
331 |
< |
if(zDiffMax < 1.0) passCut[1] = true; |
331 |
> |
if(zDiffMax < 100000.0) passCut[1] = true; |
332 |
|
|
333 |
< |
if(caloMet->Pt() > 20.0) passCut[2] = true; |
333 |
> |
if(stdMet->Pt() > 20.0) passCut[2] = true; |
334 |
|
|
335 |
|
if(dilepton->Mass() > 12.0) passCut[3] = true; |
336 |
|
|
350 |
|
passCut[4] = true; |
351 |
|
if(METdeltaPhilEt > 20) passCut[5] = true; |
352 |
|
} |
353 |
< |
|
353 |
> |
|
354 |
|
//********************************************************************************************* |
355 |
|
//Make Selection Histograms. Number of events passing each level of cut |
356 |
|
//********************************************************************************************* |
357 |
|
bool passAllCuts = true; |
358 |
|
for(int c=0; c<nCuts; c++) passAllCuts = passAllCuts & passCut[c]; |
359 |
< |
|
359 |
> |
if(passAllCuts) fNEventsSelected++; |
360 |
> |
|
361 |
|
//Cut Selection Histograms |
362 |
|
fHWWSelection->Fill(-1,NNLOWeight->GetVal()); |
363 |
|
if (finalstateType == 10 ) |
394 |
|
fLeptonEta->Fill(CleanLeptons->At(1)->Eta(),NNLOWeight->GetVal()); |
395 |
|
fLeptonPtMax->Fill(CleanLeptons->At(0)->Pt(),NNLOWeight->GetVal()); |
396 |
|
fLeptonPtMin->Fill(CleanLeptons->At(1)->Pt(),NNLOWeight->GetVal()); |
397 |
< |
fMetPtHist->Fill(caloMet->Pt(),NNLOWeight->GetVal()); |
398 |
< |
fMetPhiHist->Fill(caloMet->Phi(),NNLOWeight->GetVal()); |
397 |
> |
fMetPtHist->Fill(stdMet->Pt(),NNLOWeight->GetVal()); |
398 |
> |
fMetPhiHist->Fill(stdMet->Phi(),NNLOWeight->GetVal()); |
399 |
|
fDeltaPhiLeptons->Fill(deltaPhiLeptons,NNLOWeight->GetVal()); |
400 |
|
fDeltaEtaLeptons->Fill(deltaEtaLeptons,NNLOWeight->GetVal()); |
401 |
|
fDileptonMass->Fill(dilepton->Mass(),NNLOWeight->GetVal()); |
408 |
|
//N Jet Veto |
409 |
|
pass = true; |
410 |
|
for (int k=0;k<nCuts;k++) { |
411 |
< |
if (k != 5) { |
411 |
> |
if (k != 6) { |
412 |
|
pass = (pass && passCut[k]); |
413 |
|
} |
414 |
|
} |
419 |
|
// Final Met Cut |
420 |
|
pass = true; |
421 |
|
for (int k=0;k<nCuts;k++) { |
422 |
< |
if (k != 4) { |
422 |
> |
if (k != 5) { |
423 |
|
pass = (pass && passCut[k]); |
424 |
|
} |
425 |
|
} |
426 |
|
if (pass) { |
427 |
< |
fMetPtHist_NMinusOne->Fill(caloMet->Pt(),NNLOWeight->GetVal()); |
427 |
> |
fMetPtHist_NMinusOne->Fill(stdMet->Pt(),NNLOWeight->GetVal()); |
428 |
|
} |
429 |
|
|
430 |
|
// dilepton mass |
431 |
|
pass = true; |
432 |
|
for (int k=0;k<nCuts;k++) { |
433 |
< |
if (k != 2 && k != 3) |
433 |
> |
if (k != 3 && k != 4) |
434 |
|
pass = (pass && passCut[k]); |
435 |
|
} |
436 |
|
if (pass) { |
440 |
|
// Lepton Pt Max, Lepton Pt Min, DeltaPhiLeptons |
441 |
|
pass = true; |
442 |
|
for (int k=0;k<nCuts;k++) { |
443 |
< |
pass = (pass && passCut[k]); |
443 |
> |
if (k != 0) |
444 |
> |
pass = (pass && passCut[k]); |
445 |
|
} |
446 |
|
if (pass) { |
447 |
|
fLeptonPtMax_NMinusOne->Fill(CleanLeptons->At(0)->Pt(),NNLOWeight->GetVal()); |
452 |
|
// NSoftMuons |
453 |
|
pass = true; |
454 |
|
for (int k=0;k<nCuts;k++) { |
455 |
< |
if (k != 6) |
455 |
> |
if (k != 7) |
456 |
|
pass = (pass && passCut[k]); |
457 |
|
} |
458 |
|
if (pass) { |
467 |
|
fMtLepton1_afterCuts->Fill(mTW[0],NNLOWeight->GetVal()); |
468 |
|
fMtLepton2_afterCuts->Fill(mTW[1],NNLOWeight->GetVal()); |
469 |
|
fMtHiggs_afterCuts->Fill(mtHiggs,NNLOWeight->GetVal()); |
470 |
< |
fLeptonPtPlusMet_afterCuts->Fill(CleanLeptons->At(0)->Pt()+CleanLeptons->At(1)->Pt()+caloMet->Pt(),NNLOWeight->GetVal()); |
470 |
> |
fLeptonPtPlusMet_afterCuts->Fill(CleanLeptons->At(0)->Pt()+CleanLeptons->At(1)->Pt()+stdMet->Pt(),NNLOWeight->GetVal()); |
471 |
|
} |
472 |
|
|
473 |
|
delete dilepton; |
483 |
|
|
484 |
|
// Run finishing code on the computer (slave) that did the analysis. For this |
485 |
|
// module, we dont do anything here. |
486 |
+ |
cout << "selected events on HwwExampleAnalysisMod: " << fNEventsSelected << endl; |
487 |
|
|
488 |
|
} |
489 |
|
//-------------------------------------------------------------------------------------------------- |