Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
plotQA_cosmic_TowerCalib.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file plotQA_cosmic_TowerCalib.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_TowerCalib(const string det = "HCALOUT")
10 {
11  int hbdchanIHC[4][4] = {{16, 12, 8, 4},
12  {15, 11, 7, 3},
13  {14, 10, 6, 2},
14  {13, 9, 5, 1}};
15 
16  float sim_out_start[4] = {6.1,5.9,5.5,5.5};
17  float sim_out_stop[4] = {15.0,15.0,15.0,15.0};
18  float raw_out_start[4] = {1000.0,500.0,1000.0,1000.0};
19  float raw_out_stop[4] = {5000.0,2500.0,6000.0,5000.0};
20 
21  float energy[16] = {-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0};
22  float adc[16] = {-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0};
23  // float tower_calib[16] = {-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0};
24 
25  /*
26  string inputfile_sim = Form("/sphenix/user/xusun/software/data/cosmic/TowerCalibAna/Proto4TowerInfoSIM_%s.root",det.c_str());
27  TFile *File_InPut_SIM = TFile::Open(inputfile_sim.c_str());
28 
29  TH1F *h_hcal_tower_sim[16];
30  TF1 *f_landau_hcal_sim[16];
31  for(int i_tower = 0; i_tower < 16; ++i_tower)
32  {
33  string HistName = Form("h_m%s_SIM_twr_%d",det.c_str(),i_tower);
34  h_hcal_tower_sim[i_tower] = (TH1F*)File_InPut_SIM->Get(HistName.c_str())->Clone();
35  string FuncName = Form("f_m%s_SIM_twr_%d",det.c_str(),i_tower);
36  f_landau_hcal_sim[i_tower] = new TF1(FuncName.c_str(),"landau",0,20);
37  }
38 
39  TCanvas *c_hcal_sim = new TCanvas("c_hcal_sim","c_hcal_sim",10,10,1600,1600);
40  c_hcal_sim->Divide(4,4);
41  for(int i_row = 0; i_row < 4; ++i_row)
42  {
43  for(int i_col = 0; i_col < 4; ++i_col)
44  {
45  int i_pad = 4*i_row+i_col+1;
46  int i_tower = hbdchanIHC[i_row][i_col]-1;
47  c_hcal_sim->cd(i_pad);
48  h_hcal_tower_sim[i_tower]->GetXaxis()->SetRangeUser(2,20);
49  h_hcal_tower_sim[i_tower]->Draw();
50 
51  for(int i_par = 0; i_par < 3; ++i_par)
52  {
53  f_landau_hcal_sim[i_tower]->ReleaseParameter(i_par);
54  }
55  f_landau_hcal_sim[i_tower]->SetParameter(0,10.0);
56  f_landau_hcal_sim[i_tower]->SetParameter(1,10.0);
57  f_landau_hcal_sim[i_tower]->SetParameter(2,10.0);
58  if(det == "HCALIN") f_landau_hcal_sim[i_tower]->SetRange(5.0,15.0);
59  if(det == "HCALOUT") f_landau_hcal_sim[i_tower]->SetRange(sim_out_start[i_row],sim_out_stop[i_row]);
60  if(h_hcal_tower_sim[i_tower]->GetEntries() > 100)
61  {
62  h_hcal_tower_sim[i_tower]->Fit(f_landau_hcal_sim[i_tower],"R");
63  energy[i_tower] = f_landau_hcal_sim[i_tower]->GetParameter(1)/1000.0; // convert to GeV
64  string lable = Form("MPV %1.2f",f_landau_hcal_sim[i_tower]->GetParameter(1));
65  TLegend *leg = new TLegend(0.4,0.5,0.8,0.8);
66  leg->SetFillColor(0);
67  leg->SetBorderSize(0);
68  leg->AddEntry(h_hcal_tower_sim[i_tower],lable.c_str(),"L");
69  leg->Draw("same");
70  }
71  }
72  }
73  string fig_sim = Form("./figures/sPHENIX_CollMeeting/c_%s_sim.eps",det.c_str());
74  c_hcal_sim->SaveAs(fig_sim.c_str());
75  */
76 
77  string inputfile_raw = Form("/sphenix/user/xusun/TestBeam/TowerCalibAna/Proto4TowerInfoRAW_%s.root",det.c_str());
78  TFile *File_InPut_RAW = TFile::Open(inputfile_raw.c_str());
79 
80  TH1F *h_hcal_tower_raw[16];
81  TF1 *f_landau_hcal_raw[16];
82  for(int i_tower = 0; i_tower < 16; ++i_tower)
83  {
84  string HistName = Form("h_m%s_RAW_twr_%d",det.c_str(),i_tower);
85  h_hcal_tower_raw[i_tower] = (TH1F*)File_InPut_RAW->Get(HistName.c_str())->Clone();
86  string FuncName = Form("f_m%s_RAW_twr_%d",det.c_str(),i_tower);
87  f_landau_hcal_raw[i_tower] = new TF1(FuncName.c_str(),"landau",0,16000);
88  }
89 
90  TCanvas *c_hcal_raw = new TCanvas("c_hcal_raw","c_hcal_raw",10,10,1600,1600);
91  c_hcal_raw->Divide(4,4);
92  for(int i_row = 0; i_row < 4; ++i_row)
93  {
94  for(int i_col = 0; i_col < 4; ++i_col)
95  {
96  int i_pad = 4*i_row+i_col+1;
97  int i_tower = hbdchanIHC[i_row][i_col]-1;
98  c_hcal_raw->cd(i_pad);
99  h_hcal_tower_raw[i_tower]->Draw();
100 
101  for(int i_par = 0; i_par < 3; ++i_par)
102  {
103  f_landau_hcal_raw[i_tower]->ReleaseParameter(i_par);
104  }
105  f_landau_hcal_raw[i_tower]->SetParameter(0,10.0);
106  f_landau_hcal_raw[i_tower]->SetParameter(1,10.0);
107  f_landau_hcal_raw[i_tower]->SetParameter(2,10.0);
108  if(det == "HCALIN") f_landau_hcal_raw[i_tower]->SetRange(2000.0,8000.0);
109  if(det == "HCALOUT") f_landau_hcal_raw[i_tower]->SetRange(raw_out_start[i_row],raw_out_stop[i_row]);
110  if(h_hcal_tower_raw[i_tower]->GetEntries() > 100)
111  {
112  h_hcal_tower_raw[i_tower]->Fit(f_landau_hcal_raw[i_tower],"R");
113  adc[i_tower] = f_landau_hcal_raw[i_tower]->GetParameter(1);
114  string lable = Form("MPV %4.1f",f_landau_hcal_raw[i_tower]->GetParameter(1));
115  TLegend *leg = new TLegend(0.4,0.5,0.8,0.8);
116  leg->SetFillColor(0);
117  leg->SetBorderSize(0);
118  leg->AddEntry(h_hcal_tower_raw[i_tower],lable.c_str(),"L");
119  leg->Draw("same");
120  }
121  }
122  }
123  string fig_raw = Form("./figures/HCAL_TowerMap/c_%s_raw.eps",det.c_str());
124  c_hcal_raw->SaveAs(fig_raw.c_str());
125 
126  /*
127  string outputfile = Form("towercalib_%s.txt",det.c_str());
128  ofstream File_OutPut(outputfile.c_str());
129  for(int i_tower = 0; i_tower < 16; ++i_tower)
130  {
131  File_OutPut << det.c_str() << "_Tower_" << i_tower << ": energy = " << energy[i_tower] << ", adc = " << adc[i_tower]<< endl;
132  }
133  File_OutPut.close();
134  */
135 }