Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
plotQA_cosmic_vertical.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file plotQA_cosmic_vertical.C
1 #include "TFile.h"
2 #include "TString.h"
3 #include "TH1F.h"
4 #include "TCanvas.h"
5 #include "TLegend.h"
6 #include "TF1.h"
7 #include <string>
8 
9 void plotQA_cosmic_vertical(const int colID = 0)
10 {
11  string inputfile_hcalin_sim = "/sphenix/user/xusun/software/data/cosmic/TowerCalibAna/Proto4TowerInfoSIM_HCALIN_0.root";
12  TFile *File_HCALIN_SIM = TFile::Open(inputfile_hcalin_sim.c_str());
13 
14  TH1F *h_hcalin_tower_sim[16];
15  TF1 *f_landau_hcalin_sim[16];
16  for(int i_tower = 0; i_tower < 16; ++i_tower)
17  {
18  string HistName = Form("h_mHCALIN_SIM_twr_%d",i_tower);
19  h_hcalin_tower_sim[i_tower] = (TH1F*)File_HCALIN_SIM->Get(HistName.c_str())->Clone();
20  string FuncName = Form("f_mHCALIN_SIM_twr_%d",i_tower);
21  f_landau_hcalin_sim[i_tower] = new TF1(FuncName.c_str(),"landau",0,20);
22  }
23 
24  TCanvas *c_hcalin_sim = new TCanvas("c_hcalin_sim","c_hcalin_sim",10,10,1600,1600);
25  c_hcalin_sim->Divide(4,4);
26  for(int i_row = 0; i_row < 4; ++i_row)
27  {
28  for(int i_col = 0; i_col < 4; ++i_col)
29  {
30  int i_pad = 4*(4-(i_row+1))+i_col+1;
31  int i_tower = i_row + 4*i_col;
32  c_hcalin_sim->cd(i_pad);
33  h_hcalin_tower_sim[i_tower]->GetXaxis()->SetRangeUser(2,20);
34  h_hcalin_tower_sim[i_tower]->Draw();
35 
36  for(int i_par = 0; i_par < 3; ++i_par)
37  {
38  f_landau_hcalin_sim[i_tower]->ReleaseParameter(i_par);
39  }
40  f_landau_hcalin_sim[i_tower]->SetParameter(0,10.0);
41  f_landau_hcalin_sim[i_tower]->SetParameter(1,10.0);
42  f_landau_hcalin_sim[i_tower]->SetParameter(2,10.0);
43  f_landau_hcalin_sim[i_tower]->SetRange(0,20);
44  if(h_hcalin_tower_sim[i_tower]->GetEntries() > 100)
45  {
46  h_hcalin_tower_sim[i_tower]->Fit(f_landau_hcalin_sim[i_tower],"R");
47  string lable = Form("MPV %1.1f",f_landau_hcalin_sim[i_tower]->GetParameter(1));
48  TLegend *leg = new TLegend(0.4,0.5,0.8,0.8);
49  leg->SetFillColor(0);
50  leg->SetBorderSize(0);
51  leg->AddEntry(h_hcalin_tower_sim[i_tower],lable.c_str(),"L");
52  leg->Draw("same");
53  }
54  }
55  }
56  c_hcalin_sim->SaveAs("./figures/c_hcalin_sim_col_0.eps");
57 
58  string inputfile_hcalin_raw = "/sphenix/user/xusun/software/data/cosmic/TowerCalibAna/Proto4TowerInfoRAW_HCALIN_0.root";
59  TFile *File_HCALIN_RAW = TFile::Open(inputfile_hcalin_raw.c_str());
60 
61  TH1F *h_hcalin_tower_raw[16];
62  TF1 *f_landau_hcalin_raw[16];
63  for(int i_tower = 0; i_tower < 16; ++i_tower)
64  {
65  string HistName = Form("h_mHCALIN_RAW_twr_%d",i_tower);
66  h_hcalin_tower_raw[i_tower] = (TH1F*)File_HCALIN_RAW->Get(HistName.c_str())->Clone();
67  string FuncName = Form("f_mHCALIN_RAW_twr_%d",i_tower);
68  f_landau_hcalin_raw[i_tower] = new TF1(FuncName.c_str(),"landau",0,20);
69  }
70 
71  TCanvas *c_hcalin_raw = new TCanvas("c_hcalin_raw","c_hcalin_raw",10,10,1600,1600);
72  c_hcalin_raw->Divide(4,4);
73  for(int i_row = 0; i_row < 4; ++i_row)
74  {
75  for(int i_col = 0; i_col < 4; ++i_col)
76  {
77  int i_pad = 4*(4-(i_row+1))+i_col+1;
78  int i_tower = i_row + 4*i_col;
79  c_hcalin_raw->cd(i_pad);
80  c_hcalin_raw->cd(i_pad)->SetLogy();
81  h_hcalin_tower_raw[i_tower]->Draw();
82 
83  /*
84  for(int i_par = 0; i_par < 3; ++i_par)
85  {
86  f_landau_hcalin_raw[i_tower]->ReleaseParameter(i_par);
87  }
88  f_landau_hcalin_raw[i_tower]->SetParameter(0,10.0);
89  f_landau_hcalin_raw[i_tower]->SetParameter(1,10.0);
90  f_landau_hcalin_raw[i_tower]->SetParameter(2,10.0);
91  f_landau_hcalin_raw[i_tower]->SetRange(0,20);
92  if(h_hcalin_tower_raw[i_tower]->GetEntries() > 100)
93  {
94  h_hcalin_tower_raw[i_tower]->Fit(f_landau_hcalin_raw[i_tower],"R");
95  string lable = Form("MPV %1.1f",f_landau_hcalin_raw[i_tower]->GetParameter(1));
96  TLegend *leg = new TLegend(0.4,0.5,0.8,0.8);
97  leg->SetFillColor(0);
98  leg->SetBorderSize(0);
99  leg->AddEntry(h_hcalin_tower_raw[i_tower],lable.c_str(),"L");
100  leg->Draw("same");
101  }
102  */
103  }
104  }
105  c_hcalin_raw->SaveAs("./figures/c_hcalin_raw_col_0.eps");
106 
107  /*
108  string inputfile_hcalout = "/sphenix/user/xusun/software/data/cosmic/TowerCalib/Proto4TowerCalib_HCALOUT_00.root";
109  TFile *File_HCALOUT = TFile::Open(inputfile_hcalout.c_str());
110 
111  TH1F *h_hcalout_tower_sim[16];
112  TF1 *f_landau_hcalout[16];
113  for(int i_tower = 0; i_tower < 16; ++i_tower)
114  {
115  string HistName = Form("h_hcalout_tower_%d_sim",i_tower);
116  h_hcalout_tower_sim[i_tower] = (TH1F*)File_HCALOUT->Get(HistName.c_str())->Clone();
117  string FuncName = Form("f_hcalout_tower_%d_sim",i_tower);
118  f_landau_hcalout[i_tower] = new TF1(FuncName.c_str(),"landau",0,20);
119  }
120 
121  TCanvas *c_hcalout = new TCanvas("c_hcalout","c_hcalout",10,10,1600,1600);
122  c_hcalout->Divide(4,4,0,0);
123  for(int i_row = 0; i_row < 4; ++i_row)
124  {
125  for(int i_col = 0; i_col < 4; ++i_col)
126  {
127  int i_pad = 4*(4-(i_row+1))+i_col+1;
128  int i_tower = i_row + 4*i_col;
129  c_hcalout->cd(i_pad);
130  h_hcalout_tower_sim[i_tower]->GetXaxis()->SetRangeUser(2,20);
131  h_hcalout_tower_sim[i_tower]->Draw();
132 
133  for(int i_par = 0; i_par < 3; ++i_par)
134  {
135  f_landau_hcalout[i_tower]->ReleaseParameter(i_par);
136  }
137  f_landau_hcalout[i_tower]->SetParameter(0,10.0);
138  f_landau_hcalout[i_tower]->SetParameter(1,10.0);
139  f_landau_hcalout[i_tower]->SetParameter(2,10.0);
140  f_landau_hcalout[i_tower]->SetRange(0,20);
141  if(h_hcalout_tower_sim[i_tower]->GetEntries() > 0)
142  {
143  h_hcalout_tower_sim[i_tower]->Fit(f_landau_hcalout[i_tower],"R");
144  string lable = Form("MPV %1.1f",f_landau_hcalout[i_tower]->GetParameter(1));
145  TLegend *leg = new TLegend(0.4,0.5,0.8,0.8);
146  leg->SetFillColor(0);
147  leg->SetBorderSize(0);
148  leg->AddEntry(h_hcalout_tower_sim[i_tower],lable.c_str(),"L");
149  leg->Draw("same");
150  }
151  }
152  }
153  c_hcalout->SaveAs("./figures/c_hcalout_vertical.eps");
154  */
155 }