Rev 71 | Rev 84 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 71 | Rev 73 | ||
---|---|---|---|
Line 21... | Line 21... | ||
21 | TCanvas *c3dview; |
21 | TCanvas *c3dview; |
22 | TCanvas *cacc; |
22 | TCanvas *cacc; |
23 | int show_3d = 0, show_data = 0; |
23 | int show_3d = 0, show_data = 0; |
24 | int draw_width = 2; |
24 | int draw_width = 2; |
25 | 25 | ||
26 |
|
26 | // calls default constructor CVodnik.cpp |
27 | 27 | ||
28 | //void SetCenter(double x = -2.0, double y = 0.0, double z = 0.0) |
28 | //void SetCenter(double x = -2.0, double y = 0.0, double z = 0.0) |
29 |
|
29 | //{center.SetXYZ(x,y,z); detector = new CDetector(center);} |
30 | 30 | ||
31 | 31 | ||
32 | //void SetLGType(int in = 1, int side = 1, int out = 0) |
32 | //void SetLGType(int in = 1, int side = 1, int out = 0) |
33 |
|
33 | //{detector->SetLGType(in, side, out);} |
34 | 34 | ||
35 | //void SetLG(double SiPM0 = 3.0, double M0 = 1.666, double d0 = 3.0, double n10 = 1.0, double n20 = 1.48, double n30 = 1.48, double R0 = 0.96) |
35 | //void SetLG(double SiPM0 = 3.0, double M0 = 1.666, double d0 = 3.0, double n10 = 1.0, double n20 = 1.48, double n30 = 1.48, double R0 = 0.96) |
36 |
|
36 | //{detector->SetLG(SiPM0, M0, d0, n10, n20, n30, R0);} |
37 | 37 | ||
38 | //void SetR(double R0) {detector->SetR(R0);} |
38 | //void SetR(double R0) {detector->SetR(R0);} |
39 |
|
39 | /* |
40 | void SetGlass(int glass_on0 = 0, double glass_d0 = 0.3) |
40 | void SetGlass(int glass_on0 = 0, double glass_d0 = 0.3) |
41 | {detector->SetGlass(glass_on0, glass_d0);} |
41 | {detector->SetGlass(glass_on0, glass_d0);} |
42 | 42 | ||
43 | void SetGap(double x_gap0 = 0.3, double y_gap0 = 0.0, double z_gap0 = 0.0) |
43 | void SetGap(double x_gap0 = 0.3, double y_gap0 = 0.0, double z_gap0 = 0.0) |
44 | {detector->SetGap(x_gap0 , y_gap0, z_gap0);} |
44 | {detector->SetGap(x_gap0 , y_gap0, z_gap0);} |
45 | |
45 | |
46 | void SetRCol(int in = 2, int lg = 8, int out = 4, int gla = 6) |
46 | void SetRCol(int in = 2, int lg = 8, int out = 4, int gla = 6) |
47 | {detector->SetRCol(in, lg, out, gla);}; |
47 | {detector->SetRCol(in, lg, out, gla);}; |
48 | void SetDCol(int LG0 = 1, int glass0 = 2, int active0 = 3) |
48 | void SetDCol(int LG0 = 1, int glass0 = 2, int active0 = 3) |
49 | {detector->SetDCol(LG0, glass0, active0);}; |
49 | {detector->SetDCol(LG0, glass0, active0);}; |
50 | |
50 | |
51 | 51 | ||
52 | void SetDWidth(int w = 1) {draw_width = w;} |
52 | void SetDWidth(int w = 1) {draw_width = w;} |
53 | 53 | ||
54 | void SetFresnel(int b = 1) {detector->SetFresnel(b);} |
54 | void SetFresnel(int b = 1) {detector->SetFresnel(b);} |
55 | void SetAbsorb(int b = 0, double A0 = 1e4) {detector->SetAbsorption(b, A0);} |
55 | void SetAbsorb(int b = 0, double A0 = 1e4) {detector->SetAbsorption(b, A0);} |
56 | 56 | ||
57 | void SetGuideOn(int b = 0) {detector->SetGuideOn(b);} |
57 | void SetGuideOn(int b = 0) {detector->SetGuideOn(b);} |
58 | 58 | ||
59 | void SetTypeU() {SetGlass(1, 0.3);SetGap(0.7);} |
59 | void SetTypeU() {SetGlass(1, 0.3);SetGap(0.7);} |
60 | void SetTypeC() {SetGlass(0, 0.3);SetGap(1.03);} |
60 | void SetTypeC() {SetGlass(0, 0.3);SetGap(1.03);} |
61 | */ |
61 | */ |
62 | //----------------------------------------------------------------------------- |
62 | //----------------------------------------------------------------------------- |
63 | void Init(double rsys_scale = |
63 | void Init(double rsys_scale = 10.0) |
64 | { |
64 | { |
65 |
|
65 | RTSetStyle(gStyle); |
66 |
|
66 | gStyle->SetOptStat(10); |
67 | 67 | ||
68 |
|
68 | if(show_3d) { |
69 |
|
69 | double rsys0[]={-rsys_scale,-rsys_scale,-rsys_scale}; |
70 |
|
70 | double rsys1[]={ rsys_scale, rsys_scale, rsys_scale}; |
71 | 71 | ||
72 |
|
72 | c3dview = (TCanvas*)gROOT->FindObject("c3dview"); |
73 |
|
73 | if(!c3dview) {c3dview = new TCanvas("c3dview", "3D View", 0, 0, 700, 723); |
- | 74 | c3dview->SetFillColor(0);} |
|
74 |
|
75 | else c3dview->Clear(); |
75 | 76 | ||
76 |
|
77 | TView3D *view = new TView3D(1, rsys0, rsys1); |
77 |
|
78 | view->SetRange(rsys0[0], rsys0[1], rsys0[2], rsys1[0], rsys1[1], rsys1[2]); |
78 |
|
79 | //view->SetPerspective(); |
79 |
|
80 | view->SetParallel(); |
80 |
|
81 | view->FrontView(); |
81 |
|
82 | view->Zoom();view->Zoom();view->Zoom();//view->Zoom(); |
82 |
|
83 | //view->ToggleRulers(); |
83 |
|
84 | } |
84 | } |
85 | } |
85 | //----------------------------------------------------------------------------- |
86 | //----------------------------------------------------------------------------- |
86 | void DrawData(CDetector *detector, DetectorParameters& parameters, double theta = 0.0, double acc = 0.0, int only2d = 0) |
87 | void DrawData(CDetector *detector, DetectorParameters& parameters, double theta = 0.0, double acc = 0.0, int only2d = 0) |
87 | { |
88 | { |
88 |
|
89 | if(show_data) { |
89 |
|
90 | char sbuff[256]; |
90 |
|
91 | sprintf(sbuff, "SiPM = %.1lf, L.y. = %.2lf, d = %.1lf | gap = (%.1lf, %.1lf, %.1lf), #theta = %.1lf | acceptance = %.3lf", |
91 |
|
92 | parameters.getA(), parameters.getLightYield()*acc, parameters.getD(), |
92 |
|
93 | parameters.getGap().x(), parameters.getGap().y(), parameters.getGap().z(), theta, acc); |
93 | 94 | ||
94 |
|
95 | if(!only2d) { |
95 |
|
96 | RTCanvas *cdata = new RTCanvas((char*)"Data", sbuff, 350, 0, 950, 950); |
96 |
|
97 | cdata->Divide(3,3); |
97 |
|
98 | int cpc = 1; |
98 |
|
99 | cdata->cd(cpc++); (detector->histoPlate)->Draw("COLZ"); |
99 |
|
100 | cdata->cd(cpc++); ((detector->GetLG())->GetHIn())->Draw("COLZ"); |
100 |
|
101 | cdata->cd(cpc++); //((detector->GetLG())->GetHOut())->Draw("COLZ"); |
101 |
|
102 | (detector->GetHGlass())->Draw("COLZ"); |
102 | 103 | ||
103 |
|
104 | cdata->cd(cpc++); (detector->GetHActive())->Draw("COLZ"); |
104 |
|
105 | cdata->cd(cpc++); (detector->GetHLaser())->Draw("COLZ"); |
105 |
|
106 | cdata->cd(cpc++); (detector->GetHDetector())->Draw("COLZ"); |
106 | 107 | ||
107 |
|
108 | cdata->cd(cpc++); ((detector->GetLG())->GetHFate())->Draw(); |
108 |
|
109 | cdata->cd(cpc++); ((detector->GetLG())->GetHNOdb_all())->Draw(); |
109 |
|
110 | cdata->cd(cpc++); ((detector->GetLG())->GetHNOdb_exit())->Draw(); |
110 |
|
111 | }else{ |
111 |
|
112 | RTCanvas *cdata = new RTCanvas((char*)"Data", sbuff, 350, 0, 500, 500); |
112 |
|
113 | cdata->cd(0); (detector->GetHLaser())->Draw("COLZ"); |
113 |
|
114 | cdata->SaveAs("cdata.gif"); |
114 |
|
115 | } |
115 |
|
116 | } |
116 | } |
117 | } |
117 | //----------------------------------------------------------------------------- |
118 | //----------------------------------------------------------------------------- |
118 | void DrawAcc(int n, double *x, double *y, char *htitle = (char*)";;Acceptance", |
119 | void DrawAcc(int n, double *x, double *y, char *htitle = (char*)";;Acceptance", |
119 |
|
120 | double xmin = 1.0, double xmax = 0.0, double ymin = 0.0, double ymax = 1.0) |
120 | { |
121 | { |
121 | 122 | ||
122 |
|
123 | cacc = new TCanvas((char*)"Acceptance", (char*)"Acceptance", 0, 0, 700, 480); |
123 | 124 | ||
124 |
|
125 | (cacc->cd(0))->SetRightMargin(0.05); |
125 |
|
126 | (cacc->cd(0))->SetLeftMargin(0.13); |
126 |
|
127 | (cacc->cd(0))->SetTopMargin(0.08); |
127 | 128 | ||
128 |
|
129 | TGraph *gacceptance = new TGraph(n, x, y); |
129 |
|
130 | gacceptance->SetTitle(htitle); |
130 |
|
131 | gacceptance->SetMarkerStyle(8); |
131 |
|
132 | gacceptance->SetLineColor(12); |
132 |
|
133 | gacceptance->SetLineWidth(1); |
133 |
|
134 | if(xmin < xmax) |
134 |
|
135 | (gacceptance->GetXaxis())->SetRangeUser(xmin, xmax); |
135 |
|
136 | (gacceptance->GetYaxis())->SetRangeUser(ymin, ymax); |
136 | 137 | ||
137 |
|
138 | gacceptance->Draw("ACP"); |
138 |
|
139 | //cacc->Print("acceptance.pdf"); |
139 |
|
140 | //delete gacceptance; |
140 |
|
141 | //delete cacc; |
141 | } |
142 | } |
142 | //----------------------------------------------------------------------------- |
143 | //----------------------------------------------------------------------------- |
143 | void PrintGlassStat(CDetector *detector) |
144 | void PrintGlassStat(CDetector *detector) |
144 | { |
145 | { |
145 |
|
146 | int glass_in = ((detector->GetLG())->GetHOut())->GetEntries(); |
146 |
|
147 | int glass_out = (detector->GetHGlass())->GetEntries(); |
147 |
|
148 | printf("glass_in = %d, glass_out = %d, frac = %.3lf\n", glass_in, glass_out, glass_out/(double)glass_in); |
148 | } |
149 | } |
149 | //----------------------------------------------------------------------------- |
150 | //----------------------------------------------------------------------------- |
150 | void PrintGuideHead() |
151 | void PrintGuideHead() |
151 | { |
152 | { |
152 |
|
153 | //printf(" gap (x,y,z) | theta phi | Back | Loss | Total| Miss | Exit | Acceptance\n"); |
153 |
|
154 | printf("Acceptance\n"); |
154 | } |
155 | } |
155 | //----------------------------------------------------------------------------- |
156 | //----------------------------------------------------------------------------- |
156 | void PrintGuideStat(double acceptance) |
157 | void PrintGuideStat(double acceptance) |
157 | { |
158 | { |
158 |
|
159 | /*int n_active = (detector->GetHActive())->GetEntries(); |
159 | int n_enter = (detector->GetLG())->GetEnteranceHits(); |
160 | int n_enter = (detector->GetLG())->GetEnteranceHits(); |
160 | double izkoristek = n_active/(double)n_enter; |
161 | double izkoristek = n_active/(double)n_enter; |
161 | int fates[7]; (detector->GetLG())->GetVFate(fates); |
162 | int fates[7]; (detector->GetLG())->GetVFate(fates); |
162 | |
163 | |
163 | // printf(" gap (x,y,z) | theta phi | Back | Loss | Total| Miss | Exit | Acceptance\n"); |
164 | // printf(" gap (x,y,z) | theta phi | Back | Loss | Total| Miss | Exit | Acceptance\n"); |
164 | |
165 | |
165 | printf("%4.1lf,%4.1lf,%4.1lf | %4.1lf,%6.1lf |", |
166 | printf("%4.1lf,%4.1lf,%4.1lf | %4.1lf,%6.1lf |", |
166 | (detector->GetVGap()).x(), (detector->GetVGap()).y(), (detector->GetVGap()).z(), theta, phi); |
167 | (detector->GetVGap()).x(), (detector->GetVGap()).y(), (detector->GetVGap()).z(), theta, phi); |
167 | for(int i=0;i<5;i++) printf("%5.1lf |", 100.0*fates[i]/(double)n_enter); |
168 | for(int i=0;i<5;i++) printf("%5.1lf |", 100.0*fates[i]/(double)n_enter); |
168 | |
169 | |
169 | printf("%5.1lf\n", 100.0*izkoristek);*/ |
170 | printf("%5.1lf\n", 100.0*izkoristek);*/ |
170 | 171 | ||
171 |
|
172 | //double n_active = (detector->GetHActive())->GetEntries(); |
172 |
|
173 | //double r_acc = 100.0 * n_active / n_in; |
173 |
|
174 | double r_acc = 100.0 * acceptance; |
174 |
|
175 | printf("%7.3lf\n", r_acc); |
175 | } |
176 | } |
176 | //----------------------------------------------------------------------------- |
177 | //----------------------------------------------------------------------------- |
177 | 178 | ||
178 | //----------------------------------------------------------------------------- |
179 | //----------------------------------------------------------------------------- |
179 | // en zarek |
180 | // en zarek |
- | 181 | double Single(CDetector *detector, DetectorParameters& parameters, |
|
180 |
|
182 | TVector3 hit = TVector3(0.0, 0.0, 0.0), double theta = 0.0, double phi = 0.0) |
181 | { |
183 | { |
182 | //CDetector *detector = new CDetector(center, 3, 1.666, 3, 3, 1, 1.48, 1.48); |
- | |
183 |
|
184 | theta = Pi()*theta/180.0; |
184 |
|
185 | if(theta < 1e-6) theta = 1e-6; |
185 |
|
186 | phi = phi*Pi()/180.0; |
186 |
|
187 | if(phi < 1e-6) phi = 1e-6; |
187 | 188 | ||
188 |
|
189 | double offset = (parameters._plateOn ? parameters._plateWidth : 0); |
189 | 190 | ||
190 |
|
191 | //detector->Init(); |
191 |
|
192 | if(show_3d) detector->Draw(draw_width); |
192 | 193 | ||
193 |
|
194 | CRay *ray0 = new CRay(hit.x() - offset, hit.y(), hit.z(), |
194 |
|
195 | TMath::Cos(theta), TMath::Sin(theta)*TMath::Sin(phi), |
- | 196 | TMath::Sin(theta)*TMath::Cos(phi)); |
|
- | 197 | // Set z-polarization == vertical |
|
- | 198 | TVector3 polarization(0,0,1); |
|
- | 199 | polarization.RotateY(-theta); |
|
- | 200 | polarization.RotateZ(phi); |
|
- | 201 | if (polarization.Dot(ray0->GetK()) > 1e-5) printf("ERROR: pol not perep\n"); |
|
- | 202 | ray0->setPolarization(polarization); |
|
195 |
|
203 | CRay *ray1 = new CRay; |
196 | 204 | ||
197 |
|
205 | detector->Propagate(*ray0, ray1, show_3d); |
- | 206 | ||
- | 207 | CRay *incidentPolarization = new CRay; |
|
- | 208 | incidentPolarization->SetColor(kGreen); |
|
- | 209 | TVector3 drawPosition = ray0->GetR(); |
|
- | 210 | drawPosition.SetX(drawPosition.X() - 5); |
|
- | 211 | incidentPolarization->Set(drawPosition, polarization); |
|
- | 212 | incidentPolarization->DrawS(drawPosition.X(), 1); |
|
198 | 213 | ||
- | 214 | TVector3 outPolarization = ray1->GetP(); |
|
- | 215 | drawPosition = ray1->GetR(); |
|
- | 216 | drawPosition.SetX(drawPosition.X() + 5); |
|
- | 217 | CRay* rayPol = new CRay(drawPosition, outPolarization); |
|
- | 218 | rayPol->SetColor(kBlack); |
|
- | 219 | rayPol->DrawS(drawPosition.X(), 1); |
|
- | 220 | ||
199 |
|
221 | delete ray0; |
200 |
|
222 | delete ray1; |
201 | 223 | ||
202 |
|
224 | return (detector->GetHActive())->GetEntries() / (double)(1); |
203 | } |
225 | } |
204 | //----------------------------------------------------------------------------- |
226 | //----------------------------------------------------------------------------- |
205 | // zarki, razporejeni v mrezi |
227 | // zarki, razporejeni v mrezi |
206 | double Grid(CDetector *detector, DetectorParameters& parameters, |
228 | double Grid(CDetector *detector, DetectorParameters& parameters, |
- | 229 | int NN = 10, double theta = 0.0) |
|
207 | { |
230 | { |
208 | //CDetector *detector = new CDetector(center, 3, 1.666, 3, 3, 1, 1.48, 1.48); |
231 | //CDetector *detector = new CDetector(center, 3, 1.666, 3, 3, 1, 1.48, 1.48); |
209 |
|
232 | theta = Pi()*theta/180.0; |
210 |
|
233 | if(theta < 1e-6) theta = 1e-6; |
211 | 234 | ||
212 |
|
235 | //detector->Init(); |
213 |
|
236 | if(show_3d) detector->Draw(draw_width); |
214 | 237 | ||
215 |
|
238 | const double b = parameters.getB(); |
216 | 239 | ||
217 |
|
240 | double offset = (parameters._plateOn ? parameters._plateWidth : 0); |
218 | 241 | ||
219 |
|
242 | for(int i = 0; i < NN; i++) { |
220 |
|
243 | for(int j = 0; j < NN; j++) { |
221 |
|
244 | CRay *ray0 = new CRay(CENTER.x() - offset, |
222 |
|
245 | 0.99*(i*b/NN + b/(2.0*NN) - b/2.0), |
223 |
|
246 | 0.99*(j*b/NN + b/(2.0*NN) - b/2.0), |
224 |
|
247 | TMath::Cos(theta), |
225 |
|
248 | 0.0, |
226 |
|
249 | TMath::Sin(theta)); |
- | 250 | TVector3 polarization(0, 1, 0); |
|
- | 251 | polarization.RotateY(-theta); |
|
- | 252 | ray0->setPolarization(polarization); |
|
227 |
|
253 | CRay *ray1 = new CRay; |
228 |
|
254 | if(i == (NN/2)) |
229 |
|
255 | detector->Propagate(*ray0, ray1, show_3d); |
230 |
|
256 | else |
231 |
|
257 | detector->Propagate(*ray0, ray1, 0); |
232 |
|
258 | delete ray0; |
233 |
|
259 | delete ray1; |
234 |
|
260 | } |
235 | 261 | ||
236 |
|
262 | } |
237 |
|
263 | double acceptance = 0.0; |
238 |
|
264 | /* |
239 | if( !(parameters.getPlateOn()) ) |
265 | if( !(parameters.getPlateOn()) ) |
240 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN*NN; |
266 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN*NN; |
241 | else |
267 | else |
242 | acceptance = (detector->GetHActive())->GetEntries() / (detector->GetHPlate())->GetEntries(); |
268 | acceptance = (detector->GetHActive())->GetEntries() / (detector->GetHPlate())->GetEntries(); |
243 | |
269 | */ |
244 |
|
270 | acceptance = (detector->GetHActive())->GetEntries() / (double)((NN)*(NN)); |
245 |
|
271 | return acceptance; |
246 | } |
272 | } |
247 | //----------------------------------------------------------------------------- |
273 | //----------------------------------------------------------------------------- |
248 | // zarki z nakljucnim polozajem vpada (na vstopni pov. vodnika) |
274 | // zarki z nakljucnim polozajem vpada (na vstopni pov. vodnika) |
249 | // vsi pod kotom (theta, phi) |
275 | // vsi pod kotom (theta, phi) |
250 | double RandYZ(CDetector *detector, DetectorParameters& parameters, |
276 | double RandYZ(CDetector *detector, DetectorParameters& parameters, |
- | 277 | int NN, double theta, double phi, int show_rays) |
|
251 | { |
278 | { |
252 | //CDetector *detector = new CDetector(center, 3, 1.666, 3, 3, 1, 1.48, 1.48); |
279 | //CDetector *detector = new CDetector(center, 3, 1.666, 3, 3, 1, 1.48, 1.48); |
253 |
|
280 | theta = theta*3.14159265358979312/180.0; |
254 |
|
281 | if(theta < MARGIN) theta = MARGIN; |
255 |
|
282 | phi = phi*3.14159265358979312/180.0; |
256 |
|
283 | if(phi < MARGIN) phi = MARGIN; |
257 | 284 | ||
258 |
|
285 | TDatime now; |
259 |
|
286 | TRandom rand; |
260 |
|
287 | rand.SetSeed(now.Get()); |
261 | 288 | ||
262 |
|
289 | //detector->Init(); |
263 |
|
290 | if(show_3d) detector->Draw(draw_width); |
264 | 291 | ||
265 |
|
292 | double SiPM = parameters.getA(); |
266 |
|
293 | double M = parameters.getM(); |
267 |
|
294 | double offset = (parameters._plateOn ? parameters._plateWidth : 0); |
268 | 295 | ||
269 |
|
296 | for(int i = 0; i < NN; i++) { |
270 | 297 | ||
271 |
|
298 | double rx = CENTER.x() - offset; |
272 |
|
299 | double ry = rand.Uniform(-M*SiPM/2.0, M*SiPM/2.0); |
273 |
|
300 | double rz = rand.Uniform(-M*SiPM/2.0, M*SiPM/2.0); |
274 | 301 | ||
275 |
|
302 | double rl = TMath::Cos(theta); |
276 |
|
303 | double rm = TMath::Sin(theta)*TMath::Sin(phi); |
277 |
|
304 | double rn = TMath::Sin(theta)*TMath::Cos(phi); |
278 | 305 | ||
279 |
|
306 | CRay *ray0 = new CRay(rx, ry, rz, rl, rm, rn); |
- | 307 | TVector3 polarization(0, 0, 1); |
|
- | 308 | polarization.RotateY(-theta); |
|
- | 309 | polarization.RotateZ(phi); |
|
- | 310 | ray0->setPolarization(polarization); |
|
280 |
|
311 | CRay *ray1 = new CRay; |
281 | 312 | ||
282 |
|
313 | if(i < show_rays) |
283 |
|
314 | detector->Propagate(*ray0, ray1, show_3d); |
284 |
|
315 | else |
285 |
|
316 | detector->Propagate(*ray0, ray1, 0); |
286 |
|
317 | delete ray1; |
287 |
|
318 | delete ray0; |
288 |
|
319 | } |
289 | 320 | ||
290 |
|
321 | double acceptance = 0.0; |
291 |
|
322 | /* |
292 | if( !(parameters.getPlateOn()) ) |
323 | if( !(parameters.getPlateOn()) ) |
293 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN; |
324 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN; |
294 | else |
325 | else |
295 | acceptance = (detector->GetHActive())->GetEntries() / (detector->GetHPlate())->GetEntries(); |
326 | acceptance = (detector->GetHActive())->GetEntries() / (detector->GetHPlate())->GetEntries(); |
296 | //return (detector->GetHActive())->GetEntries() / (double)((NN)*(NN));*/ |
327 | //return (detector->GetHActive())->GetEntries() / (double)((NN)*(NN));*/ |
297 |
|
328 | acceptance = (detector->GetHActive())->GetEntries() / (double) NN; |
298 |
|
329 | return acceptance; |
299 | } |
330 | } |
300 | //----------------------------------------------------------------------------- |
331 | //----------------------------------------------------------------------------- |
301 | // zarki, izotropno porazdeljeni znotraj kota theta |
332 | // zarki, izotropno porazdeljeni znotraj kota theta |
302 | // = nakljucni vstopni polozaj in kot |
333 | // = nakljucni vstopni polozaj in kot |
303 | // NN - number of rays to be simulated with angles theta distributed uniformly |
334 | // NN - number of rays to be simulated with angles theta distributed uniformly |
304 | // in cos theta and phi uniformly: |
335 | // in cos theta and phi uniformly: |
305 | // theta [0, theta] |
336 | // theta [0, theta] |
306 | // phi [0,360] |
337 | // phi [0,360] |
- | 338 | double RandIso(CDetector *detector, DetectorParameters& parameters, |
|
307 |
|
339 | int NN = 1e3, double thetaMin=0.0, double theta = 30.0, int show_rays = 30, int show_rand = 0) |
308 | { |
340 | { |
309 | //CDetector *detector = new CDetector(center, 3, 1.666, 3, 3, 1, 1.48, 1.48); |
341 | //CDetector *detector = new CDetector(center, 3, 1.666, 3, 3, 1, 1.48, 1.48); |
310 |
|
342 | double pi = 3.14159265358979312; |
311 |
|
343 | theta = theta*3.14159265358979312/180.0; |
312 |
|
344 | if(theta < MARGIN) theta = MARGIN; |
313 | 345 | ||
314 |
|
346 | TDatime now; |
315 |
|
347 | TRandom rand; |
316 |
|
348 | rand.SetSeed(now.Get()); |
317 |
|
349 | double rx, ry, rz, rl, rm, rn; |
318 |
|
350 | double rphi, rtheta; |
319 |
|
351 | //double theta_min_rad = TMath::Power(TMath::Cos(theta), 2); |
320 |
|
352 | double theta_min_rad = TMath::Cos(theta); |
321 |
|
353 | double theta_max_rad = TMath::Cos(thetaMin); |
322 | 354 | ||
323 |
|
355 | TH1F *hphi, *htheta, *hcostheta, *hl, *hm, *hn; |
324 |
|
356 | hphi = (TH1F*)gROOT->FindObject("hphi"); if(hphi) delete hphi; |
325 |
|
357 | hphi = new TH1F("hphi", "hphi", 100, 0.0, 2.0*pi); |
326 |
|
358 | htheta = (TH1F*)gROOT->FindObject("htheta"); if(htheta) delete htheta; |
327 |
|
359 | htheta = new TH1F("htheta", "htheta", 100, 0.0, pi/2.0); |
328 |
|
360 | hcostheta = (TH1F*)gROOT->FindObject("hcostheta"); if(hcostheta) delete hcostheta; |
329 |
|
361 | hcostheta = new TH1F("hcostheta", "hcostheta", 100, 0.0, 1.0); |
330 |
|
362 | hl = (TH1F*)gROOT->FindObject("hl"); if(hl) delete hl; |
331 |
|
363 | hl = new TH1F("hl", "hl", 100, 0.0, 1.0); |
332 |
|
364 | hm = (TH1F*)gROOT->FindObject("hm"); if(hm) delete hm; |
333 |
|
365 | hm = new TH1F("hm", "hm", 100, 0.0, 1.0); |
334 |
|
366 | hn = (TH1F*)gROOT->FindObject("hn"); if(hn) delete hn; |
335 |
|
367 | hn = new TH1F("hn", "hn", 100, 0.0, 1.0); |
336 | 368 | ||
337 | 369 | ||
338 |
|
370 | //detector->Init(); |
339 |
|
371 | if (show_3d) detector->Draw(draw_width); |
340 | 372 | ||
341 |
|
373 | double SiPM = parameters.getA(); |
342 |
|
374 | double M = parameters.getM(); |
343 |
|
375 | double offset = (parameters._plateOn ? parameters._plateWidth : 0); |
344 | 376 | ||
345 |
|
377 | for(int i = 0; i < NN; i++) { |
346 | 378 | ||
347 |
|
379 | rx = CENTER.x() - offset; |
348 |
|
380 | ry = rand.Uniform(-M*SiPM/2.0, M*SiPM/2.0); |
349 |
|
381 | rz = rand.Uniform(-M*SiPM/2.0, M*SiPM/2.0); |
350 | 382 | ||
351 |
|
383 | rphi = rand.Uniform(0.0, 2.0*pi); |
352 |
|
384 | //double theta_max_rad = TMath::Cos(17.0*pi/180.0); |
353 |
|
385 | //rtheta = TMath::ACos((rand.Uniform(theta_min_rad, 1.0))); |
354 |
|
386 | rtheta = TMath::ACos((rand.Uniform(theta_min_rad, theta_max_rad))); |
355 | 387 | ||
356 |
|
388 | rl = TMath::Cos(rtheta); |
357 |
|
389 | rm = TMath::Sin(rtheta)*TMath::Sin(rphi); |
358 |
|
390 | rn = TMath::Sin(rtheta)*TMath::Cos(rphi); |
359 | 391 | ||
360 |
|
392 | if(show_rand) { |
361 |
|
393 | htheta->Fill(rtheta); |
362 |
|
394 | hcostheta->Fill( TMath::Cos(rtheta) ); |
363 |
|
395 | hphi->Fill(rphi); |
364 |
|
396 | hl->Fill(rl); hm->Fill(rm); hn->Fill(rn); |
365 |
|
397 | } |
366 | 398 | ||
367 |
|
399 | CRay *ray0 = new CRay(rx, ry, rz, rl, rm, rn); |
368 |
|
400 | CRay *ray1 = new CRay; |
369 | 401 | ||
370 |
|
402 | if(i < show_rays) { |
371 |
|
403 | detector->Propagate(*ray0, ray1, show_3d); |
372 |
|
404 | } |
373 |
|
405 | else { |
374 |
|
406 | detector->Propagate(*ray0, ray1, 0); |
375 |
|
407 | } |
376 | 408 | ||
377 |
|
409 | delete ray0; |
378 |
|
410 | delete ray1; |
379 |
|
411 | } |
380 | 412 | ||
381 |
|
413 | if(show_rand) { |
382 |
|
414 | TCanvas *c2rand = (TCanvas*)gROOT->FindObject("c2rand"); |
383 |
|
415 | if(!c2rand) c2rand = new TCanvas("c2rand", "Random", 750, 550, 700, 700); |
384 |
|
416 | else c2rand->Clear(); |
385 |
|
417 | c2rand->Divide(2,3); |
386 | 418 | ||
387 |
|
419 | c2rand->cd(1); hphi->Draw(); |
388 |
|
420 | c2rand->cd(3); htheta->Draw(); |
389 |
|
421 | c2rand->cd(5); hcostheta->Draw(); |
390 |
|
422 | c2rand->cd(2); hl->Draw(); |
391 |
|
423 | c2rand->cd(4); hm->Draw(); |
392 |
|
424 | c2rand->cd(6); hn->Draw(); |
393 |
|
425 | } |
394 | 426 | ||
395 |
|
427 | double acceptance = 0.0; |
396 |
|
428 | /* |
397 | if( !(parameters.getPlateOn()) ) |
429 | if( !(parameters.getPlateOn()) ) |
398 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN; |
430 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN; |
399 | else |
431 | else |
400 | acceptance = (detector->GetHActive())->GetEntries() / (detector->GetHPlate())->GetEntries(); |
432 | acceptance = (detector->GetHActive())->GetEntries() / (detector->GetHPlate())->GetEntries(); |
401 | |
433 | */ |
402 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN; |
434 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN; |
403 |
|
435 | return acceptance; |
404 | } |
436 | } |
405 | 437 | ||
406 | // Beamtest distribution |
438 | // Beamtest distribution |
407 | // with fixed theta and phi in interval phiMin, phiMax |
439 | // with fixed theta and phi in interval phiMin, phiMax |
- | 440 | double beamtest(CDetector *detector, DetectorParameters& parameters, |
|
408 |
|
441 | int NN, double theta, double phiMin, double phiMax, int show_rays, int show_rand) |
409 | { |
442 | { |
410 |
|
443 | double pi = 3.14159265358979312; |
411 |
|
444 | theta *= pi/180.0; |
412 |
|
445 | if(theta < MARGIN) theta = MARGIN; |
413 |
|
446 | phiMin *= pi/180.0; |
414 |
|
447 | phiMax *= pi/180.0; |
415 | 448 | ||
416 |
|
449 | TDatime now; |
417 |
|
450 | TRandom rand; |
418 |
|
451 | rand.SetSeed(now.Get()); |
419 |
|
452 | double rx, ry, rz, rl, rm, rn; |
420 |
|
453 | double rphi; |
- | 454 | ||
- | 455 | TH1F *hphi, *htheta, *hcostheta, *hl, *hm, *hn; |
|
- | 456 | hphi = (TH1F*)gROOT->FindObject("hphi"); if(hphi) delete hphi; |
|
- | 457 | hphi = new TH1F("hphi", "hphi", 100, -pi, pi); |
|
- | 458 | htheta = (TH1F*)gROOT->FindObject("htheta"); if(htheta) delete htheta; |
|
- | 459 | htheta = new TH1F("htheta", "htheta", 100, 0.0, pi/2.0); |
|
- | 460 | hcostheta = (TH1F*)gROOT->FindObject("hcostheta"); if(hcostheta) delete hcostheta; |
|
- | 461 | hcostheta = new TH1F("hcostheta", "hcostheta", 100, 0.0, 1.0); |
|
- | 462 | hl = (TH1F*)gROOT->FindObject("hl"); if(hl) delete hl; |
|
- | 463 | hl = new TH1F("hl", "hl", 100, 0.0, 1.0); |
|
- | 464 | hm = (TH1F*)gROOT->FindObject("hm"); if(hm) delete hm; |
|
- | 465 | hm = new TH1F("hm", "hm", 100, 0.0, 1.0); |
|
- | 466 | hn = (TH1F*)gROOT->FindObject("hn"); if(hn) delete hn; |
|
- | 467 | hn = new TH1F("hn", "hn", 100, 0.0, 1.0); |
|
- | 468 | ||
421 |
|
469 | //detector->Init(); |
- | 470 | if (show_3d) detector->Draw(draw_width); |
|
- | 471 | ||
- | 472 | double b = parameters.getB(); |
|
- | 473 | double offset = (parameters._plateOn ? parameters._plateWidth : 0); |
|
- | 474 | ||
- | 475 | for(int i = 0; i < NN; i++) { |
|
- | 476 | ||
- | 477 | rx = CENTER.x() - offset; |
|
- | 478 | ry = rand.Uniform(-b/2.0, b/2.0); |
|
- | 479 | rz = rand.Uniform(-b/2.0, b/2.0); |
|
- | 480 | ||
- | 481 | rphi = rand.Uniform(phiMin, phiMax); |
|
422 |
|
482 | //double theta_max_rad = TMath::Cos(17.0*pi/180.0); |
- | 483 | //rtheta = TMath::ACos((rand.Uniform(theta_min_rad, 1.0))); |
|
- | 484 | //rtheta = TMath::ACos((rand.Uniform(theta_min_rad, theta_max_rad))); |
|
- | 485 | ||
423 |
|
486 | rl = TMath::Cos(theta); |
- | 487 | rm = TMath::Sin(theta)*TMath::Sin(rphi); |
|
- | 488 | rn = TMath::Sin(theta)*TMath::Cos(rphi); |
|
- | 489 | ||
- | 490 | if(show_rand) { |
|
- | 491 | //htheta->Fill(rtheta); |
|
- | 492 | //hcostheta->Fill( TMath::Cos(rtheta) ); |
|
- | 493 | hphi->Fill(rphi); |
|
- | 494 | hl->Fill(rl); |
|
- | 495 | hm->Fill(rm); |
|
- | 496 | hn->Fill(rn); |
|
- | 497 | } |
|
- | 498 | ||
- | 499 | CRay *ray0 = new CRay(rx, ry, rz, rl, rm, rn); |
|
- | 500 | // inital polarizaton |
|
- | 501 | TVector3 polarization(0, 0, 1); |
|
- | 502 | polarization.RotateY(-theta); |
|
- | 503 | polarization.RotateX(rphi); |
|
- | 504 | ray0->setPolarization(polarization); |
|
- | 505 | CRay *ray1 = new CRay; |
|
- | 506 | ||
- | 507 | if(i < show_rays) { |
|
- | 508 | detector->Propagate(*ray0, ray1, show_3d); |
|
- | 509 | } |
|
- | 510 | else { |
|
- | 511 | detector->Propagate(*ray0, ray1, 0); |
|
- | 512 | } |
|
- | 513 | ||
- | 514 | delete ray0; |
|
- | 515 | delete ray1; |
|
- | 516 | } |
|
- | 517 | ||
- | 518 | if(show_rand) { |
|
- | 519 | TCanvas *c2rand = (TCanvas*)gROOT->FindObject("c2rand"); |
|
- | 520 | if(!c2rand) c2rand = new TCanvas("c2rand", "Random", 750, 550, 700, 700); |
|
- | 521 | else c2rand->Clear(); |
|
- | 522 | c2rand->Divide(2,3); |
|
424 | 523 | ||
425 | TH1F *hphi, *htheta, *hcostheta, *hl, *hm, *hn; |
- | |
426 | hphi = (TH1F*)gROOT->FindObject("hphi"); if(hphi) delete hphi; |
- | |
427 |
|
524 | c2rand->cd(1); hphi->Draw(); |
428 | htheta = (TH1F*)gROOT->FindObject("htheta"); if(htheta) delete htheta; |
- | |
429 | htheta = new TH1F("htheta", "htheta", 100, 0.0, pi/2.0); |
- | |
430 | hcostheta = (TH1F*)gROOT->FindObject("hcostheta"); if(hcostheta) delete hcostheta; |
- | |
431 | hcostheta = new TH1F("hcostheta", "hcostheta", 100, 0.0, 1.0); |
- | |
432 |
|
525 | c2rand->cd(3); htheta->Draw(); |
433 |
|
526 | c2rand->cd(5); hcostheta->Draw(); |
434 |
|
527 | c2rand->cd(2); hl->Draw(); |
435 |
|
528 | c2rand->cd(4); hm->Draw(); |
436 | hn = (TH1F*)gROOT->FindObject("hn"); if(hn) delete hn; |
- | |
437 |
|
529 | c2rand->cd(6); hn->Draw(); |
438 | 530 | } |
|
439 | //detector->Init(); |
- | |
440 | if (show_3d) detector->Draw(draw_width); |
- | |
441 | 531 | ||
442 | double b = parameters.getB(); |
- | |
443 | double offset = (parameters._plateOn ? parameters._plateWidth : 0); |
- | |
444 | - | ||
445 | for(int i = 0; i < NN; i++) { |
- | |
446 | - | ||
447 | rx = CENTER.x() - offset; |
- | |
448 | ry = rand.Uniform(-b/2.0, b/2.0); |
- | |
449 | rz = rand.Uniform(-b/2.0, b/2.0); |
- | |
450 | - | ||
451 | rphi = rand.Uniform(phiMin, phiMax); |
- | |
452 | //double theta_max_rad = TMath::Cos(17.0*pi/180.0); |
- | |
453 | //rtheta = TMath::ACos((rand.Uniform(theta_min_rad, 1.0))); |
- | |
454 | //rtheta = TMath::ACos((rand.Uniform(theta_min_rad, theta_max_rad))); |
- | |
455 | - | ||
456 | rl = TMath::Cos(theta); |
- | |
457 | rm = TMath::Sin(theta)*TMath::Sin(rphi); |
- | |
458 | rn = TMath::Sin(theta)*TMath::Cos(rphi); |
- | |
459 | - | ||
460 | if(show_rand) { |
- | |
461 | //htheta->Fill(rtheta); |
- | |
462 | //hcostheta->Fill( TMath::Cos(rtheta) ); |
- | |
463 | hphi->Fill(rphi); |
- | |
464 | hl->Fill(rl); hm->Fill(rm); hn->Fill(rn); |
- | |
465 | } |
- | |
466 | - | ||
467 | CRay *ray0 = new CRay(rx, ry, rz, rl, rm, rn); |
- | |
468 | CRay *ray1 = new CRay; |
- | |
469 | - | ||
470 | if(i < show_rays) { |
- | |
471 | detector->Propagate(*ray0, ray1, show_3d); |
- | |
472 | } |
- | |
473 | else { |
- | |
474 | detector->Propagate(*ray0, ray1, 0); |
- | |
475 | } |
- | |
476 | - | ||
477 | delete ray0; |
- | |
478 | delete ray1; |
- | |
479 | } |
- | |
480 | - | ||
481 | if(show_rand) { |
- | |
482 | TCanvas *c2rand = (TCanvas*)gROOT->FindObject("c2rand"); |
- | |
483 | if(!c2rand) c2rand = new TCanvas("c2rand", "Random", 750, 550, 700, 700); |
- | |
484 | else c2rand->Clear(); |
- | |
485 | c2rand->Divide(2,3); |
- | |
486 | - | ||
487 | c2rand->cd(1); hphi->Draw(); |
- | |
488 | c2rand->cd(3); htheta->Draw(); |
- | |
489 | c2rand->cd(5); hcostheta->Draw(); |
- | |
490 | c2rand->cd(2); hl->Draw(); |
- | |
491 | c2rand->cd(4); hm->Draw(); |
- | |
492 | c2rand->cd(6); hn->Draw(); |
- | |
493 | } |
- | |
494 | - | ||
495 |
|
532 | double acceptance = 0.0; |
496 |
|
533 | /* |
497 | if( !(parameters.getPlateOn()) ) |
534 | if( !(parameters.getPlateOn()) ) |
498 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN; |
535 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN; |
499 | else |
536 | else |
500 | acceptance = (detector->GetHActive())->GetEntries() / (detector->GetHPlate())->GetEntries(); |
537 | acceptance = (detector->GetHActive())->GetEntries() / (detector->GetHPlate())->GetEntries(); |
501 | |
538 | */ |
502 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN; |
539 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN; |
503 |
|
540 | return acceptance; |
504 | } |
541 | } |