00001 #ifndef LARUTILBASE_CC
00002 #define LARUTILBASE_CC
00003
00004 #include "LArUtilBase.hh"
00005
00006 namespace larutil {
00007
00008
00009 LArUtilBase::LArUtilBase()
00010 : larlight::larlight_base(),
00011 _file_name(""),
00012 _tree_name("")
00013
00014 {
00015 _name = "LArUtilBase";
00016 _loaded = false;
00017 }
00018
00019
00020 bool LArUtilBase::LoadData(bool force_reload)
00021
00022 {
00023 if(!force_reload && _loaded) return true;
00024
00025 print(larlight::MSG::INFO,__FUNCTION__,
00026 Form("Reading-in data for %s",_name.c_str()));
00027
00028 if(_file_name.empty() || _tree_name.empty()) {
00029
00030 throw LArUtilException(Form("Either file or tree name not specified to load data for %s",_name.c_str()));
00031
00032 return false;
00033 }
00034
00035 bool status=false;
00036 try {
00037
00038 print(larlight::MSG::NORMAL, __FUNCTION__,
00039 Form("Loading data for %s...\n file=%s ", _name.c_str(), _file_name.c_str()));
00040 ClearData();
00041 status = ReadTree();
00042 if(!status)
00043 throw LArUtilException("Failed to load !");
00044 }
00045 catch (LArUtilException &e) {
00046
00047 print(larlight::MSG::ERROR, __FUNCTION__,
00048 Form("Failed loading data for %s...",_name.c_str()));
00049
00050 print(larlight::MSG::ERROR, __FUNCTION__,
00051 e.what());
00052
00053 throw e;
00054 status = false;
00055 }
00056
00057 return status;
00058 }
00059
00060 }
00061 #endif