-
Notifications
You must be signed in to change notification settings - Fork 0
/
pT_propVSunprop.C
223 lines (169 loc) · 6.61 KB
/
pT_propVSunprop.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#include "TFile.h"
#include <iostream>
#include <vector>
#include "TChain.h"
#include "TTree.h"
#include "TSystem.h"
#include "TCanvas.h"
#include "TH1.h"
#include "TH2.h"
#include "TF1.h"
#include "TGraphErrors.h"
#include "TGraphAsymmErrors.h"
#include "TLorentzVector.h"
#include "TClonesArray.h"
#include "TROOT.h"
#include "TMath.h"
#include "TStyle.h"
#include "TColor.h"
#include "TLegend.h"
#include "TPad.h"
#include "TLine.h"
#include "TH1F.h"
#include "../../plugins/CosmicSplittingResolutionNtuple.h"
//you first decalre all the varaibles you are goingt o pick from the tree and use in this code. Be careful that the type of the varaible (Int, Float etc) have to be the same that when it was filled in the tree maker
//my interesting variables
float pt[n_tracks][n_track_pos];
short charge[n_tracks][n_track_pos];
float unprop_pt[n_tracks][n_track_pos];
short unprop_charge[n_tracks][n_track_pos];
////////////////////////////////////////////////////////////////////////////////
//Declaration of hitsogramm i plan to plot with this code
TH1F *pthistoGlbUP =new TH1F("pthistoGlbProp","",20,0,800);
TH1F *pthistoGlbLOW =new TH1F("pthistoGlbUnprop","",20,0,800);
//TH1F *pthistoStalone =new TH1F("pthistoStalone","",10,30,800);
TH1F *pthistoTkonlyUP =new TH1F("pthistoTkonlyProp","",20,0,800);
TH1F *pthistoTkonlyLOW =new TH1F("pthistoTkonlyLOW","",20,0,800);
TH1F *pthistoTpfmsUP =new TH1F("pthistoTpfmsProp","",20,0,800);
TH1F *pthistoTpfmsLOW =new TH1F("pthistoTpfmsLOW","",20,0,800);
TH1F *pthistoPickyUP =new TH1F("pthistoPickyProp","",20,0,800);
TH1F *pthistoPickyLOW =new TH1F("pthistoPickyLOW","",20,0,800);
TH1F *pthistoDYTUP =new TH1F("pthistoDYTProp","",20,0,800);
TH1F *pthistoDYTLOW =new TH1F("pthistoDYTLOW","",20,0,800);
//TH1F *ptRef=new TH1F("ptRef","",100,0,640);
//TH1F *ptTuneP = new TH1F("ptTuneP","",100,0,640);
//Begining of teh function
void pT_propVSunprop(){
gStyle->SetPadBorderMode(0);
gStyle->SetCanvasColor(10);
gStyle->SetCanvasBorderMode(0);
gStyle->SetCanvasBorderSize(0);
gStyle->SetFrameBorderMode(0);
gStyle->SetFrameLineColor(0);
gStyle->SetFillColor(0);
// the next line is to link the tree you have
TChain *treedata = new TChain("UTpickedTracks/t");
// this is the root file you have input with your tree inside
treedata->Add("resolution_cosmics_data.root");
// the following lines are to extract the branch of the trees, when there is a & it means that there is only one entry per event, like for run, lumi, event, dilepton mass in my case for DY events.
treedata->SetBranchAddress("charge",charge);
treedata->SetBranchAddress("pt",pt);
treedata->SetBranchAddress("unprop_charge",unprop_charge);
treedata->SetBranchAddress("unprop_pt",unprop_pt);
// This will get the numbers of entries of the tree.
Long64_t nentries = treedata->GetEntries();
//Decalaration of variable not in the tree that i use for the results
Float_t sameCharge = 0.;
Float_t goodMuon = 0.;
for ( int p=0; p<nentries ;p++){
// this loop over all the events in your tree
treedata->GetEntry(p);
//apply some quality cuts to select the entries that we think are interesting
pthistoGlbUP->Fill(pt[0][1]);
pthistoGlbLOW->Fill(unprop_pt[0][1]);
pthistoTkonlyUP->Fill(pt[2][1]);
pthistoTkonlyLOW->Fill(unprop_pt[2][1]);
pthistoTpfmsUP->Fill(pt[3][1]);
pthistoTpfmsLOW->Fill(unprop_pt[3][1]);
pthistoPickyUP->Fill(pt[4][1]);
pthistoPickyLOW->Fill(unprop_pt[4][1]);
pthistoDYTUP->Fill(pt[5][1]);
pthistoDYTLOW->Fill(unprop_pt[5][1]);
}// end loop p
TCanvas *c1 = new TCanvas("c1","",1400,900);
c1->Divide(3,2);
c1->cd(1);
pthistoGlbUP->SetXTitle("#p_{t} (GeV)");
pthistoGlbLOW->SetLineColor(8);
pthistoGlbLOW->SetLineWidth(2);
pthistoGlbLOW->Draw("E1");
pthistoGlbUP->SetLineColor(2);
pthistoGlbUP->SetLineWidth(2);
pthistoGlbUP->Draw("E1 SAME");
TLegend * leg1 = new TLegend(0.6, 0.60, 0.98, 0.77);
leg1->SetHeader("Global fit - lower leg");
leg1->SetFillColor(10);
leg1->AddEntry(pthistoGlbUP,"Propagated ","l");
leg1->AddEntry(pthistoGlbLOW,"Unpropagated","l");
leg1 -> Draw();
//TLatex t(0.2,270,"Unpropagated values");
//t.DrawClone("Same");
c1->cd(2);
pthistoTkonlyUP->SetXTitle("#pt");
pthistoTkonlyUP->SetLineColor(2);
pthistoTkonlyUP->SetLineWidth(2);
pthistoTkonlyUP->Draw("E1");
pthistoTkonlyLOW->SetLineColor(8);
pthistoTkonlyLOW->SetLineWidth(2);
pthistoTkonlyLOW->Draw("E1 SAME");
TLegend * leg2 = new TLegend(0.6, 0.60, 0.98, 0.77);
leg2->SetHeader("Tracker only - lower leg");
leg2->SetFillColor(10);
leg2->AddEntry(pthistoTkonlyUP,"Propagated ","l");
leg2->AddEntry(pthistoTkonlyLOW,"Unpropagated","l");
leg2 -> Draw();
//TLatex t2(0.2,270,"Unpropagated values");
//t2.DrawClone("Same");
c1->cd(3);
pthistoTpfmsUP->SetXTitle("#pt");
pthistoTpfmsUP->SetLineColor(2);
pthistoTpfmsUP->SetLineWidth(2);
pthistoTpfmsUP->Draw("E1");
pthistoTpfmsLOW->SetLineColor(8);
pthistoTpfmsLOW->SetLineWidth(2);
pthistoTpfmsLOW->Draw("E1 SAME");
TLegend * leg3 = new TLegend(0.6, 0.60, 0.98, 0.77);
leg3->SetHeader("TPFMS - lower leg");
leg3->SetFillColor(10);
leg3->AddEntry(pthistoTpfmsUP,"Propagated","l");
leg3->AddEntry(pthistoTpfmsLOW,"Unpropagated","l");
leg3 -> Draw();
//TLatex t3(0.2,270,"Unpropagated values");
//t3.DrawClone("Same");
c1->cd(4);
pthistoPickyUP->SetXTitle("#pt");
pthistoPickyUP->SetLineColor(2);
pthistoPickyUP->SetLineWidth(2);
pthistoPickyUP->Draw("E1");
pthistoPickyLOW->SetLineColor(8);
pthistoPickyLOW->SetLineWidth(2);
pthistoPickyLOW->Draw("E1 SAME");
TLegend * leg4 = new TLegend(0.6, 0.60, 0.98, 0.77);
leg4->SetHeader("Picky - lower leg");
leg4->SetFillColor(10);
leg4->AddEntry(pthistoPickyUP,"Propagated ","l");
leg4->AddEntry(pthistoPickyLOW,"Unpropagated","l");
leg4-> Draw();
//TLatex t4(0.2,270,"Unpropagated values");
//t4.DrawClone("Same");
c1->cd(5);
pthistoDYTUP->SetXTitle("#pt");
pthistoDYTUP->SetLineColor(2);
pthistoDYTUP->SetLineWidth(2);
pthistoDYTUP->Draw("E1");
pthistoDYTLOW->SetLineColor(8);
pthistoDYTLOW->SetLineWidth(2);
pthistoDYTLOW->Draw("E1 SAME");
TLegend * leg5 = new TLegend(0.6, 0.60, 0.98, 0.77);
leg5->SetHeader("DYT - lower leg");
leg5->SetFillColor(10);
leg5->AddEntry(pthistoDYTUP,"Propagated ","l");
leg5->AddEntry(pthistoDYTLOW,"Unpropagated","l");
leg5 -> Draw();
//TLatex t5(0.2,270,"Unpropagated values");
//t5.DrawClone("Same");
/*TFile *fout = new TFile("testpt.root ","RECREATE");
pthistoGlb->Write();
pthistoStalone->Write();
fout->Close();*/
}// end of function