Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
extractLevelingPar.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file extractLevelingPar.C
1 #include <string>
2 #include <TString.h>
3 #include <TFile.h>
4 #include <TH2F.h>
5 #include <TH1F.h>
6 #include <TF1.h>
7 #include <TCanvas.h>
8 #include <TGraphAsymmErrors.h>
9 #include <TProfile.h>
10 #include <TLine.h>
11 
13 {
14  string input_5GeV = "/sphenix/user/xusun/TestBeam/ShowerCalibAna/Proto4ShowerInfoRAW_1087.root"; // 5 GeV
15  TFile *File_5GeV = TFile::Open(input_5GeV.c_str());
16  TH2F *h_mAsymmEnergy_pion_5GeV = (TH2F*)File_5GeV->Get("h_mAsymmEnergy_pion_balancing");
17  TProfile *p_mAsymmEnergy_pion_5GeV = h_mAsymmEnergy_pion_5GeV->ProfileX("p_mAsymmEnergy_pion_5GeV",1,-1,"i");
18  p_mAsymmEnergy_pion_5GeV->SetMarkerStyle(20);
19  p_mAsymmEnergy_pion_5GeV->SetMarkerColor(1);
20  p_mAsymmEnergy_pion_5GeV->SetMarkerSize(1.0);
21 
22  string input_8GeV = "/sphenix/user/xusun/TestBeam/ShowerCalibAna/Proto4ShowerInfoRAW_0422.root"; // 8 GeV
23  TFile *File_8GeV = TFile::Open(input_8GeV.c_str());
24  TH2F *h_mAsymmEnergy_pion_8GeV = (TH2F*)File_8GeV->Get("h_mAsymmEnergy_pion_balancing");
25  TProfile *p_mAsymmEnergy_pion_8GeV = h_mAsymmEnergy_pion_8GeV->ProfileX("p_mAsymmEnergy_pion_8GeV",1,-1,"i");
26  p_mAsymmEnergy_pion_8GeV->SetMarkerStyle(20);
27  p_mAsymmEnergy_pion_8GeV->SetMarkerColor(1);
28  p_mAsymmEnergy_pion_8GeV->SetMarkerSize(1.0);
29 
30  string input_12GeV = "/sphenix/user/xusun/TestBeam/ShowerCalibAna/Proto4ShowerInfoRAW_0571.root"; // 12 GeV
31  TFile *File_12GeV = TFile::Open(input_12GeV.c_str());
32  TH2F *h_mAsymmEnergy_pion_12GeV = (TH2F*)File_12GeV->Get("h_mAsymmEnergy_pion_balancing");
33  TProfile *p_mAsymmEnergy_pion_12GeV = h_mAsymmEnergy_pion_12GeV->ProfileX("p_mAsymmEnergy_pion_12GeV",1,-1,"i");
34  p_mAsymmEnergy_pion_12GeV->SetMarkerStyle(20);
35  p_mAsymmEnergy_pion_12GeV->SetMarkerColor(1);
36  p_mAsymmEnergy_pion_12GeV->SetMarkerSize(1.0);
37 
38  float fit_start = -0.8;
39  float fit_stop = 0.8;
40  TCanvas *c_AsymmEnergy = new TCanvas("c_AsymmEnergy","c_AsymmEnergy",1500,500);
41  c_AsymmEnergy->Divide(3,1);
42  for(int i_pad = 0; i_pad < 3; ++i_pad)
43  {
44  c_AsymmEnergy->cd(i_pad+1);
45  c_AsymmEnergy->cd(i_pad+1)->SetLeftMargin(0.15);
46  c_AsymmEnergy->cd(i_pad+1)->SetBottomMargin(0.15);
47  c_AsymmEnergy->cd(i_pad+1)->SetTicks(1,1);
48  c_AsymmEnergy->cd(i_pad+1)->SetGrid(0,0);
49  }
50 
51  c_AsymmEnergy->cd(1);
52  h_mAsymmEnergy_pion_5GeV->Draw("colz");
53  p_mAsymmEnergy_pion_5GeV->Draw("pE same");
54  TF1 *f_pol_5GeV = new TF1("f_pol_5GeV","pol1",-1.0,1.0);
55  f_pol_5GeV->SetRange(fit_start,fit_stop);
56  p_mAsymmEnergy_pion_5GeV->Fit(f_pol_5GeV,"NR");
57  f_pol_5GeV->SetLineColor(2);
58  f_pol_5GeV->SetLineWidth(4);
59  f_pol_5GeV->SetLineStyle(2);
60  f_pol_5GeV->Draw("l same");
61  string formula_5GeV = Form("%2.2f#timesE_{Asymm}+%2.2f",f_pol_5GeV->GetParameter(1),f_pol_5GeV->GetParameter(0));
62  const float c_in_5GeV = f_pol_5GeV->Eval(0.0)/f_pol_5GeV->Eval(1.0);
63  const float c_out_5GeV = f_pol_5GeV->Eval(0.0)/f_pol_5GeV->Eval(-1.0);
64 
65  TLegend *leg_5GeV = new TLegend(0.35,0.7,0.75,0.85);
66  leg_5GeV->SetBorderSize(0);
67  leg_5GeV->SetFillColor(10);
68  leg_5GeV->AddEntry(h_mAsymmEnergy_pion_5GeV,"5 GeV","h");
69  leg_5GeV->AddEntry(f_pol_5GeV,formula_5GeV.c_str(),"l");
70  leg_5GeV->Draw();
71 
72  c_AsymmEnergy->cd(2);
73  h_mAsymmEnergy_pion_8GeV->Draw("colz");
74  p_mAsymmEnergy_pion_8GeV->Draw("pE same");
75  TF1 *f_pol_8GeV = new TF1("f_pol_8GeV","pol1",-1.0,1.0);
76  f_pol_8GeV->SetRange(fit_start,fit_stop);
77  p_mAsymmEnergy_pion_8GeV->Fit(f_pol_8GeV,"NR");
78  f_pol_8GeV->SetLineColor(2);
79  f_pol_8GeV->SetLineWidth(4);
80  f_pol_8GeV->SetLineStyle(2);
81  f_pol_8GeV->Draw("l same");
82  string formula_8GeV = Form("%2.2f#timesE_{Asymm}+%2.2f",f_pol_8GeV->GetParameter(1),f_pol_8GeV->GetParameter(0));
83  const float c_in_8GeV = f_pol_8GeV->Eval(0.0)/f_pol_8GeV->Eval(1.0);
84  const float c_out_8GeV = f_pol_8GeV->Eval(0.0)/f_pol_8GeV->Eval(-1.0);
85 
86  TLegend *leg_8GeV = new TLegend(0.35,0.7,0.75,0.85);
87  leg_8GeV->SetBorderSize(0);
88  leg_8GeV->SetFillColor(10);
89  leg_8GeV->AddEntry(h_mAsymmEnergy_pion_8GeV,"8 GeV","h");
90  leg_8GeV->AddEntry(f_pol_8GeV,formula_8GeV.c_str(),"l");
91  leg_8GeV->Draw();
92 
93  c_AsymmEnergy->cd(3);
94  h_mAsymmEnergy_pion_12GeV->Draw("colz");
95  p_mAsymmEnergy_pion_12GeV->Draw("pE same");
96  TF1 *f_pol_12GeV = new TF1("f_pol_12GeV","pol1",-1.0,1.0);
97  f_pol_12GeV->SetRange(fit_start,fit_stop);
98  p_mAsymmEnergy_pion_12GeV->Fit(f_pol_12GeV,"NR");
99  f_pol_12GeV->SetLineColor(2);
100  f_pol_12GeV->SetLineWidth(4);
101  f_pol_12GeV->SetLineStyle(2);
102  f_pol_12GeV->Draw("l same");
103  string formula_12GeV = Form("%2.2f#timesE_{Asymm}+%2.2f",f_pol_12GeV->GetParameter(1),f_pol_12GeV->GetParameter(0));
104  const float c_in_12GeV = f_pol_12GeV->Eval(0.0)/f_pol_12GeV->Eval(1.0);
105  const float c_out_12GeV = f_pol_12GeV->Eval(0.0)/f_pol_12GeV->Eval(-1.0);
106 
107  TLegend *leg_12GeV = new TLegend(0.35,0.7,0.75,0.85);
108  leg_12GeV->SetBorderSize(0);
109  leg_12GeV->SetFillColor(10);
110  leg_12GeV->AddEntry(h_mAsymmEnergy_pion_12GeV,"12 GeV","h");
111  leg_12GeV->AddEntry(f_pol_12GeV,formula_12GeV.c_str(),"l");
112  leg_12GeV->Draw();
113 
114  c_AsymmEnergy->SaveAs("../figures/HCAL_ShowerCalib/c_AsymmEnergy_LevelingPar.eps");
115 
116  ofstream File_OutPut("leveling_corr.txt");
117  File_OutPut << "5 GeV: c_in = " << c_in_5GeV << ", c_out = " << c_out_5GeV << endl;
118  File_OutPut << "8 GeV: c_in = " << c_in_8GeV << ", c_out = " << c_out_8GeV << endl;
119  File_OutPut << "12 GeV: c_in = " << c_in_12GeV << ", c_out = " << c_out_12GeV << endl;
120  File_OutPut.close();
121 }