Commit 8736279cca3682bc75bc2532d394cea50df4dd7a

Authored by Jürgen Knödlseder
1 parent a41c0ea0

Adapt to revised GammaLib interface.

src/ctbin/ctbin.cpp
... ... @@ -470,8 +470,6 @@ void ctbin::get_parameters(void)
470 470 *
471 471 * @exception GException::no_list
472 472 * No event list found in observation.
473   - * @exception GCTAException::no_pointing
474   - * No valid CTA pointing found.
475 473 *
476 474 * This method bins the events found in a CTA events list into a counts map
477 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 569 if (m_usepnt) {
572 570  
573 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 574 // Set reference point to pointing
580 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 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 584 } // endif: used pointing
... ... @@ -601,7 +596,10 @@ void ctbin::bin_events(GCTAObservation* obs)
601 596 // Fill sky map
602 597 GCTAEventList* events =
603 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 604 // Determine sky pixel
607 605 GCTAInstDir* inst = (GCTAInstDir*)&(event->dir());
... ... @@ -653,7 +651,7 @@ void ctbin::bin_events(GCTAObservation* obs)
653 651 GCTAEventCube cube(map, ebds, gti);
654 652  
655 653 // Replace event list by event cube in observation
656   - obs->events(&cube);
  654 + obs->events(cube);
657 655  
658 656 } // endif: observation was valid
659 657  
... ...
src/ctmodel/ctmodel.cpp
... ... @@ -511,7 +511,7 @@ void ctmodel::setup_obs(void)
511 511 obs.deadc(m_deadc);
512 512  
513 513 // Set event cube in observation
514   - obs.events(&cube);
  514 + obs.events(cube);
515 515  
516 516 // Append CTA observation to container
517 517 m_obs.append(obs);
... ... @@ -580,8 +580,9 @@ void ctmodel::setup_obs(void)
580 580 }
581 581  
582 582 // Set response if it isn't set already
583   - if (obs->response() == NULL) {
  583 + if (obs->response().aeff() == NULL) {
584 584 obs->response(m_irf, m_caldb);
  585 +
585 586 } // endif: observation already has a response
586 587  
587 588 } // endif: observation was a CTA observation
... ...
src/ctobssim/ctobssim.cpp
... ... @@ -573,7 +573,7 @@ void ctobssim::set_list(GCTAObservation* obs)
573 573 events.ebounds(ebounds);
574 574  
575 575 // Attach event list to CTA observation
576   - obs->events(&events);
  576 + obs->events(events);
577 577  
578 578 // Set observation ontime, livetime and deadtime correction factor
579 579 obs->ontime(gti.ontime());
... ... @@ -595,9 +595,6 @@ void ctobssim::set_list(GCTAObservation* obs)
595 595 * @param[in] ran Random number generator.
596 596 * @param[in] wrklog Pointer to logger.
597 597 *
598   - * @exception GCTAException::no_response
599   - * No valid response found in CTA observation
600   - *
601 598 * Simulate source events from a photon list for a given CTA observation.
602 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&amp; models,
617 614  
618 615 // Get pointer on CTA response. Throw an exception if the response
619 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 619 // Make sure that the observation holds a CTA event list. If this
626 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&amp; models,
739 733  
740 734 // Simulate event. Note that this method
741 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 740 if (event != NULL) {
747 741  
748 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&amp; filename)
504 504 double ra = m_ra;
505 505 double dec = m_dec;
506 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 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&amp; filename)
620 620 GCTAEventList eventlist;
621 621  
622 622 // Append list to observation
623   - obs->events(&eventlist);
  623 + obs->events(eventlist);
624 624  
625 625 }
626 626 else {
... ...
src/ctskymap/ctskymap.cpp
... ... @@ -397,9 +397,6 @@ void ctskymap::get_parameters(void)
397 397 *
398 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 400 * This method initialises the sky map.
404 401 ***************************************************************************/
405 402 void ctskymap::init_map(GCTAObservation* obs)
... ... @@ -419,19 +416,16 @@ void ctskymap::init_map(GCTAObservation* obs)
419 416  
420 417  
421 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 421 // Set reference point to pointing
428 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 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 431 } // endelse: map centre set to pointing
... ... @@ -482,7 +476,10 @@ void ctskymap::map_events(GCTAObservation* obs)
482 476  
483 477 // Fill sky map
484 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 484 // Skip if energy is out of range
488 485 if (event->energy() < emin || event->energy() > emax) {
... ...