Commit aa4af556bb6d015aff8920fe9f8819ca5bfc6320

Authored by Jürgen Knödlseder
1 parent b1e92b56

Do not open Fermi LAT CalDB in the void constructor.

Opening the Fermi LAT CalDB in the void constructor lead to an exception in case that the environment variable has not been set. Now, the opening is performed in the load() method.
inst/cta/test/test_CTA.cpp
... ... @@ -1712,10 +1712,9 @@ int main(void)
1712 1712  
1713 1713 // Check if data directory exists
1714 1714 bool has_data = (access(datadir.c_str(), R_OK) == 0);
1715   - if (has_data) {
1716   - std::string caldb = "CALDB="+cta_caldb;
1717   - putenv((char*)caldb.c_str());
1718   - }
  1715 +
  1716 + // Set CALDB environment variable
  1717 + setenv("CALDB", cta_caldb.c_str(), 1);
1719 1718  
1720 1719 // Initially assume that we pass all tests
1721 1720 bool success = true;
... ...
inst/lat/src/GLATResponse.cpp
... ... @@ -551,6 +551,9 @@ void GLATResponse::load(const std::string& rspname)
551 551 clear();
552 552 m_caldb = caldb;
553 553  
  554 + // Open Fermi LAT calibration database
  555 + m_caldb.open("glast", "lat");
  556 +
554 557 // Determine response types to be loaded. If no event type has been
555 558 // specified then load both front and back response.
556 559 int event_type = 0;
... ... @@ -781,9 +784,6 @@ void GLATResponse::init_members(void)
781 784 m_edisp.clear();
782 785 m_ptsrc.clear();
783 786  
784   - // Open Fermi/LAT calibration database
785   - m_caldb.open("glast", "lat");
786   -
787 787 // Return
788 788 return;
789 789 }
... ... @@ -801,19 +801,19 @@ void GLATResponse::copy_members(const GLATResponse& rsp)
801 801 m_rspname = rsp.m_rspname;
802 802 m_force_mean = rsp.m_force_mean;
803 803  
804   - // Clone Aeff
  804 + // Clone Aeff response components
805 805 m_aeff.clear();
806 806 for (int i = 0; i < rsp.m_aeff.size(); ++i) {
807 807 m_aeff.push_back(rsp.m_aeff[i]->clone());
808 808 }
809 809  
810   - // Clone Psf
  810 + // Clone Psf response components
811 811 m_psf.clear();
812 812 for (int i = 0; i < rsp.m_psf.size(); ++i) {
813 813 m_psf.push_back(rsp.m_psf[i]->clone());
814 814 }
815 815  
816   - // Clone Edisp
  816 + // Clone Edisp response components
817 817 m_edisp.clear();
818 818 for (int i = 0; i < rsp.m_edisp.size(); ++i) {
819 819 m_edisp.push_back(rsp.m_edisp[i]->clone());
... ...
inst/lat/test/test_LAT.cpp
... ... @@ -40,6 +40,7 @@
40 40 /* __ Globals ____________________________________________________________ */
41 41  
42 42 /* __ Constants __________________________________________________________ */
  43 +const std::string datadir = PACKAGE_SOURCE"/inst/lat/test/data";
43 44 const std::string lat_caldb = PACKAGE_SOURCE"/inst/lat/caldb";
44 45 const std::string dirPass6 = PACKAGE_SOURCE"/inst/lat/test/data/p6v3";
45 46 const std::string dirPass7 = PACKAGE_SOURCE"/inst/lat/test/data/p7v6";
... ... @@ -877,9 +878,9 @@ int main(void)
877 878 GTestSuites testsuites("LAT instrument specific class testing");
878 879  
879 880 // Check if data directory exists
880   - bool has_data = (access(PACKAGE_SOURCE"/inst/lat/test/data", R_OK) == 0);
  881 + bool has_data = (access(datadir.c_str(), R_OK) == 0);
881 882  
882   - // Set CALDB
  883 + // Set CALDB environment variable
883 884 setenv("CALDB", lat_caldb.c_str(), 1);
884 885  
885 886 // Initially assume that we pass all tests
... ...