Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AcceptanceMRP.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AcceptanceMRP.C
1 //
2 //
3 //
4 //
5 
7 {
8  gStyle->SetOptStat(0);
9 
10  // Open up the 3 files with the saved histograms
11  // and get the histograms
12  const int NMODES = 3;
13  const char* mode_dir[NMODES] = { "PROD1", "PROD2", "PROD4" };
14  TFile *tfile[NMODES];
15  TString name;
16 
17  TH1 *h_rapt[NMODES];
18  TH1 *h_rapt_sphenix[NMODES];
19  TH1 *h_rapt_total; // all 3 modes summed
20  TH1 *h_rapt_sphenix_total;
21 
22  TH1 *h_InvMass[NMODES];
23  TH1 *h_InvMass_sphenix[NMODES];
24  TH1 *h_InvMass_total; // all 3 modes summed
25  TH1 *h_InvMass_sphenix_total;
26 
27  TH1 *h_InvMass_smeared[NMODES];
28  TH1 *h_InvMass_smeared_sphenix[NMODES];
29  TH1 *h_InvMass_smeared_total; // all 3 modes summed
30  TH1 *h_InvMass_smeared_sphenix_total;
31 
32  TH1 *h_pt[NMODES];
33  TH1 *h_pt_sphenix[NMODES];
34  TH1 *h_pt_total; // all 3 modes summed
35  TH1 *h_pt_sphenix_total;
36 
37 
38  // Loop over the prod_modes
39  for (int imode=0; imode<NMODES; imode++)
40  {
41  // Open up the TFile
42  name = mode_dir[imode]; name += "/upc_starlight.root";
43  tfile[imode] = new TFile(name,"READ");
44 
45  // Now get the histograms rapidity
46  h_rapt[imode] = (TH1*)tfile[imode]->Get("h_rapt");
47  h_rapt_sphenix[imode] = (TH1*)tfile[imode]->Get("h_rapt_sphenix");
48 
49  // Now get the histograms Inv Mass
50  h_InvMass[imode] = (TH1*)tfile[imode]->Get("h_InvMass");
51  h_InvMass_sphenix[imode] = (TH1*)tfile[imode]->Get("h_InvMass_sphenix");
52 
53  // Now get the histograms Inv Mass with momentum resolution smearing
54  h_InvMass_smeared[imode] = (TH1*)tfile[imode]->Get("h_InvMass_smeared");
55  h_InvMass_smeared_sphenix[imode] = (TH1*)tfile[imode]->Get("h_InvMass_smeared_sphenix");
56 
57  // Now get the histograms transverse momentum
58  h_pt[imode] = (TH1*)tfile[imode]->Get("h_pt");
59  h_pt_sphenix[imode] = (TH1*)tfile[imode]->Get("h_pt_sphenix");
60 
61  }
62 
63  TFile *savefile = new TFile("AcceptanceMRP.root","RECREATE");
64 
65  // Create the total rapidity (sum of all 3 modes)
66  h_rapt_total = (TH1*)h_rapt[1]->Clone("h_rapt_total");
67  h_rapt_total->Add( h_rapt[0] );
68  h_rapt_total->Add( h_rapt[2] );
69 
70  h_rapt_sphenix_total = (TH1*)h_rapt_sphenix[0]->Clone("h_rapt_sphenix_total");
71  h_rapt_sphenix_total->Add( h_rapt_sphenix[1] );
72  h_rapt_sphenix_total->Add( h_rapt_sphenix[2] );
73 
74  float markersize = 0.7;
75 
76  // Plot the rapidity acceptance from all 3 modes combined
77  TCanvas *c_rap = new TCanvas("c_rap","Rapidity",550,425);
78  //h_rapt_total->Draw("ehist");
79  h_rapt_sphenix_total->SetLineColor(kBlack);
80  h_rapt_sphenix_total->SetMarkerColor(kBlack);
81  h_rapt_sphenix_total->SetMarkerSize( markersize );
82  h_rapt_sphenix_total->Draw("ehist");
83  h_rapt_sphenix[0]->SetLineColor(kBlue);
84  h_rapt_sphenix[0]->SetMarkerColor(kBlue);
85  h_rapt_sphenix[0]->SetMarkerSize( markersize );
86  h_rapt_sphenix[0]->Draw("ehistsame");
87  h_rapt_sphenix[1]->SetLineColor(kRed);
88  h_rapt_sphenix[1]->SetMarkerColor(kRed);
89  h_rapt_sphenix[1]->SetMarkerSize( markersize );
90  h_rapt_sphenix[1]->Draw("ehistsame");
91  h_rapt_sphenix[2]->SetLineColor(kGreen);
92  h_rapt_sphenix[2]->SetMarkerColor(kGreen);
93  h_rapt_sphenix[2]->SetMarkerSize( markersize );
94  h_rapt_sphenix[2]->Draw("ehistsame");
95  gPad->SetLogy(1);
96 
97  //Create the total invariant mass (sum of all 3 modes)
98  h_InvMass_total = (TH1*)h_InvMass[0]->Clone("h_InvMass_total");
99  h_InvMass_total->Add( h_InvMass[1] );
100  h_InvMass_total->Add( h_InvMass[2] );
101 
102  h_InvMass_sphenix_total = (TH1*)h_InvMass[0]->Clone("h_InvMass_sphenix_total");
103  h_InvMass_sphenix_total->Add( h_InvMass_sphenix[1] );
104  h_InvMass_sphenix_total->Add( h_InvMass_sphenix[2] );
105 
106  // Plot the mass acceptance from all 3 modes combined
107  TCanvas *d_rap = new TCanvas("d_InvMass","Invariant Mass",550,425);
108  h_InvMass_sphenix_total->SetLineColor(kBlack);
109  h_InvMass_sphenix_total->SetMarkerColor(kBlack);
110  h_InvMass_sphenix_total->SetMarkerSize( markersize );
111  h_InvMass_sphenix_total->Draw("ehist");
112  h_InvMass_sphenix[0]->SetLineColor(kBlue);
113  h_InvMass_sphenix[0]->SetMarkerColor(kBlue);
114  h_InvMass_sphenix[0]->SetMarkerSize( markersize );
115  h_InvMass_sphenix[0]->Draw("ehistsame");
116  h_InvMass_sphenix[1]->SetLineColor(kRed);
117  h_InvMass_sphenix[1]->SetMarkerColor(kRed);
118  h_InvMass_sphenix[1]->SetMarkerSize( markersize );
119  h_InvMass_sphenix[1]->Draw("ehistsame");
120  h_InvMass_sphenix[2]->SetLineColor(kGreen);
121  h_InvMass_sphenix[2]->SetMarkerColor(kGreen);
122  h_InvMass_sphenix[2]->SetMarkerSize( markersize );
123  h_InvMass_sphenix[2]->Draw("ehistsame");
124  gPad->SetLogy(1);
125 
126  //Create the total smeared invariant mass (sum of all 3 modes)
127  h_InvMass_smeared_total = (TH1*)h_InvMass_smeared[0]->Clone("h_InvMass_smeared_total");
128  h_InvMass_smeared_total->Add( h_InvMass_smeared[1] );
129  h_InvMass_smeared_total->Add( h_InvMass_smeared[2] );
130 
131  h_InvMass_smeared_sphenix_total = (TH1*)h_InvMass_smeared_sphenix[0]->Clone("h_InvMass_smeared_sphenix_total");
132  h_InvMass_smeared_sphenix_total->Add( h_InvMass_smeared_sphenix[1] );
133  h_InvMass_smeared_sphenix_total->Add( h_InvMass_smeared_sphenix[2] );
134 
135  // Plot the mass acceptance from all 3 modes combined
136  TCanvas *d_rap_smeared = new TCanvas("d_InvMass_smeared","Invariant Mass",550,425);
137  h_InvMass_smeared_sphenix_total->SetLineColor(kBlack);
138  h_InvMass_smeared_sphenix_total->SetMarkerColor(kBlack);
139  h_InvMass_smeared_sphenix_total->SetMarkerSize( markersize );
140  h_InvMass_smeared_sphenix_total->Draw("ehist");
141  h_InvMass_smeared_sphenix[0]->SetLineColor(kBlue);
142  h_InvMass_smeared_sphenix[0]->SetMarkerColor(kBlue);
143  h_InvMass_smeared_sphenix[0]->SetMarkerSize( markersize );
144  h_InvMass_smeared_sphenix[0]->Draw("ehistsame");
145  h_InvMass_smeared_sphenix[1]->SetLineColor(kRed);
146  h_InvMass_smeared_sphenix[1]->SetMarkerColor(kRed);
147  h_InvMass_smeared_sphenix[1]->SetMarkerSize( markersize );
148  h_InvMass_smeared_sphenix[1]->Draw("ehistsame");
149  h_InvMass_smeared_sphenix[2]->SetLineColor(kGreen);
150  h_InvMass_smeared_sphenix[2]->SetMarkerColor(kGreen);
151  h_InvMass_smeared_sphenix[2]->SetMarkerSize( markersize );
152  h_InvMass_smeared_sphenix[2]->Draw("ehistsame");
153  gPad->SetLogy(1);
154 
155  double tot_qed = h_InvMass_smeared_sphenix[0]->Integral();
156  double tot_coh = h_InvMass_smeared_sphenix[1]->Integral();
157  double tot_incoh = h_InvMass_smeared_sphenix[2]->Integral();
158  cout << "Events in sPHENIX" << endl;
159  cout << "QED: " << tot_qed << endl;
160  cout << "Coh J/Psi: " << tot_coh << endl;
161  cout << "Incoh J/Psi: " << tot_incoh << endl;
162 
163  //Create the total transverse momentum histogram (sum of all 3 modes)
164  h_pt_total = (TH1*)h_pt[0]->Clone("h_pt_total");
165  h_pt_total->Add( h_pt[1] );
166  h_pt_total->Add( h_pt[2] );
167 
168 
169  h_pt_sphenix_total = (TH1*)h_pt_sphenix[0]->Clone("h_pt_sphenix_total");
170  h_pt_sphenix_total->Add( h_pt_sphenix[1] );
171  h_pt_sphenix_total->Add( h_pt_sphenix[2] );
172 
173  //Plot the transverse momentum acceptance from all 3 modes combined
174  TCanvas *e_pt = new TCanvas("e_pt","Transverse Momentum",550,425);
175  h_pt_sphenix_total->SetLineColor(kBlack);
176  h_pt_sphenix_total->SetMarkerColor(kBlack);
177  h_pt_sphenix_total->SetMarkerSize( markersize );
178  h_pt_sphenix_total->SetXTitle( "p_{T} (GeV/c)" );
179  h_pt_sphenix_total->Draw("ehist");
180  h_pt_sphenix[0]->SetLineColor(kBlue);
181  h_pt_sphenix[0]->SetMarkerColor(kBlue);
182  h_pt_sphenix[0]->SetMarkerSize( markersize );
183  h_pt_sphenix[0]->Draw("ehistsame");
184  h_pt_sphenix[1]->SetLineColor(kRed);
185  h_pt_sphenix[1]->SetMarkerColor(kRed);
186  h_pt_sphenix[1]->SetMarkerSize( markersize );
187  h_pt_sphenix[1]->Draw("ehistsame");
188  h_pt_sphenix[2]->SetLineColor(kGreen);
189  h_pt_sphenix[2]->SetMarkerColor(kGreen);
190  h_pt_sphenix[2]->SetMarkerSize( markersize );
191  h_pt_sphenix[2]->Draw("ehistsame");
192  gPad->SetLogy(1);
193 
194  savefile->Write();
195 }
196