Commit 890b18c26e3c238bc526dc03b88eb845aa4fcf6e

Authored by knodlseder
1 parent f22ea22c

use GApplication::operator[] for parameter access and GObservations::operator[] …

…for observation access
src/ctbin/ctbin.cpp
@@ -197,7 +197,7 @@ void ctbin::execute(void) @@ -197,7 +197,7 @@ void ctbin::execute(void)
197 { 197 {
198 // Read ahead output filename so that it gets dumped correctly in the 198 // Read ahead output filename so that it gets dumped correctly in the
199 // parameters log 199 // parameters log
200 - m_outfile = par("outfile")->value(); 200 + m_outfile = (*this)["outfile"].filename();
201 201
202 // Bin the event data 202 // Bin the event data
203 run(); 203 run();
@@ -251,7 +251,7 @@ void ctbin::run(void) @@ -251,7 +251,7 @@ void ctbin::run(void)
251 for (int i = 0; i < m_obs.size(); ++i) { 251 for (int i = 0; i < m_obs.size(); ++i) {
252 252
253 // Get CTA observation 253 // Get CTA observation
254 - GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs(i)); 254 + GCTAObservation* obs = dynamic_cast<GCTAObservation*>(&m_obs[i]);
255 255
256 // Continue only if observation is a CTA observation 256 // Continue only if observation is a CTA observation
257 if (obs != NULL) { 257 if (obs != NULL) {
@@ -303,14 +303,14 @@ void ctbin::save(void) @@ -303,14 +303,14 @@ void ctbin::save(void)
303 } 303 }
304 304
305 // Get output filename 305 // Get output filename
306 - m_outfile = par("outfile")->value(); 306 + m_outfile = (*this)["outfile"].filename();
307 307
308 // Loop over all observations in the container 308 // Loop over all observations in the container
309 int file_num = 0; 309 int file_num = 0;
310 for (int i = 0; i < m_obs.size(); ++i) { 310 for (int i = 0; i < m_obs.size(); ++i) {
311 311
312 // Get CTA observation 312 // Get CTA observation
313 - GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs(i)); 313 + GCTAObservation* obs = dynamic_cast<GCTAObservation*>(&m_obs[i]);
314 314
315 // Save only if observation is a CTA observation 315 // Save only if observation is a CTA observation
316 if (obs != NULL) { 316 if (obs != NULL) {
@@ -349,7 +349,7 @@ void ctbin::get_parameters(void) @@ -349,7 +349,7 @@ void ctbin::get_parameters(void)
349 if (m_obs.size() == 0) { 349 if (m_obs.size() == 0) {
350 350
351 // Get name of CTA events file 351 // Get name of CTA events file
352 - m_evfile = par("evfile")->value(); 352 + m_evfile = (*this)["evfile"].filename();
353 353
354 // Load unbinned CTA observation 354 // Load unbinned CTA observation
355 GCTAObservation obs; 355 GCTAObservation obs;
@@ -361,16 +361,16 @@ void ctbin::get_parameters(void) @@ -361,16 +361,16 @@ void ctbin::get_parameters(void)
361 } // endif: there was no observation in the container 361 } // endif: there was no observation in the container
362 362
363 // Get remaining parameters 363 // Get remaining parameters
364 - m_emin = par("emin")->real();  
365 - m_emax = par("emax")->real();  
366 - m_enumbins = par("enumbins")->integer();  
367 - m_proj = par("proj")->value();  
368 - m_coordsys = par("coordsys")->value();  
369 - m_xref = par("xref")->real();  
370 - m_yref = par("yref")->real();  
371 - m_binsz = par("binsz")->real();  
372 - m_nxpix = par("nxpix")->integer();  
373 - m_nypix = par("nypix")->integer(); 364 + m_emin = (*this)["emin"].real();
  365 + m_emax = (*this)["emax"].real();
  366 + m_enumbins = (*this)["enumbins"].integer();
  367 + m_proj = (*this)["proj"].string();
  368 + m_coordsys = (*this)["coordsys"].string();
  369 + m_xref = (*this)["xref"].real();
  370 + m_yref = (*this)["yref"].real();
  371 + m_binsz = (*this)["binsz"].real();
  372 + m_nxpix = (*this)["nxpix"].integer();
  373 + m_nypix = (*this)["nypix"].integer();
374 374
375 // Return 375 // Return
376 return; 376 return;
src/ctlike/ctlike.cpp
@@ -196,7 +196,7 @@ void ctlike::execute(void) @@ -196,7 +196,7 @@ void ctlike::execute(void)
196 { 196 {
197 // Read ahead output filename so that it gets dumped correctly in the 197 // Read ahead output filename so that it gets dumped correctly in the
198 // parameters log 198 // parameters log
199 - m_outmdl = par("outmdl")->value(); 199 + m_outmdl = (*this)["outmdl"].filename();
200 200
201 // Bin the event data 201 // Bin the event data
202 run(); 202 run();
@@ -272,7 +272,7 @@ void ctlike::save(void) @@ -272,7 +272,7 @@ void ctlike::save(void)
272 } 272 }
273 273
274 // Get output filename 274 // Get output filename
275 - m_outmdl = par("outmdl")->value(); 275 + m_outmdl = (*this)["outmdl"].value();
276 276
277 // Write results out as XML model 277 // Write results out as XML model
278 if (toupper(m_outmdl) != "NONE") 278 if (toupper(m_outmdl) != "NONE")
@@ -309,7 +309,7 @@ void ctlike::get_parameters(void) @@ -309,7 +309,7 @@ void ctlike::get_parameters(void)
309 if (m_obs.models().size() == 0) { 309 if (m_obs.models().size() == 0) {
310 310
311 // Get models XML filename 311 // Get models XML filename
312 - std::string filename = par("srcmdl")->value(); 312 + std::string filename = (*this)["srcmdl"].filename();
313 313
314 // Setup models for optimizing. 314 // Setup models for optimizing.
315 m_obs.models(GModels(filename)); 315 m_obs.models(GModels(filename));
@@ -321,16 +321,16 @@ void ctlike::get_parameters(void) @@ -321,16 +321,16 @@ void ctlike::get_parameters(void)
321 if (m_obs.size() == 0) { 321 if (m_obs.size() == 0) {
322 322
323 // Get observation parameters 323 // Get observation parameters
324 - m_method = toupper(par("method")->value());  
325 - m_stat = toupper(par("stat")->value());  
326 - m_caldb = par("caldb")->value();  
327 - m_irf = par("irf")->value(); 324 + m_method = toupper((*this)["method"].string());
  325 + m_stat = toupper((*this)["stat"].string());
  326 + m_caldb = (*this)["caldb"].string();
  327 + m_irf = (*this)["irf"].string();
328 328
329 // Case A: set-up unbinned CTA observation 329 // Case A: set-up unbinned CTA observation
330 if (m_method == "UNBINNED") { 330 if (m_method == "UNBINNED") {
331 331
332 // Get event file name 332 // Get event file name
333 - std::string filename = par("evfile")->value(); 333 + std::string filename = (*this)["evfile"].filename();
334 334
335 // Load and append unbinned CTA observation 335 // Load and append unbinned CTA observation
336 load_unbinned(filename); 336 load_unbinned(filename);
@@ -341,7 +341,7 @@ void ctlike::get_parameters(void) @@ -341,7 +341,7 @@ void ctlike::get_parameters(void)
341 else if (m_method == "BINNED") { 341 else if (m_method == "BINNED") {
342 342
343 // Get counts map file name 343 // Get counts map file name
344 - std::string filename = par("cntmap")->value(); 344 + std::string filename = (*this)["cntmap"].filename();
345 345
346 // Load and append binned CTA observation 346 // Load and append binned CTA observation
347 load_binned(filename); 347 load_binned(filename);
@@ -357,7 +357,7 @@ void ctlike::get_parameters(void) @@ -357,7 +357,7 @@ void ctlike::get_parameters(void)
357 } // endif: there was no observation in the container 357 } // endif: there was no observation in the container
358 358
359 // Get standard parameters 359 // Get standard parameters
360 - m_refit = par("refit")->boolean(); 360 + m_refit = (*this)["refit"].boolean();
361 361
362 // Return 362 // Return
363 return; 363 return;
src/ctobssim/ctobssim.cpp
@@ -196,7 +196,7 @@ void ctobssim::execute(void) @@ -196,7 +196,7 @@ void ctobssim::execute(void)
196 { 196 {
197 // Read ahead output filename so that it gets dumped correctly in the 197 // Read ahead output filename so that it gets dumped correctly in the
198 // parameters log 198 // parameters log
199 - m_outfile = par("outfile")->value(); 199 + m_outfile = (*this)["outfile"].filename();
200 200
201 // Run the simulation 201 // Run the simulation
202 run(); 202 run();
@@ -253,7 +253,7 @@ void ctobssim::run(void) @@ -253,7 +253,7 @@ void ctobssim::run(void)
253 for (int i = 0; i < m_obs.size(); ++i) { 253 for (int i = 0; i < m_obs.size(); ++i) {
254 254
255 // Get CTA observation 255 // Get CTA observation
256 - GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs(i)); 256 + GCTAObservation* obs = dynamic_cast<GCTAObservation*>(&m_obs[i]);
257 257
258 // Continue only if observation is a CTA observation 258 // Continue only if observation is a CTA observation
259 if (obs != NULL) { 259 if (obs != NULL) {
@@ -313,14 +313,14 @@ void ctobssim::save(void) @@ -313,14 +313,14 @@ void ctobssim::save(void)
313 } 313 }
314 314
315 // Get output filename 315 // Get output filename
316 - m_outfile = par("outfile")->value(); 316 + m_outfile = (*this)["outfile"].filename();
317 317
318 // Loop over all observation in the container 318 // Loop over all observation in the container
319 int file_num = 0; 319 int file_num = 0;
320 for (int i = 0; i < m_obs.size(); ++i) { 320 for (int i = 0; i < m_obs.size(); ++i) {
321 321
322 // Get CTA observation 322 // Get CTA observation
323 - GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs(i)); 323 + GCTAObservation* obs = dynamic_cast<GCTAObservation*>(&m_obs[i]);
324 324
325 // Save only if observation is a CTA observation 325 // Save only if observation is a CTA observation
326 if (obs != NULL) { 326 if (obs != NULL) {
@@ -359,11 +359,11 @@ void ctobssim::get_parameters(void) @@ -359,11 +359,11 @@ void ctobssim::get_parameters(void)
359 if (m_obs.size() == 0) { 359 if (m_obs.size() == 0) {
360 360
361 // Get CTA observation parameters 361 // Get CTA observation parameters
362 - m_infile = par("infile")->value();  
363 - m_caldb = par("caldb")->value();  
364 - m_irf = par("irf")->value();  
365 - m_ra = par("ra")->real();  
366 - m_dec = par("dec")->real(); 362 + m_infile = (*this)["infile"].filename();
  363 + m_caldb = (*this)["caldb"].string();
  364 + m_irf = (*this)["irf"].string();
  365 + m_ra = (*this)["ra"].real();
  366 + m_dec = (*this)["dec"].real();
367 367
368 // Set pointing direction 368 // Set pointing direction
369 GCTAPointing pnt; 369 GCTAPointing pnt;
@@ -390,7 +390,7 @@ void ctobssim::get_parameters(void) @@ -390,7 +390,7 @@ void ctobssim::get_parameters(void)
390 } // endif: there was no observation in the container 390 } // endif: there was no observation in the container
391 391
392 // Get other parameters 392 // Get other parameters
393 - m_seed = par("seed")->integer(); 393 + m_seed = (*this)["seed"].integer();
394 394
395 // Initialise random number generator 395 // Initialise random number generator
396 m_ran.seed(m_seed); 396 m_ran.seed(m_seed);
@@ -411,13 +411,13 @@ void ctobssim::set_list(GCTAObservation* obs) @@ -411,13 +411,13 @@ void ctobssim::set_list(GCTAObservation* obs)
411 if (obs != NULL) { 411 if (obs != NULL) {
412 412
413 // Get CTA observation parameters 413 // Get CTA observation parameters
414 - m_ra = par("ra")->real();  
415 - m_dec = par("dec")->real();  
416 - m_rad = par("rad")->real();  
417 - m_tmin = par("tmin")->real();  
418 - m_tmax = par("tmax")->real();  
419 - m_emin = par("emin")->real();  
420 - m_emax = par("emax")->real(); 414 + m_ra = (*this)["ra"].real();
  415 + m_dec = (*this)["dec"].real();
  416 + m_rad = (*this)["rad"].real();
  417 + m_tmin = (*this)["tmin"].real();
  418 + m_tmax = (*this)["tmax"].real();
  419 + m_emin = (*this)["emin"].real();
  420 + m_emax = (*this)["emax"].real();
421 421
422 // Allocate CTA event list 422 // Allocate CTA event list
423 GCTAEventList events; 423 GCTAEventList events;
@@ -547,7 +547,7 @@ GPhotons ctobssim::simulate_photons(const GCTAObservation* obs, @@ -547,7 +547,7 @@ GPhotons ctobssim::simulate_photons(const GCTAObservation* obs,
547 for (int i = 0; i < models.size(); ++i) { 547 for (int i = 0; i < models.size(); ++i) {
548 548
549 // Get sky model (NULL if not a sky model) 549 // Get sky model (NULL if not a sky model)
550 - const GModelSky* model = dynamic_cast<const GModelSky*>(models(i)); 550 + const GModelSky* model = dynamic_cast<const GModelSky*>(&models[i]);
551 551
552 // If we have a sky model then simulate photons 552 // If we have a sky model then simulate photons
553 if (model != NULL) { 553 if (model != NULL) {
@@ -688,7 +688,7 @@ void ctobssim::simulate_background(GCTAObservation* obs, const GModels&amp; models) @@ -688,7 +688,7 @@ void ctobssim::simulate_background(GCTAObservation* obs, const GModels&amp; models)
688 688
689 // Get model (NULL if not a radial acceptance model) 689 // Get model (NULL if not a radial acceptance model)
690 const GCTAModelRadialAcceptance* model = 690 const GCTAModelRadialAcceptance* model =
691 - dynamic_cast<const GCTAModelRadialAcceptance*>(models(i)); 691 + dynamic_cast<const GCTAModelRadialAcceptance*>(&models[i]);
692 692
693 // If we have a radial acceptance model then simulate events 693 // If we have a radial acceptance model then simulate events
694 if (model != NULL) { 694 if (model != NULL) {
src/ctselect/ctselect.cpp
@@ -194,7 +194,7 @@ void ctselect::execute(void) @@ -194,7 +194,7 @@ void ctselect::execute(void)
194 { 194 {
195 // Read ahead output filename so that it gets dumped correctly in the 195 // Read ahead output filename so that it gets dumped correctly in the
196 // parameters log 196 // parameters log
197 - m_outfile = par("outfile")->value(); 197 + m_outfile = (*this)["outfile"].value();
198 198
199 // Perform event selection 199 // Perform event selection
200 run(); 200 run();
@@ -250,7 +250,7 @@ void ctselect::run(void) @@ -250,7 +250,7 @@ void ctselect::run(void)
250 for (int i = 0; i < m_obs.size(); ++i) { 250 for (int i = 0; i < m_obs.size(); ++i) {
251 251
252 // Get CTA observation 252 // Get CTA observation
253 - GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs(i)); 253 + GCTAObservation* obs = dynamic_cast<GCTAObservation*>(&m_obs[i]);
254 254
255 // Continue only if observation is a CTA observation 255 // Continue only if observation is a CTA observation
256 if (obs != NULL) { 256 if (obs != NULL) {
@@ -305,13 +305,13 @@ void ctselect::save(void) @@ -305,13 +305,13 @@ void ctselect::save(void)
305 } 305 }
306 306
307 // Get output filename 307 // Get output filename
308 - m_outfile = par("outfile")->value(); 308 + m_outfile = (*this)["outfile"].value();
309 309
310 // Loop over all observation in the container 310 // Loop over all observation in the container
311 for (int i = 0; i < m_obs.size(); ++i) { 311 for (int i = 0; i < m_obs.size(); ++i) {
312 312
313 // Get CTA observation 313 // Get CTA observation
314 - GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs(i)); 314 + GCTAObservation* obs = dynamic_cast<GCTAObservation*>(&m_obs[i]);
315 315
316 // Save only if observation is a CTA observation 316 // Save only if observation is a CTA observation
317 if (obs != NULL) { 317 if (obs != NULL) {
@@ -341,7 +341,7 @@ void ctselect::get_parameters(void) @@ -341,7 +341,7 @@ void ctselect::get_parameters(void)
341 if (m_obs.size() == 0) { 341 if (m_obs.size() == 0) {
342 342
343 // Get CTA event list file name 343 // Get CTA event list file name
344 - m_infile = par("infile")->value(); 344 + m_infile = (*this)["infile"].value();
345 345
346 // Allocate CTA observation 346 // Allocate CTA observation
347 GCTAObservation obs; 347 GCTAObservation obs;
@@ -355,13 +355,13 @@ void ctselect::get_parameters(void) @@ -355,13 +355,13 @@ void ctselect::get_parameters(void)
355 } // endif: there was no observation in the container 355 } // endif: there was no observation in the container
356 356
357 // Get parameters 357 // Get parameters
358 - m_ra = par("ra")->real();  
359 - m_dec = par("dec")->real();  
360 - m_rad = par("rad")->real();  
361 - m_tmin = par("tmin")->real();  
362 - m_tmax = par("tmax")->real();  
363 - m_emin = par("emin")->real();  
364 - m_emax = par("emax")->real(); 358 + m_ra = (*this)["ra"].real();
  359 + m_dec = (*this)["dec"].real();
  360 + m_rad = (*this)["rad"].real();
  361 + m_tmin = (*this)["tmin"].real();
  362 + m_tmax = (*this)["tmax"].real();
  363 + m_emin = (*this)["emin"].real();
  364 + m_emax = (*this)["emax"].real();
365 365
366 // Return 366 // Return
367 return; 367 return;