Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TpotQA.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TpotQA.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 
6 const char *hist_name_prefix = "QAG4SimulationMicromegas";
7 
8 // assume Micromegas layers are 55 and 56
9 static constexpr int first_layer_micromegas = 55;
10 static constexpr int nlayers_micromegas = 2;
11 
13 {
15 
16  TFile *reff = TFile::Open(reffile.c_str());
17  TFile *newf = TFile::Open(newfile.c_str());
18 
19  auto c0 = Draw( newf, reff, hist_name_prefix, "adc" );
20  auto c1 = Draw( newf, reff, hist_name_prefix, "residual" );
21  auto c2 = Draw( newf, reff, hist_name_prefix, "residual_error" );
22  auto c3 = Draw( newf, reff, hist_name_prefix, "cluster_pulls" );
23  auto c4 = Draw( newf, reff, hist_name_prefix, "clus_size" );
24 
25  TFile *outfilef = new TFile(outfile.c_str(), "recreate");
26  c1->Write();
27  c2->Write();
28  c3->Write();
29  c4->Write();
30 
31  outfilef->Close();
32 }
33 
34 
35 TCanvas* Draw( TFile* qa_file_new, TFile* qa_file_ref, const TString& hist_name_prefix, const TString& tag )
36 {
37 
38  const TString prefix = TString("h_") + hist_name_prefix + TString("_");
39 
40  auto cv = new TCanvas(
41  TString("QA_Draw_Micromegas_") + tag + TString("_") + hist_name_prefix,
42  TString("QA_Draw_Micromegas_") + tag + TString("_") + hist_name_prefix,
43  1800, 1000);
44 
45  cv->Divide( nlayers_micromegas, 1 );
46  for( int ilayer = 0; ilayer < nlayers_micromegas; ++ilayer )
47  {
48 
49  const int layer = ilayer + first_layer_micromegas;
50 
51  // get histograms
52  auto hnew = static_cast<TH1*>( qa_file_new->GetObjectChecked( Form( "%s%s_%i", prefix.Data(), tag.Data(), layer ), "TH1" ) );
53  hnew->Scale( 1./hnew->GetEntries() );
54  hnew->SetMinimum(0);
55 
56  // reference
57  auto href = qa_file_ref ? static_cast<TH1*>( qa_file_ref->GetObjectChecked( Form( "%s%s_%i", prefix.Data(), tag.Data(), layer ), "TH1" ) ) : nullptr;
58  if( href )
59  {
60  href->Scale( 1./href->GetEntries() );
61  href->SetMinimum(0);
62  }
63 
64  // draw
65  cv->cd( ilayer+1 );
66  DrawReference(hnew, href);
67 
68  auto line = VerticalLine( gPad, 0 );
69  line->Draw();
70  }
71 
72  return cv;
73 
74 }