File indexing completed on 2025-08-05 08:15:15
0001 #include "../CommonTools.h"
0002
0003 #include <sPhenixStyle.C>
0004
0005 TCanvas* Draw( TFile* qa_file_new, TFile* qa_file_ref, const TString& hist_name_prefix, const TString& tag );
0006 TCanvas* Draw_eff( TFile* qa_file_new, TFile* qa_file_ref, const TString& hist_name_prefix, const TString& tag );
0007
0008 const char *hist_name_prefix = "QAG4SimulationTpc";
0009 static constexpr int nregions_tpc = 3;
0010 void TpcQA(std::string reffile, std::string newfile, std::string outfile)
0011 {
0012 SetsPhenixStyle();
0013 TFile *reff = TFile::Open(reffile.c_str());
0014 TFile *newf = TFile::Open(newfile.c_str());
0015
0016 auto c0 = Draw_eff( newf, reff, hist_name_prefix, "efficiency" );
0017 auto c1 = Draw( newf, reff, hist_name_prefix, "drphi" );
0018 auto c2 = Draw( newf, reff, hist_name_prefix, "rphi_error" );
0019 auto c3 = Draw( newf, reff, hist_name_prefix, "phi_pulls" );
0020 auto c4 = Draw( newf, reff, hist_name_prefix, "dz" );
0021 auto c5 = Draw( newf, reff, hist_name_prefix, "z_error" );
0022 auto c6 = Draw( newf, reff, hist_name_prefix, "z_pulls" );
0023 auto c7 = Draw( newf, reff, hist_name_prefix, "clus_size" );
0024 auto c8 = Draw( newf, reff, hist_name_prefix, "clus_size_phi" );
0025 auto c9 = Draw( newf, reff, hist_name_prefix, "clus_size_z" );
0026
0027 TFile *outfilef = new TFile(outfile.c_str(), "recreate");
0028 c0->Write();
0029 c1->Write();
0030 c2->Write();
0031 c3->Write();
0032 c4->Write();
0033 c5->Write();
0034 c6->Write();
0035 c7->Write();
0036 c8->Write();
0037 c9->Write();
0038 outfilef->Close();
0039
0040 }
0041
0042 TCanvas* Draw( TFile* qa_file_new, TFile* qa_file_ref, const TString& hist_name_prefix, const TString& tag )
0043 {
0044
0045 const TString prefix = TString("h_") + hist_name_prefix + TString("_");
0046
0047 auto cv = new TCanvas(
0048 TString("QA_Draw_Tpc_") + tag + TString("_") + hist_name_prefix,
0049 TString("QA_Draw_Tpc_") + tag + TString("_") + hist_name_prefix,
0050 1800, 1000);
0051
0052 cv->Divide( nregions_tpc, 1 );
0053 for( int region = 0; region < nregions_tpc; ++region )
0054 {
0055
0056
0057 auto hnew = static_cast<TH1*>( qa_file_new->GetObjectChecked( Form( "%s%s_%i", prefix.Data(), tag.Data(), region ), "TH1" ) );
0058 hnew->Scale( 1./hnew->GetEntries() );
0059 hnew->SetMinimum(0);
0060
0061
0062 auto href = qa_file_ref ? static_cast<TH1*>( qa_file_ref->GetObjectChecked( Form( "%s%s_%i", prefix.Data(), tag.Data(), region ), "TH1" ) ) : nullptr;
0063 if( href )
0064 {
0065 href->Scale( 1./href->GetEntries() );
0066 href->SetMinimum(0);
0067 }
0068
0069
0070 cv->cd( region+1 );
0071 DrawReference(hnew, href);
0072
0073 auto line = VerticalLine( gPad, 0 );
0074 line->Draw();
0075 }
0076
0077 return cv;
0078
0079 }
0080
0081 TCanvas* Draw_eff( TFile* qa_file_new, TFile* qa_file_ref, const TString& hist_name_prefix, const TString& tag )
0082 {
0083
0084 const TString prefix = TString("h_") + hist_name_prefix + TString("_");
0085
0086 auto cv = new TCanvas(
0087 TString("QA_Draw_Tpc_") + tag + TString("_") + hist_name_prefix,
0088 TString("QA_Draw_Tpc_") + tag + TString("_") + hist_name_prefix,
0089 1800, 1000);
0090
0091
0092 auto hnew0 = static_cast<TH1*>( qa_file_new->GetObjectChecked( Form( "%s%s_0", prefix.Data(), tag.Data()), "TH1" ) );
0093 auto hnew1 = static_cast<TH1*>( qa_file_new->GetObjectChecked( Form( "%s%s_1", prefix.Data(), tag.Data()), "TH1" ) );
0094
0095 hnew1->Divide(hnew1, hnew0, 1, 1, "B");
0096 hnew1->SetMinimum(0);
0097
0098
0099 auto href0 = qa_file_ref ? static_cast<TH1*>( qa_file_ref->GetObjectChecked( Form( "%s%s_0", prefix.Data(), tag.Data()), "TH1" ) ) : nullptr;
0100 auto href1 = qa_file_ref ? static_cast<TH1*>( qa_file_ref->GetObjectChecked( Form( "%s%s_1", prefix.Data(), tag.Data()), "TH1" ) ) : nullptr;
0101 if( href0 )
0102 {
0103 href1->Divide(href1, href0, 1, 1, "B");
0104 href1->SetMinimum(0);
0105 }
0106
0107
0108 DrawReference(hnew1, href1);
0109
0110 auto line = HorizontalLine( gPad, 1 );
0111 line->Draw();
0112
0113
0114 return cv;
0115
0116 }