Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:13:19

0001 #include "sPhenixStyle.h"
0002 #include "sPhenixStyle.C"
0003 #include <iostream>
0004 #include <TGraphErrors.h>
0005 #include <TRandom3.h>
0006 #include "utilities.h"
0007 
0008 void SubjetMacro() 
0009 {
0010   SetsPhenixStyle();
0011   TH1::SetDefaultSumw2();
0012   TH2::SetDefaultSumw2();
0013 
0014   using namespace std;{
0015 
0016     
0017     TFile *fin1 = TFile::Open("../macro/condorTest/output_data3cut.root");  
0018     TH1F *_h_R04_z_g_10_20 = (TH1F*)fin1->Get("R04_z_g_10_20");
0019     _h_R04_z_g_10_20->Sumw2(); // Enable Sumw2 for this histogram
0020     TH1F *_h_R04_theta_g_10_20 = (TH1F*)fin1->Get("R04_theta_g_10_20");
0021     _h_R04_theta_g_10_20->Sumw2(); // Enable Sumw2 for this histogram
0022     TH1F *_h_R04_z_sj_10_20 = (TH1F*)fin1->Get("R04_z_sj_10_20");
0023     _h_R04_z_sj_10_20->Sumw2(); // Enable Sumw2 for this histogram
0024     TH1F *_h_R04_theta_sj_10_20 = (TH1F*)fin1->Get("R04_theta_sj_10_20");
0025     _h_R04_theta_sj_10_20->Sumw2(); // Enable Sumw2 for this histogram
0026     TH2D *correlation_theta_10_20 = (TH2D*)fin1->Get("correlation_theta_10_20");
0027     TH2D *correlation_z_10_20 = (TH2D*)fin1->Get("correlation_z_10_20");
0028     
0029     TFile *fin2 = TFile::Open("../macro/condorTest/output_data1cut.root");
0030     TH1F *_h_R04_z_g_10_20_2 = (TH1F*)fin2->Get("R04_z_g_10_20");
0031     _h_R04_z_g_10_20_2->Sumw2(); // Enable Sumw2 for this histogram
0032     TH1F *_h_R04_theta_g_10_20_2 = (TH1F*)fin2->Get("R04_theta_g_10_20");
0033     _h_R04_theta_g_10_20_2->Sumw2(); // Enable Sumw2 for this histogram
0034     TH1F *_h_R04_z_sj_10_20_2 = (TH1F*)fin2->Get("R04_z_sj_10_20");
0035     _h_R04_z_sj_10_20_2->Sumw2(); // Enable Sumw2 for this histogram
0036     TH1F *_h_R04_theta_sj_10_20_2 = (TH1F*)fin2->Get("R04_theta_sj_10_20");
0037     _h_R04_theta_sj_10_20_2->Sumw2(); // Enable Sumw2 for this histogram
0038 
0039 
0040     std::cout << "number of jets:" << _h_R04_z_sj_10_20->Integral() << std::endl;
0041 
0042     // Normalize 10-20 hists                                                                                                                                           
0043     _h_R04_z_sj_10_20->Scale(1./_h_R04_z_sj_10_20->Integral());                                                                                                        
0044     _h_R04_theta_sj_10_20->Scale(1./_h_R04_theta_sj_10_20->Integral());
0045     _h_R04_z_sj_10_20->Scale(1./0.05);  
0046     _h_R04_theta_sj_10_20->Scale(1./0.05);                                                                                                                             
0047     //SoftDrop Normalization                                                                                                                                           
0048     // Normalize 10-20 hists                                                                                                                                           
0049     _h_R04_z_g_10_20->Scale(1./_h_R04_z_g_10_20->Integral());                                                                                                          
0050     _h_R04_theta_g_10_20->Scale(1./_h_R04_theta_g_10_20->Integral());                                                                                                  
0051     _h_R04_z_g_10_20->Scale(1./0.05);   
0052     _h_R04_theta_g_10_20->Scale(1./0.05); 
0053 
0054     std::cout << "number of jets:" << _h_R04_z_sj_10_20_2->Integral() << std::endl;
0055 
0056     // Normalize 10-20 hists                                                                                                                                           
0057     _h_R04_z_sj_10_20_2->Scale(1./_h_R04_z_sj_10_20_2->Integral());
0058     _h_R04_theta_sj_10_20_2->Scale(1./_h_R04_theta_sj_10_20_2->Integral());
0059     _h_R04_z_sj_10_20_2->Scale(1./0.05);
0060     _h_R04_theta_sj_10_20_2->Scale(1./0.05);
0061     //SoftDrop Normalization                                                                                                                                           
0062     // Normalize 10-20 hists                                                                                                                                           
0063     _h_R04_z_g_10_20_2->Scale(1./_h_R04_z_g_10_20_2->Integral());
0064     _h_R04_theta_g_10_20_2->Scale(1./_h_R04_theta_g_10_20_2->Integral());
0065     _h_R04_z_g_10_20_2->Scale(1./0.05);
0066     _h_R04_theta_g_10_20_2->Scale(1./0.05);
0067 
0068     TCanvas * Spectra04 = new TCanvas("Spectra04", " ", 500, 500);
0069     
0070     // Set marker colors for histograms from the first file
0071     _h_R04_z_g_10_20->SetMarkerStyle(20);
0072     _h_R04_z_g_10_20->SetMarkerColor(kRed);
0073     _h_R04_theta_g_10_20->SetMarkerStyle(20);
0074     _h_R04_theta_g_10_20->SetMarkerColor(kRed);
0075     _h_R04_z_sj_10_20->SetMarkerStyle(20);
0076     _h_R04_z_sj_10_20->SetMarkerColor(kRed);
0077     _h_R04_theta_sj_10_20->SetMarkerStyle(20);
0078     _h_R04_theta_sj_10_20->SetMarkerColor(kRed);
0079     
0080     // Set marker colors for histograms from the second file
0081     _h_R04_z_g_10_20_2->SetMarkerStyle(20);
0082     _h_R04_z_g_10_20_2->SetMarkerColor(kBlue);
0083     _h_R04_theta_g_10_20_2->SetMarkerStyle(20);
0084     _h_R04_theta_g_10_20_2->SetMarkerColor(kBlue);
0085     _h_R04_z_sj_10_20_2->SetMarkerStyle(20);
0086     _h_R04_z_sj_10_20_2->SetMarkerColor(kBlue);
0087     _h_R04_theta_sj_10_20_2->SetMarkerStyle(20);
0088     _h_R04_theta_sj_10_20_2->SetMarkerColor(kBlue);
0089    
0090 
0091     _h_R04_z_g_10_20->SetTitle("Momentum Fraction z_{g} Between Subjets");
0092     _h_R04_z_g_10_20->SetXTitle("z_{g}");
0093     _h_R04_z_g_10_20->SetYTitle("(1/N_{jet}) dN/dz_{g}");
0094     _h_R04_z_g_10_20->GetXaxis()->SetTitleSize(0.05);
0095     _h_R04_z_g_10_20->GetXaxis()->CenterTitle(true);
0096     _h_R04_z_g_10_20->GetXaxis()->SetLabelSize(0.03);
0097     _h_R04_z_g_10_20->GetYaxis()->SetLabelSize(0.03);
0098     _h_R04_z_g_10_20->GetXaxis()->SetTitleSize(0.05);
0099     _h_R04_z_g_10_20->SetAxisRange(0, 5.0, "Y");
0100     _h_R04_z_g_10_20->SetAxisRange(0, 0.5, "X");
0101     _h_R04_z_g_10_20->SetMarkerSize(1.0);
0102     _h_R04_z_g_10_20->Draw("p E");
0103    
0104     _h_R04_z_g_10_20_2->SetAxisRange(0, 0.5, "X");
0105     _h_R04_z_g_10_20_2->SetMarkerSize(1.0);
0106     _h_R04_z_g_10_20_2->Draw("p E same");
0107 
0108     int nbins3 = _h_R04_z_g_10_20->GetNbinsX();
0109     double* ex3 = new double[nbins3];
0110     double* ey3 = new double[nbins3];
0111 
0112     for (int i = 0; i < nbins3; ++i) {
0113       ex3[i] = 0.0; // Set x error to 0
0114       ey3[i] = _h_R04_z_g_10_20->GetBinError(i+1);
0115     }
0116 
0117     TGraphErrors* errorGraph3 = new TGraphErrors(nbins3, nullptr, ey3, ex3, nullptr);
0118     errorGraph3->Draw("P same"); // "P" to draw with markers and error bars, "same" to draw on the same canvas
0119 
0120     drawText("Au+Au #sqrt{s} = 200 GeV  Run 23745", 0.25, 0.87, 14);
0121     drawText("anti-k_{T} R=0.4 jets, |#eta_{jet}| < 0.6", 0.25, 0.84, 14);
0122     drawText("R_{sj}=0.1", 0.25, 0.81, 14);
0123     drawText("10 < p_{T} < 20 [GeV/c]", 0.25, 0.775, 14);
0124     drawText("#it{#bf{sPHENIX}} Preliminary", 0.25, 0.735, 14);
0125    
0126     TLegend* legend = new TLegend(0.6, 0.735, 0.8, 0.835); // Specify the position of the legend
0127     legend->AddEntry(_h_R04_z_sj_10_20, "z_{cut}=0.3, #beta = 2.0", "p"); // Add an entry for the first dataset
0128     legend->AddEntry(_h_R04_z_sj_10_20_2, "z_{cut}=0.1, #beta = 0.0", "p"); // Add an entry for the second dataset
0129     legend->SetBorderSize(0); // Remove the border around the legend
0130     legend->SetEntrySeparation(0.03);
0131     legend->SetTextSize(0.03); 
0132     legend->Draw(); // Draw the legend on the canvas
0133    
0134     Spectra04->SaveAs("Momentum_Frac_10_20_R04_data.pdf", "RECREATE");
0135   }
0136 }