diff --git a/src/ctbin/ctbin.cpp b/src/ctbin/ctbin.cpp index 66def29..1b0c2ca 100644 --- a/src/ctbin/ctbin.cpp +++ b/src/ctbin/ctbin.cpp @@ -470,8 +470,6 @@ void ctbin::get_parameters(void) * * @exception GException::no_list * No event list found in observation. - * @exception GCTAException::no_pointing - * No valid CTA pointing found. * * This method bins the events found in a CTA events list into a counts map * and replaces the event list by the counts map in the observation. The @@ -571,19 +569,16 @@ void ctbin::bin_events(GCTAObservation* obs) if (m_usepnt) { // Get pointer on CTA pointing - const GCTAPointing *pnt = obs->pointing(); - if (pnt == NULL) { - throw GCTAException::no_pointing(G_BIN_EVENTS); - } + const GCTAPointing& pnt = obs->pointing(); // Set reference point to pointing if (gammalib::toupper(m_coordsys) == "GAL") { - xref = pnt->dir().l_deg(); - yref = pnt->dir().b_deg(); + xref = pnt.dir().l_deg(); + yref = pnt.dir().b_deg(); } else { - xref = pnt->dir().ra_deg(); - yref = pnt->dir().dec_deg(); + xref = pnt.dir().ra_deg(); + yref = pnt.dir().dec_deg(); } } // endif: used pointing @@ -601,7 +596,10 @@ void ctbin::bin_events(GCTAObservation* obs) // Fill sky map GCTAEventList* events = static_cast(const_cast(obs->events())); - for (GCTAEventList::iterator event = events->begin(); event != events->end(); ++event) { + for (int i = 0; i < events->size(); ++i) { + + // Get event + GCTAEventAtom* event = (*events)[i]; // Determine sky pixel GCTAInstDir* inst = (GCTAInstDir*)&(event->dir()); @@ -653,7 +651,7 @@ void ctbin::bin_events(GCTAObservation* obs) GCTAEventCube cube(map, ebds, gti); // Replace event list by event cube in observation - obs->events(&cube); + obs->events(cube); } // endif: observation was valid diff --git a/src/ctmodel/ctmodel.cpp b/src/ctmodel/ctmodel.cpp index 51e6f04..ac371f0 100644 --- a/src/ctmodel/ctmodel.cpp +++ b/src/ctmodel/ctmodel.cpp @@ -511,7 +511,7 @@ void ctmodel::setup_obs(void) obs.deadc(m_deadc); // Set event cube in observation - obs.events(&cube); + obs.events(cube); // Append CTA observation to container m_obs.append(obs); @@ -580,8 +580,9 @@ void ctmodel::setup_obs(void) } // Set response if it isn't set already - if (obs->response() == NULL) { + if (obs->response().aeff() == NULL) { obs->response(m_irf, m_caldb); + } // endif: observation already has a response } // endif: observation was a CTA observation diff --git a/src/ctobssim/ctobssim.cpp b/src/ctobssim/ctobssim.cpp index 524ea42..5cfda7d 100644 --- a/src/ctobssim/ctobssim.cpp +++ b/src/ctobssim/ctobssim.cpp @@ -573,7 +573,7 @@ void ctobssim::set_list(GCTAObservation* obs) events.ebounds(ebounds); // Attach event list to CTA observation - obs->events(&events); + obs->events(events); // Set observation ontime, livetime and deadtime correction factor obs->ontime(gti.ontime()); @@ -595,9 +595,6 @@ void ctobssim::set_list(GCTAObservation* obs) * @param[in] ran Random number generator. * @param[in] wrklog Pointer to logger. * - * @exception GCTAException::no_response - * No valid response found in CTA observation - * * Simulate source events from a photon list for a given CTA observation. * The events are stored in as event list in the observation. * @@ -617,10 +614,7 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models, // Get pointer on CTA response. Throw an exception if the response // is not defined. - GCTAResponse* rsp = obs->response(); - if (rsp == NULL) { - throw GCTAException::no_response(G_SIMULATE_SOURCE); - } + const GCTAResponse& rsp = obs->response(); // Make sure that the observation holds a CTA event list. If this // 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, // Simulate event. Note that this method // includes the deadtime correction. - GCTAEventAtom* event = rsp->mc(m_area, - photons[i], - *obs, - ran); + GCTAEventAtom* event = rsp.mc(m_area, + photons[i], + *obs, + ran); if (event != NULL) { // Use event only if it falls within ROI diff --git a/src/ctselect/ctselect.cpp b/src/ctselect/ctselect.cpp index 191cc9e..d5cda62 100644 --- a/src/ctselect/ctselect.cpp +++ b/src/ctselect/ctselect.cpp @@ -504,9 +504,9 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) double ra = m_ra; double dec = m_dec; if (m_usepnt) { - const GCTAPointing *pnt = obs->pointing(); - ra = pnt->dir().ra_deg(); - dec = pnt->dir().dec_deg(); + const GCTAPointing &pnt = obs->pointing(); + ra = pnt.dir().ra_deg(); + dec = pnt.dir().dec_deg(); } // 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) GCTAEventList eventlist; // Append list to observation - obs->events(&eventlist); + obs->events(eventlist); } else { diff --git a/src/ctskymap/ctskymap.cpp b/src/ctskymap/ctskymap.cpp index 68d6b7e..478a82f 100644 --- a/src/ctskymap/ctskymap.cpp +++ b/src/ctskymap/ctskymap.cpp @@ -397,9 +397,6 @@ void ctskymap::get_parameters(void) * * @param[in] obs CTA observation (no NULL pointer allowed). * - * @exception GCTAException::no_pointing - * No valid CTA pointing found. - * * This method initialises the sky map. ***************************************************************************/ void ctskymap::init_map(GCTAObservation* obs) @@ -419,19 +416,16 @@ void ctskymap::init_map(GCTAObservation* obs) // Get pointer on CTA pointing - const GCTAPointing *pnt = obs->pointing(); - if (pnt == NULL) { - throw GCTAException::no_pointing(G_INIT_MAP); - } + const GCTAPointing& pnt = obs->pointing(); // Set reference point to pointing if (gammalib::toupper(m_coordsys) == "GAL") { - xref = pnt->dir().l_deg(); - yref = pnt->dir().b_deg(); + xref = pnt.dir().l_deg(); + yref = pnt.dir().b_deg(); } else { - xref = pnt->dir().ra_deg(); - yref = pnt->dir().dec_deg(); + xref = pnt.dir().ra_deg(); + yref = pnt.dir().dec_deg(); } } // endelse: map centre set to pointing @@ -482,7 +476,10 @@ void ctskymap::map_events(GCTAObservation* obs) // Fill sky map GCTAEventList* events = static_cast(const_cast(obs->events())); - for (GCTAEventList::iterator event = events->begin(); event != events->end(); ++event) { + for (int i = 0; i < events->size(); ++i) { + + // Get event + GCTAEventAtom* event = (*events)[i]; // Skip if energy is out of range if (event->energy() < emin || event->energy() > emax) {