Rev 54 | Rev 71 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 54 | Rev 70 | ||
|---|---|---|---|
| Line 85... | Line 85... | ||
| 85 | //----------------------------------------------------------------------------- |
85 | //----------------------------------------------------------------------------- |
| 86 | void DrawData(CDetector *detector, DetectorParameters& parameters, double theta = 0.0, double acc = 0.0, int only2d = 0) |
86 | void DrawData(CDetector *detector, DetectorParameters& parameters, double theta = 0.0, double acc = 0.0, int only2d = 0) |
| 87 | { |
87 | { |
| 88 | if(show_data) { |
88 | if(show_data) { |
| 89 | char sbuff[256]; |
89 | char sbuff[256]; |
| 90 | sprintf(sbuff, "SiPM = %.1lf, |
90 | sprintf(sbuff, "SiPM = %.1lf, L.y. = %.2lf, d = %.1lf | gap = (%.1lf, %.1lf, %.1lf), #theta = %.1lf | acceptance = %.3lf", |
| 91 | parameters.getA(), parameters. |
91 | parameters.getA(), parameters.getLightYield()*acc, parameters.getD(), |
| 92 | parameters.getGap().x(), parameters.getGap().y(), parameters.getGap().z(), theta, acc); |
92 | parameters.getGap().x(), parameters.getGap().y(), parameters.getGap().z(), theta, acc); |
| 93 | 93 | ||
| 94 | if(!only2d) { |
94 | if(!only2d) { |
| 95 | RTCanvas *cdata = new RTCanvas((char*)"Data", sbuff, 350, 0, 950, 950); |
95 | RTCanvas *cdata = new RTCanvas((char*)"Data", sbuff, 350, 0, 950, 950); |
| 96 | cdata->Divide(3,3); |
96 | cdata->Divide(3,3); |
| Line 181... | Line 181... | ||
| 181 | { |
181 | { |
| 182 | //CDetector *detector = new CDetector(center, 3, 1.666, 3, 3, 1, 1.48, 1.48); |
182 | //CDetector *detector = new CDetector(center, 3, 1.666, 3, 3, 1, 1.48, 1.48); |
| 183 | theta = Pi()*theta/180.0; |
183 | theta = Pi()*theta/180.0; |
| 184 | if(theta < 1e-6) theta = 1e-6; |
184 | if(theta < 1e-6) theta = 1e-6; |
| 185 | phi = phi*Pi()/180.0; |
185 | phi = phi*Pi()/180.0; |
| - | 186 | if(phi < 1e-6) phi = 1e-6; |
|
| 186 | 187 | ||
| 187 | double offset = (parameters._plateOn ? parameters._plateWidth : 0); |
188 | double offset = (parameters._plateOn ? parameters._plateWidth : 0); |
| 188 | 189 | ||
| 189 | //detector->Init(); |
190 | //detector->Init(); |
| 190 | if(show_3d) detector->Draw(draw_width); |
191 | if(show_3d) detector->Draw(draw_width); |
| Line 192... | Line 193... | ||
| 192 | CRay *ray0 = new CRay(hit.x() - offset, hit.y(), hit.z(), |
193 | CRay *ray0 = new CRay(hit.x() - offset, hit.y(), hit.z(), |
| 193 | TMath::Cos(theta), TMath::Sin(theta)*TMath::Sin(phi), TMath::Sin(theta)*TMath::Cos(phi)); |
194 | TMath::Cos(theta), TMath::Sin(theta)*TMath::Sin(phi), TMath::Sin(theta)*TMath::Cos(phi)); |
| 194 | CRay *ray1 = new CRay; |
195 | CRay *ray1 = new CRay; |
| 195 | 196 | ||
| 196 | detector->Propagate(*ray0, ray1, show_3d); |
197 | detector->Propagate(*ray0, ray1, show_3d); |
| - | 198 | ||
| - | 199 | delete ray0; |
|
| - | 200 | delete ray1; |
|
| 197 | 201 | ||
| 198 | return (detector->GetHActive())->GetEntries() / (double)(1); |
202 | return (detector->GetHActive())->GetEntries() / (double)(1); |
| 199 | } |
203 | } |
| 200 | //----------------------------------------------------------------------------- |
204 | //----------------------------------------------------------------------------- |
| 201 | // zarki, razporejeni v mrezi |
205 | // zarki, razporejeni v mrezi |
| Line 222... | Line 226... | ||
| 222 | TMath::Sin(theta)); |
226 | TMath::Sin(theta)); |
| 223 | CRay *ray1 = new CRay; |
227 | CRay *ray1 = new CRay; |
| 224 | if(i == (NN/2)) |
228 | if(i == (NN/2)) |
| 225 | detector->Propagate(*ray0, ray1, show_3d); |
229 | detector->Propagate(*ray0, ray1, show_3d); |
| 226 | else |
230 | else |
| 227 | detector->Propagate(*ray0, ray1, 0); |
231 | detector->Propagate(*ray0, ray1, 0); |
| - | 232 | delete ray0; |
|
| - | 233 | delete ray1; |
|
| 228 | } |
234 | } |
| 229 | } |
- | |
| 230 | 235 | ||
| - | 236 | } |
|
| - | 237 | double acceptance = 0.0; |
|
| - | 238 | /* |
|
| - | 239 | if( !(parameters.getPlateOn()) ) |
|
| - | 240 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN*NN; |
|
| - | 241 | else |
|
| - | 242 | acceptance = (detector->GetHActive())->GetEntries() / (detector->GetHPlate())->GetEntries(); |
|
| - | 243 | */ |
|
| 231 |
|
244 | acceptance = (detector->GetHActive())->GetEntries() / (double)((NN)*(NN)); |
| - | 245 | return acceptance; |
|
| 232 | } |
246 | } |
| 233 | //----------------------------------------------------------------------------- |
247 | //----------------------------------------------------------------------------- |
| 234 | // zarki z nakljucnim polozajem vpada (na vstopni pov. vodnika) |
248 | // zarki z nakljucnim polozajem vpada (na vstopni pov. vodnika) |
| 235 | // vsi pod kotom (theta, phi) |
249 | // vsi pod kotom (theta, phi) |
| 236 | double RandYZ(CDetector *detector, DetectorParameters& parameters, int |
250 | double RandYZ(CDetector *detector, DetectorParameters& parameters, int NN, double theta, double phi, int show_rays) |
| 237 | { |
251 | { |
| 238 | //CDetector *detector = new CDetector(center, 3, 1.666, 3, 3, 1, 1.48, 1.48); |
252 | //CDetector *detector = new CDetector(center, 3, 1.666, 3, 3, 1, 1.48, 1.48); |
| 239 | theta = theta*3.14159265358979312/180.0; |
253 | theta = theta*3.14159265358979312/180.0; |
| 240 | if(theta < MARGIN) theta = MARGIN; |
254 | if(theta < MARGIN) theta = MARGIN; |
| 241 | phi = phi*3.14159265358979312/180.0; |
255 | phi = phi*3.14159265358979312/180.0; |
| Line 270... | Line 284... | ||
| 270 | else |
284 | else |
| 271 | detector->Propagate(*ray0, ray1, 0); |
285 | detector->Propagate(*ray0, ray1, 0); |
| 272 | //delete ray0; |
286 | //delete ray0; |
| 273 | //delete ray1; |
287 | //delete ray1; |
| 274 | } |
288 | } |
| 275 | 289 | ||
| - | 290 | double acceptance = 0.0; |
|
| - | 291 | /* |
|
| - | 292 | if( !(parameters.getPlateOn()) ) |
|
| - | 293 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN; |
|
| - | 294 | else |
|
| - | 295 | acceptance = (detector->GetHActive())->GetEntries() / (detector->GetHPlate())->GetEntries(); |
|
| - | 296 | //return (detector->GetHActive())->GetEntries() / (double)((NN)*(NN));*/ |
|
| 276 |
|
297 | acceptance = (detector->GetHActive())->GetEntries() / (double) NN; |
| - | 298 | return acceptance; |
|
| 277 | } |
299 | } |
| 278 | //----------------------------------------------------------------------------- |
300 | //----------------------------------------------------------------------------- |
| 279 | // zarki, izotropno porazdeljeni znotraj kota theta |
301 | // zarki, izotropno porazdeljeni znotraj kota theta |
| 280 | // = nakljucni vstopni polozaj in kot |
302 | // = nakljucni vstopni polozaj in kot |
| - | 303 | // NN - number of rays to be simulated with angles theta distributed uniformly |
|
| - | 304 | // in cos theta and phi uniformly: |
|
| - | 305 | // theta [0, theta] |
|
| - | 306 | // phi [0,360] |
|
| 281 | double RandIso(CDetector *detector, DetectorParameters& parameters, int NN = 1e3, double theta = 30.0, int show_rays = 30, int show_rand = 0) |
307 | double RandIso(CDetector *detector, DetectorParameters& parameters, int NN = 1e3, double thetaMin=0.0, double theta = 30.0, int show_rays = 30, int show_rand = 0) |
| 282 | { |
308 | { |
| 283 | //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); |
| 284 | double pi = 3.14159265358979312; |
310 | double pi = 3.14159265358979312; |
| 285 | theta = theta*3.14159265358979312/180.0; |
311 | theta = theta*3.14159265358979312/180.0; |
| 286 | if(theta < MARGIN) theta = MARGIN; |
312 | if(theta < MARGIN) theta = MARGIN; |
| 287 | 313 | ||
| 288 | TDatime now; |
314 | TDatime now; |
| 289 | TRandom rand; |
315 | TRandom rand; |
| 290 | rand.SetSeed(now.Get()); |
316 | rand.SetSeed(now.Get()); |
| 291 | double rx, ry, rz, rl, rm, rn; |
317 | double rx, ry, rz, rl, rm, rn; |
| 292 | double rphi, rtheta; |
318 | double rphi, rtheta; |
| 293 | //double theta_min_rad = TMath::Power(TMath::Cos(theta), 2); |
319 | //double theta_min_rad = TMath::Power(TMath::Cos(theta), 2); |
| 294 | double theta_min_rad = TMath::Cos(theta); |
320 | double theta_min_rad = TMath::Cos(theta); |
| - | 321 | double theta_max_rad = TMath::Cos(thetaMin); |
|
| 295 | 322 | ||
| 296 | TH1F *hphi, *htheta, *hcostheta, *hl, *hm, *hn; |
323 | TH1F *hphi, *htheta, *hcostheta, *hl, *hm, *hn; |
| 297 | hphi = (TH1F*)gROOT->FindObject("hphi"); if(hphi) delete hphi; |
324 | hphi = (TH1F*)gROOT->FindObject("hphi"); if(hphi) delete hphi; |
| 298 | hphi = new TH1F("hphi", "hphi", 100, 0.0, 2.0*pi); |
325 | hphi = new TH1F("hphi", "hphi", 100, 0.0, 2.0*pi); |
| 299 | htheta = (TH1F*)gROOT->FindObject("htheta"); if(htheta) delete htheta; |
326 | htheta = (TH1F*)gROOT->FindObject("htheta"); if(htheta) delete htheta; |
| Line 320... | Line 347... | ||
| 320 | rx = CENTER.x() - offset; |
347 | rx = CENTER.x() - offset; |
| 321 | ry = rand.Uniform(-M*SiPM/2.0, M*SiPM/2.0); |
348 | ry = rand.Uniform(-M*SiPM/2.0, M*SiPM/2.0); |
| 322 | rz = rand.Uniform(-M*SiPM/2.0, M*SiPM/2.0); |
349 | rz = rand.Uniform(-M*SiPM/2.0, M*SiPM/2.0); |
| 323 | 350 | ||
| 324 | rphi = rand.Uniform(0.0, 2.0*pi); |
351 | rphi = rand.Uniform(0.0, 2.0*pi); |
| - | 352 | //double theta_max_rad = TMath::Cos(17.0*pi/180.0); |
|
| 325 | rtheta |
353 | //rtheta = TMath::ACos((rand.Uniform(theta_min_rad, 1.0))); |
| - | 354 | rtheta = TMath::ACos((rand.Uniform(theta_min_rad, theta_max_rad))); |
|
| 326 | 355 | ||
| 327 | rl = TMath::Cos(rtheta); |
356 | rl = TMath::Cos(rtheta); |
| 328 | rm = TMath::Sin(rtheta)*TMath::Sin(rphi); |
357 | rm = TMath::Sin(rtheta)*TMath::Sin(rphi); |
| 329 | rn = TMath::Sin(rtheta)*TMath::Cos(rphi); |
358 | rn = TMath::Sin(rtheta)*TMath::Cos(rphi); |
| 330 | 359 | ||
| 331 | if(show_rand) { |
360 | if(show_rand) { |
| 332 | htheta->Fill(rtheta); |
361 | htheta->Fill(rtheta); |
| 333 | hcostheta->Fill( TMath::Cos(rtheta) ); |
362 | hcostheta->Fill( TMath::Cos(rtheta) ); |
| 334 | hphi->Fill(rphi); |
363 | hphi->Fill(rphi); |
| 335 | hl->Fill(rl); hm->Fill(rm); hn->Fill(rn); |
364 | hl->Fill(rl); hm->Fill(rm); hn->Fill(rn); |
| 336 | } |
365 | } |
| - | 366 | ||
| - | 367 | CRay *ray0 = new CRay(rx, ry, rz, rl, rm, rn); |
|
| - | 368 | CRay *ray1 = new CRay; |
|
| - | 369 | ||
| - | 370 | if(i < show_rays) { |
|
| - | 371 | detector->Propagate(*ray0, ray1, show_3d); |
|
| - | 372 | } |
|
| - | 373 | else { |
|
| - | 374 | detector->Propagate(*ray0, ray1, 0); |
|
| - | 375 | } |
|
| - | 376 | ||
| - | 377 | delete ray0; |
|
| - | 378 | delete ray1; |
|
| - | 379 | } |
|
| - | 380 | ||
| - | 381 | if(show_rand) { |
|
| - | 382 | TCanvas *c2rand = (TCanvas*)gROOT->FindObject("c2rand"); |
|
| - | 383 | if(!c2rand) c2rand = new TCanvas("c2rand", "Random", 750, 550, 700, 700); |
|
| - | 384 | else c2rand->Clear(); |
|
| - | 385 | c2rand->Divide(2,3); |
|
| - | 386 | ||
| - | 387 | c2rand->cd(1); hphi->Draw(); |
|
| - | 388 | c2rand->cd(3); htheta->Draw(); |
|
| - | 389 | c2rand->cd(5); hcostheta->Draw(); |
|
| - | 390 | c2rand->cd(2); hl->Draw(); |
|
| - | 391 | c2rand->cd(4); hm->Draw(); |
|
| - | 392 | c2rand->cd(6); hn->Draw(); |
|
| - | 393 | } |
|
| - | 394 | ||
| - | 395 | double acceptance = 0.0; |
|
| - | 396 | /* |
|
| - | 397 | if( !(parameters.getPlateOn()) ) |
|
| - | 398 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN; |
|
| - | 399 | else |
|
| - | 400 | acceptance = (detector->GetHActive())->GetEntries() / (detector->GetHPlate())->GetEntries(); |
|
| - | 401 | */ |
|
| - | 402 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN; |
|
| - | 403 | return acceptance; |
|
| - | 404 | } |
|
| - | 405 | ||
| - | 406 | // Beamtest distribution |
|
| - | 407 | // with fixed theta and phi in interval phiMin, phiMax |
|
| - | 408 | double beamtest(CDetector *detector, DetectorParameters& parameters, int NN, double theta, double phiMin, double phiMax, int show_rays, int show_rand) |
|
| - | 409 | { |
|
| - | 410 | double pi = 3.14159265358979312; |
|
| - | 411 | theta *= pi/180.0; |
|
| - | 412 | if(theta < MARGIN) theta = MARGIN; |
|
| - | 413 | phiMin *= pi/180.0; |
|
| - | 414 | phiMax *= pi/180.0; |
|
| - | 415 | ||
| - | 416 | TDatime now; |
|
| - | 417 | TRandom rand; |
|
| - | 418 | rand.SetSeed(now.Get()); |
|
| - | 419 | double rx, ry, rz, rl, rm, rn; |
|
| - | 420 | double rphi; |
|
| - | 421 | //double rtheta; |
|
| - | 422 | //double theta_min_rad = TMath::Power(TMath::Cos(theta), 2); |
|
| - | 423 | //double theta_min_rad = TMath::Cos(theta); |
|
| - | 424 | ||
| - | 425 | TH1F *hphi, *htheta, *hcostheta, *hl, *hm, *hn; |
|
| - | 426 | hphi = (TH1F*)gROOT->FindObject("hphi"); if(hphi) delete hphi; |
|
| - | 427 | hphi = new TH1F("hphi", "hphi", 100, -pi, pi); |
|
| - | 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 | hl = (TH1F*)gROOT->FindObject("hl"); if(hl) delete hl; |
|
| - | 433 | hl = new TH1F("hl", "hl", 100, 0.0, 1.0); |
|
| - | 434 | hm = (TH1F*)gROOT->FindObject("hm"); if(hm) delete hm; |
|
| - | 435 | hm = new TH1F("hm", "hm", 100, 0.0, 1.0); |
|
| - | 436 | hn = (TH1F*)gROOT->FindObject("hn"); if(hn) delete hn; |
|
| - | 437 | hn = new TH1F("hn", "hn", 100, 0.0, 1.0); |
|
| - | 438 | ||
| - | 439 | //detector->Init(); |
|
| - | 440 | if (show_3d) detector->Draw(draw_width); |
|
| - | 441 | ||
| - | 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 | } |
|
| 337 | 466 | ||
| 338 | CRay *ray0 = new CRay(rx, ry, rz, rl, rm, rn); |
467 | CRay *ray0 = new CRay(rx, ry, rz, rl, rm, rn); |
| 339 | CRay *ray1 = new CRay; |
468 | CRay *ray1 = new CRay; |
| 340 | 469 | ||
| 341 | if(i < show_rays) { |
470 | if(i < show_rays) { |
| 342 | detector->Propagate(*ray0, ray1, show_3d); |
471 | detector->Propagate(*ray0, ray1, show_3d); |
| 343 | } |
472 | } |
| 344 | else { |
473 | else { |
| 345 | detector->Propagate(*ray0, ray1, 0); |
474 | detector->Propagate(*ray0, ray1, 0); |
| 346 | } |
475 | } |
| 347 | 476 | ||
| 348 |
|
477 | delete ray0; |
| 349 |
|
478 | delete ray1; |
| 350 | } |
479 | } |
| 351 | 480 | ||
| 352 | if(show_rand) { |
481 | if(show_rand) { |
| 353 | TCanvas *c2rand = (TCanvas*)gROOT->FindObject("c2rand"); |
482 | TCanvas *c2rand = (TCanvas*)gROOT->FindObject("c2rand"); |
| 354 | if(!c2rand) c2rand = new TCanvas("c2rand", "Random", 750, 550, 700, 700); |
483 | if(!c2rand) c2rand = new TCanvas("c2rand", "Random", 750, 550, 700, 700); |
| 355 | else c2rand->Clear(); |
484 | else c2rand->Clear(); |
| 356 | c2rand->Divide(2,3); |
485 | c2rand->Divide(2,3); |
| Line 361... | Line 490... | ||
| 361 | c2rand->cd(2); hl->Draw(); |
490 | c2rand->cd(2); hl->Draw(); |
| 362 | c2rand->cd(4); hm->Draw(); |
491 | c2rand->cd(4); hm->Draw(); |
| 363 | c2rand->cd(6); hn->Draw(); |
492 | c2rand->cd(6); hn->Draw(); |
| 364 | } |
493 | } |
| 365 | 494 | ||
| - | 495 | double acceptance = 0.0; |
|
| 366 | 496 | /* |
|
| - | 497 | if( !(parameters.getPlateOn()) ) |
|
| 367 |
|
498 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN; |
| - | 499 | else |
|
| - | 500 | acceptance = (detector->GetHActive())->GetEntries() / (detector->GetHPlate())->GetEntries(); |
|
| - | 501 | */ |
|
| - | 502 | acceptance = (detector->GetHActive())->GetEntries() / (double)NN; |
|
| 368 | return acceptance; |
503 | return acceptance; |
| 369 | } |
504 | } |
| 370 | - | ||