Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TpcQA.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TpcQA.C
1 #include "../CommonTools.h"
2 
3 #include <sPhenixStyle.C>
4 
5 TCanvas* Draw( TFile* qa_file_new, TFile* qa_file_ref, const TString& hist_name_prefix, const TString& tag );
6 TCanvas* Draw_eff( TFile* qa_file_new, TFile* qa_file_ref, const TString& hist_name_prefix, const TString& tag );
7 
8 const char *hist_name_prefix = "QAG4SimulationTpc";
9 static constexpr int nregions_tpc = 3;
11 {
13  TFile *reff = TFile::Open(reffile.c_str());
14  TFile *newf = TFile::Open(newfile.c_str());
15 
16  auto c0 = Draw_eff( newf, reff, hist_name_prefix, "efficiency" );
17  auto c1 = Draw( newf, reff, hist_name_prefix, "drphi" );
18  auto c2 = Draw( newf, reff, hist_name_prefix, "rphi_error" );
19  auto c3 = Draw( newf, reff, hist_name_prefix, "phi_pulls" );
20  auto c4 = Draw( newf, reff, hist_name_prefix, "dz" );
21  auto c5 = Draw( newf, reff, hist_name_prefix, "z_error" );
22  auto c6 = Draw( newf, reff, hist_name_prefix, "z_pulls" );
23  auto c7 = Draw( newf, reff, hist_name_prefix, "clus_size" );
24  auto c8 = Draw( newf, reff, hist_name_prefix, "clus_size_phi" );
25  auto c9 = Draw( newf, reff, hist_name_prefix, "clus_size_z" );
26 
27  TFile *outfilef = new TFile(outfile.c_str(), "recreate");
28  c0->Write();
29  c1->Write();
30  c2->Write();
31  c3->Write();
32  c4->Write();
33  c5->Write();
34  c6->Write();
35  c7->Write();
36  c8->Write();
37  c9->Write();
38  outfilef->Close();
39 
40 }
41 
42 TCanvas* Draw( TFile* qa_file_new, TFile* qa_file_ref, const TString& hist_name_prefix, const TString& tag )
43 {
44 
45 const TString prefix = TString("h_") + hist_name_prefix + TString("_");
46 
47 auto cv = new TCanvas(
48  TString("QA_Draw_Tpc_") + tag + TString("_") + hist_name_prefix,
49  TString("QA_Draw_Tpc_") + tag + TString("_") + hist_name_prefix,
50  1800, 1000);
51 
52 cv->Divide( nregions_tpc, 1 );
53 for( int region = 0; region < nregions_tpc; ++region )
54 {
55 
56  // get histograms
57  auto hnew = static_cast<TH1*>( qa_file_new->GetObjectChecked( Form( "%s%s_%i", prefix.Data(), tag.Data(), region ), "TH1" ) );
58  hnew->Scale( 1./hnew->GetEntries() );
59  hnew->SetMinimum(0);
60 
61  // reference
62  auto href = qa_file_ref ? static_cast<TH1*>( qa_file_ref->GetObjectChecked( Form( "%s%s_%i", prefix.Data(), tag.Data(), region ), "TH1" ) ) : nullptr;
63  if( href )
64  {
65  href->Scale( 1./href->GetEntries() );
66  href->SetMinimum(0);
67  }
68 
69  // draw
70  cv->cd( region+1 );
71  DrawReference(hnew, href);
72 
73  auto line = VerticalLine( gPad, 0 );
74  line->Draw();
75 }
76 
77 return cv;
78 
79 }
80 
81 TCanvas* Draw_eff( TFile* qa_file_new, TFile* qa_file_ref, const TString& hist_name_prefix, const TString& tag )
82 {
83 
84  const TString prefix = TString("h_") + hist_name_prefix + TString("_");
85 
86  auto cv = new TCanvas(
87  TString("QA_Draw_Tpc_") + tag + TString("_") + hist_name_prefix,
88  TString("QA_Draw_Tpc_") + tag + TString("_") + hist_name_prefix,
89  1800, 1000);
90 
91  // get histograms
92  auto hnew0 = static_cast<TH1*>( qa_file_new->GetObjectChecked( Form( "%s%s_0", prefix.Data(), tag.Data()), "TH1" ) );
93  auto hnew1 = static_cast<TH1*>( qa_file_new->GetObjectChecked( Form( "%s%s_1", prefix.Data(), tag.Data()), "TH1" ) );
94 
95  hnew1->Divide(hnew1, hnew0, 1, 1, "B");
96  hnew1->SetMinimum(0);
97 
98  // reference
99  auto href0 = qa_file_ref ? static_cast<TH1*>( qa_file_ref->GetObjectChecked( Form( "%s%s_0", prefix.Data(), tag.Data()), "TH1" ) ) : nullptr;
100  auto href1 = qa_file_ref ? static_cast<TH1*>( qa_file_ref->GetObjectChecked( Form( "%s%s_1", prefix.Data(), tag.Data()), "TH1" ) ) : nullptr;
101  if( href0 )
102  {
103  href1->Divide(href1, href0, 1, 1, "B");
104  href1->SetMinimum(0);
105  }
106 
107  // draw
108  DrawReference(hnew1, href1);
109 
110  auto line = HorizontalLine( gPad, 1 );
111  line->Draw();
112 
113 
114  return cv;
115 
116 }