some bug fixing when counting parameters in use

This commit is contained in:
nemu 2008-03-14 13:00:32 +00:00
parent ef426d2a77
commit 470785ca0b
2 changed files with 14 additions and 4 deletions

View File

@ -279,7 +279,8 @@ bool PFitter::SetParameters()
// check if there is an unused parameter, if so, fix it // check if there is an unused parameter, if so, fix it
for (unsigned int i=0; i<fParams.size(); i++) { for (unsigned int i=0; i<fParams.size(); i++) {
if (fRunInfo->ParameterInUse(i) == 0) { // parameter not used in the whole theory!! // parameter not used in the whole theory and not already fixed!!
if ((fRunInfo->ParameterInUse(i) == 0) && (fParams[i].fStep != 0.0)) {
fMnUserParams.Fix(i); // fix the unused parameter so that minuit will not vary it fMnUserParams.Fix(i); // fix the unused parameter so that minuit will not vary it
cout << endl << "**WARNING** : Parameter No " << i+1 << " is not used at all, will fix it" << endl; cout << endl << "**WARNING** : Parameter No " << i+1 << " is not used at all, will fix it" << endl;
} }

View File

@ -1848,7 +1848,7 @@ void PMsrHandler::FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLi
str = ostr->GetString(); str = ostr->GetString();
if (str.IsDigit()) { // parameter number if (str.IsDigit()) { // parameter number
ival = str.Atoi(); ival = str.Atoi();
if ((ival > 0) && (ival < (int)fParam.size())) { if ((ival > 0) && (ival < (int)fParam.size()+1)) {
fParamInUse[ival-1]++; fParamInUse[ival-1]++;
//cout << endl << ">>>> theo: param no : " << ival; //cout << endl << ">>>> theo: param no : " << ival;
} }
@ -1856,6 +1856,7 @@ void PMsrHandler::FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLi
if (FilterFunMapNumber(str, "map", ival)) if (FilterFunMapNumber(str, "map", ival))
map.push_back(ival-MSR_PARAM_MAP_OFFSET); map.push_back(ival-MSR_PARAM_MAP_OFFSET);
} else if (str.Contains("fun")) { // fun } else if (str.Contains("fun")) { // fun
//cout << endl << "theo:fun: " << str.Data();
if (FilterFunMapNumber(str, "fun", ival)) if (FilterFunMapNumber(str, "fun", ival))
fun.push_back(ival-MSR_PARAM_FUN_OFFSET); fun.push_back(ival-MSR_PARAM_FUN_OFFSET);
} }
@ -1878,6 +1879,8 @@ void PMsrHandler::FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLi
// everything to lower case // everything to lower case
str.ToLower(); str.ToLower();
//cout << endl << ">> " << str.Data();
tokens = str.Tokenize(" /t"); tokens = str.Tokenize(" /t");
if (!tokens) if (!tokens)
continue; continue;
@ -1892,6 +1895,7 @@ void PMsrHandler::FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLi
// check if fun number is used, and if yes, filter parameter numbers and maps // check if fun number is used, and if yes, filter parameter numbers and maps
TString sstr; TString sstr;
for (unsigned int i=0; i<fun.size(); i++) { for (unsigned int i=0; i<fun.size(); i++) {
//cout << endl << ">> funNo: " << fun[i];
if (fun[i] == ival) { // function number found if (fun[i] == ival) { // function number found
// filter for parX // filter for parX
sstr = iter->fLine; sstr = iter->fLine;
@ -1899,6 +1903,7 @@ void PMsrHandler::FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLi
while (sstr.Index("par") != -1) { while (sstr.Index("par") != -1) {
memset(sval, 0, sizeof(sval)); memset(sval, 0, sizeof(sval));
sstr = &sstr[sstr.Index("par")+3]; // trunc sstr sstr = &sstr[sstr.Index("par")+3]; // trunc sstr
//cout << endl << ">> par:sstr: " << sstr.Data();
for (int j=0; j<sstr.Sizeof(); j++) { for (int j=0; j<sstr.Sizeof(); j++) {
if (!isdigit(sstr[j])) if (!isdigit(sstr[j]))
break; break;
@ -1914,6 +1919,7 @@ void PMsrHandler::FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLi
while (sstr.Index("map") != -1) { while (sstr.Index("map") != -1) {
memset(sval, 0, sizeof(sval)); memset(sval, 0, sizeof(sval));
sstr = &sstr[sstr.Index("map")+3]; // trunc sstr sstr = &sstr[sstr.Index("map")+3]; // trunc sstr
//cout << endl << ">> map:sstr: " << sstr.Data();
for (int j=0; j<sstr.Sizeof(); j++) { for (int j=0; j<sstr.Sizeof(); j++) {
if (!isdigit(sstr[j])) if (!isdigit(sstr[j]))
break; break;
@ -1928,11 +1934,12 @@ void PMsrHandler::FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLi
if (ival == map[pos]) if (ival == map[pos])
break; break;
} }
if ((unsigned int)ival == map.size()) { // new map value if (pos == map.size()) { // new map value
map.push_back(ival); map.push_back(ival);
} }
} }
} }
break; // since function was found, break the loop
} }
} }
@ -1990,12 +1997,14 @@ void PMsrHandler::FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLi
// handle the maps // handle the maps
if (str.Contains("map")) { if (str.Contains("map")) {
//cout << endl << ">> " << str.Data();
// tokenize string // tokenize string
tokens = str.Tokenize(" \t"); tokens = str.Tokenize(" \t");
if (!tokens) if (!tokens)
continue; continue;
// get the parameter number via map // get the parameter number via map
//cout << endl << ">> map.size() = " << map.size();
for (unsigned int i=0; i<map.size(); i++) { for (unsigned int i=0; i<map.size(); i++) {
if (map[i] < tokens->GetEntries()) { if (map[i] < tokens->GetEntries()) {
ostr = dynamic_cast<TObjString*>(tokens->At(map[i])); ostr = dynamic_cast<TObjString*>(tokens->At(map[i]));
@ -2094,7 +2103,7 @@ void PMsrHandler::FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLi
/* /*
cout << endl << ">> fParamInUse: "; cout << endl << ">> fParamInUse: ";
for (unsigned int i=0; i<fParamInUse.size(); i++) for (unsigned int i=0; i<fParamInUse.size(); i++)
cout << fParamInUse[i] << " "; cout << endl << i+1 << ", " << fParamInUse[i];
cout << endl; cout << endl;
*/ */