Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dualrich_analyzer.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file dualrich_analyzer.cc
1 
2 
3 //.L dualrich_analyzer.cpp++
4 //eic_dual_rich *a = new eic_dual_rich()
5 //a->some method of the class
6 
7 #include "dualrich_analyzer.h"
8 
9 using namespace std;
10 
11 
12 void eic_dual_rich::set_mirror(double center_posx, double center_posy, double center_posz, double radius){
13 
14  cx = center_posx;
15  cy = center_posy;
16  cz = center_posz;
17  R_mirror = radius;
18 
19 }
20 
21 void eic_dual_rich::set_radiator_one(double mean_refraction_index1){
22 
23  refidx1 = mean_refraction_index1;
24 
25 }
26 
27 void eic_dual_rich::set_radiator_two(double mean_refraction_index2){
28 
29  refidx1 = mean_refraction_index2;
30 
31 }
32 
33 double eic_dual_rich::ind_ray(double Ex, double Ey, double Ez, double Dx, double Dy, double Dz, double vx, double vy, double vz, int select_radiator){
34 
35  //int sel_radiator = 2;
36 
37  //if(select_radiator == 1) sel_radiator = 1;
38 
39  double cex,cey,cez;
40  double cdx,cdy,cdz;
41 
42  int i;//,iwhere;
43 
44  double th,a,d;
45  double x,dx;
46 
47  double y,y1;
48 
49  double eps = 0.00000000001;
50  double R = 0;
51 
52  R = R_mirror;
53 
54  double esx, esy, esz, es;
55  double ref_frac, theta1, theta2;
56 
57  double theta_c = 0.;
58 
59  cex = -cx+Ex;
60  cey = -cy+Ey;
61  cez = -cz+Ez;
62 
63  cdx = -cx+Dx;
64  cdy = -cy+Dy;
65  cdz = -cz+Dz;
66 
67  //a = TMath::Sqrt(cex*cex+cey*cey+cez*cez);
68  //d = TMath::Sqrt(cdx*cdx+cdy*cdy+cdz*cdz);
69  //th = TMath::ACos((cdx*cex+cdy*cey+cdz*cez)/a/d);
70 
71  a = sqrt(cex*cex+cey*cey+cez*cez);
72  d = sqrt(cdx*cdx+cdy*cdy+cdz*cdz);
73  th = acos((cdx*cex+cdy*cey+cdz*cez)/a/d);
74 
75  i = 0;
76  x = th/2.;
77  y = R*(a*sin(x)-d*sin(th-x))+a*d*sin(th-2*x);
78  y1 = R*(a*cos(x)+d*cos(th-x))-2*a*d*cos(th-2*x);
79  dx = -1*y/y1;
80 
81  while(abs(dx)>eps && i<100){
82 
83  x+=dx;
84  y = R*(a*sin(x)-d*sin(th-x))+a*d*sin(th-2*x);
85  y1 = R*(a*cos(x)+d*cos(th-x))-2*a*d*cos(th-2*x);
86  dx = -1*y/y1;
87  i++;
88 
89  }
90 
91  if(i>=100) cout<<"Not convergent"<<endl;
92 
93  if(i<100){
94  sx = cx + (R*cos(x)/a-R*sin(x)/tan(th)/a)*cex + (R*sin(x)/d/sin(th))*cdx;
95  sy = cy + (R*cos(x)/a-R*sin(x)/tan(th)/a)*cey + (R*sin(x)/d/sin(th))*cdy;
96  sz = cz + (R*cos(x)/a-R*sin(x)/tan(th)/a)*cez + (R*sin(x)/d/sin(th))*cdz;
97  }
98 
99  esx = sx - Ex;
100  esy = sy - Ey;
101  esz = sz - Ez;
102 
103  es = sqrt(esx*esx+esy*esy+esz*esz);
104 
105  esx = esx/es;
106  esy = esy/es;
107  esz = esz/es;
108 
109  if(select_radiator == 1){
110  ref_frac = refidx2/refidx1;
111 
112  theta2 = acos(esz);
113  theta1 = asin(sin(theta2)*ref_frac);
114 
115  esx = esx*sin(theta1)/sin(theta2);
116  esy = esy*sin(theta1)/sin(theta2);
117  esz = cos(theta1);
118  }
119  theta_c = acos((esx*vx+esy*vy+esz*vz));
120 
121  return theta_c;
122 
123 }
124 
126 
127  ch_vector.push_back (angle);
128 
129 }
130 
131 void eic_dual_rich::cut_cherenkov_array(double theta_min, double theta_max){
132 
133  vector<double> cut_vector;
134 
135  for (unsigned int i=0; i<ch_vector.size(); i++){
136 
137  if(theta_min<theta_max && ch_vector.at(i)>=theta_min && ch_vector.at(i)<=theta_max) cut_vector.push_back (ch_vector.at(i));
138  else if (theta_min>=theta_max) cout<<"Applied cut wrong: theta_min>theta_max"<<endl;
139 
140  }
141 
142  ch_vector.clear();
143 
144  for (unsigned int i=0; i<cut_vector.size(); i++){
145 
146  ch_vector.push_back(cut_vector.at(i));
147 
148  }
149 
150 }
151 
153 
154  double sum = 0.;
155 
156  for (unsigned int i=0; i<ch_vector.size(); i++){
157 
158  sum += ch_vector.at(i);
159 
160  }
161 
162  sum = sum/ch_vector.size();
163 
164  return sum;
165 
166 }
167 
169 
170  double sum = 0.;
171 
172  for (unsigned int i=0; i<ch_vector.size(); i++){
173 
174  sum += (ch_vector.at(i)-mean_cherenkov_angle())*(ch_vector.at(i)-mean_cherenkov_angle());
175 
176  }
177 
178  sum = sum/ch_vector.size();
179 
180  return sqrt(sum);
181 
182 }
183 
185 
186  ch_vector.clear();
187 
188 }
189 
190 
191 
192