Commit 500fc41f1933c2c71e56a295aa17e93a0ebe227d
1 parent
0201b1fa
Put deadtime correction after effective area selection in GCTAResponse::mc.
Showing
1 changed file
with
24 additions
and
25 deletions
inst/cta/src/GCTAResponse.cpp
| @@ -475,34 +475,33 @@ GCTAEventAtom* GCTAResponse::mc(const double& area, const GPhoton& photon, | @@ -475,34 +475,33 @@ GCTAEventAtom* GCTAResponse::mc(const double& area, const GPhoton& photon, | ||
| 475 | // Initialise event | 475 | // Initialise event |
| 476 | GCTAEventAtom* event = NULL; | 476 | GCTAEventAtom* event = NULL; |
| 477 | 477 | ||
| 478 | - // Continue only if the photon arrives at the moment when the detector | ||
| 479 | - // is not dead. This implements the deadtime correction. | ||
| 480 | - double deadc = obs.deadc(photon.time()); | ||
| 481 | - if (deadc >= 1.0 || ran.uniform() <= deadc) { | ||
| 482 | - | ||
| 483 | - // Get pointer on CTA pointing | ||
| 484 | - GCTAPointing* pnt = dynamic_cast<GCTAPointing*>(obs.pointing()); | ||
| 485 | - if (pnt == NULL) { | ||
| 486 | - throw GCTAException::no_pointing(G_MC); | ||
| 487 | - } | 478 | + // Get pointer on CTA pointing |
| 479 | + GCTAPointing* pnt = dynamic_cast<GCTAPointing*>(obs.pointing()); | ||
| 480 | + if (pnt == NULL) { | ||
| 481 | + throw GCTAException::no_pointing(G_MC); | ||
| 482 | + } | ||
| 488 | 483 | ||
| 489 | - // Get pointing direction zenith angle and azimuth [radians] | ||
| 490 | - double zenith = pnt->zenith(); | ||
| 491 | - double azimuth = pnt->azimuth(); | 484 | + // Get pointing direction zenith angle and azimuth [radians] |
| 485 | + double zenith = pnt->zenith(); | ||
| 486 | + double azimuth = pnt->azimuth(); | ||
| 492 | 487 | ||
| 493 | - // Get radial offset and polar angles of true photon in camera [radians] | ||
| 494 | - double theta_p = pnt->dir().dist(photon.dir()); | ||
| 495 | - double phi_p = 0.0; //TODO Implement Phi dependence | 488 | + // Get radial offset and polar angles of true photon in camera [radians] |
| 489 | + double theta_p = pnt->dir().dist(photon.dir()); | ||
| 490 | + double phi_p = 0.0; //TODO Implement Phi dependence | ||
| 496 | 491 | ||
| 497 | - // Compute effective area for photon | ||
| 498 | - double srcLogEng = photon.energy().log10TeV(); | ||
| 499 | - double effective_area = aeff(theta_p, phi_p, zenith, azimuth, srcLogEng); | 492 | + // Compute effective area for photon |
| 493 | + double srcLogEng = photon.energy().log10TeV(); | ||
| 494 | + double effective_area = aeff(theta_p, phi_p, zenith, azimuth, srcLogEng); | ||
| 500 | 495 | ||
| 501 | - // Compute limiting value | ||
| 502 | - double ulimite = effective_area / area; | 496 | + // Compute limiting value |
| 497 | + double ulimite = effective_area / area; | ||
| 503 | 498 | ||
| 504 | - // Continue only if event is detected | ||
| 505 | - if (ran.uniform() <= ulimite) { | 499 | + // Continue only if event is detected |
| 500 | + if (ran.uniform() <= ulimite) { | ||
| 501 | + | ||
| 502 | + // Apply deadtime correction | ||
| 503 | + double deadc = obs.deadc(photon.time()); | ||
| 504 | + if (deadc >= 1.0 || ran.uniform() <= deadc) { | ||
| 506 | 505 | ||
| 507 | // Simulate offset from photon arrival direction | 506 | // Simulate offset from photon arrival direction |
| 508 | //TODO: Make a proper implementation depending on the response | 507 | //TODO: Make a proper implementation depending on the response |
| @@ -527,9 +526,9 @@ GCTAEventAtom* GCTAResponse::mc(const double& area, const GPhoton& photon, | @@ -527,9 +526,9 @@ GCTAEventAtom* GCTAResponse::mc(const double& area, const GPhoton& photon, | ||
| 527 | event->energy(photon.energy()); | 526 | event->energy(photon.energy()); |
| 528 | event->time(photon.time()); | 527 | event->time(photon.time()); |
| 529 | 528 | ||
| 530 | - } // endif: event was detected | 529 | + } // endif: detector was alive |
| 531 | 530 | ||
| 532 | - } // endif: detector was alive | 531 | + } // endif: event was detected |
| 533 | 532 | ||
| 534 | // Return event | 533 | // Return event |
| 535 | return event; | 534 | return event; |