From 7cedf2eb14e6c4c6bca6d762540aea74215b478c Mon Sep 17 00:00:00 2001 From: nemu Date: Fri, 9 Sep 2011 06:37:22 +0000 Subject: [PATCH] FIXED wrong asymmetry fit plotting if data range is not provided (MUSR-203). Added units to run duration in TPsiRunHeader --- ChangeLog | 1 + src/classes/PRunAsymmetry.cpp | 20 +++++++++++++------- src/tests/PsiRoot/TPsiRunHeader.cpp | 8 ++++---- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 00005c0f..09c99a89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,7 @@ NEW the chi^2 calculation in single-histogram and asymmetry fits is parallelized if musrfit is built using a compiler supporting OpenMP (e.g. GCC >= 4.2) Using --disable-omp this feature can be disabled on the configure level. NEW any2many: force the user to define the exact NeXus ouput format (HDF4,HDF5,XML) +FIXED wrong asymmetry fit plotting if data range is not provided (MUSR-203) FIXED broken run-list interface to msr2data in musredit/musrgui (MUSR-202) FIXED some severe issues in the run-number-digit determination of msr2data introduced in late 2010 FIXED a musrview exception error when starting with t0's very much off to the positive side in the msr-file (MUSR-199) diff --git a/src/classes/PRunAsymmetry.cpp b/src/classes/PRunAsymmetry.cpp index 7e5704be..02f9eb45 100644 --- a/src/classes/PRunAsymmetry.cpp +++ b/src/classes/PRunAsymmetry.cpp @@ -1066,13 +1066,19 @@ Bool_t PRunAsymmetry::PrepareViewData(PRawRunData* runData, UInt_t histoNo[2]) Int_t offset = (Int_t)(10.0e-3/fTimeResolution); // needed in case first good bin is not given, default = 10ns // check if data range has been provided, and if not try to estimate them if (fRunInfo->GetDataRange(0) < 0) { - start[0] = (static_cast(t0[0])+offset) - ((static_cast(t0[0])+offset)/packing)*packing; - cerr << endl << ">> PRunAsymmetry::PrepareViewData(): **WARNING** data range (forward) was not provided, will try data range start = " << start[0] << "."; - cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; - cerr << endl; - } else if (fRunInfo->GetDataRange(2) < 0) { - start[1] = (static_cast(t0[1])+offset) - ((static_cast(t0[1])+offset)/packing)*packing; - cerr << endl << ">> PRunAsymmetry::PrepareViewData(): **WARNING** data range (backward) was not provided, will try data range start = " << start[1] << "."; + Int_t diff = offset; + + // calculate start position for plotting + Int_t val = static_cast(t0[1])+diff-packing*((static_cast(t0[1])+diff)/packing); + do { + if (static_cast(val)+t0[1]-t0[0] < 0.0) + val += packing; + } while (static_cast(val) + t0[1] - t0[0] < 0.0); + + start[0] = val; + start[1] = val + static_cast(t0[1] - t0[0]); + + cerr << endl << ">> PRunAsymmetry::PrepareViewData(): **WARNING** data range (forward/backward) not provided, will try data range start = t0_f/b+10ns."; cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; } else { diff --git a/src/tests/PsiRoot/TPsiRunHeader.cpp b/src/tests/PsiRoot/TPsiRunHeader.cpp index 01b2fa32..a6da4032 100644 --- a/src/tests/PsiRoot/TPsiRunHeader.cpp +++ b/src/tests/PsiRoot/TPsiRunHeader.cpp @@ -641,7 +641,7 @@ TObjArray* TPsiRunHeader::GetHeader(UInt_t &count) fHeader.AddLast(tostr); // add run duration - str.Form("%03d - Run Duration: %d", count++, GetRunDuration()); + str.Form("%03d - Run Duration: %d sec", count++, GetRunDuration()); tostr = new TObjString(str); fHeader.AddLast(tostr); @@ -1021,12 +1021,12 @@ Bool_t TPsiRunHeader::ExtractHeaderInformation(TObjArray *headerInfo, TString pa } else if (str.Contains("- Run Number: ")) { tokens = str.Tokenize(":"); if (tokens->GetEntries() < 2) { - cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** " << str.Data() << " couldn't tokenize it." << endl << endl; + cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** '" << str.Data() << "' couldn't tokenize it." << endl << endl; return false; } ostr = dynamic_cast(tokens->At(1)); if (!ostr->GetString().IsDigit()) { - cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** " << str.Data() << " doesn't contain a valid run number" << endl << endl; + cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** '" << str.Data() << "' doesn't contain a valid run number" << endl << endl; return false; } fRunNumber = ostr->GetString().Atoi(); @@ -1550,7 +1550,7 @@ void TPsiRunHeader::DumpHeader() const cout << endl << setw(name_width) << left << "Run Stop Time" << setw(old_width) << ": " << GetStopTimeString(); // write run duration - cout << endl << setw(name_width) << left << "Run Duration" << setw(old_width) << ": " << GetRunDuration(); + cout << endl << setw(name_width) << left << "Run Duration" << setw(old_width) << ": " << GetRunDuration() << " sec"; // write laboratory cout << endl << setw(name_width) << left << "Laboratory" << setw(old_width) << ": " << GetLaboratory().Data();