added some more sanity checks for addRun.
This commit is contained in:
@@ -168,6 +168,8 @@ bool addRun_readInputFiles(const std::string fileName, std::vector<PAddRunInfo>
|
||||
char *tok{nullptr};
|
||||
int status, ival;
|
||||
bool lastWasFile{false};
|
||||
memset(buf, '\0', sizeof(buf));
|
||||
memset(str, '\0', sizeof(str));
|
||||
while (fin.good()) {
|
||||
fin.getline(buf, 256);
|
||||
line = buf;
|
||||
@@ -176,7 +178,7 @@ bool addRun_readInputFiles(const std::string fileName, std::vector<PAddRunInfo>
|
||||
continue;
|
||||
if (line[0] == '%')
|
||||
continue;
|
||||
strcpy(buf, line.c_str());
|
||||
strncpy(buf, line.c_str(), sizeof(buf));
|
||||
tok = strtok(buf, " ");
|
||||
if (!strcmp(tok, "file")) {
|
||||
if (lastWasFile) {
|
||||
@@ -242,6 +244,10 @@ bool addRun_readInputFiles(const std::string fileName, std::vector<PAddRunInfo>
|
||||
UInt_t addRun_getPromptPeakPos(PDoubleVector *vec)
|
||||
{
|
||||
UInt_t pos=0;
|
||||
|
||||
if (vec == nullptr)
|
||||
return pos;
|
||||
|
||||
Double_t max=vec->at(0);
|
||||
|
||||
for (UInt_t i=0; i<vec->size(); i++) {
|
||||
@@ -536,13 +542,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 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 << ">> addRun **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;
|
||||
@@ -678,7 +685,7 @@ int main(int argc, char *argv[])
|
||||
if (isGood) {
|
||||
// check that all runs have the same number of histograms
|
||||
for (UInt_t i=1; i<runDataHandler.size(); i++) {
|
||||
if (runDataHandler[0]->GetRunData()->GetNoOfHistos() != runDataHandler[0]->GetRunData()->GetNoOfHistos()) {
|
||||
if (runDataHandler[0]->GetRunData()->GetNoOfHistos() != runDataHandler[i]->GetRunData()->GetNoOfHistos()) {
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "**ERROR** can only add runs with the same number of histograms." << std::endl;
|
||||
std::cerr << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user