Commit 8736279cca3682bc75bc2532d394cea50df4dd7a
1 parent
a41c0ea0
Adapt to revised GammaLib interface.
Showing
5 changed files
with
32 additions
and
42 deletions
src/ctbin/ctbin.cpp
| @@ -470,8 +470,6 @@ void ctbin::get_parameters(void) | @@ -470,8 +470,6 @@ void ctbin::get_parameters(void) | ||
| 470 | * | 470 | * |
| 471 | * @exception GException::no_list | 471 | * @exception GException::no_list |
| 472 | * No event list found in observation. | 472 | * No event list found in observation. |
| 473 | - * @exception GCTAException::no_pointing | ||
| 474 | - * No valid CTA pointing found. | ||
| 475 | * | 473 | * |
| 476 | * This method bins the events found in a CTA events list into a counts map | 474 | * This method bins the events found in a CTA events list into a counts map |
| 477 | * and replaces the event list by the counts map in the observation. The | 475 | * and replaces the event list by the counts map in the observation. The |
| @@ -571,19 +569,16 @@ void ctbin::bin_events(GCTAObservation* obs) | @@ -571,19 +569,16 @@ void ctbin::bin_events(GCTAObservation* obs) | ||
| 571 | if (m_usepnt) { | 569 | if (m_usepnt) { |
| 572 | 570 | ||
| 573 | // Get pointer on CTA pointing | 571 | // Get pointer on CTA pointing |
| 574 | - const GCTAPointing *pnt = obs->pointing(); | ||
| 575 | - if (pnt == NULL) { | ||
| 576 | - throw GCTAException::no_pointing(G_BIN_EVENTS); | ||
| 577 | - } | 572 | + const GCTAPointing& pnt = obs->pointing(); |
| 578 | 573 | ||
| 579 | // Set reference point to pointing | 574 | // Set reference point to pointing |
| 580 | if (gammalib::toupper(m_coordsys) == "GAL") { | 575 | if (gammalib::toupper(m_coordsys) == "GAL") { |
| 581 | - xref = pnt->dir().l_deg(); | ||
| 582 | - yref = pnt->dir().b_deg(); | 576 | + xref = pnt.dir().l_deg(); |
| 577 | + yref = pnt.dir().b_deg(); | ||
| 583 | } | 578 | } |
| 584 | else { | 579 | else { |
| 585 | - xref = pnt->dir().ra_deg(); | ||
| 586 | - yref = pnt->dir().dec_deg(); | 580 | + xref = pnt.dir().ra_deg(); |
| 581 | + yref = pnt.dir().dec_deg(); | ||
| 587 | } | 582 | } |
| 588 | 583 | ||
| 589 | } // endif: used pointing | 584 | } // endif: used pointing |
| @@ -601,7 +596,10 @@ void ctbin::bin_events(GCTAObservation* obs) | @@ -601,7 +596,10 @@ void ctbin::bin_events(GCTAObservation* obs) | ||
| 601 | // Fill sky map | 596 | // Fill sky map |
| 602 | GCTAEventList* events = | 597 | GCTAEventList* events = |
| 603 | static_cast<GCTAEventList*>(const_cast<GEvents*>(obs->events())); | 598 | static_cast<GCTAEventList*>(const_cast<GEvents*>(obs->events())); |
| 604 | - for (GCTAEventList::iterator event = events->begin(); event != events->end(); ++event) { | 599 | + for (int i = 0; i < events->size(); ++i) { |
| 600 | + | ||
| 601 | + // Get event | ||
| 602 | + GCTAEventAtom* event = (*events)[i]; | ||
| 605 | 603 | ||
| 606 | // Determine sky pixel | 604 | // Determine sky pixel |
| 607 | GCTAInstDir* inst = (GCTAInstDir*)&(event->dir()); | 605 | GCTAInstDir* inst = (GCTAInstDir*)&(event->dir()); |
| @@ -653,7 +651,7 @@ void ctbin::bin_events(GCTAObservation* obs) | @@ -653,7 +651,7 @@ void ctbin::bin_events(GCTAObservation* obs) | ||
| 653 | GCTAEventCube cube(map, ebds, gti); | 651 | GCTAEventCube cube(map, ebds, gti); |
| 654 | 652 | ||
| 655 | // Replace event list by event cube in observation | 653 | // Replace event list by event cube in observation |
| 656 | - obs->events(&cube); | 654 | + obs->events(cube); |
| 657 | 655 | ||
| 658 | } // endif: observation was valid | 656 | } // endif: observation was valid |
| 659 | 657 |
src/ctmodel/ctmodel.cpp
| @@ -511,7 +511,7 @@ void ctmodel::setup_obs(void) | @@ -511,7 +511,7 @@ void ctmodel::setup_obs(void) | ||
| 511 | obs.deadc(m_deadc); | 511 | obs.deadc(m_deadc); |
| 512 | 512 | ||
| 513 | // Set event cube in observation | 513 | // Set event cube in observation |
| 514 | - obs.events(&cube); | 514 | + obs.events(cube); |
| 515 | 515 | ||
| 516 | // Append CTA observation to container | 516 | // Append CTA observation to container |
| 517 | m_obs.append(obs); | 517 | m_obs.append(obs); |
| @@ -580,8 +580,9 @@ void ctmodel::setup_obs(void) | @@ -580,8 +580,9 @@ void ctmodel::setup_obs(void) | ||
| 580 | } | 580 | } |
| 581 | 581 | ||
| 582 | // Set response if it isn't set already | 582 | // Set response if it isn't set already |
| 583 | - if (obs->response() == NULL) { | 583 | + if (obs->response().aeff() == NULL) { |
| 584 | obs->response(m_irf, m_caldb); | 584 | obs->response(m_irf, m_caldb); |
| 585 | + | ||
| 585 | } // endif: observation already has a response | 586 | } // endif: observation already has a response |
| 586 | 587 | ||
| 587 | } // endif: observation was a CTA observation | 588 | } // endif: observation was a CTA observation |
src/ctobssim/ctobssim.cpp
| @@ -573,7 +573,7 @@ void ctobssim::set_list(GCTAObservation* obs) | @@ -573,7 +573,7 @@ void ctobssim::set_list(GCTAObservation* obs) | ||
| 573 | events.ebounds(ebounds); | 573 | events.ebounds(ebounds); |
| 574 | 574 | ||
| 575 | // Attach event list to CTA observation | 575 | // Attach event list to CTA observation |
| 576 | - obs->events(&events); | 576 | + obs->events(events); |
| 577 | 577 | ||
| 578 | // Set observation ontime, livetime and deadtime correction factor | 578 | // Set observation ontime, livetime and deadtime correction factor |
| 579 | obs->ontime(gti.ontime()); | 579 | obs->ontime(gti.ontime()); |
| @@ -595,9 +595,6 @@ void ctobssim::set_list(GCTAObservation* obs) | @@ -595,9 +595,6 @@ void ctobssim::set_list(GCTAObservation* obs) | ||
| 595 | * @param[in] ran Random number generator. | 595 | * @param[in] ran Random number generator. |
| 596 | * @param[in] wrklog Pointer to logger. | 596 | * @param[in] wrklog Pointer to logger. |
| 597 | * | 597 | * |
| 598 | - * @exception GCTAException::no_response | ||
| 599 | - * No valid response found in CTA observation | ||
| 600 | - * | ||
| 601 | * Simulate source events from a photon list for a given CTA observation. | 598 | * Simulate source events from a photon list for a given CTA observation. |
| 602 | * The events are stored in as event list in the observation. | 599 | * The events are stored in as event list in the observation. |
| 603 | * | 600 | * |
| @@ -617,10 +614,7 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models, | @@ -617,10 +614,7 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models, | ||
| 617 | 614 | ||
| 618 | // Get pointer on CTA response. Throw an exception if the response | 615 | // Get pointer on CTA response. Throw an exception if the response |
| 619 | // is not defined. | 616 | // is not defined. |
| 620 | - GCTAResponse* rsp = obs->response(); | ||
| 621 | - if (rsp == NULL) { | ||
| 622 | - throw GCTAException::no_response(G_SIMULATE_SOURCE); | ||
| 623 | - } | 617 | + const GCTAResponse& rsp = obs->response(); |
| 624 | 618 | ||
| 625 | // Make sure that the observation holds a CTA event list. If this | 619 | // Make sure that the observation holds a CTA event list. If this |
| 626 | // is not the case then allocate and attach a CTA event list now. | 620 | // is not the case then allocate and attach a CTA event list now. |
| @@ -739,10 +733,10 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models, | @@ -739,10 +733,10 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models, | ||
| 739 | 733 | ||
| 740 | // Simulate event. Note that this method | 734 | // Simulate event. Note that this method |
| 741 | // includes the deadtime correction. | 735 | // includes the deadtime correction. |
| 742 | - GCTAEventAtom* event = rsp->mc(m_area, | ||
| 743 | - photons[i], | ||
| 744 | - *obs, | ||
| 745 | - ran); | 736 | + GCTAEventAtom* event = rsp.mc(m_area, |
| 737 | + photons[i], | ||
| 738 | + *obs, | ||
| 739 | + ran); | ||
| 746 | if (event != NULL) { | 740 | if (event != NULL) { |
| 747 | 741 | ||
| 748 | // Use event only if it falls within ROI | 742 | // Use event only if it falls within ROI |
src/ctselect/ctselect.cpp
| @@ -504,9 +504,9 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) | @@ -504,9 +504,9 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) | ||
| 504 | double ra = m_ra; | 504 | double ra = m_ra; |
| 505 | double dec = m_dec; | 505 | double dec = m_dec; |
| 506 | if (m_usepnt) { | 506 | if (m_usepnt) { |
| 507 | - const GCTAPointing *pnt = obs->pointing(); | ||
| 508 | - ra = pnt->dir().ra_deg(); | ||
| 509 | - dec = pnt->dir().dec_deg(); | 507 | + const GCTAPointing &pnt = obs->pointing(); |
| 508 | + ra = pnt.dir().ra_deg(); | ||
| 509 | + dec = pnt.dir().dec_deg(); | ||
| 510 | } | 510 | } |
| 511 | 511 | ||
| 512 | // Set time selection interval. We make sure here that the time selection | 512 | // Set time selection interval. We make sure here that the time selection |
| @@ -620,7 +620,7 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) | @@ -620,7 +620,7 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) | ||
| 620 | GCTAEventList eventlist; | 620 | GCTAEventList eventlist; |
| 621 | 621 | ||
| 622 | // Append list to observation | 622 | // Append list to observation |
| 623 | - obs->events(&eventlist); | 623 | + obs->events(eventlist); |
| 624 | 624 | ||
| 625 | } | 625 | } |
| 626 | else { | 626 | else { |
src/ctskymap/ctskymap.cpp
| @@ -397,9 +397,6 @@ void ctskymap::get_parameters(void) | @@ -397,9 +397,6 @@ void ctskymap::get_parameters(void) | ||
| 397 | * | 397 | * |
| 398 | * @param[in] obs CTA observation (no NULL pointer allowed). | 398 | * @param[in] obs CTA observation (no NULL pointer allowed). |
| 399 | * | 399 | * |
| 400 | - * @exception GCTAException::no_pointing | ||
| 401 | - * No valid CTA pointing found. | ||
| 402 | - * | ||
| 403 | * This method initialises the sky map. | 400 | * This method initialises the sky map. |
| 404 | ***************************************************************************/ | 401 | ***************************************************************************/ |
| 405 | void ctskymap::init_map(GCTAObservation* obs) | 402 | void ctskymap::init_map(GCTAObservation* obs) |
| @@ -419,19 +416,16 @@ void ctskymap::init_map(GCTAObservation* obs) | @@ -419,19 +416,16 @@ void ctskymap::init_map(GCTAObservation* obs) | ||
| 419 | 416 | ||
| 420 | 417 | ||
| 421 | // Get pointer on CTA pointing | 418 | // Get pointer on CTA pointing |
| 422 | - const GCTAPointing *pnt = obs->pointing(); | ||
| 423 | - if (pnt == NULL) { | ||
| 424 | - throw GCTAException::no_pointing(G_INIT_MAP); | ||
| 425 | - } | 419 | + const GCTAPointing& pnt = obs->pointing(); |
| 426 | 420 | ||
| 427 | // Set reference point to pointing | 421 | // Set reference point to pointing |
| 428 | if (gammalib::toupper(m_coordsys) == "GAL") { | 422 | if (gammalib::toupper(m_coordsys) == "GAL") { |
| 429 | - xref = pnt->dir().l_deg(); | ||
| 430 | - yref = pnt->dir().b_deg(); | 423 | + xref = pnt.dir().l_deg(); |
| 424 | + yref = pnt.dir().b_deg(); | ||
| 431 | } | 425 | } |
| 432 | else { | 426 | else { |
| 433 | - xref = pnt->dir().ra_deg(); | ||
| 434 | - yref = pnt->dir().dec_deg(); | 427 | + xref = pnt.dir().ra_deg(); |
| 428 | + yref = pnt.dir().dec_deg(); | ||
| 435 | } | 429 | } |
| 436 | 430 | ||
| 437 | } // endelse: map centre set to pointing | 431 | } // endelse: map centre set to pointing |
| @@ -482,7 +476,10 @@ void ctskymap::map_events(GCTAObservation* obs) | @@ -482,7 +476,10 @@ void ctskymap::map_events(GCTAObservation* obs) | ||
| 482 | 476 | ||
| 483 | // Fill sky map | 477 | // Fill sky map |
| 484 | GCTAEventList* events = static_cast<GCTAEventList*>(const_cast<GEvents*>(obs->events())); | 478 | GCTAEventList* events = static_cast<GCTAEventList*>(const_cast<GEvents*>(obs->events())); |
| 485 | - for (GCTAEventList::iterator event = events->begin(); event != events->end(); ++event) { | 479 | + for (int i = 0; i < events->size(); ++i) { |
| 480 | + | ||
| 481 | + // Get event | ||
| 482 | + GCTAEventAtom* event = (*events)[i]; | ||
| 486 | 483 | ||
| 487 | // Skip if energy is out of range | 484 | // Skip if energy is out of range |
| 488 | if (event->energy() < emin || event->energy() > emax) { | 485 | if (event->energy() < emin || event->energy() > emax) { |