Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MvtxQA.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MvtxQA.C
1 #include "../CommonTools.h"
2 #include <sPhenixStyle.C>
3 
4 TCanvas* Draw( TFile* qa_file_new, TFile* qa_file_ref, const TString& hist_name_prefix, const TString& tag );
5 static constexpr int first_layer_mvtx = 0;
6 static constexpr int nlayers_mvtx = 3;
7 const char *hist_name_prefix = "QAG4SimulationMvtx";
8 
10 {
12  TFile *reff = TFile::Open(reffile.c_str());
13  TFile *newf = TFile::Open(newfile.c_str());
14 
15  auto c1 = Draw( newf, reff, hist_name_prefix, "drphi" );
16  auto c2 = Draw( newf, reff, hist_name_prefix, "rphi_error" );
17  auto c3 = Draw( newf, reff, hist_name_prefix, "phi_pulls" );
18  auto c4 = Draw( newf, reff, hist_name_prefix, "dz" );
19  auto c5 = Draw( newf, reff, hist_name_prefix, "z_error" );
20  auto c6 = Draw( newf, reff, hist_name_prefix, "z_pulls" );
21  auto c7 = Draw( newf, reff, hist_name_prefix, "clus_size" );
22  auto c8 = Draw( newf, reff, hist_name_prefix, "clus_size_phi" );
23  auto c9 = Draw( newf, reff, hist_name_prefix, "clus_size_z" );
24 
25  TFile *outfilef = new TFile(outfile.c_str(), "recreate");
26  c1->Write();
27  c2->Write();
28  c3->Write();
29  c4->Write();
30  c5->Write();
31  c6->Write();
32  c7->Write();
33  c8->Write();
34  c9->Write();
35  outfilef->Close();
36 
37 }
38 
39 TCanvas* Draw( TFile* qa_file_new, TFile* qa_file_ref, const TString& hist_name_prefix, const TString& tag )
40 {
41 
42  const TString prefix = TString("h_") + hist_name_prefix + TString("_");
43 
44  auto cv = new TCanvas(
45  TString("QA_Draw_Mvtx_") + tag + TString("_") + hist_name_prefix,
46  TString("QA_Draw_Mvtx_") + tag + TString("_") + hist_name_prefix,
47  1800, 1000);
48 
49  cv->Divide( nlayers_mvtx, 1 );
50  for( int ilayer = 0; ilayer < nlayers_mvtx; ++ilayer )
51  {
52 
53  const int layer = ilayer + first_layer_mvtx;
54 
55  // get histograms
56  auto hnew = static_cast<TH1*>( qa_file_new->GetObjectChecked( Form( "%s%s_%i", prefix.Data(), tag.Data(), layer ), "TH1" ) );
57  hnew->Scale( 1./hnew->GetEntries() );
58  hnew->SetMinimum(0);
59  hnew->GetXaxis()->SetMaxDigits(2);
60 
61  // reference
62  auto href = qa_file_ref ? static_cast<TH1*>( qa_file_ref->GetObjectChecked( Form( "%s%s_%i", prefix.Data(), tag.Data(), layer ), "TH1" ) ) : nullptr;
63  if( href )
64  {
65  href->Scale( 1./href->GetEntries() );
66  href->SetMinimum(0);
67  href->GetXaxis()->SetMaxDigits(2);
68  }
69 
70  // draw
71  cv->cd( ilayer+1 );
72  DrawReference(hnew, href);
73  gPad->SetRightMargin(0.15);
74 
75  auto line = VerticalLine( gPad, 0 );
76  line->Draw();
77  }
78 
79  return cv;
80 
81 }