Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:12:41

0001 //
0002 //
0003 //
0004 //
0005 
0006 void AcceptanceMRP()
0007 {
0008   gStyle->SetOptStat(0);
0009 
0010   // Open up the 3 files with the saved histograms
0011   // and get the histograms
0012   const int NMODES = 3;
0013   const char* mode_dir[NMODES] = { "PROD1", "PROD2", "PROD4" };
0014   TFile *tfile[NMODES];
0015   TString name;
0016 
0017   TH1 *h_rapt[NMODES];
0018   TH1 *h_rapt_sphenix[NMODES];
0019   TH1 *h_rapt_total;               // all 3 modes summed
0020   TH1 *h_rapt_sphenix_total;
0021 
0022   TH1 *h_InvMass[NMODES];
0023   TH1 *h_InvMass_sphenix[NMODES];
0024   TH1 *h_InvMass_total;               // all 3 modes summed
0025   TH1 *h_InvMass_sphenix_total;
0026 
0027   TH1 *h_InvMass_smeared[NMODES];
0028   TH1 *h_InvMass_smeared_sphenix[NMODES];
0029   TH1 *h_InvMass_smeared_total;               // all 3 modes summed
0030   TH1 *h_InvMass_smeared_sphenix_total;
0031 
0032   TH1 *h_pt[NMODES];
0033   TH1 *h_pt_sphenix[NMODES];
0034   TH1 *h_pt_total;               // all 3 modes summed
0035   TH1 *h_pt_sphenix_total;
0036 
0037 
0038   // Loop over the prod_modes
0039   for (int imode=0; imode<NMODES; imode++)
0040   {
0041     // Open up the TFile
0042     name = mode_dir[imode]; name += "/upc_starlight.root";
0043     tfile[imode] = new TFile(name,"READ");
0044 
0045     // Now get the histograms rapidity
0046     h_rapt[imode] = (TH1*)tfile[imode]->Get("h_rapt");
0047     h_rapt_sphenix[imode] = (TH1*)tfile[imode]->Get("h_rapt_sphenix");
0048 
0049     // Now get the histograms Inv Mass
0050     h_InvMass[imode] = (TH1*)tfile[imode]->Get("h_InvMass");
0051     h_InvMass_sphenix[imode] = (TH1*)tfile[imode]->Get("h_InvMass_sphenix");
0052 
0053     // Now get the histograms Inv Mass with momentum resolution smearing
0054     h_InvMass_smeared[imode] = (TH1*)tfile[imode]->Get("h_InvMass_smeared");
0055     h_InvMass_smeared_sphenix[imode] = (TH1*)tfile[imode]->Get("h_InvMass_smeared_sphenix");
0056 
0057     // Now get the histograms transverse momentum
0058     h_pt[imode] = (TH1*)tfile[imode]->Get("h_pt");
0059     h_pt_sphenix[imode] = (TH1*)tfile[imode]->Get("h_pt_sphenix");
0060 
0061   }
0062 
0063   TFile *savefile = new TFile("AcceptanceMRP.root","RECREATE");
0064 
0065   // Create the total rapidity (sum of all 3 modes)
0066   h_rapt_total = (TH1*)h_rapt[1]->Clone("h_rapt_total");
0067   h_rapt_total->Add( h_rapt[0] );
0068   h_rapt_total->Add( h_rapt[2] );
0069 
0070   h_rapt_sphenix_total = (TH1*)h_rapt_sphenix[0]->Clone("h_rapt_sphenix_total");
0071   h_rapt_sphenix_total->Add( h_rapt_sphenix[1] );
0072   h_rapt_sphenix_total->Add( h_rapt_sphenix[2] );
0073 
0074   float markersize = 0.7;
0075 
0076   // Plot the rapidity acceptance from all 3 modes combined
0077   TCanvas *c_rap = new TCanvas("c_rap","Rapidity",550,425);
0078   //h_rapt_total->Draw("ehist");
0079   h_rapt_sphenix_total->SetLineColor(kBlack);
0080   h_rapt_sphenix_total->SetMarkerColor(kBlack);
0081   h_rapt_sphenix_total->SetMarkerSize( markersize );
0082   h_rapt_sphenix_total->Draw("ehist");
0083   h_rapt_sphenix[0]->SetLineColor(kBlue);
0084   h_rapt_sphenix[0]->SetMarkerColor(kBlue);
0085   h_rapt_sphenix[0]->SetMarkerSize( markersize );
0086   h_rapt_sphenix[0]->Draw("ehistsame");
0087   h_rapt_sphenix[1]->SetLineColor(kRed);
0088   h_rapt_sphenix[1]->SetMarkerColor(kRed);
0089   h_rapt_sphenix[1]->SetMarkerSize( markersize );
0090   h_rapt_sphenix[1]->Draw("ehistsame");
0091   h_rapt_sphenix[2]->SetLineColor(kGreen);
0092   h_rapt_sphenix[2]->SetMarkerColor(kGreen);
0093   h_rapt_sphenix[2]->SetMarkerSize( markersize );
0094   h_rapt_sphenix[2]->Draw("ehistsame");
0095   gPad->SetLogy(1);
0096 
0097   //Create the total invariant mass (sum of all 3 modes)
0098   h_InvMass_total = (TH1*)h_InvMass[0]->Clone("h_InvMass_total");
0099   h_InvMass_total->Add( h_InvMass[1] );
0100   h_InvMass_total->Add( h_InvMass[2] );
0101 
0102   h_InvMass_sphenix_total = (TH1*)h_InvMass[0]->Clone("h_InvMass_sphenix_total");
0103   h_InvMass_sphenix_total->Add( h_InvMass_sphenix[1] );
0104   h_InvMass_sphenix_total->Add( h_InvMass_sphenix[2] );
0105 
0106   // Plot the mass acceptance from all 3 modes combined
0107   TCanvas *d_rap = new TCanvas("d_InvMass","Invariant Mass",550,425);
0108   h_InvMass_sphenix_total->SetLineColor(kBlack);
0109   h_InvMass_sphenix_total->SetMarkerColor(kBlack);
0110   h_InvMass_sphenix_total->SetMarkerSize( markersize );
0111   h_InvMass_sphenix_total->Draw("ehist");
0112   h_InvMass_sphenix[0]->SetLineColor(kBlue);
0113   h_InvMass_sphenix[0]->SetMarkerColor(kBlue);
0114   h_InvMass_sphenix[0]->SetMarkerSize( markersize );
0115   h_InvMass_sphenix[0]->Draw("ehistsame");
0116   h_InvMass_sphenix[1]->SetLineColor(kRed);
0117   h_InvMass_sphenix[1]->SetMarkerColor(kRed);
0118   h_InvMass_sphenix[1]->SetMarkerSize( markersize );
0119   h_InvMass_sphenix[1]->Draw("ehistsame");
0120   h_InvMass_sphenix[2]->SetLineColor(kGreen);
0121   h_InvMass_sphenix[2]->SetMarkerColor(kGreen);
0122   h_InvMass_sphenix[2]->SetMarkerSize( markersize );
0123   h_InvMass_sphenix[2]->Draw("ehistsame");
0124   gPad->SetLogy(1);
0125 
0126   //Create the total smeared invariant mass (sum of all 3 modes)
0127   h_InvMass_smeared_total = (TH1*)h_InvMass_smeared[0]->Clone("h_InvMass_smeared_total");
0128   h_InvMass_smeared_total->Add( h_InvMass_smeared[1] );
0129   h_InvMass_smeared_total->Add( h_InvMass_smeared[2] );
0130 
0131   h_InvMass_smeared_sphenix_total = (TH1*)h_InvMass_smeared_sphenix[0]->Clone("h_InvMass_smeared_sphenix_total");
0132   h_InvMass_smeared_sphenix_total->Add( h_InvMass_smeared_sphenix[1] );
0133   h_InvMass_smeared_sphenix_total->Add( h_InvMass_smeared_sphenix[2] );
0134 
0135   // Plot the mass acceptance from all 3 modes combined
0136   TCanvas *d_rap_smeared = new TCanvas("d_InvMass_smeared","Invariant Mass",550,425);
0137   h_InvMass_smeared_sphenix_total->SetLineColor(kBlack);
0138   h_InvMass_smeared_sphenix_total->SetMarkerColor(kBlack);
0139   h_InvMass_smeared_sphenix_total->SetMarkerSize( markersize );
0140   h_InvMass_smeared_sphenix_total->Draw("ehist");
0141   h_InvMass_smeared_sphenix[0]->SetLineColor(kBlue);
0142   h_InvMass_smeared_sphenix[0]->SetMarkerColor(kBlue);
0143   h_InvMass_smeared_sphenix[0]->SetMarkerSize( markersize );
0144   h_InvMass_smeared_sphenix[0]->Draw("ehistsame");
0145   h_InvMass_smeared_sphenix[1]->SetLineColor(kRed);
0146   h_InvMass_smeared_sphenix[1]->SetMarkerColor(kRed);
0147   h_InvMass_smeared_sphenix[1]->SetMarkerSize( markersize );
0148   h_InvMass_smeared_sphenix[1]->Draw("ehistsame");
0149   h_InvMass_smeared_sphenix[2]->SetLineColor(kGreen);
0150   h_InvMass_smeared_sphenix[2]->SetMarkerColor(kGreen);
0151   h_InvMass_smeared_sphenix[2]->SetMarkerSize( markersize );
0152   h_InvMass_smeared_sphenix[2]->Draw("ehistsame");
0153   gPad->SetLogy(1);
0154 
0155   double tot_qed = h_InvMass_smeared_sphenix[0]->Integral();
0156   double tot_coh = h_InvMass_smeared_sphenix[1]->Integral();
0157   double tot_incoh = h_InvMass_smeared_sphenix[2]->Integral();
0158   cout << "Events in sPHENIX" << endl;
0159   cout << "QED: " << tot_qed << endl;
0160   cout << "Coh J/Psi: " << tot_coh << endl;
0161   cout << "Incoh J/Psi: " << tot_incoh << endl;
0162 
0163   //Create the total transverse momentum histogram (sum of all 3 modes)
0164   h_pt_total = (TH1*)h_pt[0]->Clone("h_pt_total");  
0165   h_pt_total->Add( h_pt[1] );
0166   h_pt_total->Add( h_pt[2] );
0167 
0168 
0169   h_pt_sphenix_total = (TH1*)h_pt_sphenix[0]->Clone("h_pt_sphenix_total");
0170   h_pt_sphenix_total->Add( h_pt_sphenix[1] );
0171   h_pt_sphenix_total->Add( h_pt_sphenix[2] );
0172 
0173   //Plot the transverse momentum acceptance from all 3 modes combined
0174   TCanvas *e_pt = new TCanvas("e_pt","Transverse Momentum",550,425);
0175   h_pt_sphenix_total->SetLineColor(kBlack);
0176   h_pt_sphenix_total->SetMarkerColor(kBlack);
0177   h_pt_sphenix_total->SetMarkerSize( markersize );
0178   h_pt_sphenix_total->SetXTitle( "p_{T} (GeV/c)" );
0179   h_pt_sphenix_total->Draw("ehist");
0180   h_pt_sphenix[0]->SetLineColor(kBlue);
0181   h_pt_sphenix[0]->SetMarkerColor(kBlue);
0182   h_pt_sphenix[0]->SetMarkerSize( markersize );
0183   h_pt_sphenix[0]->Draw("ehistsame");
0184   h_pt_sphenix[1]->SetLineColor(kRed);
0185   h_pt_sphenix[1]->SetMarkerColor(kRed);
0186   h_pt_sphenix[1]->SetMarkerSize( markersize );
0187   h_pt_sphenix[1]->Draw("ehistsame");
0188   h_pt_sphenix[2]->SetLineColor(kGreen);
0189   h_pt_sphenix[2]->SetMarkerColor(kGreen);
0190   h_pt_sphenix[2]->SetMarkerSize( markersize );
0191   h_pt_sphenix[2]->Draw("ehistsame");
0192   gPad->SetLogy(1);
0193 
0194   savefile->Write();
0195 }
0196