added some more sanity checks for dump_header.
All checks were successful
Build and Deploy Documentation / build-and-deploy (push) Successful in 19s
All checks were successful
Build and Deploy Documentation / build-and-deploy (push) Successful in 19s
This commit is contained in:
@@ -201,22 +201,39 @@ int dump_header_root(const std::string fileName, const bool summary, const bool
|
||||
std::cout << std::endl << "Detector Info (for all detectors the same): ";
|
||||
std::cout << std::endl << "-------------------";
|
||||
std::cout << std::endl << "Histo Length : " << runHeader->GetNChannels();
|
||||
double *timeZero;
|
||||
double *timeZero = nullptr;
|
||||
timeZero = runHeader->GetTimeZero();
|
||||
std::cout << std::endl << "Time Zero Bin : " << timeZero[0];
|
||||
std::cout << std::endl << "First Good Bin : " << timeZero[0];
|
||||
if (timeZero != nullptr) {
|
||||
std::cout << std::endl << "Time Zero Bin : " << timeZero[0];
|
||||
std::cout << std::endl << "First Good Bin : " << timeZero[0];
|
||||
} else {
|
||||
std::cout << std::endl << "Time Zero Bin : ??";
|
||||
std::cout << std::endl << "First Good Bin : ??";
|
||||
}
|
||||
std::cout << std::endl << "Last Good Bin : " << runHeader->GetNChannels()-1;
|
||||
std::cout << std::endl << "-------------------" << std::endl << std::endl;
|
||||
} else { // MusrRoot
|
||||
// invoke the MusrRoot header object
|
||||
header = std::make_unique<TMusrRunHeader>(fileName.c_str(), true); // read quite
|
||||
if (header == nullptr) {
|
||||
std::cerr << std::endl << "**ERROR** Couldn't invoke MusrRoot RunHeader from file:" << fileName;
|
||||
std::cerr << std::endl;
|
||||
f.Close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
// check if TFolder or TDirectory is needed
|
||||
if (fileType == DH_MUSR_ROOT) { // TFolder
|
||||
f.GetObject("RunHeader", folder);
|
||||
if (folder == nullptr) {
|
||||
std::cerr << std::endl << "**ERROR** Couldn't get folder from MusrRoot RunHeader from file:" << fileName;
|
||||
std::cerr << std::endl;
|
||||
f.Close();
|
||||
return 1;
|
||||
}
|
||||
// try to populate the MusrRoot header object
|
||||
if (!header->ExtractAll(folder)) {
|
||||
std::cerr << std::endl << "**ERROR** Couldn't invoke MusrRoot RunHeader in file:" << fileName;
|
||||
std::cerr << std::endl << "**ERROR** Couldn't invoke MusrRoot RunHeader content from file:" << fileName;
|
||||
std::cerr << std::endl;
|
||||
f.Close();
|
||||
return 1;
|
||||
@@ -224,6 +241,12 @@ int dump_header_root(const std::string fileName, const bool summary, const bool
|
||||
} else { // TDirectory
|
||||
TDirectoryFile *runHeader = nullptr;
|
||||
f.GetObject("RunHeader", runHeader);
|
||||
if (runHeader == nullptr) {
|
||||
std::cerr << std::endl << "**ERROR** Couldn't get runHeader (TDirectory) from MusrRoot RunHeader from file:" << fileName;
|
||||
std::cerr << std::endl;
|
||||
f.Close();
|
||||
return 1;
|
||||
}
|
||||
// try to populate the MusrRoot header object
|
||||
if (!header->ExtractAll(runHeader)) {
|
||||
std::cerr << std::endl << "**ERROR** Couldn't invoke MusrRoot RunHeader in file:" << fileName;
|
||||
@@ -543,6 +566,7 @@ int dump_header_mud(const std::string fileName, const bool counts)
|
||||
int success;
|
||||
|
||||
char fln[256];
|
||||
memset(fln, '\0', sizeof(fln));
|
||||
strncpy(fln, fileName.c_str(), sizeof(fln));
|
||||
fh = MUD_openRead(fln, &type);
|
||||
if (fh == -1) {
|
||||
@@ -572,9 +596,12 @@ int dump_header_mud(const std::string fileName, const bool counts)
|
||||
tval = static_cast<time_t>(val);
|
||||
if (success) {
|
||||
dt = localtime(static_cast<const time_t*>(&tval));
|
||||
assert(dt);
|
||||
strftime(str, sizeof(str), "%F; %T", dt);
|
||||
std::cout << std::endl << "Run Start Time : " << str;
|
||||
if (dt != nullptr) {
|
||||
strftime(str, sizeof(str), "%F; %T", dt);
|
||||
std::cout << std::endl << "Run Start Time : " << str;
|
||||
} else {
|
||||
std::cout << std::endl << "Run Start Time : ??";
|
||||
}
|
||||
} else {
|
||||
std::cout << std::endl << "Run Start Time : ???";
|
||||
}
|
||||
@@ -583,9 +610,12 @@ int dump_header_mud(const std::string fileName, const bool counts)
|
||||
tval = static_cast<time_t>(val);
|
||||
if (success) {
|
||||
dt = localtime(static_cast<const time_t*>(&tval));
|
||||
assert(dt);
|
||||
strftime(str, sizeof(str), "%F; %T", dt);
|
||||
std::cout << std::endl << "Run Stop Time : " << str;
|
||||
if (dt != nullptr) {
|
||||
strftime(str, sizeof(str), "%F; %T", dt);
|
||||
std::cout << std::endl << "Run Stop Time : " << str;
|
||||
} else {
|
||||
std::cout << std::endl << "Run Stop Time : ??";
|
||||
}
|
||||
} else {
|
||||
std::cout << std::endl << "Run Stop Time : ???";
|
||||
}
|
||||
@@ -780,10 +810,14 @@ int dump_current_year()
|
||||
time_t rawtime;
|
||||
struct tm *timeinfo;
|
||||
char buffer[32];
|
||||
memset(buffer, '\0', sizeof(buffer));
|
||||
|
||||
time (&rawtime);
|
||||
timeinfo = localtime(&rawtime);
|
||||
strftime(buffer, 32, "%Y", timeinfo);
|
||||
if (timeinfo != nullptr)
|
||||
strftime(buffer, 32, "%Y", timeinfo);
|
||||
else
|
||||
strncpy(buffer, "1900", sizeof(buffer));
|
||||
|
||||
return atoi(buffer);
|
||||
}
|
||||
@@ -940,13 +974,14 @@ int main(int argc, char *argv[])
|
||||
// invoke the startup handler in order to get the default search paths to the data files
|
||||
// read startup file
|
||||
char startup_path_name[128];
|
||||
memset(startup_path_name, '\0', sizeof(startup_path_name));
|
||||
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
|
||||
std::unique_ptr<PStartupHandler> startupHandler = std::make_unique<PStartupHandler>();
|
||||
if (!startupHandler->StartupFileFound()) {
|
||||
std::cerr << std::endl << ">> musrfit **WARNING** couldn't find " << startupHandler->GetStartupFilePath().Data();
|
||||
std::cerr << std::endl;
|
||||
} else {
|
||||
strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data());
|
||||
strncpy(startup_path_name, startupHandler->GetStartupFilePath().Data(), sizeof(startup_path_name));
|
||||
saxParser->ConnectToHandler("PStartupHandler", startupHandler.get());
|
||||
//status = saxParser->ParseFile(startup_path_name);
|
||||
// parsing the file as above seems to lead to problems in certain environments;
|
||||
|
||||
Reference in New Issue
Block a user