musrt0 -g: handle msr-files with a GLOBAL block.
If 't0' and/or 'addt0' is present in the GLOBAL block, only issue a warning and leave the msr-file untouched. Otherwise the estimated t0's are added/updated in the RUN blocks. Missing t0/addt0/background/data tags were only written at the 'fit' line of a RUN block, which is absent if the fit range is given in the GLOBAL block; in this case they are now written after the last line of the RUN block.
This commit is contained in:
1 parent
4d6d04871c
commit
7b8574b3ee
2 files changed
+99
-55
No files matched your search
+89
-55
@@ -475,6 +475,15 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
for (UInt_t i=0; i<fRuns.size(); i++) {
|
||||
dataTagMissing.push_back(true);
|
||||
}
|
||||
// if the fit range is given in the GLOBAL block, the RUN block has no 'fit' line
|
||||
// after which missing tags could be added. In this case they are added after the
|
||||
// last non-empty line of the RUN block.
|
||||
PBoolVector fitTagMissing; // needed for proper musrt0 handling
|
||||
PIntVector lastRunLineNo;
|
||||
for (UInt_t i=0; i<fRuns.size(); i++) {
|
||||
fitTagMissing.push_back(true);
|
||||
lastRunLineNo.push_back(-1);
|
||||
}
|
||||
|
||||
// add some counters needed in connection to addruns
|
||||
Int_t addT0Counter = 0;
|
||||
@@ -489,19 +498,35 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
if (!fin.is_open()) {
|
||||
return PMUSR_MSR_LOG_FILE_WRITE_ERROR;
|
||||
}
|
||||
Bool_t inRunBlock = false;
|
||||
lineNo = 0;
|
||||
while (!fin.eof()) {
|
||||
// read a line
|
||||
getline(fin, line);
|
||||
str = line.c_str();
|
||||
lineNo++;
|
||||
|
||||
if (str.BeginsWith("RUN")) {
|
||||
runNo++;
|
||||
inRunBlock = true;
|
||||
lastRunLineNo[runNo] = lineNo;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (str.BeginsWith("FITPARAMETER") || str.BeginsWith("THEORY") || str.BeginsWith("FUNCTIONS") ||
|
||||
str.BeginsWith("GLOBAL") || str.BeginsWith("COMMANDS") || str.BeginsWith("FOURIER") ||
|
||||
str.BeginsWith("PLOT") || str.BeginsWith("STATISTIC"))
|
||||
inRunBlock = false;
|
||||
|
||||
if (runNo == -1)
|
||||
continue;
|
||||
|
||||
if (inRunBlock && !str.IsWhitespace() && !str.BeginsWith("#")) {
|
||||
lastRunLineNo[runNo] = lineNo;
|
||||
if (str.BeginsWith("fit") && !str.BeginsWith("fittype"))
|
||||
fitTagMissing[runNo] = false;
|
||||
}
|
||||
|
||||
if (str.BeginsWith("t0"))
|
||||
t0TagMissing[runNo] = false;
|
||||
else if (str.BeginsWith("background"))
|
||||
@@ -537,6 +562,65 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
return PMUSR_MSR_LOG_FILE_WRITE_ERROR;
|
||||
}
|
||||
|
||||
// writes t0/addt0/background/data of a RUN block, if the corresponding tag is missing in the msr-file
|
||||
auto writeMissingRunTags = [&](Int_t runNo) {
|
||||
// if ISIS data, do not do anything
|
||||
if (t0TagMissing[runNo] && fRuns[runNo].GetInstitute()->CompareTo("isis", TString::kIgnoreCase)) {
|
||||
if (fRuns[runNo].GetT0BinSize() > 0) {
|
||||
fout.width(16);
|
||||
fout << std::left << "t0";
|
||||
for (UInt_t j=0; j<fRuns[runNo].GetT0BinSize(); j++) {
|
||||
fout.width(8);
|
||||
fout.precision(1);
|
||||
fout.setf(std::ios::fixed,std::ios::floatfield);
|
||||
fout << std::left << fRuns[runNo].GetT0Bin(j);
|
||||
}
|
||||
fout << std::endl;
|
||||
}
|
||||
}
|
||||
for (UInt_t i=0; i<fRuns[runNo].GetAddT0BinEntries(); i++) {
|
||||
if (addt0TagMissing[runNo][i] && fRuns[runNo].GetInstitute()->CompareTo("isis", TString::kIgnoreCase)) {
|
||||
if (fRuns[runNo].GetAddT0BinSize(i) > 0) {
|
||||
fout.width(16);
|
||||
fout << std::left << "addt0";
|
||||
for (Int_t j=0; j<fRuns[runNo].GetAddT0BinSize(i); j++) {
|
||||
fout.width(8);
|
||||
fout.precision(1);
|
||||
fout.setf(std::ios::fixed,std::ios::floatfield);
|
||||
fout << std::left << fRuns[runNo].GetAddT0Bin(i, j);
|
||||
}
|
||||
fout << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (backgroundTagMissing[runNo]) {
|
||||
if (fRuns[runNo].GetBkgRange(0) >= 0) {
|
||||
fout.width(16);
|
||||
fout << std::left << "background";
|
||||
for (UInt_t j=0; j<4; j++) {
|
||||
if (fRuns[runNo].GetBkgRange(j) > 0) {
|
||||
fout.width(8);
|
||||
fout << std::left << fRuns[runNo].GetBkgRange(j);
|
||||
}
|
||||
}
|
||||
fout << std::endl;
|
||||
}
|
||||
}
|
||||
if (dataTagMissing[runNo]) {
|
||||
if (fRuns[runNo].GetDataRange(0) >= 0) {
|
||||
fout.width(16);
|
||||
fout << std::left << "data";
|
||||
for (UInt_t j=0; j<4; j++) {
|
||||
if (fRuns[runNo].GetDataRange(j) > 0) {
|
||||
fout.width(8);
|
||||
fout << std::left << fRuns[runNo].GetDataRange(j);
|
||||
}
|
||||
}
|
||||
fout << std::endl;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
tag = MSR_TAG_TITLE;
|
||||
lineNo = 0;
|
||||
runNo = -1;
|
||||
@@ -1068,61 +1152,7 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
}
|
||||
} else if (sstr.BeginsWith("fit")) {
|
||||
// check if missing t0/addt0/background/data tag are present eventhough the values are present, if so write these data values
|
||||
// if ISIS data, do not do anything
|
||||
if (t0TagMissing[runNo] && fRuns[runNo].GetInstitute()->CompareTo("isis", TString::kIgnoreCase)) {
|
||||
if (fRuns[runNo].GetT0BinSize() > 0) {
|
||||
fout.width(16);
|
||||
fout << std::left << "t0";
|
||||
for (UInt_t j=0; j<fRuns[runNo].GetT0BinSize(); j++) {
|
||||
fout.width(8);
|
||||
fout.precision(1);
|
||||
fout.setf(std::ios::fixed,std::ios::floatfield);
|
||||
fout << std::left << fRuns[runNo].GetT0Bin(j);
|
||||
}
|
||||
fout << std::endl;
|
||||
}
|
||||
}
|
||||
for (UInt_t i=0; i<fRuns[runNo].GetAddT0BinEntries(); i++) {
|
||||
if (addt0TagMissing[runNo][i] && fRuns[runNo].GetInstitute()->CompareTo("isis", TString::kIgnoreCase)) {
|
||||
if (fRuns[runNo].GetAddT0BinSize(i) > 0) {
|
||||
fout.width(16);
|
||||
fout << std::left << "addt0";
|
||||
for (Int_t j=0; j<fRuns[runNo].GetAddT0BinSize(i); j++) {
|
||||
fout.width(8);
|
||||
fout.precision(1);
|
||||
fout.setf(std::ios::fixed,std::ios::floatfield);
|
||||
fout << std::left << fRuns[runNo].GetAddT0Bin(i, j);
|
||||
}
|
||||
fout << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (backgroundTagMissing[runNo]) {
|
||||
if (fRuns[runNo].GetBkgRange(0) >= 0) {
|
||||
fout.width(16);
|
||||
fout << std::left << "background";
|
||||
for (UInt_t j=0; j<4; j++) {
|
||||
if (fRuns[runNo].GetBkgRange(j) > 0) {
|
||||
fout.width(8);
|
||||
fout << std::left << fRuns[runNo].GetBkgRange(j);
|
||||
}
|
||||
}
|
||||
fout << std::endl;
|
||||
}
|
||||
}
|
||||
if (dataTagMissing[runNo]) {
|
||||
if (fRuns[runNo].GetDataRange(0) >= 0) {
|
||||
fout.width(16);
|
||||
fout << std::left << "data";
|
||||
for (UInt_t j=0; j<4; j++) {
|
||||
if (fRuns[runNo].GetDataRange(j) > 0) {
|
||||
fout.width(8);
|
||||
fout << std::left << fRuns[runNo].GetDataRange(j);
|
||||
}
|
||||
}
|
||||
fout << std::endl;
|
||||
}
|
||||
}
|
||||
writeMissingRunTags(runNo);
|
||||
// write fit range line
|
||||
fout.width(16);
|
||||
fout << std::left << "fit";
|
||||
@@ -1163,6 +1193,10 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
} else {
|
||||
fout << str.Data() << std::endl;
|
||||
}
|
||||
// no 'fit' line in the RUN block (fit range given in the GLOBAL block), hence
|
||||
// write missing tags after the last line of the RUN block
|
||||
if (fitTagMissing[runNo] && (lineNo == lastRunLineNo[runNo]))
|
||||
writeMissingRunTags(runNo);
|
||||
break;
|
||||
case MSR_TAG_COMMANDS:
|
||||
fout << str.Data() << std::endl;
|
||||
|
||||
@@ -346,6 +346,16 @@ Int_t main(Int_t argc, Char_t *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
// t0's given in the GLOBAL block are not touched by the prompt peak estimate
|
||||
if (getT0FromPromptPeak && success) {
|
||||
PMsrGlobalBlock *global = msrHandler->GetMsrGlobal();
|
||||
if ((global->GetT0BinSize() > 0) || (global->GetAddT0BinEntries() > 0)) {
|
||||
std::cerr << std::endl << ">> musrt0 **WARNING** 't0' and/or 'addt0' already found in the GLOBAL block.";
|
||||
std::cerr << std::endl << ">> Will not estimate t0's from the prompt peak, the msr-file is left untouched." << std::endl << std::endl;
|
||||
return PMUSR_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
if (getT0FromPromptPeak && success) {
|
||||
|
||||
Int_t histoNo = -1;
|
||||
|
||||
Reference in new issue
Block a user