File indexing completed on 2025-08-05 08:15:15
0001 #include "../CommonTools.h"
0002 #include <sPhenixStyle.C>
0003
0004 TCanvas* Draw( TFile* qa_file_new, TFile* qa_file_ref, const TString& hist_name_prefix, const TString& tag );
0005
0006 const char *hist_name_prefix = "QAG4SimulationMicromegas";
0007
0008
0009 static constexpr int first_layer_micromegas = 55;
0010 static constexpr int nlayers_micromegas = 2;
0011
0012 void TpotQA(std::string reffile, std::string newfile, std::string outfile)
0013 {
0014 SetsPhenixStyle();
0015
0016 TFile *reff = TFile::Open(reffile.c_str());
0017 TFile *newf = TFile::Open(newfile.c_str());
0018
0019 auto c0 = Draw( newf, reff, hist_name_prefix, "adc" );
0020 auto c1 = Draw( newf, reff, hist_name_prefix, "residual" );
0021 auto c2 = Draw( newf, reff, hist_name_prefix, "residual_error" );
0022 auto c3 = Draw( newf, reff, hist_name_prefix, "cluster_pulls" );
0023 auto c4 = Draw( newf, reff, hist_name_prefix, "clus_size" );
0024
0025 TFile *outfilef = new TFile(outfile.c_str(), "recreate");
0026 c1->Write();
0027 c2->Write();
0028 c3->Write();
0029 c4->Write();
0030
0031 outfilef->Close();
0032 }
0033
0034
0035 TCanvas* Draw( TFile* qa_file_new, TFile* qa_file_ref, const TString& hist_name_prefix, const TString& tag )
0036 {
0037
0038 const TString prefix = TString("h_") + hist_name_prefix + TString("_");
0039
0040 auto cv = new TCanvas(
0041 TString("QA_Draw_Micromegas_") + tag + TString("_") + hist_name_prefix,
0042 TString("QA_Draw_Micromegas_") + tag + TString("_") + hist_name_prefix,
0043 1800, 1000);
0044
0045 cv->Divide( nlayers_micromegas, 1 );
0046 for( int ilayer = 0; ilayer < nlayers_micromegas; ++ilayer )
0047 {
0048
0049 const int layer = ilayer + first_layer_micromegas;
0050
0051
0052 auto hnew = static_cast<TH1*>( qa_file_new->GetObjectChecked( Form( "%s%s_%i", prefix.Data(), tag.Data(), layer ), "TH1" ) );
0053 hnew->Scale( 1./hnew->GetEntries() );
0054 hnew->SetMinimum(0);
0055
0056
0057 auto href = qa_file_ref ? static_cast<TH1*>( qa_file_ref->GetObjectChecked( Form( "%s%s_%i", prefix.Data(), tag.Data(), layer ), "TH1" ) ) : nullptr;
0058 if( href )
0059 {
0060 href->Scale( 1./href->GetEntries() );
0061 href->SetMinimum(0);
0062 }
0063
0064
0065 cv->cd( ilayer+1 );
0066 DrawReference(hnew, href);
0067
0068 auto line = VerticalLine( gPad, 0 );
0069 line->Draw();
0070 }
0071
0072 return cv;
0073
0074 }