Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
plotQA_noise.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file plotQA_noise.C
1 #include "TString.h"
2 #include "TFile.h"
3 #include "TCanvas.h"
4 #include "TH1F.h"
5 
7 {
8  int hbdchanIHC[4][4] = {{16, 12, 8, 4},
9  {15, 11, 7, 3},
10  {14, 10, 6, 2},
11  {13, 9, 5, 1}};
12 
13  string inputfile = "/sphenix/user/xusun/software/data/cosmic/TowerCalibAna/Proto4TowerInfoRAW_HCALIN_3.root";
14  TFile *File_InPut = TFile::Open(inputfile.c_str());
15 
16  TH1F *h_hcal_tower_calib[16];
17  for(int i_tower = 0; i_tower < 16; ++i_tower)
18  {
19  string HistName = Form("h_mHCALIN_RAW_twr_%d",i_tower);
20  h_hcal_tower_calib[i_tower] = (TH1F*)File_InPut->Get(HistName.c_str())->Clone();
21  h_hcal_tower_calib[i_tower]->Sumw2();
22  }
23 
24  TCanvas *c_hcal = new TCanvas("c_hcal","c_hcal",10,10,1600,1600);
25  c_hcal->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*i_row+i_col+1;
31  int i_tower = hbdchanIHC[i_row][i_col]-1;
32  c_hcal->cd(i_pad);
33  c_hcal->cd(i_pad)->SetLogy();
34  h_hcal_tower_calib[i_tower]->GetYaxis()->SetRangeUser(1.0,500.0);
35  h_hcal_tower_calib[i_tower]->Draw();
36  }
37  }
38 
39  TH1F *h_hcal_noise;
40  for(int i_tower = 0; i_tower < 12; ++i_tower)
41  {
42  if(i_tower == 0) h_hcal_noise = (TH1F*)h_hcal_tower_calib[i_tower]->Clone();
43  else h_hcal_noise->Add(h_hcal_tower_calib[i_tower],1.0);
44  }
45  h_hcal_noise->Scale(1.0/12.0);
46 
47  TH1F *h_hcal_signal;
48  for(int i_tower = 12; i_tower < 16; ++i_tower)
49  {
50  if(i_tower == 12) h_hcal_signal = (TH1F*)h_hcal_tower_calib[i_tower]->Clone();
51  else h_hcal_signal->Add(h_hcal_tower_calib[i_tower],1.0);
52  }
53  h_hcal_signal->Scale(1.0/4.0);
54 
55  TCanvas *c_noise = new TCanvas("c_noise","c_noise",10,10,1600,800);
56  c_noise->Divide(2,1);
57  for(int i_pad = 0; i_pad < 2; ++i_pad)
58  {
59  c_noise->cd(i_pad+1);
60  c_noise->cd(i_pad+1)->SetLeftMargin(0.15);
61  c_noise->cd(i_pad+1)->SetBottomMargin(0.15);
62  c_noise->cd(i_pad+1)->SetTicks(1,1);
63  c_noise->cd(i_pad+1)->SetGrid(0,0);
64  c_noise->cd(i_pad+1)->SetLogy();
65  }
66 
67  c_noise->cd(1);
68  TH1F *h_play = new TH1F("h_play","h_play",500,-0.5,99.5);
69  for(int i_bin = 0; i_bin < 500; ++i_bin)
70  {
71  h_play->SetBinContent(i_bin+1,-10000.0);
72  h_play->SetBinError(i_bin+1,1.0);
73  }
74  h_play->SetStats(0);
75  h_play->SetTitle("cosmic signal");
76  h_play->SetLineColor(1);
77  h_play->GetXaxis()->SetTitle("energy (MeV)");
78  h_play->GetXaxis()->CenterTitle();
79  h_play->GetXaxis()->SetNdivisions(505);
80  h_play->GetYaxis()->SetRangeUser(1.0,500.0);
81  h_play->DrawCopy("h");
82 
83  for(i_tower = 12; i_tower < 16; ++i_tower)
84  {
85  h_hcal_tower_calib[i_tower]->SetStats(0);
86  h_hcal_tower_calib[i_tower]->SetLineColor(i_tower-12+1);
87  h_hcal_tower_calib[i_tower]->GetXaxis()->SetTitle("energy (MeV)");
88  h_hcal_tower_calib[i_tower]->GetXaxis()->CenterTitle();
89  h_hcal_tower_calib[i_tower]->GetXaxis()->SetNdivisions(505);
90  h_hcal_tower_calib[i_tower]->DrawCopy("h same");
91  }
92 
93  c_noise->cd(2);
94  h_hcal_noise->SetStats(0);
95  h_hcal_noise->SetTitle("noise (averaged over all non-triggered towers)");
96  h_hcal_noise->SetLineColor(1);
97  h_hcal_noise->GetXaxis()->SetTitle("energy (MeV)");
98  h_hcal_noise->GetXaxis()->CenterTitle();
99  h_hcal_noise->GetXaxis()->SetNdivisions(505);
100  h_hcal_noise->GetYaxis()->SetRangeUser(1.0,500.0);
101  h_hcal_noise->DrawCopy("h");
102 
103  TCanvas *c_noise_ave = new TCanvas("c_noise_ave","c_noise_ave",10,10,1800,600);
104  c_noise_ave->Divide(3,1);
105  for(int i_pad = 0; i_pad < 3; ++i_pad)
106  {
107  c_noise_ave->cd(i_pad+1);
108  c_noise_ave->cd(i_pad+1)->SetLeftMargin(0.15);
109  c_noise_ave->cd(i_pad+1)->SetBottomMargin(0.15);
110  c_noise_ave->cd(i_pad+1)->SetTicks(1,1);
111  c_noise_ave->cd(i_pad+1)->SetGrid(0,0);
112  c_noise_ave->cd(i_pad+1)->SetLogy();
113  }
114 
115  c_noise_ave->cd(1);
116  h_hcal_signal->SetStats(0);
117  h_hcal_signal->SetTitle("signal (averaged over all triggered towers)");
118  h_hcal_signal->GetXaxis()->SetTitle("energy (MeV)");
119  h_hcal_signal->GetXaxis()->CenterTitle();
120  h_hcal_signal->GetXaxis()->SetNdivisions(505);
121  h_hcal_signal->GetYaxis()->SetRangeUser(1.0,500.0);
122  h_hcal_signal->SetLineColor(2);
123  h_hcal_signal->Draw("h same");
124 
125  c_noise_ave->cd(2);
126  h_hcal_noise->SetStats(0);
127  h_hcal_noise->SetTitle("noise (averaged over all non-triggered towers)");
128  h_hcal_noise->SetLineColor(1);
129  h_hcal_noise->GetXaxis()->SetTitle("energy (MeV)");
130  h_hcal_noise->GetXaxis()->CenterTitle();
131  h_hcal_noise->GetXaxis()->SetNdivisions(505);
132  h_hcal_noise->GetYaxis()->SetRangeUser(1.0,500.0);
133  h_hcal_noise->Draw("h");
134 
135  c_noise_ave->cd(3);
136  c_noise_ave->cd(3)->SetLogy(0);
137  TH1F *h_ratio = (TH1F*)h_hcal_noise->Clone("h_ratio");
138  h_ratio->SetTitle("noise/signal");
139  h_ratio->Divide(h_hcal_signal);
140  // h_ratio->Reset();
141  // h_ratio->Divide(h_hcal_noise,h_hcal_signal,1,1,"B");
142  h_ratio->GetYaxis()->SetRangeUser(-0.2,0.6);
143  h_ratio->GetXaxis()->SetRangeUser(0.0,60.0);
144  h_ratio->SetMarkerStyle(20);
145  h_ratio->SetMarkerColor(1);
146  h_ratio->SetMarkerSize(0.8);
147  h_ratio->Draw("pE");
148 
149  c_hcal->SaveAs("./figures/sPHENIX_CollMeeting/c_cosmic_hcalin.eps");
150  c_noise->SaveAs("./figures/sPHENIX_CollMeeting/c_noise_hcalin.eps");
151  c_noise_ave->SaveAs("./figures/sPHENIX_CollMeeting/c_noise_hcalin_averaged.eps");
152 }