-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyAnalysis.C
199 lines (162 loc) · 7.21 KB
/
MyAnalysis.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#define MyAnalysis_cxx
// The class definition in MyAnalysis.h has been generated automatically
// by the ROOT utility TTree::MakeSelector(). This class is derived
// from the ROOT class TSelector. For more information on the TSelector
// framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.
// The following methods are defined in this file:
// Begin(): called every time a loop on the tree starts,
// a convenient place to create your histograms.
// SlaveBegin(): called after Begin(), when on PROOF called only on the
// slave servers.
// Process(): called for each event, in this function you decide what
// to read and fill your histograms.
// SlaveTerminate: called at the end of the loop on the tree, when on PROOF
// called only on the slave servers.
// Terminate(): called at the end of the loop on the tree,
// a convenient place to draw/fit your histograms.
//
// To use this file, try the following session on your Tree T:
//
// Root > T->Process("MyAnalysis.C")
// Root > T->Process("MyAnalysis.C","some options")
// Root > T->Process("MyAnalysis.C+")
//
#include "MyAnalysis.h"
#include <iostream>
#include <TH1F.h>
#include <TLatex.h>
using namespace std;
void MyAnalysis::BuildEvent() {
Muons.clear();
for (int i = 0; i < NMuon; ++i) {
MyMuon muon(Muon_Px[i], Muon_Py[i], Muon_Pz[i], Muon_E[i]);
muon.SetIsolation(Muon_Iso[i]);
muon.SetCharge(Muon_Charge[i]);
Muons.push_back(muon);
}
Electrons.clear();
for (int i = 0; i < NElectron; ++i) {
MyElectron electron(Electron_Px[i], Electron_Py[i], Electron_Pz[i], Electron_E[i]);
electron.SetIsolation(Electron_Iso[i]);
electron.SetCharge(Electron_Charge[i]);
Electrons.push_back(electron);
}
Photons.clear();
for (int i = 0; i < NPhoton; ++i) {
MyPhoton photon(Photon_Px[i], Photon_Py[i], Photon_Pz[i], Photon_E[i]);
photon.SetIsolation(Photon_Iso[i]);
Photons.push_back(photon);
}
Jets.clear();
for (int i = 0; i < NJet; ++i) {
MyJet jet(Jet_Px[i], Jet_Py[i], Jet_Pz[i], Jet_E[i]);
jet.SetBTagDiscriminator(Jet_btag[i]);
jet.SetJetID(Jet_ID[i]);
Jets.push_back(jet);
}
hadB.SetXYZM(MChadronicBottom_px, MChadronicBottom_py, MChadronicBottom_pz, 4.8);
lepB.SetXYZM(MCleptonicBottom_px, MCleptonicBottom_py, MCleptonicBottom_pz, 4.8);
hadWq.SetXYZM(MChadronicWDecayQuark_px, MChadronicWDecayQuark_py, MChadronicWDecayQuark_pz, 0.0);
hadWqb.SetXYZM(MChadronicWDecayQuarkBar_px, MChadronicWDecayQuarkBar_py, MChadronicWDecayQuarkBar_pz, 0.0);
lepWl.SetXYZM(MClepton_px, MClepton_py, MClepton_pz, 0.0);
lepWn.SetXYZM(MCneutrino_px, MCneutrino_py, MCneutrino_pz, 0.0);
met.SetXYZM(MET_px, MET_py, 0., 0.);
EventWeight *= weight_factor;
}
void MyAnalysis::Begin(TTree * /*tree*/) {
// The Begin() function is called at the start of the query.
// When running with PROOF Begin() is only called on the client.
// The tree argument is deprecated (on PROOF 0 is passed).
TString option = GetOption();
}
void MyAnalysis::SlaveBegin(TTree * /*tree*/) {
// The SlaveBegin() function is called after the Begin() function.
// When running with PROOF SlaveBegin() is called on each slave server.
// The tree argument is deprecated (on PROOF 0 is passed).
TString option = GetOption();
h_Mmumu = new TH1F("Mmumu", "Invariant di-muon mass", 60, 60, 120);
h_Mmumu->SetXTitle("m_{#mu#mu}");
h_Mmumu->Sumw2();
histograms.push_back(h_Mmumu);
histograms_MC.push_back(h_Mmumu);
h_NMuon = new TH1F("NMuon", "Number of muons", 7, 0, 7);
h_NMuon->SetXTitle("No. Muons");
h_NMuon->Sumw2();
histograms.push_back(h_NMuon);
histograms_MC.push_back(h_NMuon);
}
Bool_t MyAnalysis::Process(Long64_t entry) {
// The Process() function is called for each entry in the tree (or possibly
// keyed object in the case of PROOF) to be processed. The entry argument
// specifies which entry in the currently loaded tree is to be processed.
// It can be passed to either MyAnalysis::GetEntry() or TBranch::GetEntry()
// to read either all or the required parts of the data. When processing
// keyed objects with PROOF, the object is already loaded and is available
// via the fObject pointer.
//
// This function should contain the "body" of the analysis. It can contain
// simple or elaborate selection criteria, run algorithms on the data
// of the event and typically fill histograms.
//
// The processing can be stopped by calling Abort().
//
// Use fStatus to set the return value of TTree::Process().
//
// The return value is currently not used.
++TotalEvents;
GetEntry(entry);
if (TotalEvents % 10000 == 0)
cout << "Next event -----> " << TotalEvents << endl;
BuildEvent();
double MuonPtCut = 25.;
double MuonRelIsoCut = 0.10;
// cout << "Jets: " << endl;
// for (vector<MyJet>::iterator it = Jets.begin(); it != Jets.end(); ++it) {
// cout << "pt, eta, phi, btag, id: " << it->Pt() << ", " << it->Eta() << ", " << it->Phi() << ", " << it->IsBTagged() << ", " << it->GetJetID()
// << endl;
// }
// cout << "Muons: " << endl;
// for (vector<MyMuon>::iterator it = Muons.begin(); it != Muons.end(); ++it) {
// cout << "pt, eta, phi, iso, charge: " << it->Pt() << ", " << it->Eta() << ", " << it->Phi() << ", "
// << it->GetIsolation() << ", " << it->GetCharge() << endl;
// }
// cout << "Electrons: " << endl;
// for (vector<MyElectron>::iterator it = Electrons.begin(); it != Electrons.end(); ++it) {
// cout << "pt, eta, phi, iso, charge: " << it->Pt() << ", " << it->Eta() << ", " << it->Phi() << ", "
// << it->GetIsolation() << ", " << it->GetCharge() << endl;
// }
// cout << "Photons: " << endl;
// for (vector<MyPhoton>::iterator it = Photons.begin(); it != Photons.end(); ++it) {
// cout << "pt, eta, phi, iso: " << it->Pt() << ", " << it->Eta() << ", " << it->Phi() << ", " << it->GetIsolation()
// << endl;
// }
//////////////////////////////
// Exercise 1: Invariant Di-Muon mass
int N_IsoMuon = 0;
MyMuon *muon1, *muon2;
for (vector<MyMuon>::iterator jt = Muons.begin(); jt != Muons.end(); ++jt) {
if (jt->IsIsolated(MuonRelIsoCut)) {
++N_IsoMuon;
if (N_IsoMuon == 1) muon1 = &(*jt);
if (N_IsoMuon == 2) muon2 = &(*jt);
}
}
h_NMuon->Fill(N_IsoMuon, EventWeight);
if (N_IsoMuon > 1 && triggerIsoMu24) {
if (muon1->Pt()>MuonPtCut) {
h_Mmumu->Fill((*muon1 + *muon2).M(), EventWeight);
}
}
//////////////////////////////
return kTRUE;
}
void MyAnalysis::SlaveTerminate() {
// The SlaveTerminate() function is called after all entries or objects
// have been processed. When running with PROOF SlaveTerminate() is called
// on each slave server.
}
void MyAnalysis::Terminate() {
// The Terminate() function is the last function to be called during
// a query. It always runs on the client, it can be used to present
// the results graphically or save the results to file.
}