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 static constexpr int first_layer_mvtx = 0;
0006 static constexpr int nlayers_mvtx = 3;
0007 const char *hist_name_prefix = "QAG4SimulationMvtx";
0008 
0009 void MvtxQA(std::string reffile, std::string newfile, std::string outfile)
0010 {
0011   SetsPhenixStyle();
0012   TFile *reff = TFile::Open(reffile.c_str());
0013   TFile *newf = TFile::Open(newfile.c_str());
0014   
0015   auto c1 = Draw( newf, reff, hist_name_prefix, "drphi" );
0016   auto c2 = Draw( newf, reff, hist_name_prefix, "rphi_error" );
0017   auto c3 = Draw( newf, reff, hist_name_prefix, "phi_pulls" );
0018   auto c4 = Draw( newf, reff, hist_name_prefix, "dz" );
0019   auto c5 = Draw( newf, reff, hist_name_prefix, "z_error" );
0020   auto c6 = Draw( newf, reff, hist_name_prefix, "z_pulls" );
0021   auto c7 = Draw( newf, reff, hist_name_prefix, "clus_size" );
0022   auto c8 = Draw( newf, reff, hist_name_prefix, "clus_size_phi" );
0023   auto c9 = Draw( newf, reff, hist_name_prefix, "clus_size_z" );
0024   
0025   TFile *outfilef = new TFile(outfile.c_str(), "recreate");
0026   c1->Write();
0027   c2->Write();
0028   c3->Write();
0029   c4->Write();
0030   c5->Write();
0031   c6->Write();
0032   c7->Write();
0033   c8->Write();
0034   c9->Write();
0035   outfilef->Close();
0036   
0037 }
0038 
0039 TCanvas* Draw( TFile* qa_file_new, TFile* qa_file_ref, const TString& hist_name_prefix, const TString& tag )
0040 {
0041 
0042     const TString prefix = TString("h_") + hist_name_prefix + TString("_");
0043 
0044     auto cv = new TCanvas(
0045       TString("QA_Draw_Mvtx_") + tag + TString("_") + hist_name_prefix,
0046       TString("QA_Draw_Mvtx_") + tag + TString("_") + hist_name_prefix,
0047       1800, 1000);
0048 
0049     cv->Divide( nlayers_mvtx, 1 );
0050     for( int ilayer = 0; ilayer < nlayers_mvtx; ++ilayer )
0051     {
0052 
0053       const int layer = ilayer + first_layer_mvtx;
0054 
0055       // get histograms
0056       auto hnew = static_cast<TH1*>( qa_file_new->GetObjectChecked( Form( "%s%s_%i", prefix.Data(), tag.Data(), layer ), "TH1" ) );
0057       hnew->Scale( 1./hnew->GetEntries() );
0058       hnew->SetMinimum(0);
0059       hnew->GetXaxis()->SetMaxDigits(2);
0060 
0061       // reference
0062       auto href = qa_file_ref ? static_cast<TH1*>( qa_file_ref->GetObjectChecked( Form( "%s%s_%i", prefix.Data(), tag.Data(), layer ), "TH1" ) ) : nullptr;
0063       if( href )
0064       {
0065         href->Scale( 1./href->GetEntries() );
0066         href->SetMinimum(0);
0067         href->GetXaxis()->SetMaxDigits(2);
0068       }
0069 
0070       // draw
0071       cv->cd( ilayer+1 );
0072       DrawReference(hnew, href);
0073       gPad->SetRightMargin(0.15);
0074         
0075       auto line = VerticalLine( gPad, 0 );
0076       line->Draw();
0077     }
0078 
0079     return cv;
0080 
0081 }