From 711d47ef18ebaeb516a7d5ff690b86bd04a103f7 Mon Sep 17 00:00:00 2001 From: nemu Date: Thu, 15 May 2008 14:57:51 +0000 Subject: [PATCH] different handling of the mapping input for PMsrHandler, and minor changes otherwise --- src/README | 5 +++ src/classes/PMsrHandler.cpp | 77 +++++++++++++++++++++++++++------ src/classes/PRunDataHandler.cpp | 11 ++++- 3 files changed, 77 insertions(+), 16 deletions(-) diff --git a/src/README b/src/README index eb50a940..9a6bba10 100644 --- a/src/README +++ b/src/README @@ -41,6 +41,11 @@ In order to get musrfit compiled, you need first to build the shared library lib make -f Makefile.musrfit make -f Makefile.musrfit install +If it doesn't work for linux, try to set first + +export OSTYPE=linux + +for some shells this is needed but I have no clue why it is NOT recognised automatically ... #--------------------------------------------------------------------- # this is the end ... diff --git a/src/classes/PMsrHandler.cpp b/src/classes/PMsrHandler.cpp index 2a3653a3..8d2d3b74 100644 --- a/src/classes/PMsrHandler.cpp +++ b/src/classes/PMsrHandler.cpp @@ -1208,17 +1208,13 @@ bool PMsrHandler::HandleRunEntry(PMsrLines &lines) ostr = dynamic_cast(tokens->At(i)); str = ostr->GetString(); if (str.IsDigit()) - // only fill map vector until a first zero is encountered - if (str.Atoi() != 0) - param.fMap.push_back(str.Atoi()); - else - break; + param.fMap.push_back(str.Atoi()); else error = true; } // check map entries, i.e. if the map values are within parameter bounds for (unsigned int i=0; i (int) fParam.size())) { + if ((param.fMap[i] < 0) || (param.fMap[i] > (int) fParam.size())) { cout << endl << "**SEVERE ERROR** in PMsrHandler::HandleRunEntry: map value " << param.fMap[i] << " in line " << iter->fLineNo << " is out of range!"; error = true; break; @@ -2023,7 +2019,8 @@ void PMsrHandler::FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLi // everything to lower case str.ToLower(); -//cout << endl << ">> " << str.Data(); +// cout << endl << "-----------------------"; +// cout << endl << ">> " << str.Data(); tokens = str.Tokenize(" /t"); if (!tokens) @@ -2038,8 +2035,9 @@ void PMsrHandler::FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLi // check if fun number is used, and if yes, filter parameter numbers and maps TString sstr; +// cout << endl << ">> fun.size() = " << fun.size(); for (unsigned int i=0; i> funNo: " << fun[i]; +// cout << endl << ">> funNo: " << fun[i]; if (fun[i] == ival) { // function number found // filter for parX sstr = iter->fLine; @@ -2047,7 +2045,7 @@ void PMsrHandler::FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLi while (sstr.Index("par") != -1) { memset(sval, 0, sizeof(sval)); sstr = &sstr[sstr.Index("par")+3]; // trunc sstr -//cout << endl << ">> par:sstr: " << sstr.Data(); +// cout << endl << ">> par:sstr: " << sstr.Data(); for (int j=0; j> map:sstr: " << sstr.Data(); +// cout << endl << ">> map:sstr: " << sstr.Data(); for (int j=0; j>>> mapX from func 1st, X = " << ival; +// cout << endl << ">>>> mapX from func 1st, X = " << ival; // check if map value already in map, otherwise add it if (ival > 0) { unsigned int pos; @@ -2150,13 +2148,17 @@ void PMsrHandler::FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLi // get the parameter number via map //cout << endl << ">> map.size() = " << map.size(); for (unsigned int i=0; iGetEntries()) { ostr = dynamic_cast(tokens->At(map[i])); str = ostr->GetString(); if (str.IsDigit()) { ival = str.Atoi(); - fParamInUse[ival-1]++; // this is OK since map is ranging from 1 .. + if (ival > 0) { + fParamInUse[ival-1]++; // this is OK since map is ranging from 1 .. //cout << endl << ">>>> param no : " << ival << ", via map no : " << map[i]; + } } } } @@ -2179,6 +2181,9 @@ void PMsrHandler::FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLi // everything to lower case str.ToLower(); +// cout << endl << "==========================="; +// cout << endl << ">> " << str.Data(); + tokens = str.Tokenize(" /t"); if (!tokens) continue; @@ -2206,8 +2211,8 @@ void PMsrHandler::FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLi sval[j] = sstr[j]; } sscanf(sval, "%d", &ival); -//cout << endl << ">>>> parX from func 2nd, X = " << ival; fParamInUse[ival-1]++; +//cout << endl << ">>>> parX from func 2nd, X = " << ival; } // filter for mapX @@ -2221,7 +2226,7 @@ void PMsrHandler::FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLi sval[j] = sstr[j]; } sscanf(sval, "%d", &ival); -//cout << endl << ">>>> mapX from func 2nd, X = " << ival; +// cout << endl << ">>>> mapX from func 2nd, X = " << ival; // check if map value already in map, otherwise add it if (ival > 0) { unsigned int pos; @@ -2244,6 +2249,50 @@ void PMsrHandler::FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLi } } + // go through all the run block lines 2nd time to filter remaining maps + for (iter = run.begin(); iter != run.end(); ++iter) { + // remove potential comments + str = iter->fLine; + if (str.First('#') != -1) + str.Resize(str.First('#')); + + // everything to lower case + str.ToLower(); + + // handle the maps + if (str.Contains("map")) { +//cout << endl << ">> " << str.Data(); + // tokenize string + tokens = str.Tokenize(" \t"); + if (!tokens) + continue; + + // get the parameter number via map +//cout << endl << ">> map.size() = " << map.size(); + for (unsigned int i=0; iGetEntries()) { + ostr = dynamic_cast(tokens->At(map[i])); + str = ostr->GetString(); + if (str.IsDigit()) { + ival = str.Atoi(); + if (ival > 0) { + fParamInUse[ival-1]++; // this is OK since map is ranging from 1 .. +//cout << endl << ">>>> param no : " << ival << ", via map no : " << map[i]; + } + } + } + } + + // delete tokens + if (tokens) { + delete tokens; + tokens = 0; + } + } + } + // cout << endl << ">> fParamInUse: "; // for (unsigned int i=0; i #include #include +#include #include "TLemRunHeader.h" #include "MuSR_td_PSI_bin.h" @@ -118,7 +119,7 @@ PRawRunData* PRunDataHandler::GetRunData(TString runName) unsigned int i; for (i=0; i> run name = " << fData[i].fRunName.Data(); +// cout << endl << ">> run name = " << fData[i].fRunName.Data(); if (!fData[i].fRunName.CompareTo(runName)) // run found break; } @@ -294,11 +295,17 @@ bool PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo) // WKMFULLDATAPATH has the structure: path_1:path_2:...:path_n TObjArray *tokens = str.Tokenize(":"); TObjString *ostr; + runInfo.fInstitute.ToUpper(); + runInfo.fBeamline.ToUpper(); + TDatime datetime; + TString dt; + dt += datetime.GetYear(); for (int i=0; iGetEntries(); i++) { ostr = dynamic_cast(tokens->At(i)); - str = ostr->GetString() + TString("/data/") + + str = ostr->GetString() + TString("/DATA/") + runInfo.fInstitute + TString("/") + runInfo.fBeamline + TString("/") + + dt + TString("/") + runInfo.fRunName + TString(".") + ext; cout << endl << ">> generated path: " << str.Data() << endl; if (gSystem->AccessPathName(str.Data())!=true) { // found