Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
calLevelingCorr.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file calLevelingCorr.C
1 #include <string>
2 #include "TString.h"
3 #include "TFile.h"
4 #include "TH2F.h"
5 #include "TH1F.h"
6 #include "TCanvas.h"
7 #include "TLegend.h"
8 #include "TF1.h"
9 #include <iostream>
10 #include <fstream>
11 
13 {
14  string input_4GeV = "/sphenix/user/xusun/software/data/beam/ShowerCalibAna/4GeV/Proto4ShowerInfoRAW_1241.root";
15  TFile *File_InPut_4GeV = TFile::Open(input_4GeV.c_str());
16  // TH2F *h_mAsymmEnergy_4GeV = (TH2F*)File_InPut_4GeV->Get("h_mAsymmEnergy_mixed_calib_wo_cut");
17  TH2F *h_mAsymmEnergy_4GeV = (TH2F*)File_InPut_4GeV->Get("h_mAsymmEnergy_mixed_calib");
18 
19  string input_8GeV = "/sphenix/user/xusun/software/data/beam/ShowerCalibAna/8GeV/Proto4ShowerInfoRAW_0422.root";
20  TFile *File_InPut_8GeV = TFile::Open(input_8GeV.c_str());
21  // TH2F *h_mAsymmEnergy_8GeV = (TH2F*)File_InPut_8GeV->Get("h_mAsymmEnergy_mixed_calib_wo_cut");
22  TH2F *h_mAsymmEnergy_8GeV = (TH2F*)File_InPut_8GeV->Get("h_mAsymmEnergy_mixed_calib");
23 
24  string input_12GeV = "/sphenix/user/xusun/software/data/beam/ShowerCalibAna/12GeV/Proto4ShowerInfoRAW_0571.root";
25  TFile *File_InPut_12GeV = TFile::Open(input_12GeV.c_str());
26  // TH2F *h_mAsymmEnergy_12GeV = (TH2F*)File_InPut_12GeV->Get("h_mAsymmEnergy_mixed_calib_wo_cut");
27  TH2F *h_mAsymmEnergy_12GeV = (TH2F*)File_InPut_12GeV->Get("h_mAsymmEnergy_mixed_calib");
28 
29  string input_16GeV = "/sphenix/user/xusun/software/data/beam/ShowerCalibAna/16GeV/Proto4ShowerInfoRAW_1683.root";
30  TFile *File_InPut_16GeV = TFile::Open(input_16GeV.c_str());
31  // TH2F *h_mAsymmEnergy_16GeV = (TH2F*)File_InPut_16GeV->Get("h_mAsymmEnergy_mixed_calib_wo_cut");
32  TH2F *h_mAsymmEnergy_16GeV = (TH2F*)File_InPut_16GeV->Get("h_mAsymmEnergy_mixed_calib");
33 
34  string input_24GeV = "/sphenix/user/xusun/software/data/beam/ShowerCalibAna/24GeV/Proto4ShowerInfoRAW_1666.root";
35  TFile *File_InPut_24GeV = TFile::Open(input_24GeV.c_str());
36  // TH2F *h_mAsymmEnergy_24GeV = (TH2F*)File_InPut_24GeV->Get("h_mAsymmEnergy_mixed_calib_wo_cut");
37  TH2F *h_mAsymmEnergy_24GeV = (TH2F*)File_InPut_24GeV->Get("h_mAsymmEnergy_mixed_calib");
38 
39  string input_30GeV = "/sphenix/user/xusun/software/data/beam/ShowerCalibAna/30GeV/Proto4ShowerInfoRAW_1684.root";
40  TFile *File_InPut_30GeV = TFile::Open(input_30GeV.c_str());
41  // TH2F *h_mAsymmEnergy_30GeV = (TH2F*)File_InPut_30GeV->Get("h_mAsymmEnergy_mixed_calib_wo_cut");
42  TH2F *h_mAsymmEnergy_30GeV = (TH2F*)File_InPut_30GeV->Get("h_mAsymmEnergy_mixed_calib");
43 
44  TCanvas *c_play = new TCanvas("c_play","c_play",800,1200);
45  c_play->Divide(2,3);
46  for(int i_pad = 0; i_pad < 6; ++i_pad)
47  {
48  c_play->cd(i_pad+1);
49  c_play->cd(i_pad+1)->SetLeftMargin(0.15);
50  c_play->cd(i_pad+1)->SetBottomMargin(0.15);
51  c_play->cd(i_pad+1)->SetTicks(1,1);
52  c_play->cd(i_pad+1)->SetGrid(0,0);
53  }
54  float fit_start = -0.8;
55  float fit_stop = 0.2;
56  string energy_cut = "E_{in} > 0.2 GeV & E_{out} > 0.2 GeV";
57 
58  c_play->cd(1);
59  h_mAsymmEnergy_4GeV->SetStats(0);
60  h_mAsymmEnergy_4GeV->SetTitle(energy_cut.c_str());
61  h_mAsymmEnergy_4GeV->GetYaxis()->SetTitle("Energy (GeV)");
62  h_mAsymmEnergy_4GeV->GetYaxis()->CenterTitle();
63  h_mAsymmEnergy_4GeV->GetYaxis()->SetNdivisions(505);
64  h_mAsymmEnergy_4GeV->GetXaxis()->SetTitle("E_{Asymm}");
65  h_mAsymmEnergy_4GeV->GetXaxis()->CenterTitle();
66  h_mAsymmEnergy_4GeV->Draw("colz");
67  TF1 *f_pol_4GeV = new TF1("f_pol_4GeV","pol1",fit_start,fit_stop);
68  h_mAsymmEnergy_4GeV->Fit(f_pol_4GeV,"NR");
69 
70  f_pol_4GeV->SetLineColor(1);
71  f_pol_4GeV->SetLineWidth(4);
72  f_pol_4GeV->SetLineStyle(2);
73  f_pol_4GeV->Draw("l same");
74 
75  string formula_4GeV = Form("%2.2f#timesE_{Asymm}+%2.2f",f_pol_4GeV->GetParameter(1),f_pol_4GeV->GetParameter(0));
76 
77  const float c_in_4GeV = f_pol_4GeV->Eval(0.0)/f_pol_4GeV->Eval(1.0);
78  const float c_out_4GeV = f_pol_4GeV->Eval(0.0)/f_pol_4GeV->Eval(-1.0);
79 
80  TLegend *leg_4GeV = new TLegend(0.35,0.7,0.75,0.85);
81  leg_4GeV->SetBorderSize(0);
82  leg_4GeV->SetFillColor(10);
83  leg_4GeV->AddEntry(h_mAsymmEnergy_4GeV,"4 GeV","h");
84  leg_4GeV->AddEntry(f_pol_4GeV,formula_4GeV.c_str(),"l");
85  leg_4GeV->Draw();
86 
87  c_play->cd(2);
88  h_mAsymmEnergy_8GeV->SetStats(0);
89  h_mAsymmEnergy_8GeV->SetTitle(energy_cut.c_str());
90  h_mAsymmEnergy_8GeV->GetYaxis()->SetTitle("Energy (GeV)");
91  h_mAsymmEnergy_8GeV->GetYaxis()->CenterTitle();
92  h_mAsymmEnergy_8GeV->GetYaxis()->SetNdivisions(505);
93  h_mAsymmEnergy_8GeV->GetXaxis()->SetTitle("E_{Asymm}");
94  h_mAsymmEnergy_8GeV->GetXaxis()->CenterTitle();
95  h_mAsymmEnergy_8GeV->Draw("colz");
96  TF1 *f_pol_8GeV = new TF1("f_pol_8GeV","pol1",fit_start,fit_stop);
97  h_mAsymmEnergy_8GeV->Fit(f_pol_8GeV,"NR");
98  f_pol_8GeV->SetLineColor(1);
99  f_pol_8GeV->SetLineWidth(4);
100  f_pol_8GeV->SetLineStyle(2);
101  f_pol_8GeV->Draw("l same");
102 
103  string formula_8GeV = Form("%2.2f#timesE_{Asymm}+%2.2f",f_pol_8GeV->GetParameter(1),f_pol_8GeV->GetParameter(0));
104 
105  const float c_in_8GeV = f_pol_8GeV->Eval(0.0)/f_pol_8GeV->Eval(1.0);
106  const float c_out_8GeV = f_pol_8GeV->Eval(0.0)/f_pol_8GeV->Eval(-1.0);
107 
108  TLegend *leg_8GeV = new TLegend(0.35,0.7,0.75,0.85);
109  leg_8GeV->SetBorderSize(0);
110  leg_8GeV->SetFillColor(10);
111  leg_8GeV->AddEntry(h_mAsymmEnergy_8GeV,"8 GeV","h");
112  leg_8GeV->AddEntry(f_pol_8GeV,formula_8GeV.c_str(),"l");
113  leg_8GeV->Draw();
114 
115  c_play->cd(3);
116  h_mAsymmEnergy_12GeV->SetStats(0);
117  h_mAsymmEnergy_12GeV->SetTitle(energy_cut.c_str());
118  h_mAsymmEnergy_12GeV->GetYaxis()->SetTitle("Energy (GeV)");
119  h_mAsymmEnergy_12GeV->GetYaxis()->CenterTitle();
120  h_mAsymmEnergy_12GeV->GetYaxis()->SetNdivisions(505);
121  h_mAsymmEnergy_12GeV->GetXaxis()->SetTitle("E_{Asymm}");
122  h_mAsymmEnergy_12GeV->GetXaxis()->CenterTitle();
123  h_mAsymmEnergy_12GeV->Draw("colz");
124  TF1 *f_pol_12GeV = new TF1("f_pol_12GeV","pol1",fit_start,fit_stop);
125  h_mAsymmEnergy_12GeV->Fit(f_pol_12GeV,"NR");
126  f_pol_12GeV->SetLineColor(1);
127  f_pol_12GeV->SetLineWidth(4);
128  f_pol_12GeV->SetLineStyle(2);
129  f_pol_12GeV->Draw("l same");
130 
131  string formula_12GeV = Form("%2.2f#timesE_{Asymm}+%2.2f",f_pol_12GeV->GetParameter(1),f_pol_12GeV->GetParameter(0));
132 
133  const float c_in_12GeV = f_pol_12GeV->Eval(0.0)/f_pol_12GeV->Eval(1.0);
134  const float c_out_12GeV = f_pol_12GeV->Eval(0.0)/f_pol_12GeV->Eval(-1.0);
135 
136  TLegend *leg_12GeV = new TLegend(0.35,0.7,0.75,0.85);
137  leg_12GeV->SetBorderSize(0);
138  leg_12GeV->SetFillColor(10);
139  leg_12GeV->AddEntry(h_mAsymmEnergy_12GeV,"12 GeV","h");
140  leg_12GeV->AddEntry(f_pol_12GeV,formula_12GeV.c_str(),"l");
141  leg_12GeV->Draw();
142 
143  c_play->cd(4);
144  h_mAsymmEnergy_16GeV->SetStats(0);
145  h_mAsymmEnergy_16GeV->SetTitle(energy_cut.c_str());
146  h_mAsymmEnergy_16GeV->GetYaxis()->SetTitle("Energy (GeV)");
147  h_mAsymmEnergy_16GeV->GetYaxis()->CenterTitle();
148  h_mAsymmEnergy_16GeV->GetYaxis()->SetNdivisions(505);
149  h_mAsymmEnergy_16GeV->GetXaxis()->SetTitle("E_{Asymm}");
150  h_mAsymmEnergy_16GeV->GetXaxis()->CenterTitle();
151  h_mAsymmEnergy_16GeV->Draw("colz");
152  TF1 *f_pol_16GeV = new TF1("f_pol_16GeV","pol1",fit_start,fit_stop);
153  h_mAsymmEnergy_16GeV->Fit(f_pol_16GeV,"NR");
154  f_pol_16GeV->SetLineColor(1);
155  f_pol_16GeV->SetLineWidth(4);
156  f_pol_16GeV->SetLineStyle(2);
157  f_pol_16GeV->Draw("l same");
158 
159  string formula_16GeV = Form("%2.2f#timesE_{Asymm}+%2.2f",f_pol_16GeV->GetParameter(1),f_pol_16GeV->GetParameter(0));
160 
161  const float c_in_16GeV = f_pol_16GeV->Eval(0.0)/f_pol_16GeV->Eval(1.0);
162  const float c_out_16GeV = f_pol_16GeV->Eval(0.0)/f_pol_16GeV->Eval(-1.0);
163 
164  TLegend *leg_16GeV = new TLegend(0.35,0.7,0.75,0.85);
165  leg_16GeV->SetBorderSize(0);
166  leg_16GeV->SetFillColor(10);
167  leg_16GeV->AddEntry(h_mAsymmEnergy_16GeV,"16 GeV","h");
168  leg_16GeV->AddEntry(f_pol_16GeV,formula_16GeV.c_str(),"l");
169  leg_16GeV->Draw();
170 
171  c_play->cd(5);
172  h_mAsymmEnergy_24GeV->SetStats(0);
173  h_mAsymmEnergy_24GeV->SetTitle(energy_cut.c_str());
174  h_mAsymmEnergy_24GeV->GetYaxis()->SetTitle("Energy (GeV)");
175  h_mAsymmEnergy_24GeV->GetYaxis()->CenterTitle();
176  h_mAsymmEnergy_24GeV->GetYaxis()->SetNdivisions(505);
177  h_mAsymmEnergy_24GeV->GetXaxis()->SetTitle("E_{Asymm}");
178  h_mAsymmEnergy_24GeV->GetXaxis()->CenterTitle();
179  h_mAsymmEnergy_24GeV->Draw("colz");
180  TF1 *f_pol_24GeV = new TF1("f_pol_24GeV","pol1",fit_start,fit_stop);
181  h_mAsymmEnergy_24GeV->Fit(f_pol_24GeV,"NR");
182  f_pol_24GeV->SetLineColor(1);
183  f_pol_24GeV->SetLineWidth(4);
184  f_pol_24GeV->SetLineStyle(2);
185  f_pol_24GeV->Draw("l same");
186 
187  string formula_24GeV = Form("%2.2f#timesE_{Asymm}+%2.2f",f_pol_24GeV->GetParameter(1),f_pol_24GeV->GetParameter(0));
188 
189  const float c_in_24GeV = f_pol_24GeV->Eval(0.0)/f_pol_24GeV->Eval(1.0);
190  const float c_out_24GeV = f_pol_24GeV->Eval(0.0)/f_pol_24GeV->Eval(-1.0);
191 
192  TLegend *leg_24GeV = new TLegend(0.35,0.7,0.75,0.85);
193  leg_24GeV->SetBorderSize(0);
194  leg_24GeV->SetFillColor(10);
195  leg_24GeV->AddEntry(h_mAsymmEnergy_24GeV,"24 GeV","h");
196  leg_24GeV->AddEntry(f_pol_24GeV,formula_24GeV.c_str(),"l");
197  leg_24GeV->Draw();
198 
199  c_play->cd(6);
200  h_mAsymmEnergy_30GeV->SetStats(0);
201  h_mAsymmEnergy_30GeV->SetTitle(energy_cut.c_str());
202  h_mAsymmEnergy_30GeV->GetYaxis()->SetTitle("Energy (GeV)");
203  h_mAsymmEnergy_30GeV->GetYaxis()->CenterTitle();
204  h_mAsymmEnergy_30GeV->GetYaxis()->SetNdivisions(505);
205  h_mAsymmEnergy_30GeV->GetXaxis()->SetTitle("E_{Asymm}");
206  h_mAsymmEnergy_30GeV->GetXaxis()->CenterTitle();
207  h_mAsymmEnergy_30GeV->Draw("colz");
208  TF1 *f_pol_30GeV = new TF1("f_pol_30GeV","pol1",fit_start,fit_stop);
209  h_mAsymmEnergy_30GeV->Fit(f_pol_30GeV,"NR");
210  f_pol_30GeV->SetLineColor(1);
211  f_pol_30GeV->SetLineWidth(4);
212  f_pol_30GeV->SetLineStyle(2);
213  f_pol_30GeV->Draw("l same");
214  string formula_30GeV = Form("%2.2f#timesE_{Asymm}+%2.2f",f_pol_30GeV->GetParameter(1),f_pol_30GeV->GetParameter(0));
215 
216  const float c_in_30GeV = f_pol_30GeV->Eval(0.0)/f_pol_30GeV->Eval(1.0);
217  const float c_out_30GeV = f_pol_30GeV->Eval(0.0)/f_pol_30GeV->Eval(-1.0);
218 
219  TLegend *leg_30GeV = new TLegend(0.35,0.7,0.75,0.85);
220  leg_30GeV->SetBorderSize(0);
221  leg_30GeV->SetFillColor(10);
222  leg_30GeV->AddEntry(h_mAsymmEnergy_30GeV,"30 GeV","h");
223  leg_30GeV->AddEntry(f_pol_30GeV,formula_30GeV.c_str(),"l");
224  leg_30GeV->Draw();
225 
226  string fig_Name = "./figures/sPHENIX_CollMeeting/c_mAsymmEnergy_mixed.eps";
227  c_play->SaveAs(fig_Name.c_str());
228 
229  ofstream File_OutPut("leveling_corr.txt");
230  File_OutPut << "4 GeV: c_in = " << c_in_4GeV << ", c_out = " << c_out_4GeV << endl;
231  File_OutPut << "8 GeV: c_in = " << c_in_8GeV << ", c_out = " << c_out_8GeV << endl;
232  File_OutPut << "12 GeV: c_in = " << c_in_12GeV << ", c_out = " << c_out_12GeV << endl;
233  File_OutPut << "16 GeV: c_in = " << c_in_16GeV << ", c_out = " << c_out_16GeV << endl;
234  File_OutPut << "24 GeV: c_in = " << c_in_24GeV << ", c_out = " << c_out_24GeV << endl;
235  File_OutPut << "30 GeV: c_in = " << c_in_30GeV << ", c_out = " << c_out_30GeV << endl;
236  File_OutPut.close();
237 }