ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/csander/JetResolutionFromMC/MCResolutions/test/ResponsePlotter.C
Revision: 1.2
Committed: Fri Jan 14 14:23:28 2011 UTC (14 years, 3 months ago) by csander
Content type: text/plain
Branch: MAIN
CVS Tags: V111011, V110523_BE, V_CMSSW38X, HEAD
Changes since 1.1: +4 -5 lines
Error occurred while calculating annotation data.
Log Message:
update

File Contents

# Content
1 {
2 gROOT->Reset();
3 gROOT->SetStyle("Plain");
4 gStyle->SetStatColor(0);
5 gStyle->SetCanvasColor(0);
6 gStyle->SetPadColor(0);
7 gStyle->SetPadBorderMode(0);
8 gStyle->SetCanvasBorderMode(0);
9 gStyle->SetFrameBorderMode(0);
10 gStyle->SetOptStat(0);
11 gStyle->SetStatBorderSize(2);
12 gStyle->SetTitleColor(1);
13 gStyle->SetTitleFillColor(0);
14 gStyle->SetTitleY(1.0);
15 gStyle->SetTitleX(0.12);
16 gStyle->SetTitleBorderSize(0);
17 gStyle->SetPadTickX(1);
18 gStyle->SetPadTickY(1);
19 gStyle->SetPadBorderSize(2);
20 gStyle->SetPalette(51,0);
21 gStyle->SetPadBottomMargin(0.2);
22 gStyle->SetPadTopMargin(0.1);
23 gStyle->SetPadLeftMargin(0.2);
24 gStyle->SetPadRightMargin(0.05);
25 gStyle->SetTitleOffset(1.2, "X");
26 gStyle->SetTitleOffset(1.4, "Y");
27 gStyle->SetTitleOffset(1.0, "Z");
28 gStyle->SetLabelSize(0.05, "X");
29 gStyle->SetLabelSize(0.05, "Y");
30 gStyle->SetLabelSize(0.05, "Z");
31 gStyle->SetLabelOffset(0.02, "X");
32 gStyle->SetLabelOffset(0.02, "Y");
33 gStyle->SetLabelOffset(0.02, "Z");
34 gStyle->SetTitleSize(0.06, "X");
35 gStyle->SetTitleSize(0.06, "Y");
36 gStyle->SetTitleSize(0.06, "Z");
37 gStyle->SetLineWidth(2);
38 gStyle->SetHistLineWidth(2);
39 gStyle->SetLegendBorderSize(0);
40 gStyle->SetNdivisions(505, "X");
41 gROOT->ForceStyle();
42
43 int rebin = 5;
44 double rmin = 0.;
45 double rmax = 1.5;
46 double ymin = 5;
47 int PtBin = 12;
48 int EtaBin = 0;
49 char* multiplicity = "_NJetAll";
50 //char* file1 = "MCJetResolution_Boundary01_110112.root";
51 //char* file2 = "MCJetResolution_Boundary02_110112.root";
52 char* file1 = "MCJetResolution_dR02_01_110114.root";
53 char* file2 = "MCJetResolution_dR02_02_110114.root";
54
55 TFile *g1 = TFile::Open(file1);
56 TFile *g2 = TFile::Open(file2);
57 //gDirectory->cd(tree);
58 TCanvas* b = new TCanvas("b", "my Canvas", 500, 500);
59 b->Divide(1,1);
60 b->cd(1)->SetLogy();
61
62 TH1F *hResponse_tot_1;
63 TH1F *hResponse_b_1;
64 TH1F *hResponse_dead_1;
65 TH1F *hResponse_deadb_1;
66 TH1F *hResponse_tot_2;
67 TH1F *hResponse_b_2;
68 TH1F *hResponse_dead_2;
69 TH1F *hResponse_deadb_2;
70 char dummy[100];
71 sprintf(dummy, "h_tot%s_ResponsePt_Pt%i_Eta%i", multiplicity, PtBin, EtaBin);
72 cout << dummy << endl;
73 hResponse_tot_1 = (TH1F*) g1->FindObjectAny(dummy);
74 hResponse_tot_2 = (TH1F*) g2->FindObjectAny(dummy);
75 sprintf(dummy, "h_b%s_ResponsePt_Pt%i_Eta%i", multiplicity, PtBin, EtaBin);
76 cout << dummy << endl;
77 hResponse_b_1 = (TH1F*) g1->FindObjectAny(dummy);
78 hResponse_b_2 = (TH1F*) g2->FindObjectAny(dummy);
79 sprintf(dummy, "h_dead%s_ResponsePt_Pt%i_Eta%i", multiplicity, PtBin, EtaBin);
80 cout << dummy << endl;
81 hResponse_dead_1 = (TH1F*) g1->FindObjectAny(dummy);
82 hResponse_dead_2 = (TH1F*) g2->FindObjectAny(dummy);
83 sprintf(dummy, "h_deadb%s_ResponsePt_Pt%i_Eta%i", multiplicity, PtBin, EtaBin);
84 cout << dummy << endl;
85 hResponse_deadb_1 = (TH1F*) g1->FindObjectAny(dummy);
86 hResponse_deadb_2 = (TH1F*) g2->FindObjectAny(dummy);
87
88 hResponse_tot_1->Rebin(rebin);
89 hResponse_tot_2->Rebin(rebin);
90 hResponse_tot_1->SetTitle("|#eta^{gen}| < 0.5 & 190 GeV < p_{T}^{gen} < 220 GeV");
91 hResponse_tot_1->SetXTitle("p_{T}^{reco}/p_{T}^{gen}");
92 sprintf(dummy, "Events/%4.2f/100 pb^{-1}", hResponse_tot_1->GetBinWidth(1));
93 hResponse_tot_1->SetYTitle(dummy);
94 hResponse_tot_1->SetAxisRange(rmin, rmax, "X");
95 hResponse_tot_2->SetAxisRange(rmin, rmax, "X");
96 hResponse_tot_1->SetMinimum(ymin);
97 hResponse_tot_1->SetTitleOffset(1.2, "X");
98 hResponse_tot_1->SetTitleOffset(1.4, "Y");
99 hResponse_tot_1->SetTitleOffset(1.0, "Z");
100 hResponse_tot_1->SetLineWidth(2);
101 hResponse_tot_2->SetLineWidth(2);
102 hResponse_tot_1->SetLineColor(kRed);
103 hResponse_tot_2->SetLineColor(kBlack);
104 hResponse_tot_1->Draw();
105 hResponse_tot_2->Draw("same");
106
107 hResponse_b_1->Add(hResponse_deadb_1, -1);
108 hResponse_b_2->Add(hResponse_deadb_2, -1);
109 hResponse_b_1->Rebin(rebin);
110 hResponse_b_2->Rebin(rebin);
111 hResponse_b_1->SetAxisRange(rmin, rmax, "X");
112 hResponse_b_2->SetAxisRange(rmin, rmax, "X");
113 hResponse_b_1->SetLineWidth(2);
114 hResponse_b_2->SetLineWidth(2);
115 hResponse_b_1->SetLineColor(kRed);
116 hResponse_b_2->SetLineColor(kBlack);
117
118 hResponse_dead_1->Rebin(rebin);
119 hResponse_dead_2->Rebin(rebin);
120 hResponse_dead_1->SetAxisRange(rmin, rmax, "X");
121 hResponse_dead_2->SetAxisRange(rmin, rmax, "X");
122 hResponse_dead_1->SetLineWidth(2);
123 hResponse_dead_2->SetLineWidth(2);
124 hResponse_dead_1->SetLineColor(kRed);
125 hResponse_dead_2->SetLineColor(kBlack);
126
127 //// Gauss
128 double RMS = hResponse_tot_1->GetRMS();
129 double MEAN = hResponse_tot_1->GetMean();
130 TF1* fitfunction_1 = new TF1("f1", "gaus(0)", MEAN-3*RMS, MEAN+3*RMS);
131 fitfunction_1->SetParameters(hResponse_tot_1->GetMaximum(), MEAN, RMS);
132 hResponse_tot_1->Fit(fitfunction_1, "ILRQN");
133 fitfunction_1->SetRange(rmin, rmax);
134 fitfunction_1->SetLineWidth(1);
135 fitfunction_1->SetLineColor(kRed);
136 fitfunction_1->Draw("same");
137 cout << "Sigma of gaussian: " << fitfunction_1->GetParameter(2) << "+-" << fitfunction_1->GetParError(2) << endl;
138
139 RMS = hResponse_tot_2->GetRMS();
140 MEAN = hResponse_tot_2->GetMean();
141 TF1* fitfunction_2 = new TF1("f2", "gaus(0)", MEAN-3*RMS, MEAN+3*RMS);
142 fitfunction_2->SetParameters(hResponse_tot_2->GetMaximum(), MEAN, RMS);
143 hResponse_tot_2->Fit(fitfunction_2, "ILRQN");
144 fitfunction_2->SetRange(rmin, rmax);
145 fitfunction_2->SetLineWidth(1);
146 fitfunction_2->SetLineColor(kBlack);
147 fitfunction_2->Draw("same");
148
149 leg = new TLegend(0.22,0.6,0.6,0.88);
150 leg->SetFillStyle(0);
151 leg->AddEntry(hResponse_tot_1, "MC response dR = 0.1","lep");
152 leg->AddEntry(hResponse_tot_2, "MC response dR = 0.2","lep");
153 leg->AddEntry(fitfunction_1, "Gaussian dR = 0.1","l");
154 leg->AddEntry(fitfunction_2, "Gaussian dR = 0.2","l");
155 leg->Draw("same");
156
157 b->Update();
158
159 }