Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
project_quarkonium_mass.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file project_quarkonium_mass.C
2 {
3  //SetsPhenixStyle();
4  gROOT->SetStyle("Plain");
5  gStyle->SetOptStat(0);
6  gStyle->SetOptFit(0);
7  gStyle->SetOptTitle(0);
8 
9  TFile *fout = new TFile("root_files/ntp_quarkonium_out.root","recreate");
10 
11  TH1D* recomass[4];
12  char name[500];
13  for(int istate = 0; istate < 4; ++istate)
14  {
15  sprintf(name, "recomass%i",istate);
16  //recomass[istate] = new TH1D(name,name,100,7.0,11.0);
17  recomass[istate] = new TH1D(name,name,200,7.0,11.0);
18 
19  }
20 
21  TH2D *hdca2d = new TH2D("hdca2d","hdca2d", 200, 0.0, 50.0, 1000, -0.002, 0.002);
22  TH2D *hpcaz = new TH2D("hpcaz","hpcaz",200, 0.0, 50.0, 1000,-0.1,0.1);
23 
24  Float_t event;
25  Float_t px;
26  Float_t py;
27  Float_t pz;
28  Float_t pt;
29  Float_t gembed;
30  Float_t quality;
31  Float_t charge;
32  Float_t dca2d;
33  Float_t pcaz;
34  Float_t gvz;
35  Float_t ntpc;
36  Float_t nmaps;
37 
38  Float_t decaymass=0.000511;
39 
40  // what do we have in the file?
41  int events_per_file = 1;
42  int num_ups_per_event = 20;
43 
44  // what maximum yields do we want?
45  // These are pp yields for 197 /nb of pp running, with
46  //double pair_acc = 0.60 * 0.9 * 0.98; // fraction into 1 unit of rapidity * pair eID fraction * trigger fraction
47 
48  // pp case:
49  // These are pp yields from Sasha's TN for 13,100 B pp collisions
50  //int Npp[3] = {17074, 4440, 2475}; // 1S, 2S, 3S
51 
52  // AuAu case:
53  // These are yields from Sasha's TN for 24B AuAu events with 100% eID
54  int Npp[3] = {27120, 7053, 3932}; // 1S, 2S, 3S unsuppressed
55 
56  double suppr_state[3] = {0.535, 0.17, 0.035}; // suppression factor from Strickland paper
57  double eID_eff = 0.9;
58  double tracking_eff = 0.95;
59 
60  double quality_cut = 10;
61 
62  bool no_suppression = true;
63 
64  int nupsmax[3] = {0,0,0};
65  for(int istate = 0; istate < 3; ++istate)
66  {
67  if(no_suppression) suppr_state[istate] = 1.0;
68 
69  nupsmax[istate] = eID_eff * tracking_eff * suppr_state[istate] * Npp[istate];
70 
71  nupsmax[istate] = 100000; // take all
72  cout << "Requested max Upsilon counts for istate " << istate << " = " << nupsmax[istate] << endl;
73  }
74 
75 
76  int nups[3] = {0,0,0};
77 
78  cout << "Upsilons requested = " << nupsmax << endl;
79 
80  for(int ifile=0;ifile<1000;ifile++)
81  {
82  if(nups[0] > nupsmax[0])
83  break;
84 
85  char name[2000];
86 
87  //sprintf(name,"/sphenix/user/frawley/cluster_efficiency/macros/macros/g4simulations/eval_output/g4svtx_eval_%i.root_g4svtx_eval.root",ifile);
88  //sprintf(name,"/sphenix/user/frawley/acts_qa/macros/macros/g4simulations/eval_output_3/g4svtx_eval_%i.root_g4svtx_eval.root",ifile);
89  sprintf(name,"/sphenix/user/frawley/acts_qa/macros/macros/g4simulations/eval_output_2/g4svtx_eval_%i.root_g4svtx_eval.root",ifile);
90 
91  cout << "Adding file number " << ifile << " with name " << name << endl;
92 
93  TChain* ntp_vertex = new TChain("ntp_vertex","reco events");
94  ntp_vertex->Add(name);
95 
96  TChain* ntp_track = new TChain("ntp_track","reco tracks");
97  ntp_track->Add(name);
98 
99  ntp_track->SetBranchAddress("event",&event);
100  ntp_track->SetBranchAddress("px",&px);
101  ntp_track->SetBranchAddress("py",&py);
102  ntp_track->SetBranchAddress("pz",&pz);
103  ntp_track->SetBranchAddress("pt",&pt);
104  ntp_track->SetBranchAddress("charge",&charge);
105  ntp_track->SetBranchAddress("dca2d",&dca2d);
106  ntp_track->SetBranchAddress("pcaz",&pcaz);
107  ntp_track->SetBranchAddress("gvz",&gvz);
108  ntp_track->SetBranchAddress("gembed",&gembed);
109  ntp_track->SetBranchAddress("quality",&quality);
110  ntp_track->SetBranchAddress("ntpc",&ntpc);
111  ntp_track->SetBranchAddress("nmaps",&nmaps);
112 
113  int ntracks=ntp_track->GetEntries();
114 
115  // capture the dca2d and dcaz histograms for the pions
116  for(int i=0;i<ntracks;i++)
117  {
118  ntp_track->GetEntry(i);
119 
120  if(gembed != 2)
121  continue;
122 
123  hdca2d->Fill(pt, dca2d);
124  hpcaz->Fill(pt, pcaz-gvz);
125  }
126 
127  //events_per_file = ntp_vertex->GetEntries();
128  cout << " events in this file = " << events_per_file << endl;
129 
130  for(int iev = 0;iev<events_per_file;iev++)
131  {
132  for(int iups = 0;iups< num_ups_per_event; iups++)
133  {
134  //int istate = iups%3;
135  int istate = 0;
136 
137  if(nups[istate] > nupsmax[istate])
138  continue;
139 
140  int nlept1 = 0;
141  int nlept2 = 0;
142  int lept1=-1;
143  int lept2 = -1;
144  Float_t px1=0;
145  Float_t px2=0;
146  Float_t py1=0;
147  Float_t py2=0;
148  Float_t pz1 = 0;
149  Float_t pz2 = 0;
150 
151  TLorentzVector t1;
152  TLorentzVector t2;
153  for(int i=0;i<ntracks;i++)
154  {
155  ntp_track->GetEntry(i);
156 
157  if(event != iev)
158  continue;
159 
160  if(gembed != iups+3)
161  continue;
162 
163  if(quality > quality_cut)
164  continue;
165 
166  if(ntpc < 20)
167  continue;
168 
169  if(nmaps <= 1)
170  continue;
171 
172  if(sqrt(px*px + py*py + pz*pz) < 1.0)
173  continue;
174 
175  // cout << "event = " << event << " iups " << iups << " charge " << charge << " px " << px << " py " << py << " pz " << pz << " gembed " << gembed << " quality " << quality << endl;
176 
177 
178  if(charge == 1)
179  {
180  nlept1++;
181 
182  lept1 = 1;
183  px1 = px;
184  py1 = py;
185  pz1 = pz;
186 
187  Float_t E1 = sqrt( pow(px1,2) + pow(py1,2) + pow(pz1,2) + pow(decaymass,2));
188  t1.SetPxPyPzE(px1,py1,pz1,E1);
189  }
190 
191  if(charge == -1)
192  {
193  nlept2++;
194 
195  lept2 = 1;
196  px2 = px;
197  py2 = py;
198  pz2 = pz;
199 
200  Float_t E2 = sqrt( pow(px2,2) + pow(py2,2) + pow(pz2,2) + pow(decaymass,2));
201  t2.SetPxPyPzE(px2,py2,pz2,E2);
202  }
203  //cout << " lept1 " << lept1 << " lept2 " << lept2 << endl;
204  }
205 
206  // calculate mass
207  if(nlept1 == 1 && nlept2 == 1)
208  //if(nlept1 > 0 && nlept2 > 0)
209  {
210  TLorentzVector tsum;
211  tsum = t1+t2;
212  recomass[istate]->Fill(tsum.M());
213  recomass[3]->Fill(tsum.M()); // total spectrum
214  if(tsum.M() > 7 && tsum.M() < 11)
215  nups[istate]++;
216  //cout << " event " << event << " gembed " << gembed << endl;
217  //cout << " istate " << " nups[istate] " << nups[istate] << " reco mass " << tsum.M() << endl;
218  }
219  }
220  }
221  delete ntp_track;
222  delete ntp_vertex;
223  }
224 
225  cout << " requested: " << nupsmax[0] << " reconstructed: " << nups[0] << " Upsilons " << endl;
226 
227  for(int istate =0; istate < 3; ++istate)
228  {
229  recomass[istate]->Write();
230  cout << " requested for istate: " << istate << " nupsmax = " << nupsmax[istate] << " reconstructed = " << nups[istate] << " Upsilons " << endl;
231  }
232  recomass[3]->Write();
233 
234  hdca2d->Write();
235  hpcaz->Write();
236 
237  fout->Close();
238 
239 }
240 
241