Commit 06349ac90a0139c2e178ec4c5021e461a3cc394b

Authored by Jürgen Knödlseder
1 parent da52c893

Use gammalib namespace for GammaLib functions.

src/ctbin/ctbin.cpp
@@ -503,7 +503,7 @@ void ctbin::bin_events(GCTAObservation* obs) @@ -503,7 +503,7 @@ void ctbin::bin_events(GCTAObservation* obs)
503 } 503 }
504 504
505 // Set reference point to pointing 505 // Set reference point to pointing
506 - if (toupper(m_coordsys) == "GAL") { 506 + if (gammalib::toupper(m_coordsys) == "GAL") {
507 xref = pnt->dir().l_deg(); 507 xref = pnt->dir().l_deg();
508 yref = pnt->dir().b_deg(); 508 yref = pnt->dir().b_deg();
509 } 509 }
@@ -558,13 +558,13 @@ void ctbin::bin_events(GCTAObservation* obs) @@ -558,13 +558,13 @@ void ctbin::bin_events(GCTAObservation* obs)
558 if (logTerse()) { 558 if (logTerse()) {
559 log << std::endl; 559 log << std::endl;
560 log.header1("Binning"); 560 log.header1("Binning");
561 - log << parformat("Events in list"); 561 + log << gammalib::parformat("Events in list");
562 log << obs->events()->size() << std::endl; 562 log << obs->events()->size() << std::endl;
563 - log << parformat("Events in map"); 563 + log << gammalib::parformat("Events in map");
564 log << num_in_map << std::endl; 564 log << num_in_map << std::endl;
565 - log << parformat("Events outside map area"); 565 + log << gammalib::parformat("Events outside map area");
566 log << num_outside_map << std::endl; 566 log << num_outside_map << std::endl;
567 - log << parformat("Events outside energy bins"); 567 + log << gammalib::parformat("Events outside energy bins");
568 log << num_outside_ebds << std::endl; 568 log << num_outside_ebds << std::endl;
569 } 569 }
570 570
@@ -690,7 +690,7 @@ void ctbin::free_members(void) @@ -690,7 +690,7 @@ void ctbin::free_members(void)
690 std::string ctbin::set_outfile_name(const std::string& filename) const 690 std::string ctbin::set_outfile_name(const std::string& filename) const
691 { 691 {
692 // Split input filename into path elements 692 // Split input filename into path elements
693 - std::vector<std::string> elements = split(filename, "/"); 693 + std::vector<std::string> elements = gammalib::split(filename, "/");
694 694
695 // The last path element is the filename 695 // The last path element is the filename
696 std::string outname = m_prefix + elements[elements.size()-1]; 696 std::string outname = m_prefix + elements[elements.size()-1];
src/ctlike/ctlike.cpp
@@ -264,9 +264,12 @@ void ctlike::run(void) @@ -264,9 +264,12 @@ void ctlike::run(void)
264 264
265 // Write results into logger 265 // Write results into logger
266 if (logTerse()) { 266 if (logTerse()) {
267 - log << parformat("Maximum log likelihood") << m_logL << std::endl;  
268 - log << parformat("Observed events (Nobs)") << num_events << std::endl;  
269 - log << parformat("Predicted events (Npred)") << m_obs.npred(); 267 + log << gammalib::parformat("Maximum log likelihood");
  268 + log << m_logL << std::endl;
  269 + log << gammalib::parformat("Observed events (Nobs)");
  270 + log << num_events << std::endl;
  271 + log << gammalib::parformat("Predicted events (Npred)");
  272 + log << m_obs.npred();
270 log << " (Nobs - Npred = " << num_events-m_obs.npred(); 273 log << " (Nobs - Npred = " << num_events-m_obs.npred();
271 log << ")" << std::endl; 274 log << ")" << std::endl;
272 log << m_obs.models() << std::endl; 275 log << m_obs.models() << std::endl;
@@ -294,7 +297,7 @@ void ctlike::save(void) @@ -294,7 +297,7 @@ void ctlike::save(void)
294 m_outmdl = (*this)["outmdl"].filename(); 297 m_outmdl = (*this)["outmdl"].filename();
295 298
296 // Write results out as XML model 299 // Write results out as XML model
297 - if (toupper(m_outmdl) != "NONE") { 300 + if (gammalib::toupper(m_outmdl) != "NONE") {
298 m_obs.models().save(m_outmdl); 301 m_obs.models().save(m_outmdl);
299 } 302 }
300 303
@@ -351,7 +354,7 @@ void ctlike::get_parameters(void) @@ -351,7 +354,7 @@ void ctlike::get_parameters(void)
351 } 354 }
352 355
353 // Get task parameters for event file loading 356 // Get task parameters for event file loading
354 - m_stat = toupper((*this)["stat"].string()); 357 + m_stat = gammalib::toupper((*this)["stat"].string());
355 m_caldb = (*this)["caldb"].string(); 358 m_caldb = (*this)["caldb"].string();
356 m_irf = (*this)["irf"].string(); 359 m_irf = (*this)["irf"].string();
357 360
src/ctmodel/ctmodel.cpp
@@ -403,7 +403,7 @@ void ctmodel::get_parameters(void) @@ -403,7 +403,7 @@ void ctmodel::get_parameters(void)
403 403
404 // If there is no input filename then read all parameters that 404 // If there is no input filename then read all parameters that
405 // are required to build a model map from scratch 405 // are required to build a model map from scratch
406 - if ((m_infile == "NONE") || (strip_whitespace(m_infile) == "")) { 406 + if ((m_infile == "NONE") || (gammalib::strip_whitespace(m_infile) == "")) {
407 m_ra = (*this)["ra"].real(); 407 m_ra = (*this)["ra"].real();
408 m_dec = (*this)["dec"].real(); 408 m_dec = (*this)["dec"].real();
409 m_deadc = (*this)["deadc"].real(); 409 m_deadc = (*this)["deadc"].real();
@@ -474,7 +474,7 @@ void ctmodel::setup_obs(void) @@ -474,7 +474,7 @@ void ctmodel::setup_obs(void)
474 474
475 // If no input filename has been specified, then create a model map 475 // If no input filename has been specified, then create a model map
476 // from the task parameters 476 // from the task parameters
477 - if ((m_infile == "NONE") || (strip_whitespace(m_infile) == "")) { 477 + if ((m_infile == "NONE") || (gammalib::strip_whitespace(m_infile) == "")) {
478 478
479 // Set pointing direction 479 // Set pointing direction
480 GCTAPointing pnt; 480 GCTAPointing pnt;
@@ -640,7 +640,7 @@ void ctmodel::model_map(GCTAObservation* obs, const GModels&amp; models) @@ -640,7 +640,7 @@ void ctmodel::model_map(GCTAObservation* obs, const GModels&amp; models)
640 640
641 // Log results 641 // Log results
642 if (logTerse()) { 642 if (logTerse()) {
643 - log << parformat("Model events in cube"); 643 + log << gammalib::parformat("Model events in cube");
644 log << sum << std::endl; 644 log << sum << std::endl;
645 } 645 }
646 646
@@ -767,7 +767,7 @@ void ctmodel::free_members(void) @@ -767,7 +767,7 @@ void ctmodel::free_members(void)
767 std::string ctmodel::set_outfile_name(const std::string& filename) const 767 std::string ctmodel::set_outfile_name(const std::string& filename) const
768 { 768 {
769 // Split input filename into path elements 769 // Split input filename into path elements
770 - std::vector<std::string> elements = split(filename, "/"); 770 + std::vector<std::string> elements = gammalib::split(filename, "/");
771 771
772 // The last path element is the filename 772 // The last path element is the filename
773 std::string outname = m_prefix + elements[elements.size()-1]; 773 std::string outname = m_prefix + elements[elements.size()-1];
src/ctobssim/ctobssim.cpp
@@ -251,8 +251,8 @@ void ctobssim::run(void) @@ -251,8 +251,8 @@ void ctobssim::run(void)
251 log << std::endl; 251 log << std::endl;
252 log.header1("Seed values"); 252 log.header1("Seed values");
253 for (int i = 0; i < m_rans.size(); ++i) { 253 for (int i = 0; i < m_rans.size(); ++i) {
254 - log << parformat("Seed "+str(i));  
255 - log << str(m_rans[i].seed()) << std::endl; 254 + log << gammalib::parformat("Seed "+gammalib::str(i));
  255 + log << gammalib::str(m_rans[i].seed()) << std::endl;
256 } 256 }
257 } 257 }
258 258
@@ -640,9 +640,9 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models, @@ -640,9 +640,9 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models,
640 640
641 // Dump simulation cone information 641 // Dump simulation cone information
642 if (logNormal()) { 642 if (logNormal()) {
643 - *wrklog << parformat("Simulation area");  
644 - *wrklog << str(m_area) << " cm2" << std::endl;  
645 - *wrklog << parformat("Simulation cone"); 643 + *wrklog << gammalib::parformat("Simulation area");
  644 + *wrklog << m_area << " cm2" << std::endl;
  645 + *wrklog << gammalib::parformat("Simulation cone");
646 *wrklog << "RA=" << dir.ra_deg() << " deg"; 646 *wrklog << "RA=" << dir.ra_deg() << " deg";
647 *wrklog << ", Dec=" << dir.dec_deg() << " deg"; 647 *wrklog << ", Dec=" << dir.dec_deg() << " deg";
648 *wrklog << ", r=" << rad << " deg" << std::endl; 648 *wrklog << ", r=" << rad << " deg" << std::endl;
@@ -664,7 +664,7 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models, @@ -664,7 +664,7 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models,
664 indent++; 664 indent++;
665 wrklog->indent(indent); 665 wrklog->indent(indent);
666 } 666 }
667 - *wrklog << parformat("Time interval", indent); 667 + *wrklog << gammalib::parformat("Time interval", indent);
668 *wrklog << tmin.convert(m_cta_ref); 668 *wrklog << tmin.convert(m_cta_ref);
669 *wrklog << " - "; 669 *wrklog << " - ";
670 *wrklog << tmax.convert(m_cta_ref); 670 *wrklog << tmax.convert(m_cta_ref);
@@ -684,7 +684,7 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models, @@ -684,7 +684,7 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models,
684 indent++; 684 indent++;
685 wrklog->indent(indent); 685 wrklog->indent(indent);
686 } 686 }
687 - *wrklog << parformat("Energy range", indent); 687 + *wrklog << gammalib::parformat("Energy range", indent);
688 *wrklog << emin << " - " << emax << std::endl; 688 *wrklog << emin << " - " << emax << std::endl;
689 } 689 }
690 690
@@ -722,7 +722,7 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models, @@ -722,7 +722,7 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models,
722 indent++; 722 indent++;
723 wrklog->indent(indent); 723 wrklog->indent(indent);
724 } 724 }
725 - *wrklog << parformat("Time slice", indent); 725 + *wrklog << gammalib::parformat("Time slice", indent);
726 *wrklog << tstart.convert(m_cta_ref); 726 *wrklog << tstart.convert(m_cta_ref);
727 *wrklog << " - "; 727 *wrklog << " - ";
728 *wrklog << tstop.convert(m_cta_ref); 728 *wrklog << tstop.convert(m_cta_ref);
@@ -775,14 +775,14 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models, @@ -775,14 +775,14 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models,
775 775
776 // Dump simulation results 776 // Dump simulation results
777 if (logNormal()) { 777 if (logNormal()) {
778 - *wrklog << parformat("MC source photons", indent);  
779 - *wrklog << str(nphotons); 778 + *wrklog << gammalib::parformat("MC source photons", indent);
  779 + *wrklog << nphotons;
780 if (model->name().length() > 0) { 780 if (model->name().length() > 0) {
781 *wrklog << " [" << model->name() << "]"; 781 *wrklog << " [" << model->name() << "]";
782 } 782 }
783 *wrklog << std::endl; 783 *wrklog << std::endl;
784 - *wrklog << parformat("MC source events", indent);  
785 - *wrklog << str(events->size()); 784 + *wrklog << gammalib::parformat("MC source events", indent);
  785 + *wrklog << events->size();
786 if (model->name().length() > 0) { 786 if (model->name().length() > 0) {
787 *wrklog << " [" << model->name() << "]"; 787 *wrklog << " [" << model->name() << "]";
788 } 788 }
@@ -796,8 +796,8 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models, @@ -796,8 +796,8 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models,
796 796
797 // Dump simulation results 797 // Dump simulation results
798 if (logNormal()) { 798 if (logNormal()) {
799 - *wrklog << parformat("MC source events", indent);  
800 - *wrklog << str(events->size()); 799 + *wrklog << gammalib::parformat("MC source events", indent);
  800 + *wrklog << events->size();
801 *wrklog << " (all source models)"; 801 *wrklog << " (all source models)";
802 *wrklog << std::endl; 802 *wrklog << std::endl;
803 } 803 }
@@ -909,8 +909,8 @@ void ctobssim::simulate_background(GCTAObservation* obs, @@ -909,8 +909,8 @@ void ctobssim::simulate_background(GCTAObservation* obs,
909 909
910 // Dump simulation results 910 // Dump simulation results
911 if (logNormal()) { 911 if (logNormal()) {
912 - *wrklog << parformat("MC background events");  
913 - *wrklog << str(list->size()) << std::endl; 912 + *wrklog << gammalib::parformat("MC background events");
  913 + *wrklog << list->size() << std::endl;
914 } 914 }
915 915
916 // Free event list 916 // Free event list
@@ -1087,7 +1087,7 @@ void ctobssim::save_xml(void) @@ -1087,7 +1087,7 @@ void ctobssim::save_xml(void)
1087 if (obs != NULL) { 1087 if (obs != NULL) {
1088 1088
1089 // Set event output file name 1089 // Set event output file name
1090 - std::string outfile = m_prefix + str(file_num) + ".fits"; 1090 + std::string outfile = m_prefix + gammalib::str(file_num) + ".fits";
1091 1091
1092 // Store output file name in observation 1092 // Store output file name in observation
1093 obs->eventfile(outfile); 1093 obs->eventfile(outfile);
src/ctselect/ctselect.cpp
@@ -537,7 +537,7 @@ void ctselect::select_events(GCTAObservation* obs, const std::string&amp; filename) @@ -537,7 +537,7 @@ void ctselect::select_events(GCTAObservation* obs, const std::string&amp; filename)
537 sprintf(cmax, "%.8f", tmax); 537 sprintf(cmax, "%.8f", tmax);
538 selection = "TIME >= "+std::string(cmin)+" && TIME <= "+std::string(cmax); 538 selection = "TIME >= "+std::string(cmin)+" && TIME <= "+std::string(cmax);
539 if (logTerse()) { 539 if (logTerse()) {
540 - log << parformat("Time range"); 540 + log << gammalib::parformat("Time range");
541 log << tmin << " - " << tmax << " s" << std::endl; 541 log << tmin << " - " << tmax << " s" << std::endl;
542 } 542 }
543 if (selection.length() > 0) { 543 if (selection.length() > 0) {
@@ -550,7 +550,7 @@ void ctselect::select_events(GCTAObservation* obs, const std::string&amp; filename) @@ -550,7 +550,7 @@ void ctselect::select_events(GCTAObservation* obs, const std::string&amp; filename)
550 sprintf(cmax, "%.8f", m_emax); 550 sprintf(cmax, "%.8f", m_emax);
551 selection += "ENERGY >= "+std::string(cmin)+" && ENERGY <= "+std::string(cmax); 551 selection += "ENERGY >= "+std::string(cmin)+" && ENERGY <= "+std::string(cmax);
552 if (logTerse()) { 552 if (logTerse()) {
553 - log << parformat("Energy range"); 553 + log << gammalib::parformat("Energy range");
554 log << m_emin << " - " << m_emax << " TeV" << std::endl; 554 log << m_emin << " - " << m_emax << " TeV" << std::endl;
555 } 555 }
556 if (selection.length() > 0) { 556 if (selection.length() > 0) {
@@ -565,22 +565,22 @@ void ctselect::select_events(GCTAObservation* obs, const std::string&amp; filename) @@ -565,22 +565,22 @@ void ctselect::select_events(GCTAObservation* obs, const std::string&amp; filename)
565 std::string(cdec)+",RA,DEC) <= " + 565 std::string(cdec)+",RA,DEC) <= " +
566 std::string(crad); 566 std::string(crad);
567 if (logTerse()) { 567 if (logTerse()) {
568 - log << parformat("Acceptance cone centre"); 568 + log << gammalib::parformat("Acceptance cone centre");
569 log << "RA=" << ra << ", DEC=" << dec << " deg" << std::endl; 569 log << "RA=" << ra << ", DEC=" << dec << " deg" << std::endl;
570 - log << parformat("Acceptance cone radius"); 570 + log << gammalib::parformat("Acceptance cone radius");
571 log << m_rad << " deg" << std::endl; 571 log << m_rad << " deg" << std::endl;
572 } 572 }
573 if (logTerse()) { 573 if (logTerse()) {
574 - log << parformat("cfitsio selection"); 574 + log << gammalib::parformat("cfitsio selection");
575 log << selection << std::endl; 575 log << selection << std::endl;
576 } 576 }
577 577
578 // Add additional expression 578 // Add additional expression
579 - if (strip_whitespace(m_expr).length() > 0) { 579 + if (gammalib::strip_whitespace(m_expr).length() > 0) {
580 if (selection.length() > 0) { 580 if (selection.length() > 0) {
581 selection += " && "; 581 selection += " && ";
582 } 582 }
583 - selection += "("+strip_whitespace(m_expr)+")"; 583 + selection += "("+gammalib::strip_whitespace(m_expr)+")";
584 } 584 }
585 585
586 // Build input filename including selection expression 586 // Build input filename including selection expression
@@ -588,7 +588,7 @@ void ctselect::select_events(GCTAObservation* obs, const std::string&amp; filename) @@ -588,7 +588,7 @@ void ctselect::select_events(GCTAObservation* obs, const std::string&amp; filename)
588 if (selection.length() > 0) 588 if (selection.length() > 0)
589 expression += "[EVENTS]["+selection+"]"; 589 expression += "[EVENTS]["+selection+"]";
590 if (logTerse()) { 590 if (logTerse()) {
591 - log << parformat("FITS filename"); 591 + log << gammalib::parformat("FITS filename");
592 log << expression << std::endl; 592 log << expression << std::endl;
593 } 593 }
594 594
@@ -850,7 +850,7 @@ std::string ctselect::check_infile(const std::string&amp; filename) const @@ -850,7 +850,7 @@ std::string ctselect::check_infile(const std::string&amp; filename) const
850 std::string ctselect::set_outfile_name(const std::string& filename) const 850 std::string ctselect::set_outfile_name(const std::string& filename) const
851 { 851 {
852 // Split input filename into path elements 852 // Split input filename into path elements
853 - std::vector<std::string> elements = split(filename, "/"); 853 + std::vector<std::string> elements = gammalib::split(filename, "/");
854 854
855 // The last path element is the filename 855 // The last path element is the filename
856 std::string outname = m_prefix + elements[elements.size()-1]; 856 std::string outname = m_prefix + elements[elements.size()-1];
src/ctskymap/ctskymap.cpp
@@ -425,7 +425,7 @@ void ctskymap::init_map(GCTAObservation* obs) @@ -425,7 +425,7 @@ void ctskymap::init_map(GCTAObservation* obs)
425 } 425 }
426 426
427 // Set reference point to pointing 427 // Set reference point to pointing
428 - if (toupper(m_coordsys) == "GAL") { 428 + if (gammalib::toupper(m_coordsys) == "GAL") {
429 xref = pnt->dir().l_deg(); 429 xref = pnt->dir().l_deg();
430 yref = pnt->dir().b_deg(); 430 yref = pnt->dir().b_deg();
431 } 431 }
@@ -512,13 +512,13 @@ void ctskymap::map_events(GCTAObservation* obs) @@ -512,13 +512,13 @@ void ctskymap::map_events(GCTAObservation* obs)
512 if (logTerse()) { 512 if (logTerse()) {
513 log << std::endl; 513 log << std::endl;
514 log.header1("Mapping"); 514 log.header1("Mapping");
515 - log << parformat("Events in list"); 515 + log << gammalib::parformat("Events in list");
516 log << obs->events()->size() << std::endl; 516 log << obs->events()->size() << std::endl;
517 - log << parformat("Events in map"); 517 + log << gammalib::parformat("Events in map");
518 log << num_in_map << std::endl; 518 log << num_in_map << std::endl;
519 - log << parformat("Events outside map area"); 519 + log << gammalib::parformat("Events outside map area");
520 log << num_outside_map << std::endl; 520 log << num_outside_map << std::endl;
521 - log << parformat("Events outside energy range"); 521 + log << gammalib::parformat("Events outside energy range");
522 log << num_outside_erange << std::endl; 522 log << num_outside_erange << std::endl;
523 } 523 }
524 524