Rev 73 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 73 | Rev 84 | ||
---|---|---|---|
Line 94... | Line 94... | ||
94 | 94 | ||
95 | if(!only2d) { |
95 | if(!only2d) { |
96 | RTCanvas *cdata = new RTCanvas((char*)"Data", sbuff, 350, 0, 950, 950); |
96 | RTCanvas *cdata = new RTCanvas((char*)"Data", sbuff, 350, 0, 950, 950); |
97 | cdata->Divide(3,3); |
97 | cdata->Divide(3,3); |
98 | int cpc = 1; |
98 | int cpc = 1; |
- | 99 | cdata->cd(cpc++); |
|
99 |
|
100 | TH2F* generated = detector->GetGenerated(); |
- | 101 | int nGenerated = generated->GetEntries(); |
|
- | 102 | int minimum = generated->GetBinContent(generated->GetMinimumBin()); |
|
- | 103 | int maximum = generated->GetBinContent(generated->GetMaximumBin()); |
|
- | 104 | generated->GetZaxis()->SetRangeUser(0, 1.05*maximum); |
|
- | 105 | double variation = (maximum-minimum)/(double)nGenerated; |
|
- | 106 | printf("Statistical variation (max-min)/all = %f perc. \n", variation*100); |
|
- | 107 | generated->SetTitle("Generated"); |
|
- | 108 | generated->Draw("colz"); |
|
100 | cdata->cd(cpc++); |
109 | cdata->cd(cpc++); //((detector->GetLG())->GetHIn())->Draw("COLZ"); |
- | 110 | TH2F* histoPlate = detector->GetHPlate(); |
|
- | 111 | histoPlate->Draw("COLZ"); |
|
101 | cdata->cd(cpc++); //((detector->GetLG())->GetHOut())->Draw("COLZ"); |
112 | cdata->cd(cpc++); //((detector->GetLG())->GetHOut())->Draw("COLZ"); |
- | 113 | TH2F* histoGlass = (detector->GetHGlass()); |
|
102 |
|
114 | histoGlass->Draw("COLZ"); |
103 | 115 | ||
- | 116 | cdata->cd(cpc++); |
|
104 |
|
117 | TH2F* histoActive = (detector->GetHActive()); |
- | 118 | histoActive->Draw("COLZ"); |
|
- | 119 | cdata->cd(cpc++); |
|
105 |
|
120 | TH2F* histoLaser = (detector->GetHLaser()); |
- | 121 | histoLaser->Draw("COLZ"); |
|
- | 122 | cdata->cd(cpc++); |
|
106 |
|
123 | TH2F* histoDetector = (detector->GetHDetector()); |
- | 124 | histoDetector->Draw("COLZ"); |
|
107 | 125 | ||
- | 126 | cdata->cd(cpc++); |
|
108 |
|
127 | TH1F* fate=((detector->GetLG())->GetHFate()); |
- | 128 | fate->Draw(); |
|
- | 129 | cdata->cd(cpc++); |
|
109 |
|
130 | TH1F* reflections = ((detector->GetLG())->GetHNOdb_all()); |
- | 131 | reflections->Draw(); |
|
- | 132 | cdata->cd(cpc++); |
|
110 |
|
133 | TH1F *reflectedExit = ((detector->GetLG())->GetHNOdb_exit()); |
- | 134 | reflectedExit->Draw(); |
|
111 | }else{ |
135 | }else{ |
112 | RTCanvas *cdata = new RTCanvas((char*)"Data", sbuff, 350, 0, 500, 500); |
136 | RTCanvas *cdata = new RTCanvas((char*)"Data", sbuff, 350, 0, 500, 500); |
113 | cdata->cd(0); (detector->GetHLaser())->Draw("COLZ"); |
137 | cdata->cd(0); (detector->GetHLaser())->Draw("COLZ"); |
114 | cdata->SaveAs("cdata.gif"); |
138 | cdata->SaveAs("cdata.gif"); |
115 | } |
139 | } |
Line 177... | Line 201... | ||
177 | //----------------------------------------------------------------------------- |
201 | //----------------------------------------------------------------------------- |
178 | 202 | ||
179 | //----------------------------------------------------------------------------- |
203 | //----------------------------------------------------------------------------- |
180 | // en zarek |
204 | // en zarek |
181 | double Single(CDetector *detector, DetectorParameters& parameters, |
205 | double Single(CDetector *detector, DetectorParameters& parameters, |
182 | TVector3 hit = TVector3(0.0, 0.0, 0.0), double theta = 0.0, double phi = 0.0) |
206 | TVector3 hit = TVector3(0.0, 0.0, 0.0), double theta = 0.0, double phi = 0.0) |
183 | { |
207 | { |
184 | theta = Pi()*theta/180.0; |
208 | theta = Pi()*theta/180.0; |
185 | if(theta < 1e-6) theta = 1e-6; |
209 | if(theta < 1e-6) theta = 1e-6; |
186 | phi = phi*Pi()/180.0; |
210 | phi = phi*Pi()/180.0; |
187 | if(phi < 1e-6) phi = 1e-6; |
211 | if(phi < 1e-6) phi = 1e-6; |
Line 192... | Line 216... | ||
192 | if(show_3d) detector->Draw(draw_width); |
216 | if(show_3d) detector->Draw(draw_width); |
193 | 217 | ||
194 | CRay *ray0 = new CRay(hit.x() - offset, hit.y(), hit.z(), |
218 | CRay *ray0 = new CRay(hit.x() - offset, hit.y(), hit.z(), |
195 | TMath::Cos(theta), TMath::Sin(theta)*TMath::Sin(phi), |
219 | TMath::Cos(theta), TMath::Sin(theta)*TMath::Sin(phi), |
196 | TMath::Sin(theta)*TMath::Cos(phi)); |
220 | TMath::Sin(theta)*TMath::Cos(phi)); |
197 | // Set |
221 | // Set y-polarization == vertical |
- | 222 | TVector3 k(ray0->GetK()); |
|
198 | TVector3 polarization( |
223 | TVector3 polarization(k.Orthogonal()); |
199 | polarization. |
224 | polarization.Unit(); |
200 | polarization. |
225 | polarization.Rotate(phi, k); |
201 | if (polarization.Dot(ray0->GetK()) > 1e- |
226 | if (polarization.Dot(ray0->GetK()) > 1e-2) printf("ERROR: pol not perep\n"); |
202 | ray0->setPolarization(polarization); |
227 | ray0->setPolarization(polarization); |
203 | CRay |
228 | CRay ray1; |
204 | 229 | ||
205 | detector->Propagate(*ray0, ray1, show_3d); |
230 | detector->Propagate(*ray0, ray1, show_3d); |
206 | 231 | ||
207 | CRay *incidentPolarization = new CRay; |
232 | CRay *incidentPolarization = new CRay; |
208 | incidentPolarization->SetColor(kGreen); |
233 | incidentPolarization->SetColor(kGreen); |
209 | TVector3 drawPosition = ray0->GetR(); |
234 | TVector3 drawPosition = ray0->GetR(); |
210 | drawPosition.SetX(drawPosition.X() - 5); |
235 | drawPosition.SetX(drawPosition.X() - 5); |
211 | incidentPolarization->Set(drawPosition, polarization); |
236 | incidentPolarization->Set(drawPosition, polarization); |
212 | incidentPolarization->DrawS(drawPosition.X(), 1); |
237 | incidentPolarization->DrawS(drawPosition.X(), 1); |
213 | 238 | ||
214 | TVector3 outPolarization = ray1 |
239 | TVector3 outPolarization = ray1.GetP(); |
215 | drawPosition = ray1 |
240 | drawPosition = ray1.GetR(); |
216 | drawPosition.SetX(drawPosition.X() + 5); |
241 | drawPosition.SetX(drawPosition.X() + 5); |
217 | CRay* rayPol = new CRay(drawPosition, outPolarization); |
242 | CRay* rayPol = new CRay(drawPosition, outPolarization); |
218 | rayPol->SetColor(kBlack); |
243 | rayPol->SetColor(kBlack); |
219 | rayPol->DrawS(drawPosition.X(), 1); |
244 | rayPol->DrawS(drawPosition.X(), 1); |
220 | 245 | ||
221 | delete ray0; |
246 | delete ray0; |
222 |
|
247 | //delete ray1; |
223 | 248 | ||
224 | return (detector->GetHActive())->GetEntries() / (double)(1); |
249 | return (detector->GetHActive())->GetEntries() / (double)(1); |
225 | } |
250 | } |
226 | //----------------------------------------------------------------------------- |
251 | //----------------------------------------------------------------------------- |
227 | // zarki, razporejeni v mrezi |
252 | // zarki, razporejeni v mrezi |
228 | double Grid(CDetector *detector, DetectorParameters& parameters, |
253 | double Grid(CDetector *detector, DetectorParameters& parameters, |
229 | int NN = 10, double theta = 0.0) |
254 | int NN = 10, double theta = 0.0) |
230 | { |
255 | { |
231 | //CDetector *detector = new CDetector(center, 3, 1.666, 3, 3, 1, 1.48, 1.48); |
256 | //CDetector *detector = new CDetector(center, 3, 1.666, 3, 3, 1, 1.48, 1.48); |
232 | theta = Pi()*theta/180.0; |
257 | theta = Pi()*theta/180.0; |
233 | if(theta < 1e-6) theta = 1e-6; |
258 | if(theta < 1e-6) theta = 1e-6; |
234 | 259 | ||
235 | //detector->Init(); |
260 | //detector->Init(); |
236 | if(show_3d) detector->Draw(draw_width); |
261 | if(show_3d) detector->Draw(draw_width); |
237 | 262 | ||
238 | const double b = parameters.getB(); |
263 | const double b = parameters.getB(); |
- | 264 | double simulated = 0; |
|
239 | 265 | ||
240 | double offset = (parameters._plateOn ? parameters._plateWidth : 0); |
266 | double offset = (parameters._plateOn ? parameters._plateWidth : 0); |
241 | - | ||
- | 267 | const int GRID = 100; |
|
242 | for(int i = 0; i < |
268 | for(int i = 0; i < GRID; i++) { |
243 | for(int j = 0; j < |
269 | for(int j = 0; j < GRID; j++) { |
- | 270 | for(int jk = 0; jk<NN; jk++){ |
|
244 | CRay *ray0 = new CRay(CENTER.x() - offset, |
271 | CRay *ray0 = new CRay(CENTER.x() - offset, |
245 |
|
272 | (i*b/GRID + b/(2.0*GRID) - b/2.0), |
246 |
|
273 | (j*b/GRID + b/(2.0*GRID) - b/2.0), |
247 | TMath::Cos(theta), |
274 | TMath::Cos(theta), |
248 | 0.0, |
275 | 0.0, |
249 | TMath::Sin(theta)); |
276 | TMath::Sin(theta)); |
- | 277 | TVector3 k(ray0->GetK()); |
|
250 | TVector3 polarization |
278 | TVector3 polarization(k.Orthogonal()); |
251 | polarization. |
279 | polarization.Unit(); |
252 | ray0->setPolarization(polarization); |
280 | ray0->setPolarization(polarization); |
253 |
|
281 | CRay ray1; |
254 | if |
282 | if(i == (GRID/2) and jk == 0) |
255 | detector->Propagate(*ray0, ray1, show_3d); |
283 | detector->Propagate(*ray0, ray1, show_3d); |
256 | else |
284 | else |
257 | detector->Propagate(*ray0, ray1, 0); |
285 | detector->Propagate(*ray0, ray1, 0); |
258 | delete ray0; |
286 | delete ray0; |
- | 287 | simulated++; |
|
259 |
|
288 | //delete ray1; |
- | 289 | } |
|
260 | } |
290 | } |
261 | 291 | ||
262 | } |
292 | } |
263 | double acceptance = 0.0; |
293 | double acceptance = 0.0; |
264 | /* |
294 | /* |
265 | if( !(parameters.getPlateOn()) ) |
295 | if( !(parameters.getPlateOn()) ) |
266 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN*NN; |
296 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN*NN; |
267 | else |
297 | else |
268 | acceptance = (detector->GetHActive())->GetEntries() / (detector->GetHPlate())->GetEntries(); |
298 | acceptance = (detector->GetHActive())->GetEntries() / (detector->GetHPlate())->GetEntries(); |
269 | */ |
299 | */ |
270 | acceptance = (detector->GetHActive())->GetEntries() / |
300 | acceptance = (detector->GetHActive())->GetEntries() / simulated; |
271 | return acceptance; |
301 | return acceptance; |
272 | } |
302 | } |
273 | //----------------------------------------------------------------------------- |
303 | //----------------------------------------------------------------------------- |
274 | // zarki z nakljucnim polozajem vpada (na vstopni pov. vodnika) |
304 | // zarki z nakljucnim polozajem vpada (na vstopni pov. vodnika) |
275 | // vsi pod kotom (theta, phi) |
305 | // vsi pod kotom (theta, phi) |
276 | double RandYZ(CDetector *detector, DetectorParameters& parameters, |
306 | double RandYZ(CDetector *detector, DetectorParameters& parameters, |
277 | int NN, double theta, double phi, int show_rays) |
307 | int NN, double theta, double phi, int show_rays) |
278 | { |
308 | { |
279 | //CDetector *detector = new CDetector(center, 3, 1.666, 3, 3, 1, 1.48, 1.48); |
309 | //CDetector *detector = new CDetector(center, 3, 1.666, 3, 3, 1, 1.48, 1.48); |
280 | theta = theta*3.14159265358979312/180.0; |
310 | theta = theta*3.14159265358979312/180.0; |
281 | if(theta < MARGIN) theta = MARGIN; |
311 | if(theta < MARGIN) theta = MARGIN; |
282 | phi = phi*3.14159265358979312/180.0; |
312 | phi = phi*3.14159265358979312/180.0; |
283 | if(phi < MARGIN) phi = MARGIN; |
313 | if(phi < MARGIN) phi = MARGIN; |
284 | 314 | ||
285 | TDatime now; |
315 | TDatime now; |
286 |
|
316 | TRandom2 rand; |
287 | rand.SetSeed(now.Get()); |
317 | rand.SetSeed(now.Get()); |
288 | 318 | ||
289 | //detector->Init(); |
319 | //detector->Init(); |
290 | if(show_3d) detector->Draw(draw_width); |
320 | if(show_3d) detector->Draw(draw_width); |
291 | 321 | ||
292 | double SiPM = parameters.getA(); |
- | |
293 | double |
322 | double b = parameters.getB(); |
294 | double offset = (parameters._plateOn ? parameters._plateWidth : 0); |
323 | double offset = (parameters._plateOn ? parameters._plateWidth : 0); |
295 | 324 | ||
296 | for(int i = 0; i < NN; i++) { |
325 | for(int i = 0; i < NN; i++) { |
297 | 326 | ||
298 | double rx = CENTER.x() - offset; |
327 | double rx = CENTER.x() - offset; |
299 | double ry = rand.Uniform(- |
328 | double ry = rand.Uniform(-b/2.0, b/2.0); |
300 | double rz = rand.Uniform(- |
329 | double rz = rand.Uniform(-b/2.0, b/2.0); |
301 | 330 | ||
302 | double rl = TMath::Cos(theta); |
331 | double rl = TMath::Cos(theta); |
303 | double rm = TMath::Sin(theta)*TMath::Sin(phi); |
332 | double rm = TMath::Sin(theta)*TMath::Sin(phi); |
304 | double rn = TMath::Sin(theta)*TMath::Cos(phi); |
333 | double rn = TMath::Sin(theta)*TMath::Cos(phi); |
305 | 334 | ||
306 | CRay *ray0 = new CRay(rx, ry, rz, rl, rm, rn); |
335 | CRay *ray0 = new CRay(rx, ry, rz, rl, rm, rn); |
- | 336 | TVector3 k(ray0->GetK()); |
|
307 | TVector3 polarization( |
337 | TVector3 polarization(k.Orthogonal()); |
308 | polarization. |
338 | polarization.Unit(); |
309 | polarization. |
339 | polarization.Rotate(phi, k); |
310 | ray0->setPolarization(polarization); |
340 | ray0->setPolarization(polarization); |
311 | CRay |
341 | CRay ray1; |
312 | 342 | ||
313 | if(i < show_rays) |
343 | if(i < show_rays) |
314 | detector->Propagate(*ray0, ray1, show_3d); |
344 | detector->Propagate(*ray0, ray1, show_3d); |
315 | else |
345 | else |
316 | detector->Propagate(*ray0, ray1, 0); |
346 | detector->Propagate(*ray0, ray1, 0); |
317 |
|
347 | //delete ray1; |
318 | delete ray0; |
348 | delete ray0; |
319 | } |
349 | } |
320 | 350 | ||
321 | double acceptance = 0.0; |
351 | double acceptance = 0.0; |
322 | /* |
352 | /* |
Line 334... | Line 364... | ||
334 | // NN - number of rays to be simulated with angles theta distributed uniformly |
364 | // NN - number of rays to be simulated with angles theta distributed uniformly |
335 | // in cos theta and phi uniformly: |
365 | // in cos theta and phi uniformly: |
336 | // theta [0, theta] |
366 | // theta [0, theta] |
337 | // phi [0,360] |
367 | // phi [0,360] |
338 | double RandIso(CDetector *detector, DetectorParameters& parameters, |
368 | double RandIso(CDetector *detector, DetectorParameters& parameters, |
339 | int NN = 1e3, double thetaMin=0.0, double |
369 | int NN = 1e3, double thetaMin=0.0, double thetaMax = 30.0, int show_rays = 30, int show_rand = 0) |
340 | { |
370 | { |
341 | //CDetector *detector = new CDetector(center, 3, 1.666, 3, 3, 1, 1.48, 1.48); |
371 | //CDetector *detector = new CDetector(center, 3, 1.666, 3, 3, 1, 1.48, 1.48); |
342 | double pi = 3.14159265358979312; |
372 | double pi = 3.14159265358979312; |
- | 373 | thetaMax = thetaMax*pi/180.0; |
|
343 |
|
374 | thetaMin = thetaMin*pi/180.0; |
- | 375 | if(thetaMin < MARGIN) thetaMin = MARGIN; |
|
344 | if( |
376 | if(thetaMax < MARGIN) thetaMax = MARGIN; |
345 | 377 | ||
346 | TDatime now; |
378 | TDatime now; |
347 |
|
379 | TRandom2 rand; |
348 | rand.SetSeed(now.Get()); |
380 | rand.SetSeed(now.Get()); |
349 | double rx, ry, rz, rl, rm, rn; |
- | |
350 | double rphi, rtheta; |
- | |
351 | //double theta_min_rad = TMath::Power(TMath::Cos(theta), 2); |
381 | //double theta_min_rad = TMath::Power(TMath::Cos(theta), 2); |
352 | double theta_min_rad = TMath::Cos( |
382 | double theta_min_rad = TMath::Cos(thetaMax); |
353 | double theta_max_rad = TMath::Cos(thetaMin); |
383 | double theta_max_rad = TMath::Cos(thetaMin); |
354 | 384 | ||
355 | TH1F *hphi, *htheta, *hcostheta, *hl, *hm, *hn; |
385 | TH1F *hphi, *htheta, *hcostheta, *hl, *hm, *hn; |
356 | hphi = (TH1F*)gROOT->FindObject("hphi"); if(hphi) delete hphi; |
386 | hphi = (TH1F*)gROOT->FindObject("hphi"); if(hphi) delete hphi; |
357 | hphi = new TH1F("hphi", "hphi", 100, 0.0, 2.0*pi); |
387 | hphi = new TH1F("hphi", "hphi", 100, 0.0, 2.0*pi); |
Line 368... | Line 398... | ||
368 | 398 | ||
369 | 399 | ||
370 | //detector->Init(); |
400 | //detector->Init(); |
371 | if (show_3d) detector->Draw(draw_width); |
401 | if (show_3d) detector->Draw(draw_width); |
372 | 402 | ||
373 | double SiPM = parameters.getA(); |
- | |
374 | double |
403 | double b = parameters.getB(); |
375 | double offset = (parameters._plateOn ? parameters._plateWidth : 0); |
404 | double offset = (parameters._plateOn ? parameters._plateWidth : 0); |
376 | - | ||
377 | for(int i = 0; i < NN; i++) { |
- | |
378 | 405 | ||
- | 406 | for(int i = 0; i < NN; i++) { |
|
- | 407 | ||
379 | rx = CENTER.x() - offset; |
408 | double rx = CENTER.x() - offset; |
380 | ry |
409 | double ry = rand.Uniform(-b/2.0, b/2.0); |
381 | rz |
410 | double rz = rand.Uniform(-b/2.0, b/2.0); |
382 | 411 | ||
383 |
|
412 | double phi = rand.Uniform(0.0, 2.0*pi); |
384 | //double theta_max_rad = TMath::Cos(17.0*pi/180.0); |
413 | //double theta_max_rad = TMath::Cos(17.0*pi/180.0); |
385 | //rtheta = TMath::ACos((rand.Uniform(theta_min_rad, 1.0))); |
414 | //rtheta = TMath::ACos((rand.Uniform(theta_min_rad, 1.0))); |
386 |
|
415 | double theta = TMath::ACos((rand.Uniform(theta_min_rad, theta_max_rad))); |
387 | 416 | ||
388 | rl = TMath::Cos( |
417 | double rl = TMath::Cos(theta); |
389 | rm = TMath::Sin( |
418 | double rm = TMath::Sin(theta)*TMath::Sin(phi); |
390 | rn = TMath::Sin( |
419 | double rn = TMath::Sin(theta)*TMath::Cos(phi); |
391 | 420 | ||
392 | if(show_rand) { |
421 | if(show_rand) { |
393 | htheta->Fill( |
422 | htheta->Fill(theta); |
394 | hcostheta->Fill( TMath::Cos( |
423 | hcostheta->Fill( TMath::Cos(theta) ); |
395 | hphi->Fill( |
424 | hphi->Fill(phi); |
- | 425 | hl->Fill(rl); |
|
- | 426 | hm->Fill(rm); |
|
396 |
|
427 | hn->Fill(rn); |
397 | } |
428 | } |
398 | 429 | ||
399 | CRay *ray0 = new CRay(rx, ry, rz, rl, rm, rn); |
430 | CRay *ray0 = new CRay(rx, ry, rz, rl, rm, rn); |
- | 431 | TVector3 k(ray0->GetK()); |
|
- | 432 | TVector3 polarization(k.Orthogonal()); |
|
- | 433 | polarization.Unit(); |
|
- | 434 | polarization.Rotate(phi, k); |
|
- | 435 | ray0->setPolarization(polarization); |
|
400 | CRay |
436 | CRay ray1; |
401 | 437 | ||
402 | if(i < show_rays) { |
438 | if(i < show_rays) { |
403 | detector->Propagate(*ray0, ray1, show_3d); |
439 | detector->Propagate(*ray0, ray1, show_3d); |
404 | } |
440 | } |
405 | else { |
441 | else { |
406 | detector->Propagate(*ray0, ray1, 0); |
442 | detector->Propagate(*ray0, ray1, 0); |
407 | } |
443 | } |
408 | 444 | ||
- | 445 | //delete ray1; |
|
409 | delete ray0; |
446 | delete ray0; |
410 | delete ray1; |
- | |
411 | } |
447 | } |
412 | 448 | ||
413 | if(show_rand) { |
449 | if(show_rand) { |
414 | TCanvas *c2rand = (TCanvas*)gROOT->FindObject("c2rand"); |
450 | TCanvas *c2rand = (TCanvas*)gROOT->FindObject("c2rand"); |
415 | if(!c2rand) c2rand = new TCanvas("c2rand", "Random", 750, 550, 700, 700); |
451 | if(!c2rand) c2rand = new TCanvas("c2rand", "Random", 750, 550, 700, 700); |
Line 436... | Line 472... | ||
436 | } |
472 | } |
437 | 473 | ||
438 | // Beamtest distribution |
474 | // Beamtest distribution |
439 | // with fixed theta and phi in interval phiMin, phiMax |
475 | // with fixed theta and phi in interval phiMin, phiMax |
440 | double beamtest(CDetector *detector, DetectorParameters& parameters, |
476 | double beamtest(CDetector *detector, DetectorParameters& parameters, |
441 | int NN, double theta, double phiMin, double phiMax, int show_rays, int show_rand) |
477 | int NN, double theta, double phiMin, double phiMax, int show_rays, int show_rand) |
442 | { |
478 | { |
443 | double pi = 3.14159265358979312; |
479 | double pi = 3.14159265358979312; |
444 | theta *= pi/180.0; |
480 | theta *= pi/180.0; |
445 | if(theta < MARGIN) theta = MARGIN; |
481 | if(theta < MARGIN) theta = MARGIN; |
446 | phiMin *= pi/180.0; |
482 | phiMin *= pi/180.0; |
447 | phiMax *= pi/180.0; |
483 | phiMax *= pi/180.0; |
448 | 484 | ||
449 | TDatime now; |
485 | TDatime now; |
450 |
|
486 | TRandom2 rand; |
451 | rand.SetSeed(now.Get()); |
487 | rand.SetSeed(now.Get()); |
452 | double rx, ry, rz, rl, rm, rn; |
488 | double rx, ry, rz, rl, rm, rn; |
453 | double |
489 | double phi; |
454 | 490 | ||
455 | TH1F *hphi, *htheta, *hcostheta, *hl, *hm, *hn; |
491 | TH1F *hphi, *htheta, *hcostheta, *hl, *hm, *hn; |
456 | hphi = (TH1F*)gROOT->FindObject("hphi"); if(hphi) delete hphi; |
492 | hphi = (TH1F*)gROOT->FindObject("hphi"); if(hphi) delete hphi; |
457 | hphi = new TH1F("hphi", "hphi", 100, -pi, pi); |
493 | hphi = new TH1F("hphi", "hphi", 100, -pi, pi); |
458 | htheta = (TH1F*)gROOT->FindObject("htheta"); if(htheta) delete htheta; |
494 | htheta = (TH1F*)gROOT->FindObject("htheta"); if(htheta) delete htheta; |
Line 476... | Line 512... | ||
476 | 512 | ||
477 | rx = CENTER.x() - offset; |
513 | rx = CENTER.x() - offset; |
478 | ry = rand.Uniform(-b/2.0, b/2.0); |
514 | ry = rand.Uniform(-b/2.0, b/2.0); |
479 | rz = rand.Uniform(-b/2.0, b/2.0); |
515 | rz = rand.Uniform(-b/2.0, b/2.0); |
480 | 516 | ||
481 |
|
517 | phi = rand.Uniform(phiMin, phiMax); |
482 | //double theta_max_rad = TMath::Cos(17.0*pi/180.0); |
518 | //double theta_max_rad = TMath::Cos(17.0*pi/180.0); |
483 | //rtheta = TMath::ACos((rand.Uniform(theta_min_rad, 1.0))); |
519 | //rtheta = TMath::ACos((rand.Uniform(theta_min_rad, 1.0))); |
484 | //rtheta = TMath::ACos((rand.Uniform(theta_min_rad, theta_max_rad))); |
520 | //rtheta = TMath::ACos((rand.Uniform(theta_min_rad, theta_max_rad))); |
485 | 521 | ||
486 | rl = TMath::Cos(theta); |
522 | rl = TMath::Cos(theta); |
487 | rm = TMath::Sin(theta)*TMath::Sin( |
523 | rm = TMath::Sin(theta)*TMath::Sin(phi); |
488 | rn = TMath::Sin(theta)*TMath::Cos( |
524 | rn = TMath::Sin(theta)*TMath::Cos(phi); |
489 | 525 | ||
490 | if(show_rand) { |
526 | if(show_rand) { |
491 | //htheta->Fill(rtheta); |
527 | //htheta->Fill(rtheta); |
492 | //hcostheta->Fill( TMath::Cos(rtheta) ); |
528 | //hcostheta->Fill( TMath::Cos(rtheta) ); |
493 | hphi->Fill( |
529 | hphi->Fill(phi); |
494 | hl->Fill(rl); |
530 | hl->Fill(rl); |
495 | hm->Fill(rm); |
531 | hm->Fill(rm); |
496 | hn->Fill(rn); |
532 | hn->Fill(rn); |
497 | } |
533 | } |
498 | 534 | ||
499 | CRay *ray0 = new CRay(rx, ry, rz, rl, rm, rn); |
535 | CRay *ray0 = new CRay(rx, ry, rz, rl, rm, rn); |
500 | // inital polarizaton |
536 | // inital polarizaton |
- | 537 | TVector3 k(ray0->GetK()); |
|
501 | TVector3 polarization( |
538 | TVector3 polarization(k.Orthogonal()); |
502 | polarization. |
539 | polarization.Unit(); |
503 | polarization. |
540 | polarization.Rotate(phi, k); |
504 | ray0->setPolarization(polarization); |
541 | ray0->setPolarization(polarization); |
505 | CRay |
542 | CRay ray1; |
506 | 543 | ||
507 | if(i < show_rays) { |
544 | if(i < show_rays) { |
508 | detector->Propagate(*ray0, ray1, show_3d); |
545 | detector->Propagate(*ray0, ray1, show_3d); |
509 | } |
546 | } |
510 | else { |
547 | else { |
511 | detector->Propagate(*ray0, ray1, 0); |
548 | detector->Propagate(*ray0, ray1, 0); |
512 | } |
549 | } |
513 | 550 | ||
- | 551 | //delete ray1; |
|
514 | delete ray0; |
552 | delete ray0; |
515 | delete ray1; |
- | |
516 | } |
553 | } |
517 | 554 | ||
518 | if(show_rand) { |
555 | if(show_rand) { |
519 | TCanvas *c2rand = (TCanvas*)gROOT->FindObject("c2rand"); |
556 | TCanvas *c2rand = (TCanvas*)gROOT->FindObject("c2rand"); |
520 | if(!c2rand) c2rand = new TCanvas("c2rand", "Random", 750, 550, 700, 700); |
557 | if(!c2rand) c2rand = new TCanvas("c2rand", "Random", 750, 550, 700, 700); |