Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
bnl_rich_analyzer_pid.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file bnl_rich_analyzer_pid.cpp
1 /*
2  Adjustments made to original:
3  Fixed a |= somewhere that should have been !=
4  Increased size of em[][] array
5  Added if statement to make sure imom != 0
6  Changed the i/o to append to existing output file
7  Changed read() to read(string input_filename)
8  Changed "tree_rich" to updated "eval_rich"
9 
10  Personal preference: Changed the bounds on polar angle to [15,16] instead of [12,13]
11 */
12 
13 #include <Riostream.h>
14 #include <stdio.h>
15 #include <fstream>
16 #include <sstream>
17 #include <string>
18 
19 #include <TMath.h>
20 #include <TEnv.h>
21 #include <TH2F.h>
22 #include <TH1F.h>
23 #include <TTree.h>
24 #include <TDatabasePDG.h>
25 #include <TStyle.h>
26 #include <TLine.h>
27 #include <TEllipse.h>
28 #include <TCanvas.h>
29 #include <TProfile.h>
30 #include <TH1D.h>
31 #include <TH3F.h>
32 #include <TF1.h>
33 #include <TText.h>
34 #include <TLegend.h>
35 #include <TChain.h>
36 #include <TString.h>
37 #include <TLorentzVector.h>
38 #include <TRandom.h>
39 #include <TMatrixTBase.h>
40 #include <TMatrixT.h>
41 #include "TPaveText.h"
42 #include <TGraphErrors.h>
43 #include <TFile.h>
44 #include <TTree.h>
45 #include <TSpline.h>
46 #include <TFrame.h>
47 
48 using namespace std;
49 
50 class eic_bnl_rich {
51 
52  private:
53 
54  public:
55 
56  Double_t ind_ray(double Ex, double Ey, double Ez, double Dx, double Dy, double Dz, double cx, double cy, double cz, double vx, double vy, double vz);
57 
58  void acq(string input_filename, int ind, int pix_lab, int part);
59  Double_t momentum, ch, ch_v[500];
60  Double_t c_mean, c_rms, p_ang;
61  Int_t sec;
62 
63  double qe(double energy);
64 
65  void read(string input_filename);
66 
67 };
68 
69 Double_t eic_bnl_rich::ind_ray(double Ex, double Ey, double Ez, double Dx, double Dy, double Dz, double cx, double cy, double cz, double vx, double vy, double vz){
70 
71  //Double_t cx = 100.;
72  //Double_t cy = 0.;
73  //Double_t cz = 134.5;
74 
75  //Double_t cx,cy,cz;
76  //Double_t sx,sy,sz;
77  LongDouble_t cex,cey,cez;
78  LongDouble_t cdx,cdy,cdz;
79 
80  Int_t i,iwhere;
81 
82  LongDouble_t th,a,d;
83  LongDouble_t x,dx;
84 
85  LongDouble_t y,y1;
86 
87  LongDouble_t eps = 0.00000000001;
88  LongDouble_t R = 195.; //rich
89  //LongDouble_t R = 299.9; //rich3
90 
91  //eic_dual_rich *f = new eic_dual_rich();
92 
93  Double_t sx,sy,sz;
94  Double_t esx,esy,esz;
95  Double_t es, theta_c;
96 
97  cex = -cx+Ex;
98  cey = -cy+Ey;
99  cez = -cz+Ez;
100 
101  cdx = -cx+Dx;
102  cdy = -cy+Dy;
103  cdz = -cz+Dz;
104 
105  //cout<<"ce is: "<<cex<<" "<<cey<<" "<<cez<<endl;
106  //cout<<"cd is: "<<cdx<<" "<<cdy<<" "<<cdz<<endl;
107 
108  a = TMath::Sqrt(cex*cex+cey*cey+cez*cez);
109  d = TMath::Sqrt(cdx*cdx+cdy*cdy+cdz*cdz);
110  th = TMath::ACos((cdx*cex+cdy*cey+cdz*cez)/a/d);
111 
112  //cout<<"a,d,th is: "<<a<<" "<<d<<" "<<th<<endl;
113 
114  i = 0;
115  x = th/2.;
116  //cout<<"x, sinx, sin(th-x) is: "<<x<<" "<<sin(x)<<" "<<sin(th-x)<<endl;
117  y = R*(a*sin(x)-d*sin(th-x))+a*d*sin(th-2*x);
118  y1 = R*(a*cos(x)+d*cos(th-x))-2*a*d*cos(th-2*x);
119  //cout<<"y, y1 is: "<<y<<" "<<y1<<endl;
120  //dx = -(f->newp(x, th, a, d, R)/f->newpp(x, th, a, d, R));
121  dx = -y/y1;
122 
123  while(TMath::Abs(dx)>eps && i<100){
124 
125  x+=dx;
126  y = R*(a*sin(x)-d*sin(th-x))+a*d*sin(th-2*x);
127  y1 = R*(a*cos(x)+d*cos(th-x))-2*a*d*cos(th-2*x);
128  //dx = -(f->newp(x, th, a, d, R)/f->newpp(x, th, a, d, R));
129  dx = -y/y1;
130  i++;
131 
132  }
133 
134  //if(i>=100) cout<<"Not convergent"<<endl;
135 
136  if(i<100){
137  sx = cx + (R*cos(x)/a-R*sin(x)/tan(th)/a)*cex + (R*sin(x)/d/sin(th))*cdx;
138  sy = cy + (R*cos(x)/a-R*sin(x)/tan(th)/a)*cey + (R*sin(x)/d/sin(th))*cdy;
139  sz = cz + (R*cos(x)/a-R*sin(x)/tan(th)/a)*cez + (R*sin(x)/d/sin(th))*cdz;
140 
141  }
142 
143  esx = sx - Ex;
144  esy = sy - Ey;
145  esz = sz - Ez;
146 
147  //cout<<"S: "<<sx<<" "<<sy<<" "<<sz<<endl;
148 
149  es = sqrt(esx*esx+esy*esy+esz*esz);
150 
151  esx = esx/es;
152  esy = esy/es;
153  esz = esz/es;
154 
155  theta_c = TMath::ACos((esx*vx+esy*vy+esz*vz));
156 
157  return theta_c;
158 
159 }
160 
161 double eic_bnl_rich::qe(double energy){
162 
163  Double_t qe = 0.;
164 
165  qe = 12.5*(energy-6.2);
166  if(energy>10.3) qe = 0.; // no photons below 120 nm = 10.3 eV
167 
168  return qe;
169 
170 }
171 
172 void eic_bnl_rich::acq(string input_filename, int ind, int pix_lab, int part){
173 
174  c_mean = 0.;
175  c_rms = 0.;
176  p_ang = 0.;
177 
178  Double_t rtd = 180./TMath::Pi();
179 
180  TFile *file=new TFile(input_filename.c_str());
181  if (file->IsZombie()) {
182  cout << "Error opening file" << input_filename << endl;
183  exit(-1);
184  }
185  //else cout << "open file " << input_filename << endl;
186 
187  TTree *eic_rich = (TTree*) file->Get("eval_rich");
188 
189  Int_t eic_rich_event=0,eic_rich_bankid=0,eic_rich_volumeid=0,eic_rich_hitid=0,*eic_rich_pid=0,eic_rich_mpid=0,eic_rich_trackid=0,eic_rich_mtrackid=0,eic_rich_otrackid=0;
190  Double_t eic_rich_hit_x=0,eic_rich_hit_y=0,eic_rich_hit_z=0, eic_rich_emi_x=0, eic_rich_emi_y=0, eic_rich_emi_z=0,eic_rich_px=0,eic_rich_py=0,eic_rich_pz=0,eic_rich_mpx=0,eic_rich_mpy=0,eic_rich_mpz=0,eic_rich_e=0,eic_rich_me=0,eic_rich_edep=0;
191 
192  eic_rich->SetBranchAddress("event",&eic_rich_event);
193  eic_rich->SetBranchAddress("hit_x",&eic_rich_hit_x);
194  eic_rich->SetBranchAddress("hit_y",&eic_rich_hit_y);
195  eic_rich->SetBranchAddress("hit_z",&eic_rich_hit_z);
196  eic_rich->SetBranchAddress("emi_x",&eic_rich_emi_x);
197  eic_rich->SetBranchAddress("emi_y",&eic_rich_emi_y);
198  eic_rich->SetBranchAddress("emi_z",&eic_rich_emi_z);
199  eic_rich->SetBranchAddress("px",&eic_rich_px);
200  eic_rich->SetBranchAddress("py",&eic_rich_py);
201  eic_rich->SetBranchAddress("pz",&eic_rich_pz);
202  eic_rich->SetBranchAddress("mpx",&eic_rich_mpx);
203  eic_rich->SetBranchAddress("mpy",&eic_rich_mpy);
204  eic_rich->SetBranchAddress("mpz",&eic_rich_mpz);
205  eic_rich->SetBranchAddress("e",&eic_rich_e);
206  eic_rich->SetBranchAddress("me",&eic_rich_me);
207  eic_rich->SetBranchAddress("edep",&eic_rich_edep);
208  eic_rich->SetBranchAddress("bankid",&eic_rich_bankid);
209  eic_rich->SetBranchAddress("volumeid",&eic_rich_volumeid);
210  eic_rich->SetBranchAddress("hitid",&eic_rich_hitid);
211  eic_rich->SetBranchAddress("pid",&eic_rich_pid);
212  eic_rich->SetBranchAddress("mpid",&eic_rich_mpid);
213  eic_rich->SetBranchAddress("trackid",&eic_rich_trackid);
214  eic_rich->SetBranchAddress("mtrackid",&eic_rich_mtrackid);
215  eic_rich->SetBranchAddress("otrackid",&eic_rich_otrackid);
216 
217  TRandom rran;
218  rran.SetSeed(0);
219  Int_t ev_count[61];
220  for(Int_t i=0;i<61;i++) ev_count[i]=0;
221  Int_t ph_count = 0;
222  Int_t ph_ch_count = 0;
223 
224  TH2F *ph_det = new TH2F("ph_det","", 1666, -250., 250., 1666, -250., 250.);
225  TH2F *ph_det1 = new TH2F("ph_det1","", 1666, -250., 250., 1666, -250., 250.);
226  Double_t momvv_x[10000];
227  Double_t momvv_y[10000];
228  Double_t momvv_z[10000];
229 
230  TH1F *h = new TH1F("","",1000,-70,70);
231  TH1F *spectrum_ev = new TH1F("","",1000,4.,12.);
232  TH1F *spectrum_nm = new TH1F("","",1000,100.,300.);
233  TH1F *ch_ang = new TH1F("","",1000,0.,0.3);
234  Double_t ang_cut = 0.;
235  Double_t momv[3] = {0.,0.,0.};
236  //Double_t momvv[10000][3];
237  Double_t m_emi[3] = {0.,0.,0.};
238  Double_t d_hit[3] = {0.,0.,0.};
239  Double_t xbin = 0.;
240  Double_t ybin = 0.;
241  Double_t theta = 0.;
242  Double_t phi = 0.;
243  Double_t rr[3] = {0.,0.,0.};
244  Double_t theta_cc = 0.;
245  Double_t m[4]={0.000511, 0.13957018, 0.493677, 0.938272};
246  Double_t em[3][10000];
247  Double_t vv = 0.;
248  Int_t imom = 0;
249  Double_t mom_check = 999.;
250  Int_t event_check = 1.;
251  Int_t event_check1 = 1.;
252  Int_t nph_count = 0;
253 
254  //theta_cc = 0.02;
255 
256  //cout<<theta_cc<<endl;
257 
258  TH1F **ch_pi_h;
259  ch_pi_h=new TH1F*[61];
260  for(Int_t i=0;i<61;i++){
261  ch_pi_h[i] = new TH1F(Form("ch_pi_h%d",i),"",10000,0,0.3);
262  }
263  TH1F *h_mom = new TH1F("","",100,0.,100.);
264 
265 
266  for(Int_t i=0;(i<eic_rich->GetEntries());i++){
267 
268  eic_rich->GetEntry(i);
269 
270  if(eic_rich_event<=ind){
271 
272  ph_count++;
273 
274  em[0][ph_count-1] = eic_rich_emi_x;
275  em[1][ph_count-1] = eic_rich_emi_y;
276  em[2][ph_count-1] = eic_rich_emi_z;
277 
278  //cout<<em[2][0]<<" "<<em[2][11]<<endl;
279 
280  vv = sqrt((em[0][11]-em[0][0])*(em[0][11]-em[0][0])+(em[1][11]-em[1][0])*(em[1][11]-em[1][0])+(em[2][11]-em[2][0])*(em[2][11]-em[2][0]));
281 
282  if(ph_count>50){
283  momvv_x[eic_rich_event-1]=(em[0][11]-em[0][0])/vv;
284  momvv_y[eic_rich_event-1]=(em[1][11]-em[1][0])/vv;
285  momvv_z[eic_rich_event-1]=(em[2][11]-em[2][0])/vv;
286  }
287  if(eic_rich_event!=event_check){
288  ph_count=0;
289  event_check = eic_rich_event;
290  //cout<<event_check<<endl;
291  }
292  }
293  }
294 
295  for(Int_t i=0;(i<eic_rich->GetEntries());i++){
296 
297  eic_rich->GetEntry(i);
298  //if(eic_rich_event==1){
299  //h->Fill(eic_rich_mpz);
300  //}
301 
302  ang_cut = TMath::ACos(eic_rich_mpz/sqrt(eic_rich_mpx*eic_rich_mpx+eic_rich_mpy*eic_rich_mpy+eic_rich_mpz*eic_rich_mpz))*rtd;
303 
304 
305 
306  //if(eic_rich_event<=ind && rran.Uniform(0,100)<qe(eic_rich_edep*1000000000.)){
307  if(eic_rich_event<=ind){
308 
309  momentum = sqrt(eic_rich_mpx*eic_rich_mpx+eic_rich_mpy*eic_rich_mpy+eic_rich_mpz*eic_rich_mpz);
310  imom = momentum;
311  if (imom == 0)
312  continue;
313  theta_cc = acos(sqrt(imom*imom+m[part]*m[part])/imom/1.00054);
314 
315  momv[0] = momvv_x[eic_rich_event-1];
316  momv[1] = momvv_y[eic_rich_event-1];
317  momv[2] = momvv_z[eic_rich_event-1];
318 
319  //if(eic_rich_event==1)cout<<momv[2]<<" "<<eic_rich_event<<endl;
320 
321  //momv[0] = eic_rich_mpx/sqrt(eic_rich_mpx*eic_rich_mpx+eic_rich_mpy*eic_rich_mpy+eic_rich_mpz*eic_rich_mpz);
322  //momv[1] = eic_rich_mpy/sqrt(eic_rich_mpx*eic_rich_mpx+eic_rich_mpy*eic_rich_mpy+eic_rich_mpz*eic_rich_mpz);
323  //momv[2] = eic_rich_mpz/sqrt(eic_rich_mpx*eic_rich_mpx+eic_rich_mpy*eic_rich_mpy+eic_rich_mpz*eic_rich_mpz);
324 
325  /*momv[0] = eic_rich_emi_x/sqrt(eic_rich_emi_x*eic_rich_emi_x+eic_rich_emi_y*eic_rich_emi_y+eic_rich_emi_z*eic_rich_emi_z);
326  momv[1] = eic_rich_emi_y/sqrt(eic_rich_emi_x*eic_rich_emi_x+eic_rich_emi_y*eic_rich_emi_y+eic_rich_emi_z*eic_rich_emi_z);
327  momv[2] = eic_rich_emi_z/sqrt(eic_rich_emi_x*eic_rich_emi_x+eic_rich_emi_y*eic_rich_emi_y+eic_rich_emi_z*eic_rich_emi_z);*/
328 
329  //cout<<sqrt(eic_rich_mpx*eic_rich_mpx+eic_rich_mpy*eic_rich_mpy+eic_rich_mpz*eic_rich_mpz)<<endl;
330 
331  theta = TMath::ACos(momv[2]);
332  phi = TMath::ATan2(momv[1],momv[0]);
333 
334  p_ang = theta*rtd;
335 
336  //cout<<theta*rtd<<endl;
337  //cout<<1240./(eic_rich_e*1000000000.)<<endl;
338 
339  m_emi[0] = ((220.)/momv[2])*momv[0]; //mean emission point
340  m_emi[1] = ((220.)/momv[2])*momv[1];
341  m_emi[2] = ((220.)/momv[2])*momv[2];
342 
343  /*m_emi[0] = eic_rich_emi_x; //real emission point
344  m_emi[1] = eic_rich_emi_y;
345  m_emi[2] = eic_rich_emi_z;*/
346 
347  d_hit[0] = eic_rich_hit_x;
348  d_hit[1] = eic_rich_hit_y;
349  d_hit[2] = eic_rich_hit_z;
350 
351  xbin = ph_det->GetXaxis()->FindBin(eic_rich_hit_x);
352  ybin = ph_det->GetYaxis()->FindBin(eic_rich_hit_y);
353 
354  if(pix_lab!=0)d_hit[0] = ph_det->GetXaxis()->GetBinCenter(xbin);
355  if(pix_lab!=0)d_hit[1] = ph_det->GetYaxis()->GetBinCenter(ybin);
356 
357  ph_det->Fill(d_hit[0],d_hit[1]);
358 
359  //cout<<theta*rtd<<" "<<phi*rtd<<endl;
360  //cout<<"V: "<<momv[0]<<" "<<momv[1]<<" "<<momv[2]<<endl;
361  //cout<<"E: "<<m_emi[0]<<" "<<m_emi[1]<<" "<<m_emi[2]<<endl;
362  //cout<<"D: "<<d_hit[0]<<" "<<d_hit[1]<<" "<<d_hit[2]<<endl;
363  //cout<<eic_rich_volumeid<<endl;
364 
365  rr[0] = -18.5*TMath::Sin(eic_rich_volumeid*TMath::Pi()/4.);
366  rr[1] = 18.5*TMath::Cos(eic_rich_volumeid*TMath::Pi()/4.);
367  rr[2] = 75.;
368  sec = eic_rich_volumeid;
369 
370  //cout<<rr[0]<<" "<<rr[1]<<" "<<rr[2]<<endl;
371 
372  ch = ind_ray(m_emi[0], m_emi[1], m_emi[2], d_hit[0], d_hit[1], d_hit[2], rr[0], rr[1], rr[2], momv[0], momv[1], momv[2]);
373  //ch_v[ph_ch_count] = ch;
374  ph_ch_count++;
375  //cout<<ch<<endl;
376  //if(ch<(theta_cc+0.01) && ch>(theta_cc-0.01))ch_ang->Fill(ch);
377 
378  //if(ch<(theta_cc+0.008) && ch>(theta_cc-0.008) && theta*rtd>15. && theta*rtd<16. && (ph_det->GetBinContent(xbin,ybin) == 1)){ //here are the cuts: central polar angle [12,13] (changed to [15,16]) and the cuts on theta_cc are about 5 sigma (assuming the measured 1 p.e. resulution) interval around the central value of theta_cc, the last cut takes just 1 p.e. per pixel ####################################################
379  //if(rran.Uniform(0,100)<qe(eic_rich_edep*1000000000.))ch_pi_h[imom]->Fill(ch);
380  if(ch<(theta_cc+0.008) && ch>(theta_cc-0.008) && theta*rtd>15. && theta*rtd<16.){
381 
382  ch_pi_h[imom]->Fill(ch);
383  spectrum_nm->Fill(1240./(eic_rich_edep*1000000000.));
384  //nph_count++;
385  ph_det1->Fill(d_hit[0],d_hit[1]);
386 
387  //if((eic_rich_event-1)==0)cout<<nph_v[0]<<endl;
388 
389  if(momentum!=mom_check){
390  h_mom->Fill(imom);
391  ev_count[imom]++;
392  //if(imom==14) cout<<eic_rich_mpid<<endl;
393  //if(imom==60)cout<<momentum<<" "<<imom<<endl;
394  //nph_count++;
395  mom_check=momentum;
396  }
397  }
398  //if(imom==14)cout<<ch<<" "<<eic_rich_mpid<<" "<<theta*rtd<<" "<<phi*rtd<<endl;
399  if(eic_rich_event!=event_check1){
400  //if(eic_rich_event<100)cout<<event_check1<<endl;
401  //cout<<ph_det_nosup->GetEntries()<<endl;
402  ph_det->Reset();
403  event_check1 = eic_rich_event;
404  //nph_count=0;
405  }
406  }
407 
408  }
409 
410  //cout<<ph_count<<endl;
411 
412  //ch_ang->Draw();
413  //ch_pi_h[32]->Draw();
414  //spectrum_nm->Draw();
415  //cout<<ev_count[9]<<endl;
416  //h_mom->Draw();
417 
418  Int_t summm=0;
419 
420  ofstream out("pid_test.txt", ios::app);
421  streambuf *coutbuf = cout.rdbuf();
422  cout.rdbuf(out.rdbuf());
423 
424  for(Int_t i=0;i<61;i++){
425  if(ch_pi_h[i]->GetEntries()!=0)cout<<ch_pi_h[i]->GetMean()<<" "<<ch_pi_h[i]->GetRMS()<<" "<<(int)(ch_pi_h[i]->GetEntries()/ev_count[i])<<" "<<i<<" "<<part<<endl;
426  else if(i<60)cout<<ch_pi_h[i]->GetMean()<<" "<<ch_pi_h[i]->GetRMS()<<" "<<0<<" "<<i<<" "<<part<<endl;
427  summm = summm + ev_count[i];
428  }
429 
430  //cout<<nph_count<<endl;
431 
432  ph_det1->Draw("colz");
433  ch_pi_h[45]->Draw();
434 
435  //c_mean = ch_ang->GetMean();
436  //c_rms = ch_ang->GetRMS();
437 
438  //delete ch_ang;
439 }
440 
441 
442 void eic_bnl_rich::read(string input_filename){
443 
444  ifstream inputFile;
445  inputFile.open(input_filename);
446  if (!inputFile) {
447  cerr << "Error in opening the file";
448  exit(1);
449  }
450 
451  Double_t theta_ch, sigma_theta, nph, momentum, ptype;
452  Double_t ch_e_v[60],rms_e_v[60],nph_e_v[60],mom_e_v[60];
453  Double_t ch_pi_v[60],rms_pi_v[60],nph_pi_v[60],mom_pi_v[60];
454  Double_t ch_k_v[60],rms_k_v[60],nph_k_v[60],mom_k_v[60];
455  Double_t ch_p_v[60],rms_p_v[60],nph_p_v[60],mom_p_v[60];
456  Double_t n_sig_e_pi[60],n_sig_pi_k[60],n_sig_k_p[60],mm_e_pi[60],mm_pi_k[60],mm_k_p[60];
457  Int_t idx[4] = {0,0,0,0};
458 
459  while (inputFile>>theta_ch>>sigma_theta>>nph>>momentum>>ptype){
460 
461  if(ptype==0){
462  ch_e_v[idx[0]]=theta_ch;
463  rms_e_v[idx[0]]=sigma_theta;
464  nph_e_v[idx[0]]=nph*0.6;
465  if(theta_ch==0) nph_e_v[idx[0]]=0;
466  mom_e_v[idx[0]]=momentum;
467  idx[0]++;
468  }
469  if(ptype==1){
470  ch_pi_v[idx[1]]=theta_ch;
471  rms_pi_v[idx[1]]=sigma_theta;
472  nph_pi_v[idx[1]]=nph*0.6; //0.6 is a scale factor to normalize the MC value on expwerimantal data
473  if(theta_ch==0) nph_pi_v[idx[1]]=0;
474  mom_pi_v[idx[1]]=momentum;
475  idx[1]++;
476  }
477  if(ptype==2){
478  ch_k_v[idx[2]]=theta_ch;
479  rms_k_v[idx[2]]=sigma_theta;
480  nph_k_v[idx[2]]=nph*0.6;
481  if(theta_ch==0) nph_k_v[idx[2]]=0;
482  mom_k_v[idx[2]]=momentum;
483  idx[2]++;
484  }
485  if(ptype==3){
486  ch_p_v[idx[3]]=theta_ch;
487  rms_p_v[idx[3]]=sigma_theta;
488  nph_p_v[idx[3]]=nph*0.6;
489  if(theta_ch==0) nph_p_v[idx[3]]=0;
490  mom_p_v[idx[3]]=momentum;
491  idx[3]++;
492  }
493  //cout<<theta_ch<<" "<<sigma_theta<<" "<<nph<<" "<<momentum<<" "<<ptype<<endl;
494 
495  }
496 
497  Int_t ii=0;
498  Int_t iii=0;
499  Int_t iiii=0;
500 
501  for(Int_t i=0;i<idx[0];i++){
502 
503  if(ch_e_v[i]!=0 && ch_pi_v[i]!=0 && i>2){
504  n_sig_e_pi[ii] = (ch_e_v[i]-ch_pi_v[i])*sqrt((nph_e_v[i]+nph_pi_v[i])*0.5)/((rms_e_v[i]+rms_pi_v[i])*0.5);
505  mm_e_pi[ii] = mom_e_v[i]+0.5;
506  //cout<<"e/pi: "<<n_sig_e_pi[ii]<<" "<<mm_e_pi[ii]<<endl;
507  ii++;
508  }
509  if(ch_pi_v[i]!=0 && ch_k_v[i]!=0 && i>16){
510  n_sig_pi_k[iii] = (ch_pi_v[i]-ch_k_v[i])*sqrt((nph_pi_v[i]+nph_k_v[i])*0.5)/((rms_pi_v[i]+rms_k_v[i])*0.5);
511  mm_pi_k[iii] = mom_pi_v[i]+0.5;
512  //cout<<ch_pi_v[i]<<" "<<ch_k_v[i]<<endl;
513  //cout<<"pi/k: "<<n_sig_pi_k[iii]<<" "<<mm_pi_k[iii]<<endl;
514  iii++;
515  }
516  if(ch_k_v[i]!=0 && ch_p_v[i]!=0 && i>30){
517  n_sig_k_p[iiii] = (ch_k_v[i]-ch_p_v[i])*sqrt((nph_k_v[i]+nph_p_v[i])*0.5)/((rms_k_v[i]+rms_p_v[i])*0.5);
518  mm_k_p[iiii] = mom_k_v[i]+0.5;
519  //cout<<"k/p: "<<n_sig_k_p[iiii]<<" "<<mm_k_p[iiii]<<endl;
520  iiii++;
521  }
522 
523  //cout<<ch_e_v[i]<<" "<<nph_e_v[i]<<endl;
524 
525  }
526 
527  TGraph *sig_pi = new TGraph(idx[1],mom_pi_v,rms_pi_v);
528  TGraph *nph_pi = new TGraph(idx[1],mom_pi_v,nph_pi_v);
529 
530  TGraph *gr_e_pi = new TGraph(ii,mm_e_pi,n_sig_e_pi);
531  TGraph *gr_pi_k = new TGraph(iii,mm_pi_k,n_sig_pi_k);
532  TGraph *gr_k_p = new TGraph(iiii,mm_k_p,n_sig_k_p);
533 
534  TCanvas *c1 = new TCanvas("c1","",1000,600);
535  c1->Divide(1,1);
536  c1->cd(1);
537  gr_e_pi->SetLineStyle(2);
538  gr_e_pi->SetLineWidth(2);
539  gr_e_pi->SetLineColor(kGreen);
540  gr_e_pi->SetMarkerColor(kGreen);
541  gr_e_pi->SetTitle("");
542  gr_e_pi->GetXaxis()->SetTitle("Momentum [Gev/c]");
543  gr_e_pi->GetYaxis()->SetTitle("N_{#sigma}^{Ring}");
544  gr_e_pi->Draw("AC*");
545  gr_pi_k->SetLineStyle(3);
546  gr_pi_k->SetLineWidth(2);
547  gr_pi_k->SetLineColor(kRed);
548  gr_pi_k->SetMarkerColor(kRed);
549  gr_pi_k->SetTitle("");
550  gr_pi_k->Draw("C*");
551  gr_k_p->SetLineStyle(4);
552  gr_k_p->SetLineWidth(2);
553  gr_pi_k->SetLineColor(kBlue);
554  gr_pi_k->SetMarkerColor(kBlue);
555  gr_k_p->SetTitle("");
556  gr_k_p->Draw("C*");
557  c1->Print("test1.pdf","pdf");
558 
559  for(Int_t j=0;j<iiii;j++) cout<<n_sig_k_p[j]<<" "<<mm_k_p[j]<<endl;
560 
561  TCanvas *c2 = new TCanvas("c2","",1000,600);
562  c2->Divide(1,1);
563  c2->cd(1);
564  sig_pi->SetTitle("");
565  sig_pi->GetXaxis()->SetTitle("Momentum [Gev/c]");
566  sig_pi->GetYaxis()->SetTitle("#sigma_{#theta_{C}}");
567  sig_pi->Draw("AP*");
568  c2->Print("test2.pdf","pdf");
569 
570  TCanvas *c3 = new TCanvas("c3","",1000,600);
571  c3->Divide(1,1);
572  c3->cd(1);
573  nph_pi->SetTitle("");
574  nph_pi->GetXaxis()->SetTitle("Momentum [Gev/c]");
575  nph_pi->GetYaxis()->SetTitle("N_{p.e.}");
576  nph_pi->Draw("AP*");
577  c3->Print("test3.pdf","pdf");
578 
579 }