make msr-file reader more robust against leading spaces.
This commit is contained in:
parent
324045f396
commit
70d1a24534
@ -165,6 +165,9 @@ Int_t PMsrHandler::ReadMsrFile()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove leading spaces
|
||||||
|
line.Remove(TString::kLeading, ' ');
|
||||||
|
|
||||||
if (!line.IsWhitespace()) { // if not an empty line, handle it
|
if (!line.IsWhitespace()) { // if not an empty line, handle it
|
||||||
// check for a msr block
|
// check for a msr block
|
||||||
if (line_no == 1) { // title
|
if (line_no == 1) { // title
|
||||||
@ -3186,7 +3189,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
Bool_t error = false;
|
Bool_t error = false;
|
||||||
Bool_t runLinePresent = false;
|
Bool_t runLinePresent = false;
|
||||||
|
|
||||||
TString str;
|
TString str, line;
|
||||||
TObjArray *tokens = 0;
|
TObjArray *tokens = 0;
|
||||||
TObjString *ostr = 0;
|
TObjString *ostr = 0;
|
||||||
|
|
||||||
@ -3211,8 +3214,13 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// copy of the current line
|
||||||
|
line = iter->fLine;
|
||||||
|
// strip leading spaces from the begining
|
||||||
|
line.Remove(TString::kLeading, ' ');
|
||||||
|
|
||||||
// RUN line ----------------------------------------------
|
// RUN line ----------------------------------------------
|
||||||
if (iter->fLine.BeginsWith("run", TString::kIgnoreCase)) {
|
if (line.BeginsWith("run", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
runLinePresent = true; // this is needed to make sure that a run line is present before and ADDRUN is following
|
runLinePresent = true; // this is needed to make sure that a run line is present before and ADDRUN is following
|
||||||
|
|
||||||
@ -3249,7 +3257,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ADDRUN line ---------------------------------------------
|
// ADDRUN line ---------------------------------------------
|
||||||
if (iter->fLine.BeginsWith("addrun", TString::kIgnoreCase)) {
|
if (line.BeginsWith("addrun", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
if (!runLinePresent) {
|
if (!runLinePresent) {
|
||||||
cerr << endl << ">> PMsrHandler::HandleRunEntry: **ERROR** Found ADDRUN without prior RUN, or";
|
cerr << endl << ">> PMsrHandler::HandleRunEntry: **ERROR** Found ADDRUN without prior RUN, or";
|
||||||
@ -3284,7 +3292,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fittype -------------------------------------------------
|
// fittype -------------------------------------------------
|
||||||
if (iter->fLine.BeginsWith("fittype", TString::kIgnoreCase)) {
|
if (line.BeginsWith("fittype", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
||||||
|
|
||||||
@ -3312,7 +3320,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// alpha -------------------------------------------------
|
// alpha -------------------------------------------------
|
||||||
if (iter->fLine.BeginsWith("alpha", TString::kIgnoreCase)) {
|
if (line.BeginsWith("alpha", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
||||||
|
|
||||||
@ -3334,7 +3342,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// beta -------------------------------------------------
|
// beta -------------------------------------------------
|
||||||
if (iter->fLine.BeginsWith("beta", TString::kIgnoreCase)) {
|
if (line.BeginsWith("beta", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
||||||
|
|
||||||
@ -3356,7 +3364,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// norm -------------------------------------------------
|
// norm -------------------------------------------------
|
||||||
if (iter->fLine.BeginsWith("norm", TString::kIgnoreCase)) {
|
if (line.BeginsWith("norm", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
||||||
|
|
||||||
@ -3380,7 +3388,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// backgr.fit --------------------------------------------
|
// backgr.fit --------------------------------------------
|
||||||
if (iter->fLine.BeginsWith("backgr.fit", TString::kIgnoreCase)) {
|
if (line.BeginsWith("backgr.fit", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
||||||
|
|
||||||
@ -3402,7 +3410,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// lifetime ------------------------------------------------
|
// lifetime ------------------------------------------------
|
||||||
if (iter->fLine.BeginsWith("lifetime ", TString::kIgnoreCase)) {
|
if (line.BeginsWith("lifetime ", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
||||||
|
|
||||||
@ -3424,7 +3432,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// lifetimecorrection ---------------------------------------
|
// lifetimecorrection ---------------------------------------
|
||||||
if (iter->fLine.BeginsWith("lifetimecorrection", TString::kIgnoreCase)) {
|
if (line.BeginsWith("lifetimecorrection", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
||||||
|
|
||||||
@ -3432,7 +3440,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// map ------------------------------------------------------
|
// map ------------------------------------------------------
|
||||||
if (iter->fLine.BeginsWith("map", TString::kIgnoreCase)) {
|
if (line.BeginsWith("map", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
||||||
|
|
||||||
@ -3462,7 +3470,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// forward ------------------------------------------------
|
// forward ------------------------------------------------
|
||||||
if (iter->fLine.BeginsWith("forward", TString::kIgnoreCase)) {
|
if (line.BeginsWith("forward", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
||||||
|
|
||||||
@ -3487,7 +3495,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// backward -----------------------------------------------
|
// backward -----------------------------------------------
|
||||||
if (iter->fLine.BeginsWith("backward", TString::kIgnoreCase)) {
|
if (line.BeginsWith("backward", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
||||||
|
|
||||||
@ -3512,7 +3520,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// backgr.fix ----------------------------------------------
|
// backgr.fix ----------------------------------------------
|
||||||
if (iter->fLine.BeginsWith("backgr.fix", TString::kIgnoreCase)) {
|
if (line.BeginsWith("backgr.fix", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
||||||
|
|
||||||
@ -3531,7 +3539,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// background ---------------------------------------------
|
// background ---------------------------------------------
|
||||||
if (iter->fLine.BeginsWith("background", TString::kIgnoreCase)) {
|
if (line.BeginsWith("background", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
||||||
|
|
||||||
@ -3555,7 +3563,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// data --------------------------------------------------
|
// data --------------------------------------------------
|
||||||
if (iter->fLine.BeginsWith("data", TString::kIgnoreCase)) {
|
if (line.BeginsWith("data", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
||||||
|
|
||||||
@ -3579,7 +3587,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// t0 -----------------------------------------------------
|
// t0 -----------------------------------------------------
|
||||||
if (iter->fLine.BeginsWith("t0", TString::kIgnoreCase)) {
|
if (line.BeginsWith("t0", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
||||||
|
|
||||||
@ -3603,7 +3611,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// addt0 -----------------------------------------------------
|
// addt0 -----------------------------------------------------
|
||||||
if (iter->fLine.BeginsWith("addt0", TString::kIgnoreCase)) {
|
if (line.BeginsWith("addt0", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
||||||
|
|
||||||
@ -3629,7 +3637,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fit -----------------------------------------------------
|
// fit -----------------------------------------------------
|
||||||
if (iter->fLine.BeginsWith("fit ", TString::kIgnoreCase)) {
|
if (line.BeginsWith("fit ", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
||||||
|
|
||||||
@ -3684,7 +3692,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// packing --------------------------------------------------
|
// packing --------------------------------------------------
|
||||||
if (iter->fLine.BeginsWith("packing", TString::kIgnoreCase)) {
|
if (line.BeginsWith("packing", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
||||||
|
|
||||||
@ -3706,7 +3714,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// xy-data -----------------------------------------------
|
// xy-data -----------------------------------------------
|
||||||
if (iter->fLine.BeginsWith("xy-data", TString::kIgnoreCase)) {
|
if (line.BeginsWith("xy-data", TString::kIgnoreCase)) {
|
||||||
|
|
||||||
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user