path-run-name in RUN block of the msr-file can now handle spaces.

This commit is contained in:
suter_a 2025-01-18 13:35:08 +01:00
parent bfade6f4b8
commit 8dc871e082
4 changed files with 61 additions and 33 deletions

View File

@ -1,7 +1,7 @@
# - musrfit --- DKS ----------------------------------------------------------- # - musrfit --- DKS -----------------------------------------------------------
cmake_minimum_required(VERSION 3.17) 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 ------------------------------------------------- #--- musrfit specific options -------------------------------------------------
option(dks "build musrfit with DKS (GPU/MIC) support" ON) option(dks "build musrfit with DKS (GPU/MIC) support" ON)

View File

@ -12,6 +12,11 @@ or
https://bitbucket.org/muonspin/musrfit/commits/all 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 Release of V1.9.6, 2024/12/02
============================= =============================

View File

@ -140,29 +140,32 @@ int PMsr2Data::DetermineRunNumberDigits(unsigned int runNo, bool normalMode) con
strLine.str(line); strLine.str(line);
strLine >> firstOnLine; strLine >> firstOnLine;
if (!to_lower_copy(firstOnLine).compare("run")) { if (!to_lower_copy(firstOnLine).compare("run")) {
firstOnLine.clear(); // for path-names with spaces
strLine >> firstOnLine; std::string::size_type loc{0};
std::string::size_type loc = firstOnLine.rfind(tempRunNumber.str()); while (!strLine.eof()) {
if ( loc != std::string::npos ) { firstOnLine.clear();
while ( loc > 0 ) { strLine >> firstOnLine;
if (isdigit(firstOnLine.at(--loc))) { loc = firstOnLine.rfind(tempRunNumber.str());
++fRunNumberDigits; if ( loc != std::string::npos ) {
} else { while ( loc > 0 ) {
break; 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;"; 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.str(line);
strLine >> firstOnLine; strLine >> firstOnLine;
if (!to_lower_copy(firstOnLine).compare("run")) { if (!to_lower_copy(firstOnLine).compare("run")) {
strLine >> firstOnLine; // needed for path-fln with spaces
std::string::size_type loc = firstOnLine.rfind(tempRunNumber.str()); std::string::size_type loc;
if ( loc != std::string::npos ) { std::string sstr{""};
firstOnLine.replace(loc, fRunNumberDigits, newRunNumber.str()); firstOnLine.clear();
} else { 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** 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 << ">> msr2data: **WARNING** Unexpected things will happen... (for sure)";
std::cerr << std::endl; std::cerr << std::endl;
@ -694,7 +709,6 @@ bool PMsr2Data::PrepareGlobalInputFile(unsigned int tempRun, const std::string &
msrParamList->at(i).fIsGlobal = true; msrParamList->at(i).fIsGlobal = true;
++fNumGlobalParam; ++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 // 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()); rawRunData = fDataHandler->GetRunData((*msrRunList)[0].GetRunName()->Data());
} }
if (rawRunData == nullptr)
return -1;
switch (rawRunData->GetNoOfTemperatures()) { switch (rawRunData->GetNoOfTemperatures()) {
case 1: case 1:
dataParamNames.push_back("dataT"); dataParamNames.push_back("dataT");

View File

@ -3244,7 +3244,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
while ((iter != lines.end()) && !error) { while ((iter != lines.end()) && !error) {
// remove potential comment at the end of lines // remove potential comment at the end of lines
str = iter->fLine; str = iter->fLine;
Ssiz_t idx = str.Index("#"); Ssiz_t idx = str.Index("(");
if (idx != -1) if (idx != -1)
str.Remove(idx); str.Remove(idx);
@ -3274,23 +3274,29 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
} }
// get run name, beamline, institute, and file-format // 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) { if (tokens->GetEntries() < 5) {
error = true; error = true;
} else { } else {
// run name // run name
ostr = dynamic_cast<TObjString*>(tokens->At(1)); str = TString("");
str = ostr->GetString(); 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); param.SetRunName(str);
// beamline // beamline
ostr = dynamic_cast<TObjString*>(tokens->At(2)); ostr = dynamic_cast<TObjString*>(tokens->At(tokens->GetEntries()-3));
str = ostr->GetString(); str = ostr->GetString();
param.SetBeamline(str); param.SetBeamline(str);
// institute // institute
ostr = dynamic_cast<TObjString*>(tokens->At(3)); ostr = dynamic_cast<TObjString*>(tokens->At(tokens->GetEntries()-2));
str = ostr->GetString(); str = ostr->GetString();
param.SetInstitute(str); param.SetInstitute(str);
// data file format // data file format
ostr = dynamic_cast<TObjString*>(tokens->At(4)); ostr = dynamic_cast<TObjString*>(tokens->At(tokens->GetEntries()-1));
str = ostr->GetString(); str = ostr->GetString();
param.SetFileFormat(str); param.SetFileFormat(str);
} }