Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:16:16

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 = "QAG4SimulationIntt";
0007 
0008 // assume INTT layers are 3 to 6
0009 static constexpr int first_layer_intt = 3;
0010 static constexpr int nlayers_intt = 4;
0011 
0012 void InttQA(std::string reffile, std::string newfile, std::string outfile)
0013 {
0014   SetsPhenixStyle();
0015   TFile *reff = TFile::Open(reffile.c_str());
0016   TFile *newf = TFile::Open(newfile.c_str());
0017 
0018   auto c1 = Draw( newf, reff, hist_name_prefix, "drphi" );
0019   auto c2 = Draw( newf, reff, hist_name_prefix, "rphi_error" );
0020   auto c3 = Draw( newf, reff, hist_name_prefix, "phi_pulls" );
0021   auto c4 = Draw( newf, reff, hist_name_prefix, "dz" );
0022   auto c5 = Draw( newf, reff, hist_name_prefix, "z_error" );
0023   auto c6 = Draw( newf, reff, hist_name_prefix, "z_pulls" );
0024   auto c7 = Draw( newf, reff, hist_name_prefix, "clus_size" );
0025   auto c8 = Draw( newf, reff, hist_name_prefix, "clus_size_phi" );
0026   auto c9 = Draw( newf, reff, hist_name_prefix, "clus_size_z" );
0027   
0028   TFile *outfilef = new TFile(outfile.c_str(), "recreate");
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 
0043 TCanvas* Draw( TFile* qa_file_new, TFile* qa_file_ref, const TString& hist_name_prefix, const TString& tag )
0044 {
0045 
0046     const TString prefix = TString("h_") + hist_name_prefix + TString("_");
0047 
0048     auto cv = new TCanvas(
0049       TString("QA_Draw_Intt_") + tag + TString("_") + hist_name_prefix,
0050       TString("QA_Draw_Intt_") + tag + TString("_") + hist_name_prefix,
0051       1800, 1000);
0052 
0053     DivideCanvas( cv, nlayers_intt );
0054     for( int ilayer = 0; ilayer < nlayers_intt; ++ilayer )
0055     {
0056 
0057       const int layer = ilayer + first_layer_intt;
0058 
0059       // get histograms
0060       auto hnew = static_cast<TH1*>( qa_file_new->GetObjectChecked( Form( "%s%s_%i", prefix.Data(), tag.Data(), layer ), "TH1" ) );
0061       hnew->Scale( 1./hnew->GetEntries() );
0062       hnew->SetMinimum(0);
0063 
0064       // reference
0065       auto href = qa_file_ref ? static_cast<TH1*>( qa_file_ref->GetObjectChecked( Form( "%s%s_%i", prefix.Data(), tag.Data(), layer ), "TH1" ) ) : nullptr;
0066       if( href )
0067       {
0068         href->Scale( 1./href->GetEntries() );
0069         href->SetMinimum(0);
0070       }
0071 
0072       // draw
0073       cv->cd( ilayer+1 );
0074       DrawReference(hnew, href);
0075 
0076       auto line = VerticalLine( gPad, 0 );
0077       line->Draw();
0078     }
0079 
0080     return cv;
0081 
0082 }