path-run-name in RUN block of the msr-file can now handle spaces.
This commit is contained in:
parent
bfade6f4b8
commit
8dc871e082
@ -1,7 +1,7 @@
|
||||
# - musrfit --- DKS -----------------------------------------------------------
|
||||
cmake_minimum_required(VERSION 3.17)
|
||||
|
||||
project(musrfit VERSION 1.9.6 LANGUAGES C CXX)
|
||||
project(musrfit VERSION 1.9.7 LANGUAGES C CXX)
|
||||
|
||||
#--- musrfit specific options -------------------------------------------------
|
||||
option(dks "build musrfit with DKS (GPU/MIC) support" ON)
|
||||
|
@ -12,6 +12,11 @@ or
|
||||
|
||||
https://bitbucket.org/muonspin/musrfit/commits/all
|
||||
|
||||
Release of V1.9.7, 2025/01/18
|
||||
=============================
|
||||
|
||||
allow spaces in RUN block path-filename
|
||||
|
||||
Release of V1.9.6, 2024/12/02
|
||||
=============================
|
||||
|
||||
|
@ -140,29 +140,32 @@ int PMsr2Data::DetermineRunNumberDigits(unsigned int runNo, bool normalMode) con
|
||||
strLine.str(line);
|
||||
strLine >> firstOnLine;
|
||||
if (!to_lower_copy(firstOnLine).compare("run")) {
|
||||
firstOnLine.clear();
|
||||
strLine >> firstOnLine;
|
||||
std::string::size_type loc = firstOnLine.rfind(tempRunNumber.str());
|
||||
if ( loc != std::string::npos ) {
|
||||
while ( loc > 0 ) {
|
||||
if (isdigit(firstOnLine.at(--loc))) {
|
||||
++fRunNumberDigits;
|
||||
} else {
|
||||
break;
|
||||
// for path-names with spaces
|
||||
std::string::size_type loc{0};
|
||||
while (!strLine.eof()) {
|
||||
firstOnLine.clear();
|
||||
strLine >> firstOnLine;
|
||||
loc = firstOnLine.rfind(tempRunNumber.str());
|
||||
if ( loc != std::string::npos ) {
|
||||
while ( loc > 0 ) {
|
||||
if (isdigit(firstOnLine.at(--loc))) {
|
||||
++fRunNumberDigits;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
in->close();
|
||||
fRunVectorIter = fRunVector.begin(); // set back the runlist-iterator which might have changed during the search for the correct file
|
||||
return 0;
|
||||
}
|
||||
in->close();
|
||||
fRunVectorIter = fRunVector.begin(); // set back the runlist-iterator which might have changed during the search for the correct file
|
||||
return 0;
|
||||
} else {
|
||||
std::cerr << std::endl << ">> msr2data: **ERROR** The first processed run file number does not match the \"file index\"!";
|
||||
std::cerr << std::endl << ">> msr2data: **ERROR** The number of digits to be used for formatting the run numbers cannot be determined!";
|
||||
std::cerr << std::endl << ">> msr2data: **ERROR** Please check the first msr-file that should be processed;";
|
||||
std::cerr << std::endl << ">> msr2data: **ERROR** this is either some template or the first existing file from the run list.";
|
||||
std::cerr << std::endl;
|
||||
in->close();
|
||||
return -2;
|
||||
}
|
||||
std::cerr << std::endl << ">> msr2data: **ERROR** The first processed run file number does not match the \"file index\"!";
|
||||
std::cerr << std::endl << ">> msr2data: **ERROR** The number of digits to be used for formatting the run numbers cannot be determined!";
|
||||
std::cerr << std::endl << ">> msr2data: **ERROR** Please check the first msr-file that should be processed;";
|
||||
std::cerr << std::endl << ">> msr2data: **ERROR** this is either some template or the first existing file from the run list.";
|
||||
std::cerr << std::endl;
|
||||
in->close();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
std::cerr << std::endl << ">> msr2data: **ERROR** Please check the first msr-file that should be processed;";
|
||||
@ -558,11 +561,23 @@ bool PMsr2Data::PrepareNewInputFile(unsigned int tempRun, bool calledFromGlobalM
|
||||
strLine.str(line);
|
||||
strLine >> firstOnLine;
|
||||
if (!to_lower_copy(firstOnLine).compare("run")) {
|
||||
strLine >> firstOnLine;
|
||||
std::string::size_type loc = firstOnLine.rfind(tempRunNumber.str());
|
||||
if ( loc != std::string::npos ) {
|
||||
firstOnLine.replace(loc, fRunNumberDigits, newRunNumber.str());
|
||||
} else {
|
||||
// needed for path-fln with spaces
|
||||
std::string::size_type loc;
|
||||
std::string sstr{""};
|
||||
firstOnLine.clear();
|
||||
while (!strLine.eof()) {
|
||||
strLine >> sstr;
|
||||
if (firstOnLine.empty())
|
||||
firstOnLine = sstr;
|
||||
else
|
||||
firstOnLine += " " + sstr;
|
||||
loc = firstOnLine.rfind(tempRunNumber.str());
|
||||
if ( loc != std::string::npos ) {
|
||||
firstOnLine.replace(loc, fRunNumberDigits, newRunNumber.str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (strLine.eof()) {
|
||||
std::cerr << std::endl << ">> msr2data: **WARNING** The template run file number does not match the \"file index\"";
|
||||
std::cerr << std::endl << ">> msr2data: **WARNING** Unexpected things will happen... (for sure)";
|
||||
std::cerr << std::endl;
|
||||
@ -694,7 +709,6 @@ bool PMsr2Data::PrepareGlobalInputFile(unsigned int tempRun, const std::string &
|
||||
msrParamList->at(i).fIsGlobal = true;
|
||||
++fNumGlobalParam;
|
||||
}
|
||||
// std::cout << "debug> " << msrParamList->at(i).fNo << ": " << msrParamList->at(i).fName.Data() << " is global: " << msrParamList->at(i).fIsGlobal << std::endl;
|
||||
}
|
||||
|
||||
// there should be at least one run specific parameter, otherwise the GLOBAL option doesn't make sense
|
||||
@ -1801,6 +1815,9 @@ int PMsr2Data::WriteOutput(const std::string &outfile, const std::vector<unsigne
|
||||
rawRunData = fDataHandler->GetRunData((*msrRunList)[0].GetRunName()->Data());
|
||||
}
|
||||
|
||||
if (rawRunData == nullptr)
|
||||
return -1;
|
||||
|
||||
switch (rawRunData->GetNoOfTemperatures()) {
|
||||
case 1:
|
||||
dataParamNames.push_back("dataT");
|
||||
|
@ -3244,7 +3244,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
||||
while ((iter != lines.end()) && !error) {
|
||||
// remove potential comment at the end of lines
|
||||
str = iter->fLine;
|
||||
Ssiz_t idx = str.Index("#");
|
||||
Ssiz_t idx = str.Index("(");
|
||||
if (idx != -1)
|
||||
str.Remove(idx);
|
||||
|
||||
@ -3274,23 +3274,29 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
||||
}
|
||||
|
||||
// get run name, beamline, institute, and file-format
|
||||
// the path/filename could potentially contain spaces! Hence the run name needs to be reconstructed from the parsing
|
||||
if (tokens->GetEntries() < 5) {
|
||||
error = true;
|
||||
} else {
|
||||
// run name
|
||||
ostr = dynamic_cast<TObjString*>(tokens->At(1));
|
||||
str = ostr->GetString();
|
||||
str = TString("");
|
||||
for (Int_t i=1; i<tokens->GetEntries()-3; i++) {
|
||||
ostr = dynamic_cast<TObjString*>(tokens->At(i));
|
||||
str += ostr->GetString();
|
||||
if (i<tokens->GetEntries()-4)
|
||||
str += TString(" ");
|
||||
}
|
||||
param.SetRunName(str);
|
||||
// beamline
|
||||
ostr = dynamic_cast<TObjString*>(tokens->At(2));
|
||||
ostr = dynamic_cast<TObjString*>(tokens->At(tokens->GetEntries()-3));
|
||||
str = ostr->GetString();
|
||||
param.SetBeamline(str);
|
||||
// institute
|
||||
ostr = dynamic_cast<TObjString*>(tokens->At(3));
|
||||
ostr = dynamic_cast<TObjString*>(tokens->At(tokens->GetEntries()-2));
|
||||
str = ostr->GetString();
|
||||
param.SetInstitute(str);
|
||||
// data file format
|
||||
ostr = dynamic_cast<TObjString*>(tokens->At(4));
|
||||
ostr = dynamic_cast<TObjString*>(tokens->At(tokens->GetEntries()-1));
|
||||
str = ostr->GetString();
|
||||
param.SetFileFormat(str);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user