Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
plotQA_cosmic_XY.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file plotQA_cosmic_XY.C
1 #include <string>
2 #include "TString.h"
3 #include "TFile.h"
4 #include "TCanvas.h"
5 #include "TH1F.h"
6 #include "TH3F.h"
7 #include "TLegend.h"
8 
10 {
11  string inputdir = "Cosmic_orig";
12  // string inputdir = "Cosmic_Scint";
13  // string inputdir = "BeamTest_SF_orig";
14  // string inputdir = "BeamTest_SF_Scint";
15  string inputfile_in = Form("./OutPut/SampleFrac/%s/Proto4SampleFrac_HCALIN.root",inputdir.c_str());
16  TFile *File_HCALIN = TFile::Open(inputfile_in.c_str());
17  TH2F *h_in_cal = (TH2F*)File_HCALIN->Get("h_QAG4Sim_HCALIN_G4Hit_XY_cal");
18  TH2F *h_in_abs = (TH2F*)File_HCALIN->Get("h_QAG4Sim_HCALIN_G4Hit_XY_abs");
19  TH1F *h_in_sf = (TH1F*)File_HCALIN->Get("h_QAG4Sim_HCALIN_G4Hit_SF");
20 
21  string inputfile_out = Form("./OutPut/SampleFrac/%s/Proto4SampleFrac_HCALOUT.root",inputdir.c_str());
22  TFile *File_HCALOUT = TFile::Open(inputfile_out.c_str());
23  TH2F *h_out_cal = (TH2F*)File_HCALOUT->Get("h_QAG4Sim_HCALOUT_G4Hit_XY_cal");
24  TH2F *h_out_abs = (TH2F*)File_HCALOUT->Get("h_QAG4Sim_HCALOUT_G4Hit_XY_abs");
25  TH1F *h_out_sf = (TH1F*)File_HCALOUT->Get("h_QAG4Sim_HCALOUT_G4Hit_SF");
26 
27  TH2F *h_cal = (TH2F*)h_in_cal->Clone("h_cal");
28  h_cal->Add(h_out_cal,1.0);
29 
30  TH2F *h_abs = (TH2F*)h_in_abs->Clone("h_abs");
31  h_abs->Add(h_out_abs,1.0);
32 
33  TH1F *h_play = new TH1F("h_play","h_play",500,0,500);
34  for(int i_bin = 0; i_bin < 500; ++i_bin)
35  {
36  h_play->SetBinContent(i_bin+1,-10000.0);
37  h_play->SetBinError(i_bin+1,1.0);
38  }
39  // h_play->SetTitle("G4Hit Display");
40  h_play->SetStats(0);
41  h_play->GetYaxis()->SetRangeUser(-100,100);
42  h_play->GetXaxis()->SetRangeUser(50,350);
43 
44  TCanvas *c_cal = new TCanvas("c_cal","c_cal",10,10,1500,500);
45  c_cal->Divide(3,1);
46  for(int i_pad = 0; i_pad < 3; ++i_pad)
47  {
48  c_cal->cd(i_pad+1)->SetLeftMargin(0.15);
49  c_cal->cd(i_pad+1)->SetBottomMargin(0.15);
50  c_cal->cd(i_pad+1)->SetGrid(0,0);
51  c_cal->cd(i_pad+1)->SetTicks(1,1);
52  }
53 
54  c_cal->cd(1);
55  h_play->SetTitle("Cal G4Hit Display");
56  h_play->DrawCopy("pE");
57  // h_in_cal->Draw("colz same");
58  // h_out_cal->Draw("col same");
59  h_cal->Draw("colz same");
60 
61  c_cal->cd(2);
62  h_play->SetTitle("Abs G4Hit Display");
63  h_play->DrawCopy("pE");
64  // h_in_abs->Draw("colz same");
65  // h_out_abs->Draw("col same");
66  h_abs->Draw("colz same");
67 
68  c_cal->cd(3);
69  h_out_sf->SetTitle("Sampling Fraction");
70  h_out_sf->SetStats(0);
71  h_out_sf->GetXaxis()->SetTitle("Sampling Fraction");
72  h_out_sf->GetXaxis()->CenterTitle();
73  h_out_sf->SetLineColor(2);
74  h_out_sf->SetLineWidth(2);
75  h_out_sf->Draw("");
76  std::string sf_out = Form("sf_out = %1.4f",h_out_sf->GetMean());
77 
78  h_in_sf->SetLineColor(1);
79  h_in_sf->SetLineWidth(2);
80  h_in_sf->Draw("same");
81  std::string sf_in = Form("sf_in = %1.4f",h_in_sf->GetMean());
82 
83  TLegend *leg = new TLegend(0.5,0.5,0.8,0.7);
84  leg->SetFillColor(10);
85  leg->AddEntry(h_in_sf,sf_in.c_str(),"l");
86  leg->AddEntry(h_out_sf,sf_out.c_str(),"l");
87  leg->Draw("same");
88 
89  string output_fig = Form("./figures/c_G4Hit_%s.eps",inputdir.c_str());
90  c_cal->SaveAs(output_fig.c_str());
91 }