Commit 1314bbfacbb61c1fcd7360df473ad45e511a87b3
1 parent
ec890686
Add deadtime correction to GResponse::irf and GResponse::npred methods
Showing
1 changed file
with
41 additions
and
8 deletions
src/obs/GResponse.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GResponse.cpp - Response abstract base class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -18,6 +18,11 @@ |
| 18 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. * |
| 19 | 19 | * * |
| 20 | 20 | ***************************************************************************/ |
| 21 | +/** | |
| 22 | + * @file GResponse.hpp | |
| 23 | + * @brief Abstract response base class interface definition | |
| 24 | + * @author J. Knoedlseder | |
| 25 | + */ | |
| 21 | 26 | |
| 22 | 27 | /* __ Includes ___________________________________________________________ */ |
| 23 | 28 | #ifdef HAVE_CONFIG_H |
| ... | ... | @@ -148,6 +153,14 @@ GResponse& GResponse::operator= (const GResponse& rsp) |
| 148 | 153 | * @param[in] srcTime True photon arrival time. |
| 149 | 154 | * @param[in] obs Observation. |
| 150 | 155 | * |
| 156 | + * Returns the instrument response function for a given event, given a sky | |
| 157 | + * model, the incident photon energy, the photon arrival time, and an | |
| 158 | + * observation. | |
| 159 | + * | |
| 160 | + * Note that this method applies the deadtime correction, so that the | |
| 161 | + * response function can be directly multiplied by the exposure time (also | |
| 162 | + * known as ontime). | |
| 163 | + * | |
| 151 | 164 | * @todo Throw exception if model pointer is invalid. |
| 152 | 165 | ***************************************************************************/ |
| 153 | 166 | double GResponse::irf(const GEvent& event, |
| ... | ... | @@ -165,15 +178,21 @@ double GResponse::irf(const GEvent& event, |
| 165 | 178 | const GModelDiffuseSource* difsrc = dynamic_cast<const GModelDiffuseSource*>(&model); |
| 166 | 179 | |
| 167 | 180 | // Call model dependent method |
| 168 | - if (ptsrc != NULL) | |
| 181 | + if (ptsrc != NULL) { | |
| 169 | 182 | irf = irf_ptsrc(event.dir(), event.energy(), event.time(), |
| 170 | 183 | *ptsrc, srcEng, srcTime, obs); |
| 171 | - else if (extsrc != NULL) | |
| 184 | + } | |
| 185 | + else if (extsrc != NULL) { | |
| 172 | 186 | irf = irf_extended(event.dir(), event.energy(), event.time(), |
| 173 | 187 | *extsrc, srcEng, srcTime, obs); |
| 174 | - else if (difsrc != NULL) | |
| 188 | + } | |
| 189 | + else if (difsrc != NULL) { | |
| 175 | 190 | irf = irf_diffuse(event.dir(), event.energy(), event.time(), |
| 176 | 191 | *difsrc, srcEng, srcTime, obs); |
| 192 | + } | |
| 193 | + | |
| 194 | + // Apply deadtime correction | |
| 195 | + irf *= obs.deadc(srcTime); | |
| 177 | 196 | |
| 178 | 197 | // Return IRF value |
| 179 | 198 | return irf; |
| ... | ... | @@ -278,6 +297,14 @@ double GResponse::irf_diffuse(const GInstDir& obsDir, |
| 278 | 297 | * @param[in] srcTime True photon arrival time. |
| 279 | 298 | * @param[in] obs Observation. |
| 280 | 299 | * |
| 300 | + * Returns the data space integral of the instrument response function for | |
| 301 | + * a given sky model, given the incident photon energy, the photon arrival | |
| 302 | + * time, and an observations. | |
| 303 | + * | |
| 304 | + * Note that this method applies the deadtime correction, so that the | |
| 305 | + * result can be directly multiplied by the exposure time (also known as | |
| 306 | + * ontime). | |
| 307 | + * | |
| 281 | 308 | * @todo Throw exception if model pointer is invalid. |
| 282 | 309 | ***************************************************************************/ |
| 283 | 310 | double GResponse::npred(const GModelSky& model, |
| ... | ... | @@ -294,12 +321,18 @@ double GResponse::npred(const GModelSky& model, |
| 294 | 321 | const GModelDiffuseSource* difsrc = dynamic_cast<const GModelDiffuseSource*>(&model); |
| 295 | 322 | |
| 296 | 323 | // Call model dependent method |
| 297 | - if (ptsrc != NULL) | |
| 324 | + if (ptsrc != NULL) { | |
| 298 | 325 | npred = npred_ptsrc(*ptsrc, srcEng, srcTime, obs); |
| 299 | - else if (extsrc != NULL) | |
| 326 | + } | |
| 327 | + else if (extsrc != NULL) { | |
| 300 | 328 | npred = npred_extended(*extsrc, srcEng, srcTime, obs); |
| 301 | - else if (difsrc != NULL) | |
| 329 | + } | |
| 330 | + else if (difsrc != NULL) { | |
| 302 | 331 | npred = npred_diffuse(*difsrc, srcEng, srcTime, obs); |
| 332 | + } | |
| 333 | + | |
| 334 | + // Apply deadtime correction | |
| 335 | + npred *= obs.deadc(srcTime); | |
| 303 | 336 | |
| 304 | 337 | // Return response value |
| 305 | 338 | return npred; |
| ... | ... | @@ -376,7 +409,7 @@ double GResponse::npred_extended(const GModelExtendedSource& model, |
| 376 | 409 | |
| 377 | 410 | // Compile option: Show integration results |
| 378 | 411 | #if defined(G_DEBUG_NPRED_EXTENDED) |
| 379 | - std::cout << "npred_extended:"; | |
| 412 | + std::cout << "GResponse::npred_extended:"; | |
| 380 | 413 | std::cout << " theta_min=" << theta_min; |
| 381 | 414 | std::cout << " theta_max=" << theta_max; |
| 382 | 415 | std::cout << " npred=" << npred << std::endl; | ... | ... |