Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 09:18:59

0001 // Macro to superimpose the pull distributions
0002 // Shyam Kumar; INFN Bari, shyam.kumar@ba.infn.it
0003 
0004 void compare_Pulls(TString name ="objectname", TString histtitle=""){
0005     
0006     gStyle->SetPalette(kRainBow);
0007     gStyle->SetTitleSize(0.045,"XY");   
0008     gStyle->SetTitleSize(0.04,"XY");    
0009     gStyle->SetLabelSize(0.04,"XY");    
0010     gStyle->SetTitleOffset(1.0,"XY");   
0011     gStyle->SetOptStat(1);
0012     gStyle->SetOptFit(1);
0013     gStyle->SetOptTitle(1);
0014     gStyle->SetGridColor(kBlack);     
0015     gStyle->SetGridWidth(2);        
0016     gStyle->SetGridStyle(2);
0017 
0018 
0019     TFile *f1 = TFile::Open("./Pull_distribution_vertex_test_D0.list.root");
0020     TFile *f2 = TFile::Open("./Pull_distribution_vertex_test_DIS.list.root");
0021 
0022     const int nplots = 1;
0023     double arr[2];
0024  
0025     TCanvas *c[nplots]; 
0026     for (int i=0; i<nplots; ++i){
0027     c[i]= new TCanvas(Form("c%d",i),Form("c%d",i),0,52,1400,1000);
0028     c[i]->SetGrid();
0029     c[i]->SetMargin(0.10, 0.03 ,0.12,0.07);
0030     } 
0031     
0032      c[0]->cd();
0033      TH1D *h0 = (TH1D*)f1->Get(Form("%s",name.Data()));
0034      TH1D *h1 = (TH1D*)f2->Get(Form("%s",name.Data()));
0035      
0036      arr[0] = h0->GetMaximum();       arr[1] = h1->GetMaximum();      
0037      int size = sizeof(arr) / sizeof(arr[0]);
0038      int max_val = *std::max_element(arr, arr + size);
0039       
0040       h0->SetLineColor(kBlue);
0041       h0->SetLineStyle(10);
0042       h0->SetMaximum(max_val*1.10);
0043       h0->SetTitle(Form(";%s; Entries (a.u.)",histtitle.Data()));
0044       h0->SetLineWidth(2);
0045       h0->Draw("hist");
0046       c[0]->Modified(); c[0]->Update();
0047       TPaveStats *stats = (TPaveStats*) h0->FindObject("stats"); // First need to update to make sure stats is there
0048       stats->SetTextColor(kBlue);
0049       stats->SetY2NDC(stats->GetY2NDC());
0050       stats->SetY1NDC(stats->GetY2NDC()-0.15); 
0051       double y1 = stats->GetY1NDC();  
0052     
0053       h1->SetLineColor(kRed);
0054       h1->SetLineStyle(9);
0055       h1->SetLineWidth(2);
0056       h1->Draw("sames");
0057       c[0]->Modified(); c[0]->Update();
0058       stats = (TPaveStats*) h1->FindObject("stats"); // First need to update to make sure stats is there
0059       stats->SetTextColor(kRed);
0060       stats->SetY2NDC(y1);  
0061      stats->SetY1NDC(y1-0.15);
0062      y1 = stats->GetY1NDC();   
0063       c[0]->Modified();
0064      c[0]->Update();
0065      
0066      TLegend *lhit = new TLegend(0.18,0.70,0.38,0.92);
0067       lhit->SetHeader(Form("(10X100) Q2>1 GeV^{2} [25.04.1]"),"C");
0068       lhit->SetTextSize(0.035);
0069       lhit->SetBorderSize(0);
0070       lhit->AddEntry(h0,"D0 Sample");
0071       lhit->AddEntry(h1,"DIS Sample");
0072       lhit->Draw();
0073       c[0]->SaveAs(Form("%s_%s.png",name.Data(),histtitle.Data()));
0074 
0075 }   
0076 
0077 
0078 
0079 
0080 
0081 
0082 
0083 
0084 
0085 
0086 
0087 
0088 
0089 
0090 
0091 
0092 
0093 
0094