From 001aed134cad677c5fb0042a5902340fd23196c2 Mon Sep 17 00:00:00 2001 From: Suter Andreas Date: Fri, 4 Sep 2015 16:23:27 +0200 Subject: [PATCH 1/4] minor change in Fourier-block output (PMsrHandler::WriteMsrLogFileand PMsrHandler::WriteMsrLogFile) to avoid truncated range labels. --- ChangeLog | 4 +++- src/classes/PMsrHandler.cpp | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 32e077e2..2779193d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,7 +5,9 @@ changes since 0.14.0 =================================== NEW 2015-02-23 implemented an average-per-data-set option for musrFT. -NEW 2015-02-21 add proper Mac icon to musredit +NEW 2015-02-21 add proper Mac icon to musredit +FIXED 2015-09-04 minor change in Fourier-block output (PMsrHandler::WriteMsrLogFile + and PMsrHandler::WriteMsrLogFile) to avoid truncated range labels. FIXED 2015-06-30 changed setf/unsetf bug (PMsr2Data.cpp) FIXED 2015-05-15 another path check for HDF5 with ubuntu 15.04 FIXED 2015-03-16 some minor correction for ASCII export in any2many diff --git a/src/classes/PMsrHandler.cpp b/src/classes/PMsrHandler.cpp index e851b315..7601309d 100644 --- a/src/classes/PMsrHandler.cpp +++ b/src/classes/PMsrHandler.cpp @@ -1089,6 +1089,7 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages) } else if (sstr.BeginsWith("range_for_phase_correction")) { fout << "range_for_phase_correction " << fFourier.fRangeForPhaseCorrection[0] << " " << fFourier.fRangeForPhaseCorrection[1] << endl; } else if (sstr.BeginsWith("range ")) { + fout.unsetf(ios::floatfield); fout << "range " << fFourier.fPlotRange[0] << " " << fFourier.fPlotRange[1] << endl; } else { fout << str.Data() << endl; @@ -1971,6 +1972,7 @@ Int_t PMsrHandler::WriteMsrFile(const Char_t *filename, map *co // range if ((fFourier.fPlotRange[0] != -1.0) || (fFourier.fPlotRange[1] != -1.0)) { + fout.unsetf(ios::floatfield); fout << "range " << fFourier.fPlotRange[0] << " " << fFourier.fPlotRange[1] << endl; } From 4d211ddcc150d92d6b4292afe523019cd9455ff5 Mon Sep 17 00:00:00 2001 From: Suter Andreas Date: Fri, 4 Sep 2015 17:36:57 +0200 Subject: [PATCH 2/4] updated to the previous incomplete fix. FOURIER range is not truncated anymore. --- src/classes/PMsrHandler.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/classes/PMsrHandler.cpp b/src/classes/PMsrHandler.cpp index 7601309d..afac766b 100644 --- a/src/classes/PMsrHandler.cpp +++ b/src/classes/PMsrHandler.cpp @@ -1090,6 +1090,10 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages) fout << "range_for_phase_correction " << fFourier.fRangeForPhaseCorrection[0] << " " << fFourier.fRangeForPhaseCorrection[1] << endl; } else if (sstr.BeginsWith("range ")) { fout.unsetf(ios::floatfield); + neededPrec = LastSignificant(fFourier.fPlotRange[0]); + if (LastSignificant(fFourier.fPlotRange[1]) > neededPrec) + neededPrec = LastSignificant(fFourier.fPlotRange[1]); + fout.precision(neededPrec+1); fout << "range " << fFourier.fPlotRange[0] << " " << fFourier.fPlotRange[1] << endl; } else { fout << str.Data() << endl; @@ -1973,6 +1977,10 @@ Int_t PMsrHandler::WriteMsrFile(const Char_t *filename, map *co // range if ((fFourier.fPlotRange[0] != -1.0) || (fFourier.fPlotRange[1] != -1.0)) { fout.unsetf(ios::floatfield); + UInt_t neededPrec = LastSignificant(fFourier.fPlotRange[0]); + if (LastSignificant(fFourier.fPlotRange[1]) > neededPrec) + neededPrec = LastSignificant(fFourier.fPlotRange[1]); + fout.precision(neededPrec+1); fout << "range " << fFourier.fPlotRange[0] << " " << fFourier.fPlotRange[1] << endl; } From 8d496a41c0a854fcd23b125f67161f9278ccef8e Mon Sep 17 00:00:00 2001 From: Suter Andreas Date: Tue, 8 Sep 2015 08:50:26 +0200 Subject: [PATCH 3/4] added little root macro to check the c++ io formatting. --- src/tests/iotests/iotests.C | 99 +++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/tests/iotests/iotests.C diff --git a/src/tests/iotests/iotests.C b/src/tests/iotests/iotests.C new file mode 100644 index 00000000..edaeda91 --- /dev/null +++ b/src/tests/iotests/iotests.C @@ -0,0 +1,99 @@ +// in order to illustrate the c++ io stream formatting +// usage: 1) start root +// 2) root 5.34.x -> .L iotests.C // root 6.x.y -> .L iotests.C+ +// 3) iotests() + +#include +using namespace std; + +void dump_ioflags(const ios_base::fmtflags flags) +{ + cout << endl << ">> flags decoded:" << endl; + if (flags & ios_base::boolalpha) + cout << ">> read/write bool elements as alphabetic strings (true and false)." << endl; + if (flags & ios_base::showbase) + cout << ">> write integral values preceded by their corresponding numeric base prefix." << endl; + if (flags & ios_base::showpoint) + cout << ">> write floating-point values including always the decimal point." << endl; + if (flags & ios_base::showpos) + cout << ">> write non-negative numerical values preceded by a plus sign (+)." << endl; + if (flags & ios_base::skipws) + cout << ">> skip leading whitespaces on certain input operations." << endl; + if (flags & ios_base::unitbuf) + cout << ">> flush output after each inserting operation." << endl; + if (flags & ios_base::uppercase) + cout << ">> write uppercase letters replacing lowercase letters in certain insertion operations." << endl; + if (flags & ios_base::dec) + cout << ">> read/write integral values using decimal base format." << endl; + if (flags & ios_base::hex) + cout << ">> read/write integral values using hexadecimal base format." << endl; + if (flags & ios_base::oct) + cout << ">> read/write integral values using octal base format." << endl; + if (flags & ios_base::fixed) + cout << ">> write floating point values in fixed-point notation." << endl; + if (flags & ios_base::scientific) + cout << ">> write floating-point values in scientific notation." << endl; + if (flags & ios_base::internal) + cout << ">> the output is padded to the field width by inserting fill characters at a specified internal point." << endl; + if (flags & ios_base::left) + cout << ">> the output is padded to the field width appending fill characters at the end." << endl; + if (flags & ios_base::right) + cout << ">> the output is padded to the field width by inserting fill characters at the beginning." << endl; + cout << "---" << endl; +} + +void iotests() +{ + Double_t dval = 13.24; + + // default settings printout + cout << "default flags = " << cout.flags() << ":" << endl; + dump_ioflags(cout.flags()); + cout << "dval = " << dval << endl; + cout << "++++" << endl << endl; + // printout of the 'floatfield' flags + cout << "ios_base::floatfield :" << ios_base::floatfield << endl; + dump_ioflags(ios_base::floatfield); + cout << "set floatfield flags." << endl; + cout.setf(ios_base::floatfield); + cout << "dval = " << dval << endl; + cout << "++++" << endl << endl; + // unset 'floatfield' flags in order to see if the default is recovered + cout.unsetf(ios::floatfield); + cout << "cout.unsetf(ios::floatfield) -> cout.flags()=" << cout.flags() << endl; + dump_ioflags(cout.flags()); + cout << "dval = " << dval << endl; + cout << "++++" << endl << endl; + // set 'fixed' flag + cout.setf(ios_base::fixed); + cout << "cout.setf(ios_base::fixed) -> cout.flags()=" << cout.flags() << endl; + dump_ioflags(cout.flags()); + cout << "dval = " << dval << endl; + cout << "++++" << endl << endl; + // unset 'fixed' flag and set 'scientific' instead + cout.unsetf(ios_base::fixed); + cout << "cout.unsetf(ios_base::fixed)" << endl; + cout.setf(ios_base::scientific); + cout << "cout.setf(ios_base::scientific) -> cout.flags()=" << cout.flags() << endl; + dump_ioflags(cout.flags()); + cout << "dval = " << dval << endl; + cout << "++++" << endl << endl; + + // precision playground according to http://www.cplusplus.com/reference/ios/ios_base/precision/ + cout << "precision playground according to http://www.cplusplus.com/reference/ios/ios_base/precision/" << endl; + Double_t f = 3.14159; + cout.unsetf ( ios::floatfield ); // floatfield not set + cout << "cout.unsetf ( ios::floatfield ) -> cout.flags()=" << cout.flags() << endl; + dump_ioflags(cout.flags()); + cout.precision(5); + cout << "set cout.precision(5)" << endl; + cout << f << endl; + cout.precision(10); + cout << "set cout.precision(10)" << endl; + cout << f << endl; + cout.setf( ios::fixed, ios::floatfield ); // floatfield set to fixed + cout << "cout.setf( ios::fixed, ios::floatfield ) -> cout.flags()=" << cout.flags() << endl; + dump_ioflags(cout.flags()); + cout << f << endl; + cout << "++++" << endl << endl; +} From 5a00d49bbdbf3d720cba61ff1c27b378da5f81fa Mon Sep 17 00:00:00 2001 From: Suter Andreas Date: Tue, 8 Sep 2015 13:08:41 +0200 Subject: [PATCH 4/4] fixed error in view_packing for single histo (wrong norm of the theory). --- ChangeLog | 1 + src/classes/PRunSingleHisto.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2779193d..7d19ff69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ changes since 0.14.0 =================================== NEW 2015-02-23 implemented an average-per-data-set option for musrFT. NEW 2015-02-21 add proper Mac icon to musredit +FIXED 2015-09-08 fixed error in view_packing for single histo (wrong norm of the theory). FIXED 2015-09-04 minor change in Fourier-block output (PMsrHandler::WriteMsrLogFile and PMsrHandler::WriteMsrLogFile) to avoid truncated range labels. FIXED 2015-06-30 changed setf/unsetf bug (PMsr2Data.cpp) diff --git a/src/classes/PRunSingleHisto.cpp b/src/classes/PRunSingleHisto.cpp index 66f46131..7d8d14ee 100644 --- a/src/classes/PRunSingleHisto.cpp +++ b/src/classes/PRunSingleHisto.cpp @@ -861,7 +861,7 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi if (fScaleN0AndBkg) { dataNorm = 1.0/ (packing * (fTimeResolution * 1.0e3)); // fTimeResolution us->ns } else if (!fScaleN0AndBkg && (fMsrInfo->GetMsrPlotList()->at(0).fViewPacking > 0)) { - theoryNorm = (Double_t)fMsrInfo->GetMsrPlotList()->at(0).fViewPacking/(Double_t)packing; + theoryNorm = (Double_t)fMsrInfo->GetMsrPlotList()->at(0).fViewPacking/(Double_t)fPacking; } // raw data, since PMusrCanvas is doing ranging etc. @@ -1052,7 +1052,7 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo if (fScaleN0AndBkg) { dataNorm = 1.0/ (packing * (fTimeResolution * 1.0e3)); // fTimeResolution us->ns } else if (!fScaleN0AndBkg && (fMsrInfo->GetMsrPlotList()->at(0).fViewPacking > 0)) { - theoryNorm = (Double_t)fMsrInfo->GetMsrPlotList()->at(0).fViewPacking/(Double_t)packing; + theoryNorm = (Double_t)fMsrInfo->GetMsrPlotList()->at(0).fViewPacking/(Double_t)fPacking; } // transform raw histo data. This is done the following way (for details see the manual):