42#include "PStringUtils.h"
87 while (fFileName.Index(
"/", idx+1) != -1) {
88 idx = fFileName.Index(
"/", idx+1);
93 fMsrFileDirectoryPath =
"./";
198 f.open(
fFileName.Data(), std::iostream::in);
214 current.
fLine = line;
216 if (line.BeginsWith(
"#") || line.IsWhitespace()) {
221 line.Remove(TString::kLeading,
' ');
223 if (!line.IsWhitespace()) {
227 }
else if (line.BeginsWith(
"FITPARAMETER")) {
229 }
else if (line.BeginsWith(
"THEORY")) {
231 theory.push_back(current);
232 }
else if (line.BeginsWith(
"FUNCTIONS")) {
234 functions.push_back(current);
235 }
else if (line.BeginsWith(
"GLOBAL")) {
237 global.push_back(current);
238 }
else if (line.BeginsWith(
"RUN")) {
240 run.push_back(current);
241 }
else if (line.BeginsWith(
"COMMANDS")) {
243 commands.push_back(current);
244 }
else if (line.BeginsWith(
"FOURIER")) {
246 fourier.push_back(current);
247 }
else if (line.BeginsWith(
"PLOT")) {
249 plot.push_back(current);
250 }
else if (line.BeginsWith(
"STATISTIC")) {
252 statistic.push_back(current);
257 fit_parameter.push_back(current);
260 theory.push_back(current);
263 functions.push_back(current);
266 global.push_back(current);
269 run.push_back(current);
272 commands.push_back(current);
275 fourier.push_back(current);
278 plot.push_back(current);
281 statistic.push_back(current);
323 for (UInt_t i=0; i<
fCommands.size(); i++) {
324 if (
fCommands[i].fLine.Contains(
"MAX_LIKELIHOOD"))
343 fLastErrorMsg <<
">> PMsrHandler::ReadMsrFile: **SEVERE ERROR** parameter name " <<
fParam[parX].fName.Data() <<
" is identical for parameter no " <<
fParam[parX].fNo <<
" and " <<
fParam[parY].fNo <<
"!\n";
389 fit_parameter.clear();
445 const UInt_t prec = 6;
446 UInt_t neededPrec = 0;
447 UInt_t neededWidth = 9;
449 Int_t tag, lineNo = 0, number;
450 Int_t runNo = -1, addRunNo = 0;
453 TString logFileName, str, sstr, *pstr;
454 Bool_t found =
false;
455 Bool_t statisticBlockFound =
false;
456 Bool_t partialStatisticBlockFound =
true;
459 for (UInt_t i=0; i<
fRuns.size(); i++) {
460 t0TagMissing.push_back(
true);
462 std::vector<PBoolVector> addt0TagMissing;
464 for (UInt_t i=0; i<
fRuns.size(); i++) {
466 for (UInt_t j=0; j<
fRuns[i].GetAddT0BinEntries(); j++)
467 bvec.push_back(
true);
468 addt0TagMissing.push_back(bvec);
471 for (UInt_t i=0; i<
fRuns.size(); i++) {
472 backgroundTagMissing.push_back(
true);
475 for (UInt_t i=0; i<
fRuns.size(); i++) {
476 dataTagMissing.push_back(
true);
480 Int_t addT0Counter = 0;
481 Int_t addT0GlobalCounter = 0;
488 fin.open(
fFileName.Data(), std::iostream::in);
489 if (!fin.is_open()) {
497 if (str.BeginsWith(
"RUN")) {
505 if (str.BeginsWith(
"t0"))
506 t0TagMissing[runNo] =
false;
507 else if (str.BeginsWith(
"background"))
508 backgroundTagMissing[runNo] =
false;
509 else if (str.BeginsWith(
"data"))
510 dataTagMissing[runNo] =
false;
517 while (
fFileName.Index(
".", idx+1) != -1) {
525 logFileName.Remove(idx+1);
526 logFileName +=
"mlog";
529 fin.open(
fFileName.Data(), std::iostream::in);
530 if (!fin.is_open()) {
535 fout.open(logFileName.Data(), std::iostream::out);
536 if (!fout.is_open()) {
552 if (str.BeginsWith(
"FITPARAMETER")) {
554 }
else if (str.BeginsWith(
"THEORY")) {
556 fout << str.Data() << std::endl;
558 }
else if (str.BeginsWith(
"FUNCTIONS")) {
560 fout << str.Data() << std::endl;
562 }
else if (str.BeginsWith(
"GLOBAL")) {
564 fout << str.Data() << std::endl;
566 }
else if (str.BeginsWith(
"RUN")) {
571 }
else if (str.BeginsWith(
"COMMANDS")) {
573 fout << str.Data() << std::endl;
575 }
else if (str.BeginsWith(
"FOURIER")) {
577 fout << str.Data() << std::endl;
579 }
else if (str.BeginsWith(
"PLOT")) {
582 }
else if (str.BeginsWith(
"STATISTIC")) {
590 fout <<
fTitle.Data() << std::endl;
592 fout << str.Data() << std::endl;
595 std::vector<std::string> tokens = PStringUtils::Split(str.Data(),
" \t");
596 if (tokens.empty()) {
597 fout << str.Data() << std::endl;
599 if (PStringUtils::IsInt(tokens[0])) {
600 number = PStringUtils::ToInt(tokens[0]);
603 assert ((number >= 0) && (number < (Int_t)
fParam.size()));
606 fout << std::right <<
fParam[number].fNo;
610 fout << std::left <<
fParam[number].fName.Data();
613 if (
fParam[number].fStep == 0.0)
622 neededWidth = neededPrec + 3;
623 fout.width(neededWidth);
624 fout.setf(std::ios::fixed, std::ios::floatfield);
625 fout.precision(neededPrec);
626 fout << std::left <<
fParam[number].fValue;
630 fout.setf(std::ios::fixed);
631 if (
fParam[number].fStep == 0.0)
633 fout.precision(neededPrec);
634 fout << std::left <<
fParam[number].fStep;
637 fout.setf(std::ios::fixed);
638 fout.precision(neededPrec);
639 if ((
fParam[number].fNoOfParams == 5) || (
fParam[number].fNoOfParams == 7))
640 if (
fParam[number].fPosErrorPresent && (
fParam[number].fStep != 0))
641 fout << std::left <<
fParam[number].fPosError;
643 fout << std::left <<
"none";
645 fout << std::left <<
"none";
647 fout.unsetf(std::ios::floatfield);
649 if (
fParam[number].fNoOfParams > 5) {
651 fout.precision(prec);
652 if (
fParam[number].fLowerBoundaryPresent)
653 fout << std::left <<
fParam[number].fLowerBoundary;
655 fout << std::left <<
"none";
658 fout.precision(prec);
659 if (
fParam[number].fUpperBoundaryPresent)
660 fout << std::left <<
fParam[number].fUpperBoundary;
662 fout << std::left <<
"none";
667 fout << str.Data() << std::endl;
674 for (UInt_t i=0; i<
fTheory.size(); i++) {
675 if (
fTheory[i].fLineNo == lineNo) {
676 fout <<
fTheory[i].fLine.Data() << std::endl;
681 fout << str.Data() << std::endl;
686 sstr.Remove(TString::kLeading,
' ');
687 if (str.BeginsWith(
"fun")) {
692 fout << sstr.Data() << std::endl;
695 fout << str.Data() << std::endl;
700 if (sstr.BeginsWith(
"fittype")) {
702 switch (
fGlobal.GetFitType()) {
710 fout << std::left <<
"fittype" <<
MSR_FITTYPE_ASYM <<
" (asymmetry fit)" << std::endl ;
719 fout << std::left <<
"fittype" <<
MSR_FITTYPE_BNMR <<
" (beta-NMR fit)" << std::endl ;
729 fout << std::left <<
"rrf_freq ";
732 fout.precision(neededPrec);
733 fout << std::left << std::fixed <<
fGlobal.GetRRFFreq(
fGlobal.GetRRFUnit().Data());
734 fout <<
" " <<
fGlobal.GetRRFUnit();
738 fout <<
"rrf_phase ";
740 fout << std::left <<
fGlobal.GetRRFPhase();
744 fout <<
"rrf_packing ";
746 fout << std::left <<
fGlobal.GetRRFPacking();
748 }
else if (sstr.BeginsWith(
"data")) {
750 fout << std::left <<
"data";
751 for (UInt_t j=0; j<4; j++) {
752 if (
fGlobal.GetDataRange(j) > 0) {
754 fout << std::left <<
fGlobal.GetDataRange(j);
758 }
else if (sstr.BeginsWith(
"t0")) {
760 fout << std::left <<
"t0";
761 for (UInt_t j=0; j<
fGlobal.GetT0BinSize(); j++) {
764 fout.setf(std::ios::fixed,std::ios::floatfield);
765 fout << std::left <<
fGlobal.GetT0Bin(j);
768 }
else if (sstr.BeginsWith(
"addt0")) {
770 fout << std::left <<
"addt0";
771 for (Int_t j=0; j<
fGlobal.GetAddT0BinSize(addT0GlobalCounter); j++) {
774 fout.setf(std::ios::fixed,std::ios::floatfield);
775 fout << std::left <<
fGlobal.GetAddT0Bin(addT0GlobalCounter, j);
778 addT0GlobalCounter++;
779 }
else if (sstr.BeginsWith(
"fit")) {
781 fout << std::left <<
"fit";
782 if (
fGlobal.IsFitRangeInBin()) {
784 if (
fGlobal.GetFitRangeOffset(0) > 0)
785 fout <<
"+" <<
fGlobal.GetFitRangeOffset(0);
787 if (
fGlobal.GetFitRangeOffset(1) > 0)
788 fout <<
"-" <<
fGlobal.GetFitRangeOffset(1);
792 fout.precision(neededPrec);
793 fout <<
" # in time: " <<
fGlobal.GetFitRange(0) <<
".." <<
fGlobal.GetFitRange(1) <<
" (usec)";
795 for (UInt_t j=0; j<2; j++) {
796 if (
fGlobal.GetFitRange(j) == -1)
800 fout.width(neededWidth);
801 fout.precision(neededPrec);
802 fout << std::left << std::fixed <<
fGlobal.GetFitRange(j);
808 }
else if (sstr.BeginsWith(
"packing")) {
810 fout << std::left <<
"packing";
811 fout <<
fGlobal.GetPacking() << std::endl;
812 }
else if (sstr.BeginsWith(
"deadtime-cor")) {
814 fout << std::left <<
"deadtime-cor";
815 fout <<
fGlobal.GetDeadTimeCorrection() << std::endl;
817 fout << str.Data() << std::endl;
822 sstr.Remove(TString::kLeading,
' ');
823 if (sstr.BeginsWith(
"RUN")) {
825 fout <<
"RUN " <<
fRuns[runNo].GetRunName()->Data() <<
" ";
826 pstr =
fRuns[runNo].GetBeamline();
827 if (pstr ==
nullptr) {
828 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **ERROR** Couldn't obtain beamline data." << std::endl;
832 fout << pstr->Data() <<
" ";
833 pstr =
fRuns[runNo].GetInstitute();
834 if (pstr ==
nullptr) {
835 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **ERROR** Couldn't obtain institute data." << std::endl;
839 fout << pstr->Data() <<
" ";
840 pstr =
fRuns[runNo].GetFileFormat();
841 if (pstr ==
nullptr) {
842 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **ERROR** Couldn't obtain file format data." << std::endl;
846 fout << pstr->Data() <<
" (name beamline institute data-file-format)" << std::endl;
847 }
else if (sstr.BeginsWith(
"ADDRUN")) {
849 fout <<
"ADDRUN " <<
fRuns[runNo].GetRunName(addRunNo)->Data() <<
" ";
850 pstr =
fRuns[runNo].GetBeamline(addRunNo);
851 if (pstr ==
nullptr) {
852 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **ERROR** Couldn't obtain beamline data (addrun)." << std::endl;
856 fout << pstr->Data() <<
" ";
857 pstr =
fRuns[runNo].GetInstitute(addRunNo);
858 if (pstr ==
nullptr) {
859 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **ERROR** Couldn't obtain institute data (addrun)." << std::endl;
863 fout << pstr->Data() <<
" ";
864 pstr =
fRuns[runNo].GetFileFormat(addRunNo);
865 if (pstr ==
nullptr) {
866 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **ERROR** Couldn't obtain file format data (addrun)." << std::endl;
870 fout << pstr->Data() <<
" (name beamline institute data-file-format)" << std::endl;
871 }
else if (sstr.BeginsWith(
"fittype")) {
873 switch (
fRuns[runNo].GetFitType()) {
881 fout << std::left <<
"fittype" <<
MSR_FITTYPE_ASYM <<
" (asymmetry fit)" << std::endl ;
890 fout << std::left <<
"fittype" <<
MSR_FITTYPE_BNMR <<
" (beta-NMR fit)" << std::endl ;
898 }
else if (sstr.BeginsWith(
"alpha ")) {
900 fout << std::left <<
"alpha";
905 fout <<
fRuns[runNo].GetAlphaParamNo();
907 }
else if (sstr.BeginsWith(
"beta ")) {
909 fout << std::left <<
"beta";
913 fout <<
fRuns[runNo].GetBetaParamNo();
915 }
else if (sstr.BeginsWith(
"norm")) {
917 fout << std::left <<
"norm";
922 fout <<
fRuns[runNo].GetNormParamNo();
924 }
else if (sstr.BeginsWith(
"backgr.fit")) {
926 fout << std::left <<
"backgr.fit";
927 fout <<
fRuns[runNo].GetBkgFitParamNo() << std::endl;
928 }
else if (sstr.BeginsWith(
"lifetime ")) {
930 fout << std::left <<
"lifetime";
931 fout <<
fRuns[runNo].GetLifetimeParamNo() << std::endl;
932 }
else if (sstr.BeginsWith(
"lifetimecorrection")) {
934 }
else if (sstr.BeginsWith(
"map")) {
936 for (UInt_t j=0; j<
fRuns[runNo].GetMap()->size(); j++) {
938 fout << std::right <<
fRuns[runNo].GetMap(j);
941 if (
fRuns[runNo].GetMap()->size() < 10) {
942 for (UInt_t j=
fRuns[runNo].GetMap()->size(); j<10; j++)
946 }
else if (sstr.BeginsWith(
"forward")) {
947 if (
fRuns[runNo].GetForwardHistoNoSize() == 0) {
948 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **WARNING** 'forward' tag without any data found!";
949 std::cerr << std::endl <<
">> Something is VERY fishy, please check your msr-file carfully." << std::endl;
953 for (UInt_t i=0; i<
fRuns[runNo].GetForwardHistoNoSize(); i++)
954 forward.push_back(
fRuns[runNo].GetForwardHistoNo(i));
957 fout << result.Data() << std::endl;
959 }
else if (sstr.BeginsWith(
"backward")) {
960 if (
fRuns[runNo].GetBackwardHistoNoSize() == 0) {
961 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **WARNING** 'backward' tag without any data found!";
962 std::cerr << std::endl <<
">> Something is VERY fishy, please check your msr-file carfully." << std::endl;
966 for (UInt_t i=0; i<
fRuns[runNo].GetBackwardHistoNoSize(); i++)
967 backward.push_back(
fRuns[runNo].GetBackwardHistoNo(i));
970 fout << result.Data() << std::endl;
972 }
else if (sstr.BeginsWith(
"backgr.fix")) {
974 fout << std::left <<
"backgr.fix";
975 for (UInt_t j=0; j<2; j++) {
977 fout.precision(prec);
979 fout << std::left <<
fRuns[runNo].GetBkgFix(j);
983 }
else if (sstr.BeginsWith(
"background")) {
984 backgroundTagMissing[runNo] =
false;
986 fout << std::left <<
"background";
987 for (UInt_t j=0; j<4; j++) {
988 if (
fRuns[runNo].GetBkgRange(j) > 0) {
990 fout << std::left <<
fRuns[runNo].GetBkgRange(j);
995 if ((Int_t)log10(
fRuns[runNo].GetBkgEstimated(0))+1 >= 4)
997 fout <<
" # estimated bkg: ";
999 fout.precision(precision);
1000 fout <<
fRuns[runNo].GetBkgEstimated(0);
1004 fout.precision(precision);
1005 fout <<
fRuns[runNo].GetBkgEstimated(1);
1009 }
else if (sstr.BeginsWith(
"data")) {
1010 dataTagMissing[runNo] =
false;
1012 fout << std::left <<
"data";
1013 for (UInt_t j=0; j<4; j++) {
1014 if (
fRuns[runNo].GetDataRange(j) > 0) {
1016 fout << std::left <<
fRuns[runNo].GetDataRange(j);
1020 }
else if (sstr.BeginsWith(
"t0")) {
1021 t0TagMissing[runNo] =
false;
1023 fout << std::left <<
"t0";
1024 for (UInt_t j=0; j<
fRuns[runNo].GetT0BinSize(); j++) {
1027 fout.setf(std::ios::fixed,std::ios::floatfield);
1028 fout << std::left <<
fRuns[runNo].GetT0Bin(j);
1031 }
else if (sstr.BeginsWith(
"addt0")) {
1032 addt0TagMissing[runNo][addT0Counter] =
false;
1033 if (
fRuns[runNo].GetAddT0BinSize(addT0Counter) <=0) {
1034 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **WARNING** 'addt0' tag without any data found!";
1035 std::cerr << std::endl <<
">> Something is VERY fishy, please check your msr-file carfully." << std::endl;
1038 fout << std::left <<
"addt0";
1039 for (Int_t j=0; j<
fRuns[runNo].GetAddT0BinSize(addT0Counter); j++) {
1042 fout.setf(std::ios::fixed,std::ios::floatfield);
1043 fout << std::left <<
fRuns[runNo].GetAddT0Bin(addT0Counter, j);
1048 }
else if (sstr.BeginsWith(
"xy-data")) {
1049 if (
fRuns[runNo].GetXDataIndex() != -1) {
1051 fout << std::left <<
"xy-data";
1054 fout << std::left << std::fixed <<
fRuns[runNo].GetXDataIndex();
1057 fout << std::left << std::fixed <<
fRuns[runNo].GetYDataIndex();
1059 }
else if (!
fRuns[runNo].GetXDataLabel()->IsWhitespace()) {
1061 fout << std::left <<
"xy-data";
1063 fout << std::left << std::fixed <<
fRuns[runNo].GetXDataLabel()->Data();
1066 fout << std::left << std::fixed <<
fRuns[runNo].GetYDataLabel()->Data();
1069 }
else if (sstr.BeginsWith(
"fit")) {
1072 if (t0TagMissing[runNo] &&
fRuns[runNo].GetInstitute()->CompareTo(
"isis", TString::kIgnoreCase)) {
1073 if (
fRuns[runNo].GetT0BinSize() > 0) {
1075 fout << std::left <<
"t0";
1076 for (UInt_t j=0; j<
fRuns[runNo].GetT0BinSize(); j++) {
1079 fout.setf(std::ios::fixed,std::ios::floatfield);
1080 fout << std::left <<
fRuns[runNo].GetT0Bin(j);
1085 for (UInt_t i=0; i<
fRuns[runNo].GetAddT0BinEntries(); i++) {
1086 if (addt0TagMissing[runNo][i] &&
fRuns[runNo].GetInstitute()->CompareTo(
"isis", TString::kIgnoreCase)) {
1087 if (
fRuns[runNo].GetAddT0BinSize(i) > 0) {
1089 fout << std::left <<
"addt0";
1090 for (Int_t j=0; j<
fRuns[runNo].GetAddT0BinSize(i); j++) {
1093 fout.setf(std::ios::fixed,std::ios::floatfield);
1094 fout << std::left <<
fRuns[runNo].GetAddT0Bin(i, j);
1100 if (backgroundTagMissing[runNo]) {
1101 if (
fRuns[runNo].GetBkgRange(0) >= 0) {
1103 fout << std::left <<
"background";
1104 for (UInt_t j=0; j<4; j++) {
1105 if (
fRuns[runNo].GetBkgRange(j) > 0) {
1107 fout << std::left <<
fRuns[runNo].GetBkgRange(j);
1113 if (dataTagMissing[runNo]) {
1114 if (
fRuns[runNo].GetDataRange(0) >= 0) {
1116 fout << std::left <<
"data";
1117 for (UInt_t j=0; j<4; j++) {
1118 if (
fRuns[runNo].GetDataRange(j) > 0) {
1120 fout << std::left <<
fRuns[runNo].GetDataRange(j);
1128 fout << std::left <<
"fit";
1129 if (
fRuns[runNo].IsFitRangeInBin()) {
1131 if (
fRuns[runNo].GetFitRangeOffset(0) > 0)
1132 fout <<
"+" <<
fRuns[runNo].GetFitRangeOffset(0);
1134 if (
fRuns[runNo].GetFitRangeOffset(1) > 0)
1135 fout <<
"-" <<
fRuns[runNo].GetFitRangeOffset(1);
1139 fout.precision(neededPrec);
1140 fout <<
" # in time: " <<
fRuns[runNo].GetFitRange(0) <<
".." <<
fRuns[runNo].GetFitRange(1) <<
" (usec)";
1142 for (UInt_t j=0; j<2; j++) {
1143 if (
fRuns[runNo].GetFitRange(j) == -1)
1147 fout.width(neededWidth);
1148 fout.precision(neededPrec);
1149 fout << std::left << std::fixed <<
fRuns[runNo].GetFitRange(j);
1155 }
else if (sstr.BeginsWith(
"packing")) {
1157 fout << std::left <<
"packing";
1158 fout <<
fRuns[runNo].GetPacking() << std::endl;
1159 }
else if (sstr.BeginsWith(
"deadtime-cor")) {
1161 fout << std::left <<
"deadtime-cor";
1162 fout <<
fRuns[runNo].GetDeadTimeCorrection() << std::endl;
1164 fout << str.Data() << std::endl;
1168 fout << str.Data() << std::endl;
1172 sstr.Remove(TString::kLeading,
' ');
1173 if (sstr.BeginsWith(
"units")) {
1184 fout <<
" # units either 'Gauss', 'Tesla', 'MHz', or 'Mc/s'";
1186 }
else if (sstr.BeginsWith(
"fourier_power")) {
1187 fout <<
"fourier_power " <<
fFourier.fFourierPower << std::endl;
1188 }
else if (sstr.BeginsWith(
"dc-corrected")) {
1189 fout <<
"dc-corrected ";
1191 fout <<
"true" << std::endl;
1193 fout <<
"false" << std::endl;
1194 }
else if (sstr.BeginsWith(
"apodization")) {
1195 fout <<
"apodization ";
1205 fout <<
" # NONE, WEAK, MEDIUM, STRONG";
1207 }
else if (sstr.BeginsWith(
"plot")) {
1214 fout <<
"REAL_AND_IMAG";
1220 fout <<
"PHASE_OPT_REAL";
1222 fout <<
" # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE, PHASE_OPT_REAL";
1224 }
else if (sstr.BeginsWith(
"phase")) {
1225 if (
fFourier.fPhaseParamNo.size() > 0) {
1227 fout <<
"phase " << phaseParamStr << std::endl;
1228 }
else if (
fFourier.fPhase.size() > 0) {
1230 for (UInt_t i=0; i<
fFourier.fPhase.size()-1; i++) {
1231 fout <<
fFourier.fPhase[i] <<
", ";
1235 }
else if (sstr.BeginsWith(
"range_for_phase_correction")) {
1236 fout <<
"range_for_phase_correction " <<
fFourier.fRangeForPhaseCorrection[0] <<
" " <<
fFourier.fRangeForPhaseCorrection[1] << std::endl;
1237 }
else if (sstr.BeginsWith(
"range ")) {
1238 fout.setf(std::ios::fixed,std::ios::floatfield);
1242 fout.precision(neededPrec);
1243 fout <<
"range " <<
fFourier.fPlotRange[0] <<
" " <<
fFourier.fPlotRange[1] << std::endl;
1245 fout << str.Data() << std::endl;
1250 sstr.Remove(TString::kLeading,
' ');
1251 if (sstr.BeginsWith(
"PLOT")) {
1252 switch (
fPlots[plotNo].fPlotType) {
1254 fout <<
"PLOT " <<
fPlots[plotNo].fPlotType <<
" (single histo plot)" << std::endl;
1257 fout <<
"PLOT " <<
fPlots[plotNo].fPlotType <<
" (single histo RRF plot)" << std::endl;
1260 fout <<
"PLOT " <<
fPlots[plotNo].fPlotType <<
" (asymmetry plot)" << std::endl;
1263 fout <<
"PLOT " <<
fPlots[plotNo].fPlotType <<
" (asymmetry RRF plot)" << std::endl;
1266 fout <<
"PLOT " <<
fPlots[plotNo].fPlotType <<
" (mu minus plot)" << std::endl;
1269 fout <<
"PLOT " <<
fPlots[plotNo].fPlotType <<
" (beta-NMR asymmetry plot)" << std::endl;
1272 fout <<
"PLOT " <<
fPlots[plotNo].fPlotType <<
" (non muSR plot)" << std::endl;
1277 if (
fPlots[plotNo].fLifeTimeCorrection) {
1278 fout <<
"lifetimecorrection" << std::endl;
1280 }
else if (sstr.BeginsWith(
"lifetimecorrection")) {
1284 }
else if (sstr.BeginsWith(
"runs")) {
1287 for (UInt_t j=0; j<
fPlots[plotNo].fRuns.size(); j++) {
1289 fout <<
fPlots[plotNo].fRuns[j];
1292 }
else if (sstr.BeginsWith(
"range")) {
1295 fout.precision(neededPrec);
1296 fout <<
fPlots[plotNo].fTmin[0];
1299 fout.precision(neededPrec);
1300 fout <<
fPlots[plotNo].fTmax[0];
1301 if (
fPlots[plotNo].fYmin.size() > 0) {
1304 fout.precision(neededPrec);
1305 fout <<
fPlots[plotNo].fYmin[0] <<
" ";
1307 fout.precision(neededPrec);
1308 fout <<
fPlots[plotNo].fYmax[0];
1312 fout << str.Data() << std::endl;
1316 statisticBlockFound =
true;
1318 sstr.Remove(TString::kLeading,
' ');
1319 if (sstr.BeginsWith(
"STATISTIC")) {
1321 fout <<
"STATISTIC --- " << dt.AsSQLString() << std::endl;
1322 }
else if (sstr.BeginsWith(
"chisq") || sstr.BeginsWith(
"maxLH")) {
1323 partialStatisticBlockFound =
false;
1330 fout << str.Data() << std::endl;
1332 std::cout << std::endl << str.Data() << std::endl;
1337 str.Form(
" expected chisq = %.1lf, NDF = %d, expected chisq/NDF = %lf",
1340 str.Form(
" expected maxLH = %.1lf, NDF = %d, expected maxLH/NDF = %lf",
1345 fout << str.Data() << std::endl;
1348 std::cout << std::endl << str.Data() << std::endl;
1350 for (UInt_t i=0; i<
fStatistic.fMinExpectedPerHisto.size(); i++) {
1353 str.Form(
" run block %d: (NDF/red.chisq/red.chisq_e) = (%d/%lf/%lf)",
1356 str.Form(
" run block %d: (NDF/red.maxLH/red.maxLH_e) = (%d/%lf/%lf)",
1361 fout << str.Data() << std::endl;
1365 std::cout << str.Data() << std::endl;
1368 }
else if (
fStatistic.fNdfPerHisto.size() > 1) {
1369 for (UInt_t i=0; i<
fStatistic.fNdfPerHisto.size(); i++) {
1371 str.Form(
" run block %d: (NDF/red.chisq) = (%d/%lf)",
1374 str.Form(
" run block %d: (NDF/maxLH.chisq) = (%d/%lf)",
1379 fout << str.Data() << std::endl;
1383 std::cout << str.Data() << std::endl;
1387 fout <<
"*** FIT DID NOT CONVERGE ***" << std::endl;
1389 std::cout << std::endl <<
"*** FIT DID NOT CONVERGE ***" << std::endl;
1391 }
else if (sstr.BeginsWith(
"*** FIT DID NOT CONVERGE ***")) {
1392 partialStatisticBlockFound =
false;
1399 fout << str.Data() << std::endl;
1401 std::cout << std::endl << str.Data() << std::endl;
1406 str.Form(
" expected chisq = %.1lf, NDF = %d, expected chisq/NDF = %lf",
1409 str.Form(
" expected maxLH = %.1lf, NDF = %d, expected maxLH/NDF = %lf",
1414 fout << str.Data() << std::endl;
1417 std::cout << str.Data() << std::endl;
1419 for (UInt_t i=0; i<
fStatistic.fMinExpectedPerHisto.size(); i++) {
1422 str.Form(
" run block %d: (NDF/red.chisq/red.chisq_e) = (%d/%lf/%lf)",
1425 str.Form(
" run block %d: (NDF/red.maxLH/red.maxLH_e) = (%d/%lf/%lf)",
1430 fout << str.Data() << std::endl;
1434 std::cout << str.Data() << std::endl;
1437 }
else if (
fStatistic.fNdfPerHisto.size() > 1) {
1438 for (UInt_t i=0; i<
fStatistic.fNdfPerHisto.size(); i++) {
1440 str.Form(
" run block %d: (NDF/red.chisq) = (%d/%lf)",
1443 str.Form(
" run block %d: (NDF/red.maxLH) = (%d/%lf)",
1448 fout << str.Data() << std::endl;
1452 std::cout << str.Data() << std::endl;
1456 fout <<
"*** FIT DID NOT CONVERGE ***" << std::endl;
1458 std::cout << std::endl <<
"*** FIT DID NOT CONVERGE ***" << std::endl;
1461 if (str.Length() > 0) {
1463 sstr.Remove(TString::kLeading,
' ');
1464 if (!sstr.BeginsWith(
"expected chisq") && !sstr.BeginsWith(
"expected maxLH") && !sstr.BeginsWith(
"run block"))
1465 fout << str.Data() << std::endl;
1478 if (!statisticBlockFound) {
1479 partialStatisticBlockFound =
false;
1480 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **WARNING** no STATISTIC block present, will write a default one" << std::endl;
1481 fout <<
"###############################################################" << std::endl;
1483 fout <<
"STATISTIC --- " << dt.AsSQLString() << std::endl;
1490 fout << str.Data() << std::endl;
1492 std::cout << std::endl << str.Data() << std::endl;
1497 str.Form(
" expected chisq = %.1lf, NDF = %d, expected chisq/NDF = %lf",
1500 str.Form(
" expected maxLH = %.1lf, NDF = %d, expected maxLH/NDF = %lf",
1505 fout << str.Data() << std::endl;
1508 std::cout << str.Data() << std::endl;
1510 for (UInt_t i=0; i<
fStatistic.fMinExpectedPerHisto.size(); i++) {
1513 str.Form(
" run block %d: (NDF/red.chisq/red.chisq_e) = (%d/%lf/%lf)",
1516 str.Form(
" run block %d: (NDF/red.maxLH/red.maxLH_e) = (%d/%lf/%lf)",
1521 fout << str.Data() << std::endl;
1525 std::cout << str.Data() << std::endl;
1528 }
else if (
fStatistic.fNdfPerHisto.size() > 1) {
1529 for (UInt_t i=0; i<
fStatistic.fNdfPerHisto.size(); i++) {
1531 str.Form(
" run block %d: (NDF/red.chisq) = (%d/%lf)",
1534 str.Form(
" run block %d: (NDF/red.maxLH) = (%d/%lf)",
1539 fout << str.Data() << std::endl;
1543 std::cout << str.Data() << std::endl;
1547 fout <<
"*** FIT DID NOT CONVERGE ***" << std::endl;
1549 std::cout << std::endl <<
"*** FIT DID NOT CONVERGE ***" << std::endl;
1554 if (partialStatisticBlockFound) {
1555 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **WARNING** garbage STATISTIC block present in the msr-input file.";
1556 std::cerr << std::endl <<
">> ** WILL ADD SOME SENSIBLE STUFF, BUT YOU HAVE TO CHECK IT SINCE I AM **NOT** REMOVING THE GARBAGE! **" << std::endl;
1558 fout <<
"STATISTIC --- " << dt.AsSQLString() << std::endl;
1565 fout << str.Data() << std::endl;
1567 std::cout << std::endl << str.Data() << std::endl;
1572 str.Form(
" expected chisq = %.1lf, NDF = %d, expected chisq/NDF = %lf",
1575 str.Form(
" expected maxLH = %.1lf, NDF = %d, expected maxLH/NDF = %lf",
1580 fout << str.Data() << std::endl;
1583 std::cout << str.Data() << std::endl;
1585 for (UInt_t i=0; i<
fStatistic.fMinExpectedPerHisto.size(); i++) {
1588 str.Form(
" run block %d: (NDF/red.chisq/red.chisq_e) =(%d/%lf/%lf)",
1591 str.Form(
" run block %d: (NDF/red.maxLH/red.maxLH_e) =(%d/%lf/%lf)",
1596 fout << str.Data() << std::endl;
1600 std::cout << str.Data() << std::endl;
1603 }
else if (
fStatistic.fNdfPerHisto.size() > 1) {
1604 for (UInt_t i=0; i<
fStatistic.fNdfPerHisto.size(); i++) {
1606 str.Form(
" run block %d: (NDF/red.chisq) = (%d/%lf)",
1609 str.Form(
" run block %d: (NDF/red.maxLH) = (%d/%lf)",
1614 fout << str.Data() << std::endl;
1618 std::cout << str.Data() << std::endl;
1622 fout <<
"*** FIT DID NOT CONVERGE (4) ***" << std::endl;
1624 std::cout << std::endl <<
"*** FIT DID NOT CONVERGE ***" << std::endl;
1633 t0TagMissing.clear();
1634 backgroundTagMissing.clear();
1635 dataTagMissing.clear();
1691 std::map<UInt_t, TString> *commentsTHE, \
1692 std::map<UInt_t, TString> *commentsFUN, \
1693 std::map<UInt_t, TString> *commentsRUN)
1695 const UInt_t prec = 6;
1696 const TString hline =
"###############################################################";
1698 std::map<UInt_t, TString>::iterator iter;
1702 std::ofstream fout(filename);
1708 fout <<
fTitle.Data() << std::endl;
1709 fout << hline.Data() << std::endl;
1712 fout <<
"FITPARAMETER" << std::endl;
1713 fout <<
"# No Name Value Step Pos_Error Boundaries" << std::endl;
1715 for (i = 0; i <
fParam.size(); ++i) {
1717 iter = commentsPAR->find(i+1);
1718 if (iter != commentsPAR->end()) {
1720 fout <<
"# " << iter->second.Data() << std::endl;
1722 commentsPAR->erase(iter);
1727 fout << std::right <<
fParam[i].fNo;
1731 fout << std::left <<
fParam[i].fName.Data();
1735 fout.precision(prec);
1736 fout << std::left <<
fParam[i].fValue;
1740 fout.precision(prec);
1741 fout << std::left <<
fParam[i].fStep;
1744 fout.precision(prec);
1745 if ((
fParam[i].fNoOfParams == 5) || (
fParam[i].fNoOfParams == 7))
1746 if (
fParam[i].fPosErrorPresent && (
fParam[i].fStep != 0))
1747 fout << std::left <<
fParam[i].fPosError;
1749 fout << std::left <<
"none";
1751 fout << std::left <<
"none";
1754 if (
fParam[i].fNoOfParams > 5) {
1756 fout.precision(prec);
1757 if (
fParam[i].fLowerBoundaryPresent)
1758 fout << std::left <<
fParam[i].fLowerBoundary;
1760 fout << std::left <<
"none";
1763 fout.precision(prec);
1764 if (
fParam[i].fUpperBoundaryPresent)
1765 fout << std::left <<
fParam[i].fUpperBoundary;
1767 fout << std::left <<
"none";
1772 if (commentsPAR && !commentsPAR->empty()) {
1774 for(iter = commentsPAR->begin(); iter != commentsPAR->end(); ++iter) {
1775 fout <<
"# " << iter->second.Data() << std::endl;
1777 commentsPAR->clear();
1780 fout << hline.Data() << std::endl;
1783 fout <<
"THEORY" << std::endl;
1785 for (i = 1; i <
fTheory.size(); ++i) {
1787 iter = commentsTHE->find(i);
1788 if (iter != commentsTHE->end()) {
1790 fout <<
"# " << iter->second.Data() << std::endl;
1792 commentsTHE->erase(iter);
1795 fout <<
fTheory[i].fLine.Data() << std::endl;
1797 if (commentsTHE && !commentsTHE->empty()) {
1799 for(iter = commentsTHE->begin(); iter != commentsTHE->end(); ++iter) {
1800 fout <<
"# " << iter->second.Data() << std::endl;
1802 commentsTHE->clear();
1805 fout << hline.Data() << std::endl;
1811 fout <<
"FUNCTIONS" << std::endl;
1815 iter = commentsFUN->find(i);
1816 if (iter != commentsFUN->end()) {
1818 fout <<
"# " << iter->second.Data() << std::endl;
1820 commentsFUN->erase(iter);
1823 fout <<
fFunctions[i].fLine.Data() << std::endl;
1825 if (commentsFUN && !commentsFUN->empty()) {
1827 for(iter = commentsFUN->begin(); iter != commentsFUN->end(); ++iter) {
1828 fout <<
"# " << iter->second.Data() << std::endl;
1830 commentsFUN->clear();
1833 fout << hline.Data() << std::endl;
1837 fout <<
"GLOBAL" << std::endl;
1840 if (
fGlobal.GetFitType() != -1) {
1842 switch (
fGlobal.GetFitType()) {
1850 fout << std::left <<
"fittype" <<
MSR_FITTYPE_ASYM <<
" (asymmetry fit)" << std::endl ;
1853 fout << std::left <<
"fittype" <<
MSR_FITTYPE_ASYM_RRF <<
" (asymmetry RRF fit)" << std::endl ;
1859 fout << std::left <<
"fittype" <<
MSR_FITTYPE_BNMR <<
" (beta-NMR fit)" << std::endl ;
1872 fout << std::left <<
"rrf_freq ";
1874 fout << std::left <<
fGlobal.GetRRFFreq(
fGlobal.GetRRFUnit().Data());
1875 fout <<
" " <<
fGlobal.GetRRFUnit();
1880 fout <<
"rrf_phase ";
1882 fout << std::left <<
fGlobal.GetRRFPhase();
1887 fout <<
"rrf_packing ";
1889 fout << std::left <<
fGlobal.GetRRFPacking();
1894 if ((
fGlobal.GetDataRange(0) != -1) || (
fGlobal.GetDataRange(1) != -1) || (
fGlobal.GetDataRange(2) != -1) || (
fGlobal.GetDataRange(3) != -1)) {
1896 fout << std::left <<
"data";
1897 for (UInt_t j=0; j<4; ++j) {
1898 if (
fGlobal.GetDataRange(j) > 0) {
1900 fout << std::left <<
fGlobal.GetDataRange(j);
1907 if (
fGlobal.GetT0BinSize() > 0) {
1909 fout << std::left <<
"t0";
1910 for (UInt_t j=0; j<
fGlobal.GetT0BinSize(); ++j) {
1913 fout.setf(std::ios::fixed,std::ios::floatfield);
1914 fout << std::left <<
fGlobal.GetT0Bin(j);
1920 for (UInt_t j = 0; j <
fGlobal.GetAddT0BinEntries(); ++j) {
1921 if (
fGlobal.GetAddT0BinSize(j) > 0) {
1923 fout << std::left <<
"addt0";
1924 for (Int_t k=0; k<
fGlobal.GetAddT0BinSize(j); ++k) {
1927 fout.setf(std::ios::fixed,std::ios::floatfield);
1928 fout << std::left <<
fGlobal.GetAddT0Bin(j, k);
1935 if ( (
fGlobal.IsFitRangeInBin() &&
fGlobal.GetFitRangeOffset(0) != -1) ||
1938 fout << std::left <<
"fit";
1939 if (
fGlobal.IsFitRangeInBin()) {
1941 if (
fGlobal.GetFitRangeOffset(0) > 0)
1942 fout <<
"+" <<
fGlobal.GetFitRangeOffset(0);
1944 if (
fGlobal.GetFitRangeOffset(1) > 0)
1945 fout <<
"-" <<
fGlobal.GetFitRangeOffset(1);
1947 for (UInt_t j=0; j<2; j++) {
1948 if (
fGlobal.GetFitRange(j) == -1)
1950 UInt_t neededWidth = 7;
1952 fout.width(neededWidth);
1953 fout.precision(neededPrec);
1954 fout << std::left << std::fixed <<
fGlobal.GetFitRange(j);
1963 if (
fGlobal.GetPacking() != -1) {
1965 fout << std::left <<
"packing";
1966 fout <<
fGlobal.GetPacking() << std::endl;
1969 fout << std::endl << hline.Data() << std::endl;
1973 for (i = 0; i <
fRuns.size(); ++i) {
1975 iter = commentsRUN->find(i + 1);
1976 if (iter != commentsRUN->end()) {
1979 fout <<
"# " << iter->second.Data() << std::endl;
1981 commentsRUN->erase(iter);
1984 fout <<
"RUN " <<
fRuns[i].GetRunName()->Data() <<
" ";
1985 pstr =
fRuns[i].GetBeamline();
1986 if (pstr ==
nullptr) {
1987 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrFile: **ERROR** Couldn't obtain beamline data." << std::endl;
1991 fout << pstr->Data() <<
" ";
1992 pstr =
fRuns[i].GetInstitute();
1993 if (pstr ==
nullptr) {
1994 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrFile: **ERROR** Couldn't obtain institute data." << std::endl;
1998 fout << pstr->Data() <<
" ";
1999 pstr =
fRuns[i].GetFileFormat();
2000 if (pstr ==
nullptr) {
2001 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrFile: **ERROR** Couldn't obtain file format data." << std::endl;
2005 fout << pstr->Data() <<
" (name beamline institute data-file-format)" << std::endl;
2008 for (UInt_t j = 1; j <
fRuns[i].GetRunNameSize(); ++j) {
2009 fout <<
"ADDRUN " <<
fRuns[i].GetRunName(j)->Data() <<
" ";
2010 pstr =
fRuns[i].GetBeamline(j);
2011 if (pstr ==
nullptr) {
2012 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrFile: **ERROR** Couldn't obtain beamline data (addrun)." << std::endl;
2016 fout << pstr->Data() <<
" ";
2017 pstr =
fRuns[i].GetInstitute(j);
2018 if (pstr ==
nullptr) {
2019 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrFile: **ERROR** Couldn't obtain institute data (addrun)." << std::endl;
2023 fout << pstr->Data() <<
" ";
2024 pstr =
fRuns[i].GetFileFormat(j);
2025 if (pstr ==
nullptr) {
2026 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrFile: **ERROR** Couldn't obtain file format data (addrun)." << std::endl;
2030 fout << pstr->Data() <<
" (name beamline institute data-file-format)" << std::endl;
2034 if (
fRuns[i].GetFitType() != -1) {
2036 switch (
fRuns[i].GetFitType()) {
2044 fout << std::left <<
"fittype" <<
MSR_FITTYPE_ASYM <<
" (asymmetry fit)" << std::endl ;
2047 fout << std::left <<
"fittype" <<
MSR_FITTYPE_ASYM_RRF <<
" (asymmetry RRF fit)" << std::endl ;
2053 fout << std::left <<
"fittype" <<
MSR_FITTYPE_BNMR <<
" (beta-NMR fit)" << std::endl ;
2064 if (
fRuns[i].GetAlphaParamNo() != -1) {
2066 fout << std::left <<
"alpha";
2071 fout <<
fRuns[i].GetAlphaParamNo();
2076 if (
fRuns[i].GetBetaParamNo() != -1) {
2078 fout << std::left <<
"beta";
2083 fout <<
fRuns[i].GetBetaParamNo();
2088 if (
fRuns[i].GetNormParamNo() != -1) {
2090 fout << std::left <<
"norm";
2095 fout <<
fRuns[i].GetNormParamNo();
2100 if (
fRuns[i].GetBkgFitParamNo() != -1) {
2102 fout << std::left <<
"backgr.fit";
2103 fout <<
fRuns[i].GetBkgFitParamNo() << std::endl;
2107 if (
fRuns[i].GetLifetimeParamNo() != -1) {
2109 fout << std::left <<
"lifetime";
2110 fout <<
fRuns[i].GetLifetimeParamNo() << std::endl;
2115 fout <<
"lifetimecorrection" << std::endl;
2120 for (UInt_t j=0; j<
fRuns[i].GetMap()->size(); ++j) {
2122 fout << std::right <<
fRuns[i].GetMap(j);
2125 if (
fRuns[i].GetMap()->size() < 10) {
2126 for (UInt_t j=
fRuns[i].GetMap()->size(); j<10; ++j)
2132 if (
fRuns[i].GetForwardHistoNoSize() == 0) {
2133 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrFile: **WARNING** No 'forward' data found!";
2134 std::cerr << std::endl <<
">> Something is VERY fishy, please check your msr-file carfully." << std::endl;
2137 fout << std::left <<
"forward";
2138 for (UInt_t j=0; j<
fRuns[i].GetForwardHistoNoSize(); ++j) {
2140 fout <<
fRuns[i].GetForwardHistoNo(j);
2146 if (
fRuns[i].GetBackwardHistoNoSize() > 0) {
2148 fout << std::left <<
"backward";
2149 for (UInt_t j=0; j<
fRuns[i].GetBackwardHistoNoSize(); ++j) {
2151 fout <<
fRuns[i].GetBackwardHistoNo(j);
2159 fout << std::left <<
"backgr.fix";
2160 for (UInt_t j=0; j<2; ++j) {
2162 fout.precision(prec);
2164 fout << std::left <<
fRuns[i].GetBkgFix(j);
2171 if ((
fRuns[i].GetBkgRange(0) != -1) || (
fRuns[i].GetBkgRange(1) != -1) || (
fRuns[i].GetBkgRange(2) != -1) || (
fRuns[i].GetBkgRange(3) != -1)) {
2173 fout << std::left <<
"background";
2174 for (UInt_t j=0; j<4; ++j) {
2175 if (
fRuns[i].GetBkgRange(j) > 0) {
2177 fout << std::left <<
fRuns[i].GetBkgRange(j);
2184 if ((
fRuns[i].GetDataRange(0) != -1) || (
fRuns[i].GetDataRange(1) != -1) || (
fRuns[i].GetDataRange(2) != -1) || (
fRuns[i].GetDataRange(3) != -1)) {
2186 fout << std::left <<
"data";
2187 for (UInt_t j=0; j<4; ++j) {
2188 if (
fRuns[i].GetDataRange(j) > 0) {
2190 fout << std::left <<
fRuns[i].GetDataRange(j);
2197 if (
fRuns[i].GetT0BinSize() > 0) {
2199 fout << std::left <<
"t0";
2200 for (UInt_t j=0; j<
fRuns[i].GetT0BinSize(); ++j) {
2203 fout.setf(std::ios::fixed,std::ios::floatfield);
2204 fout << std::left <<
fRuns[i].GetT0Bin(j);
2210 if (
fRuns[i].GetAddT0BinEntries() > 0) {
2211 for (UInt_t j = 0; j <
fRuns[i].GetRunNameSize() - 1; ++j) {
2212 if (
fRuns[i].GetAddT0BinSize(j) > 0) {
2214 fout << std::left <<
"addt0";
2215 for (Int_t k=0; k<
fRuns[i].GetAddT0BinSize(j); ++k) {
2218 fout.setf(std::ios::fixed,std::ios::floatfield);
2219 fout << std::left <<
fRuns[i].GetAddT0Bin(j, k);
2227 if (
fRuns[i].GetXDataIndex() != -1) {
2229 fout << std::left <<
"xy-data";
2232 fout << std::left << std::fixed <<
fRuns[i].GetXDataIndex();
2235 fout << std::left << std::fixed <<
fRuns[i].GetYDataIndex();
2237 }
else if (!
fRuns[i].GetXDataLabel()->IsWhitespace()) {
2239 fout << std::left <<
"xy-data";
2241 fout << std::left << std::fixed <<
fRuns[i].GetXDataLabel()->Data();
2244 fout << std::left << std::fixed <<
fRuns[i].GetYDataLabel()->Data();
2249 if ( (
fRuns[i].IsFitRangeInBin() &&
fRuns[i].GetFitRangeOffset(0) != -1) ||
2252 fout << std::left <<
"fit";
2253 if (
fRuns[i].IsFitRangeInBin()) {
2255 if (
fRuns[i].GetFitRangeOffset(0) > 0)
2256 fout <<
"+" <<
fRuns[i].GetFitRangeOffset(0);
2258 if (
fRuns[i].GetFitRangeOffset(1) > 0)
2259 fout <<
"-" <<
fRuns[i].GetFitRangeOffset(1);
2261 for (UInt_t j=0; j<2; j++) {
2262 if (
fRuns[i].GetFitRange(j) == -1)
2264 UInt_t neededWidth = 7;
2266 fout.width(neededWidth);
2267 fout.precision(neededPrec);
2268 fout << std::left << std::fixed <<
fRuns[i].GetFitRange(j);
2277 if (
fRuns[i].GetPacking() != -1) {
2279 fout << std::left <<
"packing";
2280 fout <<
fRuns[i].GetPacking() << std::endl;
2286 if (commentsRUN && !commentsRUN->empty()) {
2287 for(iter = commentsRUN->begin(); iter != commentsRUN->end(); ++iter) {
2288 fout <<
"# " << iter->second.Data() << std::endl;
2291 commentsRUN->clear();
2293 fout << hline.Data() << std::endl;
2296 fout <<
"COMMANDS" << std::endl;
2297 for (i = 0; i <
fCommands.size(); ++i) {
2298 if (
fCommands[i].fLine.BeginsWith(
"SET BATCH") ||
fCommands[i].fLine.BeginsWith(
"END RETURN"))
2301 fout <<
fCommands[i].fLine.Data() << std::endl;
2304 fout << hline.Data() << std::endl;
2307 if (
fFourier.fFourierBlockPresent) {
2308 fout <<
"FOURIER" << std::endl;
2322 fout <<
" # units either 'Gauss', 'Tesla', 'MHz', or 'Mc/s'";
2327 if (
fFourier.fFourierPower != -1) {
2328 fout <<
"fourier_power " <<
fFourier.fFourierPower << std::endl;
2333 fout <<
"apodization ";
2343 fout <<
" # NONE, WEAK, MEDIUM, STRONG";
2355 fout <<
"REAL_AND_IMAG";
2361 fout <<
"PHASE_OPT_REAL";
2363 fout <<
" # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE, PHASE_OPT_REAL";
2368 if (
fFourier.fPhaseParamNo.size() > 0) {
2370 fout <<
"phase " << phaseParamStr << std::endl;
2371 }
else if (
fFourier.fPhase.size() > 0) {
2373 for (UInt_t i=0; i<
fFourier.fPhase.size()-1; i++) {
2374 fout <<
fFourier.fPhase[i] <<
", ";
2380 if ((
fFourier.fRangeForPhaseCorrection[0] != -1.0) || (
fFourier.fRangeForPhaseCorrection[1] != -1.0)) {
2381 fout <<
"range_for_phase_correction " <<
fFourier.fRangeForPhaseCorrection[0] <<
" " <<
fFourier.fRangeForPhaseCorrection[1] << std::endl;
2385 if ((
fFourier.fPlotRange[0] != -1.0) || (
fFourier.fPlotRange[1] != -1.0)) {
2386 fout.setf(std::ios::fixed,std::ios::floatfield);
2390 fout.precision(neededPrec);
2391 fout <<
"range " <<
fFourier.fPlotRange[0] <<
" " <<
fFourier.fPlotRange[1] << std::endl;
2400 fout << hline.Data() << std::endl;
2404 for (i = 0; i <
fPlots.size(); ++i) {
2405 switch (
fPlots[i].fPlotType) {
2407 fout <<
"PLOT " <<
fPlots[i].fPlotType <<
" (single histo plot)" << std::endl;
2410 fout <<
"PLOT " <<
fPlots[i].fPlotType <<
" (single histo RRF plot)" << std::endl;
2413 fout <<
"PLOT " <<
fPlots[i].fPlotType <<
" (asymmetry plot)" << std::endl;
2416 fout <<
"PLOT " <<
fPlots[i].fPlotType <<
" (asymmetry RRF plot)" << std::endl;
2419 fout <<
"PLOT " <<
fPlots[i].fPlotType <<
" (mu minus plot)" << std::endl;
2422 fout <<
"PLOT " <<
fPlots[i].fPlotType <<
" (beta-NMR asymmetry plot)" << std::endl;
2425 fout <<
"PLOT " <<
fPlots[i].fPlotType <<
" (non muSR plot)" << std::endl;
2434 for (UInt_t j=0; j<
fPlots[i].fRuns.size(); ++j) {
2436 fout <<
fPlots[i].fRuns[j];
2441 if ((
fPlots[i].fTmin.size() == 1) && (
fPlots[i].fTmax.size() == 1)) {
2444 fout <<
fPlots[i].fTmin[0] <<
" " <<
fPlots[i].fTmax[0];
2445 }
else if ((
fPlots[i].fTmin.size() > 1) && (
fPlots[i].fTmax.size() > 1)) {
2446 fout <<
"sub_ranges ";
2448 for (UInt_t j=0; j <
fPlots[i].fTmin.size(); ++j) {
2449 fout <<
" " <<
fPlots[i].fTmin[j] <<
" " <<
fPlots[i].fTmax[j];
2452 if (!
fPlots[i].fYmin.empty() && !
fPlots[i].fYmax.empty()) {
2453 fout <<
" " <<
fPlots[i].fYmin[0] <<
" " <<
fPlots[i].fYmax[0];
2458 if (
fPlots[i].fUseFitRanges) {
2459 if (!
fPlots[i].fYmin.empty() && !
fPlots[i].fYmax.empty())
2460 fout <<
"use_fit_ranges " <<
fPlots[i].fYmin[0] <<
" " <<
fPlots[i].fYmax[0] << std::endl;
2462 fout <<
"use_fit_ranges" << std::endl;
2466 if (
fPlots[i].fViewPacking != -1) {
2467 fout <<
"view_packing " <<
fPlots[i].fViewPacking << std::endl;
2472 fout <<
"logx" << std::endl;
2477 fout <<
"logy" << std::endl;
2481 if (
fPlots[i].fLifeTimeCorrection) {
2482 fout <<
"lifetimecorrection" << std::endl;
2486 if (
fPlots[i].fRRFPacking) {
2487 fout <<
"rrf_packing " <<
fPlots[i].fRRFPacking << std::endl;
2491 if (
fPlots[i].fRRFFreq) {
2492 fout <<
"rrf_freq " <<
fPlots[i].fRRFFreq <<
" ";
2493 switch (
fPlots[i].fRRFUnit) {
2516 if (
fPlots[i].fRRFPhaseParamNo > 0) {
2517 fout <<
"rrf_phase par" <<
fPlots[i].fRRFPhaseParamNo << std::endl;
2518 }
else if (
fPlots[i].fRRFPhase) {
2519 fout <<
"rrf_phase " <<
fPlots[i].fRRFPhase << std::endl;
2525 fout << hline.Data() << std::endl;
2530 fout <<
"STATISTIC --- " << dt.AsSQLString() << std::endl;
2537 str +=
", chisq/NDF = ";
2539 fout << str.Data() << std::endl;
2545 str +=
", maxLH/NDF = ";
2547 fout << str.Data() << std::endl;
2550 fout <<
"*** FIT DID NOT CONVERGE ***" << std::endl;
2577 if (idx >=
fParam.size()) {
2580 fLastErrorMsg <<
">> PMsrHandler::SetMsrParamValue(): **ERROR** idx = " << idx <<
" is >= than the number of fit parameters " <<
fParam.size() <<
"\n";
2585 fParam[idx].fValue = value;
2606 if (idx >=
fParam.size()) {
2609 fLastErrorMsg <<
">> PMsrHandler::SetMsrParamValue(): **ERROR** idx = " << idx <<
" is larger than the number of parameters " <<
fParam.size() <<
"\n";
2614 fParam[idx].fStep = value;
2634 if (idx >=
fParam.size()) {
2637 fLastErrorMsg <<
">> PMsrHandler::SetMsrParamPosErrorPresent(): **ERROR** idx = " << idx <<
" is larger than the number of parameters " <<
fParam.size() <<
"\n";
2642 fParam[idx].fPosErrorPresent = value;
2662 if (idx >=
fParam.size()) {
2665 fLastErrorMsg <<
">> PMsrHandler::SetMsrParamPosError(): **ERROR** idx = " << idx <<
" is larger than the number of parameters " <<
fParam.size() <<
"\n";
2670 fParam[idx].fPosErrorPresent =
true;
2671 fParam[idx].fPosError = value;
2688 if (runNo >=
fRuns.size()) {
2691 fLastErrorMsg <<
">> PMsrHandler::SetMsrT0Entry: **ERROR** runNo = " << runNo <<
", is out of valid range 0.." <<
fRuns.size() <<
"\n";
2696 if (idx >=
fRuns[runNo].GetT0BinSize()) {
2697 std::cerr << std::endl <<
">> PMsrHandler::SetMsrT0Entry: **WARNING** idx = " << idx <<
", is out of valid range 0.." <<
fRuns[runNo].GetT0BinSize();
2698 std::cerr << std::endl <<
">> Will add it anyway.";
2699 std::cerr << std::endl;
2702 fRuns[runNo].SetT0Bin(bin, idx);
2718 if (runNo >=
fRuns.size()) {
2721 fLastErrorMsg <<
">> PMsrHandler::SetMsrAddT0Entry: **ERROR** runNo = " << runNo <<
", is out of valid range 0.." <<
fRuns.size() <<
"\n";
2726 if (addRunIdx >=
fRuns[runNo].GetAddT0BinEntries()) {
2727 std::cerr << std::endl <<
">> PMsrHandler::SetMsrAddT0Entry: **WARNING** addRunIdx = " << addRunIdx <<
", is out of valid range 0.." <<
fRuns[runNo].GetAddT0BinEntries();
2728 std::cerr << std::endl <<
">> Will add it anyway.";
2729 std::cerr << std::endl;
2732 if (
static_cast<Int_t
>(histoIdx) >
fRuns[runNo].GetAddT0BinSize(addRunIdx)) {
2733 std::cerr << std::endl <<
">> PMsrHandler::SetMsrAddT0Entry: **WARNING** histoIdx = " << histoIdx <<
", is out of valid range 0.." <<
fRuns[runNo].GetAddT0BinSize(addRunIdx);
2734 std::cerr << std::endl <<
">> Will add it anyway.";
2735 std::cerr << std::endl;
2738 fRuns[runNo].SetAddT0Bin(bin, addRunIdx, histoIdx);
2753 if (runNo >=
fRuns.size()) {
2756 fLastErrorMsg <<
">> PMsrHandler::SetMsrDataRangeEntry: **ERROR** runNo = " << runNo <<
", is out of valid range 0.." <<
fRuns.size() <<
"\n";
2761 fRuns[runNo].SetDataRange(bin, idx);
2776 if (runNo >=
fRuns.size()) {
2779 fLastErrorMsg <<
">> PMsrHandler::SetMsrBkgRangeEntry: **ERROR** runNo = " << runNo <<
", is out of valid range 0.." <<
fRuns.size() <<
"\n";
2784 fRuns[runNo].SetBkgRange(bin, idx);
2805 if (paramNo >=
fParam.size())
2838 Bool_t error =
false;
2840 PMsrLines::iterator iter;
2842 std::vector<std::string> tokens;
2845 iter = lines.begin();
2846 while ((iter != lines.end()) && !error) {
2851 param.
fName = TString(
"");
2861 tokens = PStringUtils::Split(iter->fLine.Data(),
" \t");
2864 if ((tokens.size() < 4) || (tokens.size() > 7) || (tokens.size() == 6)) {
2869 param.
fNo = PStringUtils::ToInt(tokens[0], &ok);
2874 param.
fName = tokens[1].c_str();
2877 param.
fValue = PStringUtils::ToDouble(tokens[2], &ok);
2882 param.
fStep = PStringUtils::ToDouble(tokens[3], &ok);
2887 if (tokens.size() == 4) {
2892 if (tokens.size() == 5) {
2896 param.
fPosError = PStringUtils::ToDouble(tokens[4], &ok);
2899 }
else if (PStringUtils::IsEqualNoCase(tokens[4],
"none")) {
2907 if (tokens.size() == 7) {
2911 param.
fPosError = PStringUtils::ToDouble(tokens[4], &ok);
2914 }
else if (PStringUtils::IsEqualNoCase(tokens[4],
"none")) {
2922 if (PStringUtils::IsEqualNoCase(tokens[5],
"none")) {
2935 if (PStringUtils::IsEqualNoCase(tokens[6],
"none")) {
2957 fLastErrorMsg <<
">> PMsrHandler::HandleFitParameterEntry: **ERROR** in line " << iter->fLineNo <<
":\n";
2959 fLastErrorMsg <<
">> A Fit Parameter line needs to have the following form:\n";
2961 fLastErrorMsg <<
">> No Name Value Step/Error [Lower_Boundary Upper_Boundary]\n\n";
2963 fLastErrorMsg <<
">> No Name Value Step/Neg_Error Pos_Error [Lower_Boundary Upper_Boundary]\n\n";
2964 fLastErrorMsg <<
">> No: the parameter number (an Int_t)\n";
2965 fLastErrorMsg <<
">> Name: the name of the parameter (less than 256 character)\n";
2966 fLastErrorMsg <<
">> Value: the starting value of the parameter (a Double_t)\n";
2968 fLastErrorMsg <<
">> Step/Neg_Error: the starting step value in a fit (a Double_t), or\n";
2969 fLastErrorMsg <<
">> the symmetric error (MIGRAD, SIMPLEX), or\n";
2971 fLastErrorMsg <<
">> Pos_Error: the positive error (MINOS), (a Double_t or \"none\")\n";
2972 fLastErrorMsg <<
">> Lower_Boundary: the lower boundary allowed for the fit parameter (a Double_t or \"none\")\n";
2973 fLastErrorMsg <<
">> Upper_Boundary: the upper boundary allowed for the fit parameter (a Double_t or \"none\")\n";
2983 for (UInt_t i=0; i<
fParam.size(); i++) {
2984 if (
fParam[i].fNo !=
static_cast<Int_t
>(i)+1) {
2988 fLastErrorMsg <<
">> PMsrHandler::HandleFitParameterEntry: **ERROR**\n";
2989 fLastErrorMsg <<
">> Sorry, you are assuming to much from this program, it cannot\n";
2990 fLastErrorMsg <<
">> handle none subsequent numbered parameters yet or in the near future.\n";
2992 fLastErrorMsg <<
">> parameter number " <<
fParam[i].fNo <<
", at paramter position " << i+1 <<
".\n";
3055 if ((
fFuncHandler->GetNoOfFuncs() == 0) && !lines.empty()) {
3056 std::cerr << std::endl <<
">> PMsrHandler::HandleFunctionsEntry: **WARNING** empty FUNCTIONS block found!";
3057 std::cerr << std::endl;
3077 PMsrLines::iterator iter;
3080 Bool_t error =
false;
3083 std::vector<std::string> tokens;
3085 Double_t dval = 0.0;
3086 UInt_t addT0Counter = 0;
3091 iter = lines.begin();
3092 while ((iter != lines.end()) && !error) {
3095 Ssiz_t idx = str.Index(
"#");
3100 tokens = PStringUtils::Split(str.Data(),
" \t");
3102 if (iter->fLine.BeginsWith(
"fittype", TString::kIgnoreCase)) {
3103 if (tokens.size() < 2) {
3107 Int_t fittype = PStringUtils::ToInt(tokens[1], &ok);
3120 }
else if (iter->fLine.BeginsWith(
"rrf_freq", TString::kIgnoreCase)) {
3121 if (tokens.size() < 3) {
3125 dval = PStringUtils::ToDouble(tokens[1], &ok);
3126 if (!ok || dval <= 0.0)
3134 }
else if (iter->fLine.BeginsWith(
"rrf_packing", TString::kIgnoreCase)) {
3135 if (tokens.size() < 2) {
3139 ival = PStringUtils::ToInt(tokens[1], &ok);
3140 if (ok && ival > 0) {
3146 }
else if (iter->fLine.BeginsWith(
"rrf_phase", TString::kIgnoreCase)) {
3147 if (tokens.size() < 2) {
3151 dval = PStringUtils::ToDouble(tokens[1], &ok);
3157 }
else if (iter->fLine.BeginsWith(
"data", TString::kIgnoreCase)) {
3158 if (tokens.size() < 3) {
3161 for (UInt_t i=1; i<tokens.size(); i++) {
3163 ival = PStringUtils::ToInt(tokens[i], &ok);
3164 if (ok && ival >= 0) {
3171 }
else if (iter->fLine.BeginsWith(
"t0", TString::kIgnoreCase)) {
3172 if (tokens.size() < 2) {
3175 for (UInt_t i=1; i<tokens.size(); i++) {
3177 dval = PStringUtils::ToDouble(tokens[i], &ok);
3178 if (ok && dval >= 0.0)
3184 }
else if (iter->fLine.BeginsWith(
"addt0", TString::kIgnoreCase)) {
3185 if (tokens.size() < 2) {
3188 for (UInt_t i=1; i<tokens.size(); i++) {
3190 dval = PStringUtils::ToDouble(tokens[i], &ok);
3191 if (ok && dval >= 0.0)
3198 }
else if (iter->fLine.BeginsWith(
"fit", TString::kIgnoreCase)) {
3199 if (tokens.size() < 3) {
3202 if (iter->fLine.Contains(
"fgb", TString::kIgnoreCase)) {
3204 std::string numStr = tokens[1];
3205 std::string::size_type pos = numStr.find(
'+');
3206 if (pos != std::string::npos) {
3207 numStr = numStr.substr(pos+1);
3208 if (PStringUtils::IsFloat(numStr)) {
3218 pos = numStr.find(
'-');
3219 if (pos != std::string::npos) {
3220 numStr = numStr.substr(pos+1);
3221 if (PStringUtils::IsFloat(numStr)) {
3232 for (UInt_t i=1; i<3; i++) {
3234 const double range = PStringUtils::ToDouble(tokens[i], &ok);
3242 }
else if (iter->fLine.BeginsWith(
"packing", TString::kIgnoreCase)) {
3243 if (tokens.size() < 2) {
3247 ival = PStringUtils::ToInt(tokens[1], &ok);
3248 if (ok && ival >= 0) {
3254 }
else if (iter->fLine.BeginsWith(
"deadtime-cor", TString::kIgnoreCase)) {
3255 if (tokens.size() < 2) {
3258 if (PStringUtils::IsEqualNoCase(tokens[1],
"no") ||
3259 PStringUtils::IsEqualNoCase(tokens[1],
"file") ||
3260 PStringUtils::IsEqualNoCase(tokens[1],
"estimate")) {
3275 fLastErrorMsg <<
">> PMsrHandler::HandleGlobalEntry: **ERROR** in line " << iter->fLineNo <<
":\n";
3277 fLastErrorMsg <<
">> GLOBAL block syntax is too complex to print it here. Please check the manual.\n";
3300 PMsrLines::iterator iter;
3302 Bool_t first =
true;
3303 Bool_t error =
false;
3304 Bool_t runLinePresent =
false;
3307 std::vector<std::string> tokens;
3309 UInt_t addT0Counter = 0;
3314 iter = lines.begin();
3315 while ((iter != lines.end()) && !error) {
3318 Ssiz_t idx = str.Index(
"#");
3321 idx = str.Index(
"(");
3326 tokens = PStringUtils::Split(str.Data(),
" \t");
3331 line.Remove(TString::kLeading,
' ');
3334 if (line.BeginsWith(
"run", TString::kIgnoreCase)) {
3336 runLinePresent =
true;
3339 fRuns.push_back(param);
3347 if (tokens.size() < 5) {
3351 std::string runName(
"");
3352 for (UInt_t i=1; i<tokens.size()-3; i++) {
3353 runName += tokens[i];
3354 if (i<tokens.size()-4)
3357 str = runName.c_str();
3360 str = tokens[tokens.size()-3].c_str();
3363 str = tokens[tokens.size()-2].c_str();
3366 str = tokens[tokens.size()-1].c_str();
3374 if (line.BeginsWith(
"addrun", TString::kIgnoreCase)) {
3376 if (!runLinePresent) {
3379 fLastErrorMsg <<
">> PMsrHandler::HandleRunEntry: **ERROR** Found ADDRUN without prior RUN, or\n";
3380 fLastErrorMsg <<
">> ADDRUN lines intercepted by other stuff. All this is not allowed!\n";
3381 fLastErrorMsg <<
">> error in line " << iter->fLineNo <<
"\n";
3388 if (tokens.size() < 5) {
3392 str = tokens[1].c_str();
3395 str = tokens[2].c_str();
3398 str = tokens[3].c_str();
3401 str = tokens[4].c_str();
3407 if (line.BeginsWith(
"fittype", TString::kIgnoreCase)) {
3409 runLinePresent =
false;
3411 if (tokens.size() < 2) {
3415 Int_t fittype = PStringUtils::ToInt(tokens[1], &ok);
3431 if (line.BeginsWith(
"alpha", TString::kIgnoreCase)) {
3433 runLinePresent =
false;
3435 if (tokens.size() < 2) {
3439 ival = PStringUtils::ToInt(tokens[1], &ok);
3445 }
else if (tokens[1].find(
"fun") != std::string::npos) {
3458 if (line.BeginsWith(
"beta", TString::kIgnoreCase)) {
3460 runLinePresent =
false;
3462 if (tokens.size() < 2) {
3466 ival = PStringUtils::ToInt(tokens[1], &ok);
3472 }
else if (tokens[1].find(
"fun") != std::string::npos) {
3485 if (line.BeginsWith(
"norm", TString::kIgnoreCase)) {
3487 runLinePresent =
false;
3489 if (tokens.size() < 2) {
3493 ival = PStringUtils::ToInt(tokens[1], &ok);
3496 }
else if (tokens[1].find(
"fun") != std::string::npos) {
3509 if (line.BeginsWith(
"backgr.fit", TString::kIgnoreCase)) {
3511 runLinePresent =
false;
3513 if (tokens.size() < 2) {
3517 ival = PStringUtils::ToInt(tokens[1], &ok);
3526 if (line.BeginsWith(
"lifetime ", TString::kIgnoreCase)) {
3528 runLinePresent =
false;
3530 if (tokens.size() < 2) {
3534 ival = PStringUtils::ToInt(tokens[1], &ok);
3543 if (line.BeginsWith(
"lifetimecorrection", TString::kIgnoreCase)) {
3545 runLinePresent =
false;
3551 if (line.BeginsWith(
"map", TString::kIgnoreCase)) {
3553 runLinePresent =
false;
3555 for (UInt_t i=1; i<tokens.size(); i++) {
3557 ival = PStringUtils::ToInt(tokens[i], &ok);
3558 if (ok && ival >= 0)
3565 for (UInt_t i=0; i<param.
GetMap()->size(); i++) {
3566 if ((param.
GetMap(i) < 0) || (param.
GetMap(i) >
static_cast<Int_t
>(
fParam.size()))) {
3569 fLastErrorMsg <<
">> PMsrHandler::HandleRunEntry: **SEVERE ERROR** map value " << param.
GetMap(i) <<
" in line " << iter->fLineNo <<
" is out of range!\n";
3579 if (line.BeginsWith(
"forward", TString::kIgnoreCase)) {
3581 runLinePresent =
false;
3583 if (tokens.size() < 2) {
3588 std::unique_ptr<PStringNumberList> rl = std::make_unique<PStringNumberList>(str.Data());
3589 std::string errorMsg(
"");
3590 if (rl->Parse(errorMsg,
true)) {
3591 group = rl->GetList();
3592 for (UInt_t i=0; i<group.size(); i++) {
3603 if (line.BeginsWith(
"backward", TString::kIgnoreCase)) {
3605 runLinePresent =
false;
3607 if (tokens.size() < 2) {
3612 std::unique_ptr<PStringNumberList> rl = std::make_unique<PStringNumberList>(str.Data());
3613 std::string errorMsg(
"");
3614 if (rl->Parse(errorMsg,
true)) {
3615 group = rl->GetList();
3616 for (UInt_t i=0; i<group.size(); i++) {
3627 if (line.BeginsWith(
"backgr.fix", TString::kIgnoreCase)) {
3629 runLinePresent =
false;
3631 if (tokens.size() < 2) {
3634 for (UInt_t i=1; i<tokens.size(); i++) {
3636 const double bkgFix = PStringUtils::ToDouble(tokens[i], &ok);
3646 if (line.BeginsWith(
"background", TString::kIgnoreCase)) {
3648 runLinePresent =
false;
3650 if ((tokens.size() < 3) || (tokens.size() % 2 != 1)) {
3653 for (UInt_t i=1; i<tokens.size(); i++) {
3655 ival = PStringUtils::ToInt(tokens[i], &ok);
3665 if (line.BeginsWith(
"data", TString::kIgnoreCase)) {
3667 runLinePresent =
false;
3669 if ((tokens.size() < 3) || (tokens.size() % 2 != 1)) {
3672 for (UInt_t i=1; i<tokens.size(); i++) {
3674 ival = PStringUtils::ToInt(tokens[i], &ok);
3684 if (line.BeginsWith(
"t0", TString::kIgnoreCase)) {
3686 runLinePresent =
false;
3688 if (tokens.size() < 2) {
3691 for (UInt_t i=1; i<tokens.size(); i++) {
3693 dval = PStringUtils::ToDouble(tokens[i], &ok);
3694 if (ok && dval >= 0.0)
3703 if (line.BeginsWith(
"addt0", TString::kIgnoreCase)) {
3705 runLinePresent =
false;
3707 if (tokens.size() < 2) {
3710 for (UInt_t i=1; i<tokens.size(); i++) {
3712 dval = PStringUtils::ToDouble(tokens[i], &ok);
3713 if (ok && dval >= 0.0)
3724 if (line.BeginsWith(
"fit ", TString::kIgnoreCase)) {
3726 runLinePresent =
false;
3728 if (tokens.size() < 3) {
3731 if (iter->fLine.Contains(
"fgb", TString::kIgnoreCase)) {
3733 std::string numStr = tokens[1];
3734 std::string::size_type pos = numStr.find(
'+');
3735 if (pos != std::string::npos) {
3736 numStr = numStr.substr(pos+1);
3737 if (PStringUtils::IsFloat(numStr)) {
3747 pos = numStr.find(
'-');
3748 if (pos != std::string::npos) {
3749 numStr = numStr.substr(pos+1);
3750 if (PStringUtils::IsFloat(numStr)) {
3762 for (UInt_t i=1; i<3; i++) {
3764 const double range = PStringUtils::ToDouble(tokens[i], &ok);
3775 if (line.BeginsWith(
"packing", TString::kIgnoreCase)) {
3777 runLinePresent =
false;
3779 if (tokens.size() != 2) {
3783 ival = PStringUtils::ToInt(tokens[1], &ok);
3792 if (iter->fLine.BeginsWith(
"deadtime-cor", TString::kIgnoreCase)) {
3794 runLinePresent =
false;
3796 if (tokens.size() < 2) {
3799 if (PStringUtils::IsEqualNoCase(tokens[1],
"no") ||
3800 PStringUtils::IsEqualNoCase(tokens[1],
"file") ||
3801 PStringUtils::IsEqualNoCase(tokens[1],
"estimate")) {
3811 if (line.BeginsWith(
"xy-data", TString::kIgnoreCase)) {
3813 runLinePresent =
false;
3815 if (tokens.size() != 3) {
3818 if (PStringUtils::IsInt(tokens[1])) {
3820 if (PStringUtils::IsInt(tokens[2])) {
3821 ival = PStringUtils::ToInt(tokens[2]);
3830 str = tokens[1].c_str();
3832 str = tokens[2].c_str();
3845 fLastErrorMsg <<
">> PMsrHandler::HandleRunEntry: **ERROR** in line " << iter->fLineNo <<
":\n";
3847 fLastErrorMsg <<
">> RUN block syntax is too complex to print it here. Please check the manual.\n";
3850 fRuns.push_back(param);
3877 Int_t found, no_found=-1;
3880 Char_t *cstr, filterStr[32];
3881 cstr =
new Char_t[str.Sizeof()];
3882 strncpy(cstr, str.Data(), str.Sizeof());
3883 snprintf(filterStr,
sizeof(filterStr),
"%s%%d", filter);
3886 found = sscanf(cstr, filterStr, &no_found);
3888 if (no_found < 1000)
3889 no = no_found + offset;
3897 if ((no_found < 0) || (no_found > 1000))
3920 PMsrLines::iterator iter;
3922 if (lines.empty()) {
3923 std::cerr << std::endl <<
">> PMsrHandler::HandleCommandsEntry(): **WARNING**: There is no COMMAND block! Do you really want this?";
3924 std::cerr << std::endl;
3927 for (iter = lines.begin(); iter != lines.end(); ++iter) {
3928 if (!iter->fLine.BeginsWith(
"COMMANDS"))
3954 for (UInt_t i=0; i<2; i++) {
3973 Ssiz_t idx = str.First(
'#');
3977 truncStr.Resize(idx-1);
3997 Bool_t result =
true;
3999 std::vector<std::string> tok = PStringUtils::Split(str.Data(),
" ,;\t");
4002 if (tok.size() < 2) {
4008 for (UInt_t i=1; i<tok.size(); i++) {
4010 const double phase = PStringUtils::ToDouble(tok[i], &ok);
4012 fourier.
fPhase.push_back(phase);
4018 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseValueVector: **ERROR** in Fourier phase line.\n";
4019 fLastErrorMsg <<
">> Attempt to mix val, parX? This is currently not supported.\n\n";
4048 Bool_t result =
true;
4051 std::vector<std::string> tok = PStringUtils::Split(str.Data(),
" ,;\t");
4054 if (tok.size() < 2) {
4060 for (UInt_t i=1; i<tok.size(); i++) {
4061 if (tok[i].rfind(
"par", 0) != 0) {
4064 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseParVector: **ERROR** found unhandable token '" << tok[i] <<
"'\n";
4071 if (tok[i].rfind(
"parR", 0) == 0) {
4076 if (tok[i].rfind(
"par(", 0) == 0) {
4085 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseParVector: **ERROR** found multiple parR's! Only one reference phase is accepted.\n";
4092 if (result !=
false) {
4093 for (UInt_t i=1; i<tok.size(); i++) {
4094 std::string sstr = tok[i];
4096 if (sstr.rfind(
"parR", 0) == 0) {
4099 sstr = sstr.substr(rmNoOf);
4101 Int_t val = PStringUtils::ToInt(sstr, &ok);
4109 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseParVector: **ERROR** found token '" << tok[i] <<
"' which is not parX with X an integer.\n";
4147 wstr = wstr.Strip(TString::kLeading,
' ');
4150 if (!wstr.BeginsWith(
"par(") && !wstr.BeginsWith(
"parR(")) {
4153 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** token should start with 'par(' or 'parR(', found: '" << wstr <<
"' -> ERROR\n";
4159 Bool_t relativePhase =
false;
4160 if (wstr.BeginsWith(
"parR(")) {
4162 relativePhase =
true;
4164 wstr.Remove(0, noOf);
4167 wstr = wstr.Strip(TString::kTrailing,
' ');
4170 Ssiz_t idx=wstr.Last(
')');
4171 wstr.Remove(idx, wstr.Length()-idx);
4174 std::vector<std::string> tok = PStringUtils::Split(wstr.Data(),
",;");
4177 if (tok.size() != 3) {
4180 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** wrong syntax for the expected par(X0, offset, #param).\n";
4186 Int_t x0, offset, noParam;
4190 x0 = PStringUtils::ToInt(tok[0], &ok);
4194 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** X0='" << tok[0] <<
"' is not an integer.\n";
4201 offset = PStringUtils::ToInt(tok[1], &ok);
4205 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** offset='" << tok[1] <<
"' is not an integer.\n";
4212 noParam = PStringUtils::ToInt(tok[2], &ok);
4216 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** #Param='" << tok[2] <<
"' is not an integer.\n";
4228 for (Int_t i=0; i<noParam; i++)
4248 Bool_t error =
false;
4259 PMsrLines::iterator iter;
4261 std::vector<std::string> tokens;
4262 TString pcStr=TString(
"");
4266 iter = lines.begin();
4267 while ((iter != lines.end()) && !error) {
4269 tokens = PStringUtils::Split(iter->fLine.Data(),
" \t");
4271 if (iter->fLine.BeginsWith(
"units", TString::kIgnoreCase)) {
4272 if (tokens.size() < 2) {
4276 if (PStringUtils::IsEqualNoCase(tokens[1],
"gauss")) {
4278 }
else if (PStringUtils::IsEqualNoCase(tokens[1],
"tesla")) {
4280 }
else if (PStringUtils::IsEqualNoCase(tokens[1],
"mhz")) {
4282 }
else if (PStringUtils::IsEqualNoCase(tokens[1],
"mc/s")) {
4289 }
else if (iter->fLine.BeginsWith(
"fourier_power", TString::kIgnoreCase)) {
4290 if (tokens.size() < 2) {
4295 ival = PStringUtils::ToInt(tokens[1], &ok);
4296 if (ok && (ival >= 0) && (ival <= 20)) {
4303 }
else if (iter->fLine.BeginsWith(
"dc-corrected", TString::kIgnoreCase)) {
4304 if (tokens.size() < 2) {
4308 if (PStringUtils::IsEqualNoCase(tokens[1],
"true") || (tokens[1] ==
"1")) {
4310 }
else if (PStringUtils::IsEqualNoCase(tokens[1],
"false") || (tokens[1] ==
"0")) {
4317 }
else if (iter->fLine.BeginsWith(
"apodization", TString::kIgnoreCase)) {
4318 if (tokens.size() < 2) {
4322 if (PStringUtils::IsEqualNoCase(tokens[1],
"none")) {
4324 }
else if (PStringUtils::IsEqualNoCase(tokens[1],
"weak")) {
4326 }
else if (PStringUtils::IsEqualNoCase(tokens[1],
"medium")) {
4328 }
else if (PStringUtils::IsEqualNoCase(tokens[1],
"strong")) {
4335 }
else if (iter->fLine.BeginsWith(
"plot", TString::kIgnoreCase)) {
4336 if (tokens.size() < 2) {
4340 if (PStringUtils::IsEqualNoCase(tokens[1],
"real")) {
4342 }
else if (PStringUtils::IsEqualNoCase(tokens[1],
"imag")) {
4344 }
else if (PStringUtils::IsEqualNoCase(tokens[1],
"real_and_imag")) {
4346 }
else if (PStringUtils::IsEqualNoCase(tokens[1],
"power")) {
4348 }
else if (PStringUtils::IsEqualNoCase(tokens[1],
"phase")) {
4350 }
else if (PStringUtils::IsEqualNoCase(tokens[1],
"phase_opt_real")) {
4357 }
else if (iter->fLine.BeginsWith(
"phase", TString::kIgnoreCase)) {
4358 if (tokens.size() < 2) {
4388 if (!result || error) {
4398 fLastErrorMsg <<
">> PMsrHandler::HandleFourierEntry: found Fourier parameter entry par" << fourier.
fPhaseParamNo[i] <<
" > #Param = " <<
fParam.size() <<
"\n";
4408 Double_t phaseRef = 0.0;
4423 }
else if (iter->fLine.BeginsWith(
"range_for_phase_correction", TString::kIgnoreCase)) {
4427 pcStr = iter->fLine;
4428 }
else if (iter->fLine.BeginsWith(
"range", TString::kIgnoreCase)) {
4429 if (tokens.size() < 3) {
4433 for (UInt_t i=0; i<2; i++) {
4435 fourier.
fPlotRange[i] = PStringUtils::ToDouble(tokens[i+1], &ok);
4442 }
else if (!iter->fLine.BeginsWith(
"fourier", TString::kIgnoreCase) && !iter->fLine.BeginsWith(
"#") &&
4443 !iter->fLine.IsWhitespace() && (iter->fLine.Length() != 0)) {
4452 if ((pcStr.Length() != 0) && !error) {
4454 tokens = PStringUtils::Split(pcStr.Data(),
" \t");
4456 switch (tokens.size()) {
4458 if (PStringUtils::IsEqualNoCase(tokens[1],
"all")) {
4466 for (UInt_t i=0; i<2; i++) {
4482 fLastErrorMsg <<
">> PMsrHandler::HandleFourierEntry: **ERROR** in line " << iter->fLineNo <<
":\n\n";
4484 fLastErrorMsg <<
">> FOURIER block syntax, parameters in [] are optinal:\n\n";
4487 fLastErrorMsg <<
">> [fourier_power n # n is a number such that zero padding up to 2^n will be used]\n";
4491 fLastErrorMsg <<
">> [apodization none | weak | medium | strong]\n";
4492 fLastErrorMsg <<
">> [plot real | imag | real_and_imag | power | phase | phase_opt_real]\n";
4493 fLastErrorMsg <<
">> [phase valList | parList | parIterList [# comment]]\n";
4494 fLastErrorMsg <<
">> valList : val [sep val ... sep val]. sep=' ,;\\t'\n";
4495 fLastErrorMsg <<
">> parList : parX0 [sep parX1 ... sep parXn], Xi is the parameter number\n";
4496 fLastErrorMsg <<
">> parList : parRX0 sep parX1 ... sep parXn, parRX0 is the reference phase, e.g. parR3\n";
4497 fLastErrorMsg <<
">> parIterList : par(X0,offset,#param), with X0=first parameter number\n";
4498 fLastErrorMsg <<
">> offset=parameter offset, #param=number of phase parameters.\n";
4499 fLastErrorMsg <<
">> [range_for_phase_correction min max | all]\n";
4523 Bool_t error =
false;
4527 PMsrLines::iterator iter1;
4528 PMsrLines::iterator iter2;
4529 std::vector<std::string> tokens;
4531 if (lines.empty()) {
4532 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry(): **WARNING**: There is no PLOT block! Do you really want this?";
4533 std::cerr << std::endl;
4536 iter1 = lines.begin();
4537 while ((iter1 != lines.end()) && !error) {
4543 param.
fLogX =
false;
4544 param.
fLogY =
false;
4546 param.
fRuns.clear();
4547 param.
fTmin.clear();
4548 param.
fTmax.clear();
4549 param.
fYmin.clear();
4550 param.
fYmax.clear();
4560 for ( ; iter2 != lines.end(); ++iter2) {
4561 if (iter2->fLine.Contains(
"PLOT"))
4566 while ((iter1 != iter2) && !error) {
4567 TString line = iter1->fLine;
4568 if (line.First(
'#') != -1)
4569 line.Resize(line.First(
'#'));
4571 if (line.Contains(
"PLOT")) {
4572 tokens = PStringUtils::Split(line.Data(),
" \t");
4573 if (tokens.size() < 2) {
4577 param.
fPlotType = PStringUtils::ToInt(tokens[1], &ok);
4581 }
else if (line.Contains(
"lifetimecorrection", TString::kIgnoreCase)) {
4583 }
else if (line.Contains(
"runs", TString::kIgnoreCase)) {
4585 std::unique_ptr<PStringNumberList> rl;
4586 std::string errorMsg;
4599 rl = std::make_unique<PStringNumberList>(line.Data());
4600 if (!rl->Parse(errorMsg,
true)) {
4603 fLastErrorMsg <<
">> PMsrHandler::HandlePlotEntry: **SEVERE ERROR** Couldn't tokenize PLOT in line " << iter1->fLineNo <<
"\n";
4608 runList = rl->GetList();
4609 for (UInt_t i=0; i<runList.size(); i++) {
4610 run = TComplex(runList[i], -1.0);
4611 param.
fRuns.push_back(run);
4620 }
else if (line.Contains(
"range ", TString::kIgnoreCase)) {
4622 param.
fTmin.clear();
4623 param.
fTmax.clear();
4624 param.
fYmin.clear();
4625 param.
fYmax.clear();
4627 tokens = PStringUtils::Split(line.Data(),
" \t");
4628 if ((tokens.size() != 3) && (tokens.size() != 5)) {
4634 const double tmin = PStringUtils::ToDouble(tokens[1], &ok);
4636 param.
fTmin.push_back(tmin);
4641 const double tmax = PStringUtils::ToDouble(tokens[2], &ok);
4643 param.
fTmax.push_back(tmax);
4647 if (tokens.size() == 5) {
4650 const double ymin = PStringUtils::ToDouble(tokens[3], &ok);
4652 param.
fYmin.push_back(ymin);
4657 const double ymax = PStringUtils::ToDouble(tokens[4], &ok);
4659 param.
fYmax.push_back(ymax);
4664 }
else if (line.Contains(
"sub_ranges", TString::kIgnoreCase)) {
4666 param.
fTmin.clear();
4667 param.
fTmax.clear();
4668 param.
fYmin.clear();
4669 param.
fYmax.clear();
4671 tokens = PStringUtils::Split(line.Data(),
" \t");
4672 if ((tokens.size() != 2*param.
fRuns.size() + 1) && (tokens.size() != 2*param.
fRuns.size() + 3)) {
4676 for (UInt_t i=0; i<param.
fRuns.size(); i++) {
4680 const double tmin = PStringUtils::ToDouble(tokens[2*i+1], &ok);
4682 param.
fTmin.push_back(tmin);
4687 const double tmax = PStringUtils::ToDouble(tokens[2*i+2], &ok);
4689 param.
fTmax.push_back(tmax);
4695 if (tokens.size() == 2*param.
fRuns.size() + 3) {
4699 const double ymin = PStringUtils::ToDouble(tokens[2*param.
fRuns.size()+1], &ok);
4701 param.
fYmin.push_back(ymin);
4706 const double ymax = PStringUtils::ToDouble(tokens[2*param.
fRuns.size()+2], &ok);
4708 param.
fYmax.push_back(ymax);
4713 }
else if (line.Contains(
"use_fit_ranges", TString::kIgnoreCase)) {
4717 tokens = PStringUtils::Split(line.Data(),
" \t");
4719 if (tokens.size() == 3) {
4722 const double ymin = PStringUtils::ToDouble(tokens[1], &ok);
4724 param.
fYmin.push_back(ymin);
4729 const double ymax = PStringUtils::ToDouble(tokens[2], &ok);
4731 param.
fYmax.push_back(ymax);
4736 if ((tokens.size() != 1) && (tokens.size() != 3)) {
4737 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry: **WARNING** use_fit_ranges with undefined additional parameters in line " << iter1->fLineNo;
4738 std::cerr << std::endl <<
">> Will ignore this PLOT block command line, sorry.";
4739 std::cerr << std::endl <<
">> Proper syntax: use_fit_ranges [ymin ymax]";
4740 std::cerr << std::endl <<
">> Found: '" << iter1->fLine.Data() <<
"'" << std::endl;
4742 }
else if (iter1->fLine.Contains(
"logx", TString::kIgnoreCase)) {
4744 }
else if (iter1->fLine.Contains(
"logy", TString::kIgnoreCase)) {
4746 }
else if (iter1->fLine.Contains(
"lifetimecorrection", TString::kIgnoreCase)) {
4748 }
else if (iter1->fLine.Contains(
"view_packing", TString::kIgnoreCase)) {
4749 tokens = PStringUtils::Split(iter1->fLine.Data(),
" \t");
4750 if (tokens.size() != 2) {
4754 Int_t val = PStringUtils::ToInt(tokens[1], &ok);
4760 }
else if (iter1->fLine.Contains(
"rrf_freq", TString::kIgnoreCase)) {
4763 tokens = PStringUtils::Split(iter1->fLine.Data(),
" \t");
4764 if (tokens.size() != 3) {
4769 param.
fRRFFreq = PStringUtils::ToDouble(tokens[1], &ok);
4773 if (PStringUtils::ContainsNoCase(tokens[2],
"kHz"))
4775 else if (PStringUtils::ContainsNoCase(tokens[2],
"MHz"))
4777 else if (PStringUtils::ContainsNoCase(tokens[2],
"Mc/s"))
4779 else if (PStringUtils::ContainsNoCase(tokens[2],
"G"))
4781 else if (PStringUtils::ContainsNoCase(tokens[2],
"T"))
4786 }
else if (iter1->fLine.Contains(
"rrf_phase", TString::kIgnoreCase)) {
4789 tokens = PStringUtils::Split(iter1->fLine.Data(),
" \t");
4790 if (tokens.size() != 2) {
4795 const double rrfPhase = PStringUtils::ToDouble(tokens[1], &ok);
4798 }
else if (PStringUtils::BeginsWithNoCase(tokens[1],
"par")) {
4802 if (
static_cast<Int_t
>(
fParam.size()) < no) {
4815 }
else if (iter1->fLine.Contains(
"rrf_packing", TString::kIgnoreCase)) {
4817 tokens = PStringUtils::Split(iter1->fLine.Data(),
" \t");
4818 if (tokens.size() != 2) {
4823 param.
fRRFPacking = PStringUtils::ToInt(tokens[1], &ok);
4838 if (param.
fRuns.empty()) {
4841 if ((param.
fTmin.size() > 0) || (param.
fTmax.size() > 0)) {
4842 for (UInt_t i=0; i<param.
fTmin.size(); i++) {
4844 keep = param.
fTmin[i];
4846 param.
fTmax[i] = keep;
4851 if ((param.
fYmin.size() > 0) || (param.
fYmax.size() > 0)) {
4852 for (UInt_t i=0; i<param.
fYmin.size(); i++) {
4854 keep = param.
fYmin[i];
4856 param.
fYmax[i] = keep;
4864 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry(): **ERROR** found RRF frequency but no required RRF packing.";
4865 std::cerr << std::endl <<
">> Will ignore the RRF option.";
4866 std::cerr << std::endl;
4872 for (UInt_t i=0; i<param.
fRuns.size(); i++) {
4873 if (param.
fRuns[i] >
static_cast<Int_t
>(
fRuns.size())) {
4874 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry(): **WARNING** found plot run number " << param.
fRuns[i] <<
".";
4875 std::cerr << std::endl <<
">> There are only " <<
fRuns.size() <<
" runs present, will ignore this run.";
4876 std::cerr << std::endl;
4880 if (param.
fRuns[i] == 0) {
4881 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry(): **WARNING** found plot run number 0.";
4882 std::cerr << std::endl <<
">> Pot number needs to be > 0. Will ignore this entry.";
4883 std::cerr << std::endl;
4889 if (param.
fRuns.size() > 0) {
4892 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry: **ERROR** no valid PLOT block entries, will ignore the entire PLOT block.";
4893 std::cerr << std::endl;
4898 if (
fPlots.size() == 0) {
4900 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry: **ERROR** no valid PLOT block at all present. Fix this first!";
4901 std::cerr << std::endl;
4906 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry: **ERROR** in line " << iter1->fLineNo <<
": " << iter1->fLine.Data();
4907 std::cerr << std::endl <<
">> A PLOT block needs to have the following structure:";
4908 std::cerr << std::endl;
4909 std::cerr << std::endl <<
">> PLOT <plot_type>";
4910 std::cerr << std::endl <<
">> runs <run_list>";
4911 std::cerr << std::endl <<
">> [range tmin tmax [ymin ymax]]";
4912 std::cerr << std::endl <<
">> [sub_ranges tmin1 tmax1 tmin2 tmax2 ... tminN tmaxN [ymin ymax]";
4913 std::cerr << std::endl <<
">> [logx | logy]";
4914 std::cerr << std::endl <<
">> [use_fit_ranges [ymin ymax]]";
4915 std::cerr << std::endl <<
">> [view_packing n]";
4916 std::cerr << std::endl;
4917 std::cerr << std::endl <<
">> where <plot_type> is: 0=single histo,";
4918 std::cerr << std::endl <<
">> 1=RRF single histo,";
4919 std::cerr << std::endl <<
">> 2=forward-backward asym,";
4920 std::cerr << std::endl <<
">> 3=forward-backward RRF asym,";
4921 std::cerr << std::endl <<
">> 4=mu minus single histo,";
4922 std::cerr << std::endl <<
">> 5=forward-backward beta-NMR asym,";
4923 std::cerr << std::endl <<
">> 8=non muSR.";
4924 std::cerr << std::endl <<
">> <run_list> is the list of runs, e.g. runs 1 3";
4925 std::cerr << std::endl <<
">> range is optional";
4926 std::cerr << std::endl <<
">> sub_ranges (if present) will plot the N given runs each on its own sub-range";
4927 std::cerr << std::endl <<
">> logx, logy (if present) will present the x-, y-axis in log-scale";
4928 std::cerr << std::endl <<
">> use_fit_ranges (if present) will plot each run on its fit-range";
4929 std::cerr << std::endl <<
">> view_packing n (if present) will bin all data by n (> 0) rather than the binning of the fit";
4930 std::cerr << std::endl;
4933 param.
fRuns.clear();
4958 if (lines.empty()) {
4959 std::cerr << std::endl <<
">> PMsrHandler::HandleStatisticEntry: **WARNING** There is no STATISTIC block! Do you really want this?";
4960 std::cerr << std::endl;
4972 for (UInt_t i=0; i<lines.size(); i++) {
4974 tstr = lines[i].fLine;
4975 tstr.Remove(TString::kLeading,
' ');
4976 if (tstr.Length() > 0) {
4977 if (!tstr.BeginsWith(
"#") && !tstr.BeginsWith(
"STATISTIC") && !tstr.BeginsWith(
"chisq") &&
4978 !tstr.BeginsWith(
"maxLH") && !tstr.BeginsWith(
"*** FIT DID NOT CONVERGE ***") &&
4979 !tstr.BeginsWith(
"expected chisq") && !tstr.BeginsWith(
"expected maxLH") &&
4980 !tstr.BeginsWith(
"run block")) {
4981 std::cerr << std::endl <<
">> PMsrHandler::HandleStatisticEntry: **SYNTAX ERROR** in line " << lines[i].fLineNo;
4982 std::cerr << std::endl <<
">> '" << lines[i].fLine.Data() <<
"'";
4983 std::cerr << std::endl <<
">> not a valid STATISTIC block line";
4984 std::cerr << std::endl <<
">> If you do not understand this, just remove the STATISTIC block, musrfit will recreate after fitting";
4985 std::cerr << std::endl << std::endl;
4992 if (lines[i].fLine.Contains(
"STATISTIC")) {
4993 status = sscanf(lines[i].fLine.Data(),
"STATISTIC --- %s%s", date, time);
4995 fStatistic.fDate = TString(date)+TString(
", ")+TString(time);
4997 fStatistic.fDate = TString(
"\?\?\?\?-\?\?-\?\?, \?\?:\?\?:\?\?");
5001 if (lines[i].fLine.Contains(
"chisq =")) {
5002 if (lines[i].fLine.Contains(
"expected")) {
5003 strncpy(str, lines[i].fLine.Data(),
sizeof(str));
5004 status = sscanf(str+lines[i].fLine.Index(
"chisq = ")+8,
"%lf", &dval);
5012 strncpy(str, lines[i].fLine.Data(),
sizeof(str));
5013 status = sscanf(str+lines[i].fLine.Index(
"chisq = ")+8,
"%lf", &dval);
5022 if (lines[i].fLine.Contains(
"maxLH =")) {
5024 strncpy(str, lines[i].fLine.Data(),
sizeof(str));
5025 status = sscanf(str+lines[i].fLine.Index(
"maxLH = ")+8,
"%lf", &dval);
5033 if (lines[i].fLine.Contains(
", NDF =")) {
5034 strncpy(str, lines[i].fLine.Data(),
sizeof(str));
5035 status = sscanf(str+lines[i].fLine.Index(
", NDF = ")+8,
"%u", &ival);
5060 UInt_t noOfFitParameters = 0;
5064 std::vector<std::string> tokens;
5070 if (idx >=
fRuns.size()) {
5071 std::cerr << std::endl <<
">> PMsrHandler::GetNoOfFitParameters() **ERROR** idx=" << idx <<
", out of range fRuns.size()=" <<
fRuns.size();
5072 std::cerr << std::endl;
5077 if (
fRuns[idx].GetNormParamNo() != -1) {
5079 paramVector.push_back(
fRuns[idx].GetNormParamNo());
5085 if (
fRuns[idx].GetBkgFitParamNo() != -1)
5086 paramVector.push_back(
fRuns[idx].GetBkgFitParamNo());
5089 if (
fRuns[idx].GetAlphaParamNo() != -1) {
5091 paramVector.push_back(
fRuns[idx].GetAlphaParamNo());
5097 if (
fRuns[idx].GetBetaParamNo() != -1) {
5099 paramVector.push_back(
fRuns[idx].GetBetaParamNo());
5106 for (UInt_t i=0; i<
fTheory.size(); i++) {
5109 pos = str.Index(
'#');
5113 tokens = PStringUtils::Split(str.Data(),
" \t");
5115 for (UInt_t j=0; j<tokens.size(); j++) {
5117 if (PStringUtils::IsInt(tokens[j])) {
5118 dval = PStringUtils::ToInt(tokens[j]);
5119 paramVector.push_back(dval);
5123 if (tokens[j].find(
"map") != std::string::npos) {
5124 status = sscanf(tokens[j].c_str(),
"map%d", &dval);
5126 mapVector.push_back(dval);
5131 if (tokens[j].find(
"fun") != std::string::npos) {
5132 status = sscanf(tokens[j].c_str(),
"fun%d", &dval);
5134 funVector.push_back(dval);
5141 for (UInt_t i=0; i<funVector.size(); i++) {
5146 if (dval == funVector[i])
5153 std::cerr << std::endl <<
">> PMsrHandler::GetNoOfFitParameters() **ERROR** couldn't find fun" << funVector[i];
5154 std::cerr << std::endl << std::endl;
5159 paramVector.clear();
5166 pos = str.Index(
'#');
5171 tokens = PStringUtils::Split(str.Data(),
" \t");
5174 for (UInt_t j=0; j<tokens.size(); j++) {
5177 if (tokens[j].rfind(
"par", 0) == 0) {
5178 status = sscanf(tokens[j].c_str(),
"par%d", &dval);
5180 paramVector.push_back(dval);
5184 if (tokens[j].rfind(
"map", 0) == 0) {
5185 status = sscanf(tokens[j].c_str(),
"map%d", &dval);
5187 mapVector.push_back(dval);
5193 for (UInt_t i=0; i<mapVector.size(); i++) {
5194 paramVector.push_back(
fRuns[idx].GetMap(mapVector[i]-1));
5199 param.push_back(paramVector[0]);
5200 for (UInt_t i=0; i<paramVector.size(); i++) {
5201 for (k=0; k<param.size(); k++) {
5202 if (param[k] == paramVector[i])
5205 if (k == param.size())
5206 param.push_back(paramVector[i]);
5210 for (UInt_t i=0; i<param.size(); i++) {
5211 if (
fParam[param[i]-1].fStep != 0.0)
5212 noOfFitParameters++;
5219 paramVector.clear();
5221 return noOfFitParameters;
5239 PMsrLines::iterator iter;
5240 std::vector<std::string> tokens;
5245 for (UInt_t i=0; i<
fParam.size(); i++)
5249 for (iter = theory.begin(); iter != theory.end(); ++iter) {
5252 if (str.First(
'#') != -1)
5253 str.Resize(str.First(
'#'));
5259 tokens = PStringUtils::Split(str.Data(),
" \t");
5262 for (UInt_t i=0; i<tokens.size(); i++) {
5263 if (PStringUtils::IsInt(tokens[i])) {
5264 ival = PStringUtils::ToInt(tokens[i]);
5265 if ((ival > 0) && (ival <
static_cast<Int_t
>(
fParam.size())+1)) {
5268 }
else if (tokens[i].find(
"map") != std::string::npos) {
5271 }
else if (tokens[i].find(
"fun") != std::string::npos) {
5279 for (iter = funcs.begin(); iter != funcs.end(); ++iter) {
5282 if (str.First(
'#') != -1)
5283 str.Resize(str.First(
'#'));
5288 tokens = PStringUtils::Split(str.Data(),
" /t");
5299 for (UInt_t i=0; i<fun.size(); i++) {
5300 if (fun[i] == funNo) {
5304 while (sstr.Index(
"par") != -1) {
5305 memset(sval, 0,
sizeof(sval));
5306 sstr = &sstr[sstr.Index(
"par")+3];
5307 for (Int_t j=0; j<sstr.Sizeof(); j++) {
5308 if (!isdigit(sstr[j]))
5312 sscanf(sval,
"%d", &ival);
5318 while (sstr.Index(
"map") != -1) {
5319 memset(sval, 0,
sizeof(sval));
5320 sstr = &sstr[sstr.Index(
"map")+3];
5321 for (Int_t j=0; j<sstr.Sizeof(); j++) {
5322 if (!isdigit(sstr[j]))
5326 sscanf(sval,
"%d", &ival);
5330 for (pos=0; pos<map.size(); pos++) {
5331 if (ival == map[pos])
5334 if (pos == map.size()) {
5335 map.push_back(ival);
5345 for (iter = run.begin(); iter != run.end(); ++iter) {
5348 if (str.First(
'#') != -1)
5349 str.Resize(str.First(
'#'));
5355 if (str.Contains(
"alpha") || str.Contains(
"beta") ||
5356 str.Contains(
"alpha2") || str.Contains(
"beta2") ||
5357 str.Contains(
"norm") || str.Contains(
"backgr.fit") ||
5358 str.Contains(
"lifetime ")) {
5360 tokens = PStringUtils::Split(str.Data(),
" \t");
5361 if (tokens.size()<2)
5364 std::string tok1 = tokens[1];
5366 if (PStringUtils::IsInt(tok1)) {
5367 ival = PStringUtils::ToInt(tok1);
5371 if (tok1.find(
"fun") != std::string::npos) {
5379 if (str.Contains(
"map")) {
5381 tokens = PStringUtils::Split(str.Data(),
" \t");
5384 for (UInt_t i=0; i<map.size(); i++) {
5387 if (map[i] <
static_cast<Int_t
>(tokens.size())) {
5388 if (PStringUtils::IsInt(tokens[map[i]])) {
5389 ival = PStringUtils::ToInt(tokens[map[i]]);
5400 for (iter = funcs.begin(); iter != funcs.end(); ++iter) {
5403 if (str.First(
'#') != -1)
5404 str.Resize(str.First(
'#'));
5409 tokens = PStringUtils::Split(str.Data(),
" /t");
5420 for (UInt_t i=0; i<fun.size(); i++) {
5421 if (fun[i] == funNo) {
5425 while (sstr.Index(
"par") != -1) {
5426 memset(sval, 0,
sizeof(sval));
5427 sstr = &sstr[sstr.Index(
"par")+3];
5428 for (Int_t j=0; j<sstr.Sizeof(); j++) {
5429 if (!isdigit(sstr[j]))
5433 sscanf(sval,
"%d", &ival);
5439 while (sstr.Index(
"map") != -1) {
5440 memset(sval, 0,
sizeof(sval));
5441 sstr = &sstr[sstr.Index(
"map")+3];
5442 for (Int_t j=0; j<sstr.Sizeof(); j++) {
5443 if (!isdigit(sstr[j]))
5447 sscanf(sval,
"%d", &ival);
5451 for (pos=0; pos<map.size(); pos++) {
5452 if (ival == map[pos])
5455 if (
static_cast<UInt_t
>(pos) == map.size()) {
5456 map.push_back(ival);
5465 for (iter = run.begin(); iter != run.end(); ++iter) {
5468 if (str.First(
'#') != -1)
5469 str.Resize(str.First(
'#'));
5475 if (str.Contains(
"map")) {
5477 tokens = PStringUtils::Split(str.Data(),
" \t");
5480 for (UInt_t i=0; i<map.size(); i++) {
5483 if (map[i] <
static_cast<Int_t
>(tokens.size())) {
5484 if (PStringUtils::IsInt(tokens[map[i]])) {
5485 ival = PStringUtils::ToInt(tokens[map[i]]);
5496 for (UInt_t i=0; i<
fParam.size(); i++) {
5498 if (
fParam[i].fStep != 0.0) {
5499 std::cerr << std::endl <<
">> **WARNING** : Parameter No " << i+1 <<
" is not used at all, will fix it" << std::endl;
5526 for (UInt_t i=0; i<
fRuns.size(); i++) {
5528 fitType =
fRuns[i].GetFitType();
5529 if (fitType == -1) {
5530 fitType =
fGlobal.GetFitType();
5531 if (fitType == -1) {
5532 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** fittype is neither defined in RUN block number " << i+1 <<
", nor in the GLOBAL block." << std::endl;
5538 Int_t detectorGroups = 1;
5543 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5544 std::cerr << std::endl <<
">> Norm parameter number not defined. Necessary for single histogram fits." << std::endl;
5551 if (
fRuns[i].GetNormParamNo() >
static_cast<Int_t
>(
fParam.size())) {
5552 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5553 std::cerr << std::endl <<
">> Norm parameter number " <<
fRuns[i].GetNormParamNo() <<
" is larger than the number of fit parameters (" <<
fParam.size() <<
").";
5554 std::cerr << std::endl <<
">> Consider to check the manual ;-)" << std::endl;
5559 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5560 std::cerr << std::endl <<
">> Norm parameter function number " <<
fRuns[i].GetNormParamNo()-
MSR_PARAM_FUN_OFFSET <<
" is larger than the number of functions (" <<
GetNoOfFuncs() <<
").";
5561 std::cerr << std::endl <<
">> Consider to check the manual ;-)" << std::endl;
5567 if (
fRuns[i].GetForwardHistoNo() == -1) {
5568 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5569 std::cerr << std::endl <<
">> forward parameter number not defined. Necessary for single histogram fits." << std::endl;
5575 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5576 std::cerr << std::endl <<
">> forward histogram number " <<
fRuns[i].GetNormParamNo() <<
" is larger than the number of fit parameters (" <<
fParam.size() <<
").";
5577 std::cerr << std::endl <<
">> Consider to check the manual ;-)" << std::endl;
5584 if (!
fGlobal.IsFitRangeInBin()) {
5586 std::cerr << std::endl <<
"PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5587 std::cerr << std::endl <<
" Fit range is not defined. Necessary for single histogram fits." << std::endl;
5594 detectorGroups =
fRuns[i].GetForwardHistoNoSize();
5595 if ((
fRuns[i].GetT0BinSize() > detectorGroups) || (
fGlobal.GetT0BinSize() > detectorGroups)) {
5596 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5597 if (
fRuns[i].GetT0BinSize() > detectorGroups)
5598 std::cerr << std::endl <<
">> In RUN Block " << i+1 <<
": found " <<
fRuns[i].GetT0BinSize() <<
" T0 entries. Expecting max. " << detectorGroups <<
" entries.";
5599 if (
fGlobal.GetT0BinSize() > 1)
5600 std::cerr << std::endl <<
">> In GLOBAL block: found " <<
fGlobal.GetT0BinSize() <<
" T0 entries. Expecting max. " << detectorGroups <<
" entries. Needs to be fixed.";
5601 std::cerr << std::endl <<
">> In case you added runs, please use the key word 'addt0' to add the t0's of the runs to be added." << std::endl;
5606 if ((
fRuns[i].GetPacking() == -1) && (
fGlobal.GetPacking() == -1)) {
5607 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **WARNING** in RUN block number " << i+1;
5608 std::cerr << std::endl <<
">> Packing is neither defined here, nor in the GLOBAL block, will set it to 1." << std::endl;
5609 fRuns[i].SetPacking(1);
5614 if (
fRuns[i].GetForwardHistoNo() == -1) {
5615 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5616 std::cerr << std::endl <<
">> forward parameter number not defined. Necessary for single histogram RRF fits." << std::endl;
5622 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5623 std::cerr << std::endl <<
">> forward histogram number " <<
fRuns[i].GetNormParamNo() <<
" is larger than the number of fit parameters (" <<
fParam.size() <<
").";
5624 std::cerr << std::endl <<
">> Consider to check the manual ;-)" << std::endl;
5631 if (!
fGlobal.IsFitRangeInBin()) {
5633 std::cerr << std::endl <<
"PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5634 std::cerr << std::endl <<
" Fit range is not defined. Necessary for single histogram fits." << std::endl;
5641 detectorGroups =
fRuns[i].GetForwardHistoNoSize();
5642 if ((
fRuns[i].GetT0BinSize() > detectorGroups) || (
fGlobal.GetT0BinSize() > detectorGroups)) {
5643 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5644 if (
fRuns[i].GetT0BinSize() > detectorGroups)
5645 std::cerr << std::endl <<
">> In RUN Block " << i+1 <<
": found " <<
fRuns[i].GetT0BinSize() <<
" T0 entries. Expecting max. " << detectorGroups <<
" entries.";
5646 if (
fGlobal.GetT0BinSize() > 1)
5647 std::cerr << std::endl <<
">> In GLOBAL block: found " <<
fGlobal.GetT0BinSize() <<
" T0 entries. Expecting max. " << detectorGroups <<
" entries. Needs to be fixed.";
5648 std::cerr << std::endl <<
">> In case you added runs, please use the key word 'addt0' to add the t0's of the runs to be added." << std::endl;
5653 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** no RRF frequency found in the GLOBAL block." << std::endl;
5657 if (
fGlobal.GetRRFPacking() == -1) {
5658 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** no RRF packing found in the GLOBAL block." << std::endl;
5665 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5666 std::cerr << std::endl <<
">> alpha parameter number missing which is needed for an asymmetry fit.";
5667 std::cerr << std::endl <<
">> Consider to check the manual ;-)" << std::endl;
5671 if (
fRuns[i].GetForwardHistoNo() == -1) {
5672 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5673 std::cerr << std::endl <<
">> forward histogram number not defined. Necessary for asymmetry fits." << std::endl;
5677 if (
fRuns[i].GetBackwardHistoNo() == -1) {
5678 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5679 std::cerr << std::endl <<
">> backward histogram number not defined. Necessary for asymmetry fits." << std::endl;
5683 if (!
fRuns[i].IsFitRangeInBin()) {
5686 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5687 std::cerr << std::endl <<
">> Fit range is not defined, also NOT present in the GLOBAL block. Necessary for asymmetry fits." << std::endl;
5693 detectorGroups = 2*
fRuns[i].GetForwardHistoNoSize();
5694 if (detectorGroups < 2*
fRuns[i].GetBackwardHistoNoSize())
5695 detectorGroups = 2*
fRuns[i].GetBackwardHistoNoSize();
5696 if ((
fRuns[i].GetT0BinSize() > detectorGroups) || (
fGlobal.GetT0BinSize() > detectorGroups)) {
5697 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5698 if (
fRuns[i].GetT0BinSize() > detectorGroups)
5699 std::cerr << std::endl <<
">> In RUN Block " << i+1 <<
": found " <<
fRuns[i].GetT0BinSize() <<
" T0 entries. Expecting max. " << detectorGroups <<
" entries.";
5700 if (
fGlobal.GetT0BinSize() > 1)
5701 std::cerr << std::endl <<
">> In GLOBAL block: found " <<
fGlobal.GetT0BinSize() <<
" T0 entries. Expecting max. " << detectorGroups <<
" entries. Needs to be fixed.";
5702 std::cerr << std::endl <<
">> In case you added runs, please use the key word 'addt0' to add the t0's of the runs to be added." << std::endl;
5706 if ((
fRuns[i].GetPacking() == -1) && (
fGlobal.GetPacking() == -1)) {
5707 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **WARNING** in RUN block number " << i+1;
5708 std::cerr << std::endl <<
">> Packing is neither defined here, nor in the GLOBAL block, will set it to 1." << std::endl;
5709 fRuns[i].SetPacking(1);
5721 if (
fRuns[i].GetForwardHistoNo() == -1) {
5722 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5723 std::cerr << std::endl <<
">> forward histogram number not defined. Necessary for asymmetry fits." << std::endl;
5727 if (
fRuns[i].GetBackwardHistoNo() == -1) {
5728 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5729 std::cerr << std::endl <<
">> backward histogram number not defined. Necessary for asymmetry fits." << std::endl;
5733 if (!
fRuns[i].IsFitRangeInBin()) {
5736 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5737 std::cerr << std::endl <<
">> Fit range is not defined, also NOT present in the GLOBAL block. Necessary for asymmetry fits." << std::endl;
5743 if ((
fRuns[i].GetT0BinSize() > 2*
fRuns[i].GetForwardHistoNoSize()) &&
5744 (
fGlobal.GetT0BinSize() > 2*
fRuns[i].GetForwardHistoNoSize())) {
5745 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5746 std::cerr << std::endl <<
">> Found " <<
fRuns[i].GetT0BinSize() <<
" T0 entries. Expecting only " << 2*
fRuns[i].GetForwardHistoNoSize() <<
" in forward. Needs to be fixed." << std::endl;
5747 std::cerr << std::endl <<
">> In GLOBAL block: " <<
fGlobal.GetT0BinSize() <<
" T0 entries. Expecting only " << 2*
fRuns[i].GetForwardHistoNoSize() <<
". Needs to be fixed." << std::endl;
5750 if ((
fRuns[i].GetT0BinSize() > 2*
fRuns[i].GetBackwardHistoNoSize()) &&
5751 (
fGlobal.GetT0BinSize() > 2*
fRuns[i].GetBackwardHistoNoSize())) {
5752 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5753 std::cerr << std::endl <<
">> Found " <<
fRuns[i].GetT0BinSize() <<
" T0 entries. Expecting only " << 2*
fRuns[i].GetBackwardHistoNoSize() <<
" in backward. Needs to be fixed." << std::endl;
5754 std::cerr << std::endl <<
">> In GLOBAL block: " <<
fGlobal.GetT0BinSize() <<
" T0 entries. Expecting only " << 2*
fRuns[i].GetBackwardHistoNoSize() <<
". Needs to be fixed." << std::endl;
5758 if ((
fRuns[i].GetPacking() == -1) && (
fGlobal.GetPacking() == -1)) {
5759 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **WARNING** in RUN block number " << i+1;
5760 std::cerr << std::endl <<
">> Packing is neither defined here, nor in the GLOBAL block, will set it to 1." << std::endl;
5761 fRuns[i].SetPacking(1);
5767 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5768 std::cerr << std::endl <<
">> alpha parameter number missing which is needed for an asymmetry RRF fit.";
5769 std::cerr << std::endl <<
">> Consider to check the manual ;-)" << std::endl;
5773 if (
fRuns[i].GetForwardHistoNo() == -1) {
5774 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5775 std::cerr << std::endl <<
">> forward histogram number not defined. Necessary for asymmetry RRF fits." << std::endl;
5779 if (
fRuns[i].GetBackwardHistoNo() == -1) {
5780 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5781 std::cerr << std::endl <<
">> backward histogram number not defined. Necessary for asymmetry RRF fits." << std::endl;
5785 if (!
fRuns[i].IsFitRangeInBin()) {
5788 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5789 std::cerr << std::endl <<
">> Fit range is not defined, also NOT present in the GLOBAL block. Necessary for asymmetry RRF fits." << std::endl;
5795 detectorGroups = 2*
fRuns[i].GetForwardHistoNoSize();
5796 if (detectorGroups < 2*
fRuns[i].GetBackwardHistoNoSize())
5797 detectorGroups = 2*
fRuns[i].GetBackwardHistoNoSize();
5798 if ((
fRuns[i].GetT0BinSize() > detectorGroups) || (
fGlobal.GetT0BinSize() > detectorGroups)) {
5799 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5800 if (
fRuns[i].GetT0BinSize() > detectorGroups)
5801 std::cerr << std::endl <<
">> In RUN Block " << i+1 <<
": found " <<
fRuns[i].GetT0BinSize() <<
" T0 entries. Expecting max. " << detectorGroups <<
" entries.";
5802 if (
fGlobal.GetT0BinSize() > 1)
5803 std::cerr << std::endl <<
">> In GLOBAL block: found " <<
fGlobal.GetT0BinSize() <<
" T0 entries. Expecting max. " << detectorGroups <<
" entries. Needs to be fixed.";
5804 std::cerr << std::endl <<
">> In case you added runs, please use the key word 'addt0' to add the t0's of the runs to be added." << std::endl;
5809 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** no RRF frequency found in the GLOBAL block." << std::endl;
5813 if (
fGlobal.GetRRFPacking() == -1) {
5814 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** no RRF packing found in the GLOBAL block." << std::endl;
5823 if ((
fRuns[i].GetXDataIndex() == -1) && (
fRuns[i].GetXDataLabel()->Length() == 0)) {
5824 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5825 std::cerr << std::endl <<
">> xy-data is missing. Necessary for non muSR fits." << std::endl;
5831 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
5832 std::cerr << std::endl <<
">> Fit range is not defined, neither in the RUN block, nor in the GLOBAL block.";
5833 std::cerr << std::endl <<
">> Necessary for non muSR fits." << std::endl;
5838 if (
fRuns[i].GetPacking() == -1) {
5839 if (
fGlobal.GetPacking() == -1) {
5840 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **WARNING** in RUN block number " << i+1;
5841 std::cerr << std::endl <<
">> Packing is not defined, will set it to 1." << std::endl;
5842 fRuns[i].SetPacking(1);
5847 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** fittype " << fitType <<
" undefined." << std::endl;
5872 Bool_t unique =
true;
5874 for (UInt_t i=0; i<
fParam.size()-1; i++) {
5875 for (UInt_t j=i+1; j<
fParam.size(); j++) {
5901 Bool_t result =
true;
5907 std::vector<std::string> tokens;
5912 for (UInt_t i=0; i<
fTheory.size(); i++) {
5913 if (
fTheory[i].fLine.Contains(
"map", TString::kIgnoreCase)) {
5915 tokens = PStringUtils::Split(
fTheory[i].fLine.Data(),
" \t");
5916 for (UInt_t j=0; j<tokens.size(); j++) {
5917 if (PStringUtils::ContainsNoCase(tokens[j],
"map")) {
5919 mapVec.push_back(no);
5920 mapBlock.push_back(0);
5921 mapLineNo.push_back(
fTheory[i].fLineNo);
5930 if (
fFunctions[i].fLine.Contains(
"map", TString::kIgnoreCase)) {
5932 tokens = PStringUtils::Split(
fFunctions[i].fLine.Data(),
" \t");
5933 for (UInt_t j=0; j<tokens.size(); j++) {
5934 if (PStringUtils::ContainsNoCase(tokens[j],
"map")) {
5936 mapVec.push_back(no);
5937 mapBlock.push_back(1);
5947 for (UInt_t i=0; i<mapVec.size(); i++) {
5949 for (UInt_t j=0; j<
fRuns.size(); j++) {
5960 std::cerr << std::endl <<
">> PMsrHandler::CheckMaps: **ERROR** map" << mapVec[i]-
MSR_PARAM_MAP_OFFSET <<
" found in the ";
5961 if (mapBlock[i] == 0)
5962 std::cerr <<
"theory-block ";
5964 std::cerr <<
"functions-block ";
5965 std::cerr <<
"in line " << mapLineNo[i] <<
" is not present in the run-block!";
5966 std::cerr << std::endl;
5968 std::cerr << std::endl <<
">> by the way: map must be > 0 ...";
5969 std::cerr << std::endl;
5995 Bool_t result =
true;
6004 std::vector<std::string> tokens;
6010 for (UInt_t i=0; i<
fTheory.size(); i++) {
6011 if (
fTheory[i].fLine.Contains(
"fun", TString::kIgnoreCase)) {
6013 tokens = PStringUtils::Split(
fTheory[i].fLine.Data(),
" \t");
6014 for (UInt_t j=0; j<tokens.size(); j++) {
6015 if (PStringUtils::ContainsNoCase(tokens[j],
"fun")) {
6017 funVec.push_back(no);
6018 funBlock.push_back(0);
6019 funLineBlockNo.push_back(
fTheory[i].fLineNo);
6027 for (UInt_t i=0; i<
fRuns.size(); i++) {
6029 funVec.push_back(
fRuns[i].GetNormParamNo());
6030 funBlock.push_back(1);
6031 funLineBlockNo.push_back(i+1);
6037 for (UInt_t i=0; i<funVec.size(); i++) {
6043 str = TString(
"fun");
6045 if (
fFunctions[j].fLine.Contains(str, TString::kIgnoreCase)) {
6052 std::cerr << std::endl <<
">> PMsrHandler::CheckFuncs: **ERROR** fun" << funVec[i]-
MSR_PARAM_FUN_OFFSET <<
" found in the ";
6053 if (funBlock[i] == 0)
6054 std::cerr <<
"theory-block in line " << funLineBlockNo[i] <<
" is not present in the functions-block!";
6056 std::cerr <<
"run-block No " << funLineBlockNo[i] <<
" (norm) is not present in the functions-block!";
6057 std::cerr << std::endl;
6064 funLineBlockNo.clear();
6081 Bool_t result =
true;
6083 for (UInt_t i=0; i<
fRuns.size(); i++) {
6085 if (
fRuns[i].GetForwardHistoNoSize() > 1) {
6086 for (UInt_t j=0; j<
fRuns[i].GetForwardHistoNoSize(); j++) {
6087 for (UInt_t k=j+1; k<
fRuns[i].GetForwardHistoNoSize(); k++) {
6088 if (
fRuns[i].GetForwardHistoNo(j) ==
fRuns[i].GetForwardHistoNo(k)) {
6089 std::cerr << std::endl <<
">> PMsrHandler::CheckHistoGrouping: **WARNING** grouping identical histograms!!";
6090 std::cerr << std::endl <<
">> run no " << i+1 <<
", forward histo " << j+1 <<
" == forward histo " << k+1 <<
".";
6091 std::cerr << std::endl <<
">> this really doesn't make any sense, but you are the boss.";
6092 std::cerr << std::endl;
6098 if (
fRuns[i].GetBackwardHistoNoSize() > 1) {
6099 for (UInt_t j=0; j<
fRuns[i].GetBackwardHistoNoSize(); j++) {
6100 for (UInt_t k=j+1; k<
fRuns[i].GetBackwardHistoNoSize(); k++) {
6101 if (
fRuns[i].GetBackwardHistoNo(j) ==
fRuns[i].GetBackwardHistoNo(k)) {
6102 std::cerr << std::endl <<
">> PMsrHandler::CheckHistoGrouping: **WARNING** grouping identical histograms!!";
6103 std::cerr << std::endl <<
">> run no " << i+1 <<
", backward histo " << j+1 <<
" == backward histo " << k+1 <<
".";
6104 std::cerr << std::endl <<
">> this really doesn't make any sense, but you are the boss.";
6105 std::cerr << std::endl;
6127 Bool_t result =
true;
6129 for (UInt_t i=0; i<
fRuns.size(); i++) {
6130 if (
fRuns[i].GetRunNameSize() > 1) {
6132 if (
fRuns[i].GetAddT0BinEntries() != 0) {
6133 if (
fRuns[i].GetAddT0BinEntries() !=
fRuns[i].GetRunNameSize()-1) {
6136 fLastErrorMsg <<
">> PMsrHandler::CheckAddRunParameters: **ERROR** # of addt0 != # of addruns.\n";
6160 for (UInt_t i=0; i<
fRuns.size(); i++) {
6165 fLastErrorMsg <<
">> PMsrHandler::CheckMaxLikelihood: **WARNING**: Maximum Log Likelihood Fit is only implemented\n";
6166 fLastErrorMsg <<
">> for Single Histogram and Mu Minus Fits. Will fall back to Chi Square Fit.\n";
6167 std::cerr << std::endl << std::endl;
6184 Bool_t result =
true;
6185 Int_t fittype =
fGlobal.GetFitType();
6189 if (fittype != -1) {
6192 std::cerr << std::endl <<
">> PMsrHandler::CheckRRFSettings: **ERROR** found GLOBAL fittype " << fittype <<
" and";
6193 std::cerr << std::endl <<
">> RRF settings in the GLOBAL section. This is NOT compatible. Fix it first.";
6197 for (UInt_t i=0; i<
fRuns.size(); i++) {
6198 fittype =
fRuns[i].GetFitType();
6201 std::cerr << std::endl <<
">> PMsrHandler::CheckRRFSettings: **ERROR** found RUN with fittype " << fittype <<
" and";
6202 std::cerr << std::endl <<
">> RRF settings in the GLOBAL section. This is NOT compatible. Fix it first.";
6209 if (
fGlobal.GetRRFPacking() != -1) {
6210 std::cerr << std::endl <<
">> PMsrHandler::CheckRRFSettings: **WARNING** found in the GLOBAL section rrf_packing, without";
6211 std::cerr << std::endl <<
">> rrf_freq. Doesn't make any sense. Will drop rrf_packing";
6212 std::cerr << std::endl << std::endl;
6215 if (
fGlobal.GetRRFPhase() != 0.0) {
6216 std::cerr << std::endl <<
">> PMsrHandler::CheckRRFSettings: **WARNING** found in the GLOBAL section rrf_phase, without";
6217 std::cerr << std::endl <<
">> rrf_freq. Doesn't make any sense. Will drop rrf_phase";
6218 std::cerr << std::endl << std::endl;
6230 fittype =
fGlobal.GetFitType();
6234 std::cerr << std::endl <<
">> PMsrHandler::CheckRRFSettings: **ERROR** RRF fit chosen, but";
6235 std::cerr << std::endl <<
">> no RRF frequency found in the GLOBAL section! Fix it.";
6238 if (
fGlobal.GetRRFPacking() == -1) {
6239 std::cerr << std::endl <<
">> PMsrHandler::CheckRRFSettings: **ERROR** RRF fit chosen, but";
6240 std::cerr << std::endl <<
">> no RRF packing found in the GLOBAL section! Fix it.";
6244 UInt_t rrfFitCounter = 0;
6245 for (UInt_t i=0; i<
fRuns.size(); i++) {
6246 fittype =
fRuns[i].GetFitType();
6252 if (rrfFitCounter !=
fRuns.size()) {
6253 std::cerr << std::endl <<
">> PMsrHandler::CheckRRFSettings: **ERROR** #Runs (" <<
fRuns.size() <<
") != # RRF fits found (" << rrfFitCounter <<
")";
6254 std::cerr << std::endl <<
">> This is currently not supported.";
6258 std::cerr << std::endl <<
">> PMsrHandler::CheckRRFSettings: **ERROR** RRF fit chosen, but";
6259 std::cerr << std::endl <<
">> no RRF frequency found in the GLOBAL section! Fix it.";
6262 if (
fGlobal.GetRRFPacking() == -1) {
6263 std::cerr << std::endl <<
">> PMsrHandler::CheckRRFSettings: **ERROR** RRF fit chosen, but";
6264 std::cerr << std::endl <<
">> no RRF packing found in the GLOBAL section! Fix it.";
6283 if (!
fFourier.fFourierBlockPresent)
6295 fLastErrorMsg <<
">> PMsrHandler::ReadMsrFile: **ERROR** if more than one phase is given in the Fourier block,\n";
6296 fLastErrorMsg <<
">> it needs to correspond to the number of runs in the Plot block!\n";
6298 fLastErrorMsg <<
">> number of runs in the PLOT block: " <<
fPlots[0].fRuns.size() <<
"\n";
6306 if ((
fFourier.fPhase.size() == 0) && (
fFourier.fPhaseParamNo.size() == 0)) {
6309 fLastErrorMsg <<
">> PMsrHandler::ReadMsrFile: **ERROR** for FOURIER plot != POWER,\n";
6310 fLastErrorMsg <<
">> phases need to be defined in the FOURIER block!\n";
6313 fLastErrorMsg <<
">> where parR7 is the reference phase, and the others the relative phases.\n";
6314 fLastErrorMsg <<
">> I.e. phase of run 2: parR7 + par9, etc.\n";
6338 if (!detector.CompareTo(
"forward", TString::kIgnoreCase)) {
6339 for (UInt_t i=0; i<
fRuns[runNo].GetForwardHistoNoSize(); i++)
6340 grouping.push_back(
fRuns[runNo].GetForwardHistoNo(i));
6342 }
else if (!detector.CompareTo(
"backward", TString::kIgnoreCase)) {
6343 for (UInt_t i=0; i<
fRuns[runNo].GetBackwardHistoNoSize(); i++)
6344 grouping.push_back(
fRuns[runNo].GetBackwardHistoNo(i));
6347 groupingStr =
"**ERROR** unkown detector. Allow forward/backward.";
6387 for (UInt_t i=0; i<precLimit; i++) {
6388 if (
static_cast<Int_t
>(dval*pow(10.0,
static_cast<Double_t
>(i))) != 0) {
6394 if (prec == precLimit) {
6395 std::cerr << std::endl <<
">> PMsrHandler::NeededPrecision(): **WARNING** precision limit of " << precLimit <<
", requested.";
6414 UInt_t lastSignificant = 2;
6415 UInt_t decimalPoint = 0;
6419 snprintf(str,
sizeof(str),
"%lf", dval);
6422 for (UInt_t i=0; i<strlen(str); i++) {
6423 if (str[i] ==
'.') {
6430 for (Int_t i=strlen(str)-1; i>=0; i--) {
6431 if (str[i] !=
'0') {
6432 if ((
static_cast<UInt_t
>(i)-decimalPoint) < precLimit)
6433 lastSignificant =
static_cast<UInt_t
>(i)-decimalPoint;
6435 lastSignificant = precLimit;
6440 return lastSignificant;
6456 if (includeDetector) {
6457 result = str + TString(
" ");
6458 if (str == TString(
"forward"))
6464 if (group.size()==0)
6470 if (j+1 < group.size()) {
6471 while (group[j]+1 == group[j+1]) {
6473 if (j == group.size()-1)
6488 }
while (i<group.size());
6504 TString formatStr(
"par%d, par%d");
6506 if (
fFourier.fPhaseParamNo.size() == 0)
6509 Int_t phaseRef =
fFourier.fPhaseRef;
6511 if (
fFourier.fPhaseParamNo.size() == 1) {
6512 str = TString::Format(
"par%d",
fFourier.fPhaseParamNo[0]);
6513 }
else if (
fFourier.fPhaseParamNo.size() == 2) {
6514 if (phaseRef ==
fFourier.fPhaseParamNo[0])
6515 formatStr =
"parR%d, par%d";
6516 if (phaseRef ==
fFourier.fPhaseParamNo[1])
6517 formatStr =
"par%d, parR%d";
6518 str = TString::Format(formatStr,
fFourier.fPhaseParamNo[0],
fFourier.fPhaseParamNo[1]);
6520 Bool_t phaseIter =
true;
6524 for (Int_t i=2; i<
fFourier.fPhaseParamNo.size(); i++) {
6532 if (phaseRef != -1) {
6533 str = TString::Format(
"parR(%d, %d, %lu)",
fFourier.fPhaseParamNo[0], offset,
fFourier.fPhaseParamNo.size());
6535 str = TString::Format(
"par(%d, %d, %lu)",
fFourier.fPhaseParamNo[0], offset,
fFourier.fPhaseParamNo.size());
6539 for (Int_t i=0; i<
fFourier.fPhaseParamNo.size()-1; i++) {
6540 if (phaseRef ==
fFourier.fPhaseParamNo[i]) {
6572 for (UInt_t i=0; i<
fPlots.size(); i++) {
6573 for (UInt_t j=0; j<
fPlots[i].fRuns.size(); j++) {
6574 idx =
fPlots[i].fRuns[j]-1;
6575 if (
fRuns[idx].IsLifetimeCorrected()) {
6576 fPlots[i].fLifeTimeCorrection =
true;
#define MSR_TAG_TITLE
TITLE block - describes the experiment.
#define MSR_TAG_RUN
RUN block - run-specific settings and data file information.
std::vector< UInt_t > PUIntVector
#define MSR_PARAM_MAP_OFFSET
Offset added to map indices for parameter parsing.
#define PRUN_ASYMMETRY
Asymmetry fit using forward and backward detectors.
#define MSR_TAG_FUNCTIONS
FUNCTIONS block - user-defined mathematical functions.
#define MSR_FITTYPE_ASYM
Fit asymmetry A(t) = (F-αB)/(F+αB)
#define PMUSR_MSR_LOG_FILE_WRITE_ERROR
Failed to write to MSR log file.
#define PRUN_MU_MINUS
Negative muon (μ-) single histogram fit.
#define MSR_PLOT_SINGLE_HISTO
Plot single histogram.
#define FOURIER_UNIT_FREQ
Frequency in MHz.
#define FOURIER_PLOT_REAL_AND_IMAG
Plot both real and imaginary components (default)
#define PRUN_ASYMMETRY_RRF
Asymmetry fit in rotating reference frame (RRF)
#define RRF_UNIT_MHz
Frequency in MHz (megahertz)
#define PMUSR_SUCCESS
Successful operation completion.
#define FOURIER_UNIT_GAUSS
Magnetic field in Gauss (G)
#define MSR_FITTYPE_SINGLE_HISTO_RRF
Fit single histogram in rotating reference frame.
#define FOURIER_PLOT_NOT_GIVEN
Plot type not specified.
#define FOURIER_PLOT_POWER
Plot power spectrum |F(ω)|²
#define MSR_TAG_COMMANDS
COMMANDS block - post-fit commands (e.g., parameter output)
#define MSR_TAG_FOURIER
FOURIER block - Fourier transform settings.
#define PMUSR_MSR_FILE_NOT_FOUND
MSR file could not be found at specified path.
#define MSR_PARAM_FUN_OFFSET
Offset added to function indices for parameter parsing.
#define MSR_TAG_THEORY
THEORY block - specifies the theory function(s) to fit.
std::vector< Bool_t > PBoolVector
#define MSR_FITTYPE_SINGLE_HISTO
Fit single histogram (e.g., positron counts vs. time)
#define PRUN_SINGLE_HISTO_RRF
Single histogram fit in rotating reference frame (RRF)
#define FOURIER_PLOT_REAL
Plot real component only.
#define FOURIER_PLOT_PHASE_OPT_REAL
Plot phase-optimized real component.
#define MSR_FITTYPE_MU_MINUS
Fit negative muon (μ-) single histogram.
#define FOURIER_APOD_WEAK
Weak apodization (gentle windowing)
#define MSR_PLOT_ASYM_RRF
Plot asymmetry in rotating reference frame.
std::vector< PMsrLineStructure > PMsrLines
#define MSR_FITTYPE_ASYM_RRF
Fit asymmetry in rotating reference frame.
#define MSR_FITTYPE_NON_MUSR
Fit non-μSR data (general x-y data)
#define MSR_PLOT_SINGLE_HISTO_RRF
Plot single histogram in rotating reference frame.
#define PMUSR_MSR_SYNTAX_ERROR
Syntax error detected in MSR file content.
#define FOURIER_APOD_NONE
No apodization (rectangular window)
#define FOURIER_UNIT_CYCLES
Angular frequency in Mc/s (Mega-cycles per second)
#define MSR_PLOT_ASYM
Plot asymmetry.
#define PRUN_NON_MUSR
Non-μSR data fit (general x-y data)
#define FOURIER_APOD_STRONG
Strong apodization (heavy windowing for best frequency resolution)
#define MSR_TAG_PLOT
PLOT block - plotting configuration for data visualization.
#define PRUN_SINGLE_HISTO
Single histogram fit (e.g., forward or backward detector)
std::vector< Int_t > PIntVector
#define PMUSR_MSR_FILE_WRITE_ERROR
Failed to write MSR file.
#define MSR_PLOT_MU_MINUS
Plot negative muon (μ-) data.
#define MSR_TAG_FITPARAMETER
FITPARAMETER block - defines fit parameters with initial values and constraints.
#define MSR_FITTYPE_BNMR
Fit beta-detected NMR asymmetry.
#define RRF_UNIT_Mcs
Angular frequency in Mc/s (Mega-cycles per second)
#define RRF_UNIT_G
Equivalent magnetic field in Gauss (G)
#define FOURIER_PLOT_IMAG
Plot imaginary component only.
#define MSR_TAG_STATISTIC
STATISTIC block - fit statistics and results (generated after fit)
#define RRF_UNIT_kHz
Frequency in kHz (kilohertz)
#define FOURIER_APOD_MEDIUM
Medium apodization (moderate windowing)
#define MSR_PLOT_BNMR
Plot beta-detected NMR data.
#define RRF_UNIT_T
Equivalent magnetic field in Tesla (T)
#define FOURIER_PLOT_PHASE
Plot phase spectrum arg(F(ω))
#define FOURIER_UNIT_NOT_GIVEN
Units not specified.
#define PRUN_ASYMMETRY_BNMR
Beta-detected NMR asymmetry fit.
#define FOURIER_UNIT_TESLA
Magnetic field in Tesla (T)
#define FOURIER_APOD_NOT_GIVEN
Apodization not specified.
#define RRF_UNIT_UNDEF
RRF unit undefined.
#define MSR_TAG_GLOBAL
GLOBAL block - global fit settings (RRF, fit type, etc.)
#define MSR_PLOT_NON_MUSR
Plot non-μSR data.
virtual void SetT0Bin(Double_t dval, Int_t idx=-1)
virtual void SetFitRangeInBins(Bool_t bval)
virtual void SetRRFFreq(Double_t freq, const char *unit)
virtual void SetFitRange(Double_t dval, UInt_t idx)
virtual void SetGlobalPresent(Bool_t bval)
virtual void SetFitType(Int_t ival)
virtual void SetDeadTimeCorrection(TString str)
virtual void SetDataRange(Int_t ival, Int_t idx)
virtual void SetPacking(Int_t ival)
virtual void SetRRFPhase(Double_t phase)
virtual void SetRRFPacking(Int_t pack)
virtual void SetFitRangeOffset(Int_t ival, UInt_t idx)
virtual void SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx)
virtual Double_t GetRRFFreq(const char *unit)
virtual Bool_t CheckMaps()
Validates that all map indices are within parameter range.
virtual UInt_t GetNoOfFitParameters(UInt_t idx)
virtual UInt_t NeededPrecision(Double_t dval, UInt_t precLimit=13)
Calculates precision needed for formatting a double value.
virtual Bool_t ParseFourierPhaseValueVector(PMsrFourierStructure &fourier, const TString &str, Bool_t &error)
Parses Fourier phase value vector.
virtual Bool_t CheckHistoGrouping()
Checks histogram grouping consistency across runs.
virtual void SetMsrBkgRangeEntry(UInt_t runNo, UInt_t idx, Int_t bin)
virtual Bool_t SetMsrParamStep(UInt_t i, Double_t value)
virtual Bool_t CheckRRFSettings()
Validates RRF (Rotating Reference Frame) settings.
virtual Bool_t EstimateN0()
Bool_t fFourierOnly
Flag indicating Fourier transform only mode (for musrFT)
std::stringstream fLastErrorMsg
Stream accumulating error messages during parsing.
std::unique_ptr< PFunctionHandler > fFuncHandler
Handler for parsing and evaluating user-defined functions.
virtual void SetMsrAddT0Entry(UInt_t runNo, UInt_t addRunIdx, UInt_t histoIdx, Double_t bin)
virtual Bool_t HandleGlobalEntry(PMsrLines &line)
Parses GLOBAL block entries.
TString fTitle
MSR file title string.
virtual void SetMsrT0Entry(UInt_t runNo, UInt_t idx, Double_t bin)
virtual void FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLines &run)
Determines which parameters are used in theory and functions.
virtual void SetMsrDataRangeEntry(UInt_t runNo, UInt_t idx, Int_t bin)
virtual Int_t GetNoOfFuncs()
Returns the number of user-defined functions in FUNCTIONS block.
virtual Bool_t HandleFourierEntry(PMsrLines &line)
Parses FOURIER block entries.
virtual Bool_t HandleFitParameterEntry(PMsrLines &line)
Parses FITPARAMETER block entries.
PMsrGlobalBlock fGlobal
Global block settings (fit type, data format, etc.)
virtual ~PMsrHandler()
Destructor that cleans up all data structures.
virtual Bool_t CheckRunBlockIntegrity()
Validates RUN block structure and consistency.
Bool_t fCopyStatisticsBlock
If true, copy old statistics block (musrt0); if false, write new one (musrfit)
virtual Bool_t CheckAddRunParameters()
Validates addrun parameter references.
virtual Bool_t SetMsrParamPosError(UInt_t i, Double_t value)
PMsrStatisticStructure fStatistic
Fit statistics (χ², NDF, convergence status)
virtual Bool_t HandleTheoryEntry(PMsrLines &line)
Parses THEORY block entries.
virtual Bool_t ParseFourierPhaseParIterVector(PMsrFourierStructure &fourier, const TString &str, Bool_t &error)
Parses Fourier phase parameter iteration vector.
virtual Bool_t SetMsrParamValue(UInt_t i, Double_t value)
virtual Bool_t SetMsrParamPosErrorPresent(UInt_t i, Bool_t value)
PIntVector fParamInUse
Flags indicating which parameters are actually used in theory/functions.
virtual TString BeautifyFourierPhaseParameterString()
Formats Fourier phase parameter string for display.
PMsrLines fFunctions
User-defined functions block lines.
virtual Int_t WriteMsrFile(const Char_t *filename, std::map< UInt_t, TString > *commentsPAR=0, std::map< UInt_t, TString > *commentsTHE=0, std::map< UInt_t, TString > *commentsFUN=0, std::map< UInt_t, TString > *commentsRUN=0)
Writes an MSR file from internal data structures.
virtual Bool_t HandleCommandsEntry(PMsrLines &line)
Parses COMMANDS block entries.
virtual Bool_t CheckRealFFT()
Checks if real FFT requirements are met.
virtual Bool_t HandleStatisticEntry(PMsrLines &line)
Parses STATISTIC block entries.
virtual Bool_t FilterNumber(TString str, const Char_t *filter, Int_t offset, Int_t &no)
Extracts number from string with specific filter pattern.
virtual Bool_t HandleRunEntry(PMsrLines &line)
Parses RUN block entries.
virtual UInt_t LastSignificant(Double_t dval, UInt_t precLimit=6)
Finds position of last significant digit in a double value.
virtual Int_t ReadMsrFile()
Reads and parses the MSR file.
virtual Bool_t ParseFourierPhaseParVector(PMsrFourierStructure &fourier, const TString &str, Bool_t &error)
Parses Fourier phase parameter vector.
virtual void CheckMaxLikelihood()
Validates maximum likelihood fit settings.
virtual void RemoveComment(const TString &str, TString &truncStr)
Removes comments from MSR file line.
PMsrRunList fRuns
List of RUN blocks with data file specifications.
virtual Bool_t HandleFunctionsEntry(PMsrLines &line)
Parses FUNCTIONS block entries.
virtual Int_t WriteMsrLogFile(const Bool_t messages=true)
Writes an MSR log file (.mlog) with parsed MSR content.
virtual void GetGroupingString(Int_t runNo, TString detector, TString &groupingStr)
TString fMsrFileDirectoryPath
Directory path of the MSR file.
PMsrLines fTheory
Theory block lines defining asymmetry/relaxation functions.
PStartupOptions * fStartupOptions
Pointer to startup options from musrfit_startup.xml.
TString fFileName
MSR file name (with path)
virtual UInt_t GetFuncIndex(Int_t funNo)
PMsrFourierStructure fFourier
Fourier transform parameters and settings.
virtual Bool_t CheckFuncs()
Validates user-defined functions syntax and parameter usage.
PMsrHandler(const Char_t *fileName, PStartupOptions *startupOptions=0, const Bool_t fourierOnly=false)
Constructor that initializes the MSR handler.
virtual Int_t ParameterInUse(UInt_t paramNo)
virtual void MakeDetectorGroupingString(TString str, PIntVector &group, TString &result, Bool_t includeDetector=true)
Creates detector grouping string from integer vector.
virtual void InitFourierParameterStructure(PMsrFourierStructure &fourier)
Initializes Fourier parameter structure with default values.
Int_t fMsrBlockCounter
Counter to track current MSR block during parsing.
virtual void CheckLegacyLifetimecorrection()
Checks for deprecated lifetimecorrection syntax and warns user.
PMsrLines fCommands
MINUIT commands block lines.
PMsrParamList fParam
List of fit parameters with values, errors, constraints.
virtual Bool_t HandlePlotEntry(PMsrLines &line)
Parses PLOT block entries.
PMsrPlotList fPlots
List of PLOT blocks with plotting parameters.
virtual Bool_t CheckUniquenessOfParamNames(UInt_t &parX, UInt_t &parY)
Checks that all parameter names are unique.
virtual PIntVector * GetMap()
virtual void SetLifetimeParamNo(Int_t ival)
virtual void SetFitRangeOffset(Int_t ival, UInt_t idx)
virtual void SetBeamline(TString &str, Int_t idx=-1)
virtual void SetBkgFix(Double_t dval, Int_t idx)
virtual void SetXDataLabel(TString &str)
virtual void SetFitType(Int_t ival)
virtual void SetFitRange(Double_t dval, UInt_t idx)
virtual void SetFileFormat(TString &str, Int_t idx=-1)
virtual void SetMap(Int_t mapVal, Int_t idx=-1)
virtual void SetPacking(Int_t ival)
virtual void SetYDataIndex(Int_t ival)
virtual void SetLifetimeCorrection(Bool_t bval)
virtual void SetT0Bin(Double_t dval, Int_t idx=-1)
virtual void SetBkgFitParamNo(Int_t ival)
virtual void SetBackwardHistoNo(Int_t histoNo, Int_t idx=-1)
virtual void SetDataRange(Int_t ival, Int_t idx)
virtual void SetXDataIndex(Int_t ival)
virtual void SetRunName(TString &str, Int_t idx=-1)
virtual void SetBetaParamNo(Int_t ival)
virtual void SetYDataLabel(TString &str)
virtual void SetAlphaParamNo(Int_t ival)
virtual void SetBkgRange(Int_t ival, Int_t idx)
virtual void SetInstitute(TString &str, Int_t idx=-1)
virtual void SetDeadTimeCorrection(TString str)
virtual void SetNormParamNo(Int_t ival)
virtual void SetFitRangeInBins(Bool_t bval)
virtual void SetForwardHistoNo(Int_t histoNo, Int_t idx=-1)
virtual void SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx)
Int_t fPlotTag
tag used for initial plot. 0=real, 1=imaginary, 2=real & imaginary (default), 3=power,...
Bool_t fFourierBlockPresent
flag indicating if a Fourier block is present in the msr-file
Double_t fPlotRange[2]
field/frequency plot range
PDoubleVector fPhase
phase(s)
Double_t fRangeForPhaseCorrection[2]
field/frequency range for automatic phase correction
PIntVector fPhaseParamNo
parameter number(s) if used instead of a phase value
Int_t fFourierPower
i.e. zero padding up to 2^fFourierPower, default = 0 which means NO zero padding
Int_t fUnits
flag used to indicate the units. 1=field units (G); 2=field units (T); 3=frequency units (MHz); 4=Mc/...
Int_t fPhaseRef
phase reference for relative phase(s)
Bool_t fDCCorrected
if set true, the dc offset of the signal/theory will be removed before the FFT is made.
Int_t fApodization
tag indicating the kind of apodization wished, 0=no appodization (default), 1=weak,...
Int_t fLineNo
Line number in original MSR file (1-based)
TString fLine
Content of the MSR file line.
Double_t fStep
Step size / error / negative error (context-dependent)
Double_t fPosError
Positive error for asymmetric uncertainties.
Bool_t fLowerBoundaryPresent
True if lower bound constraint is active.
Int_t fNoOfParams
Total number of parameters in FITPARAMETER block.
Double_t fLowerBoundary
Lower boundary value for parameter constraints.
Int_t fNo
Parameter number (1, 2, 3, ...)
Double_t fUpperBoundary
Upper boundary value for parameter constraints.
Bool_t fPosErrorPresent
True if positive error explicitly defined (asymmetric errors)
Bool_t fUpperBoundaryPresent
True if upper bound constraint is active.
Double_t fValue
Parameter value (initial or fitted)
TString fName
Parameter name (e.g., "alpha", "lambda", "field")
Bool_t fUseFitRanges
yes -> use the fit ranges to plot the data, no (default) -> use range information if present
PIntVector fRuns
list of runs to be plotted
UInt_t fRRFUnit
RRF frequency unit. 0=kHz, 1=MHz, 2=Mc/s, 3=Gauss, 4=Tesla.
Bool_t fLogY
yes -> y-axis in log-scale, no (default) -> y-axis in lin-scale
Bool_t fLogX
yes -> x-axis in log-scale, no (default) -> x-axis in lin-scale
Int_t fRRFPhaseParamNo
parameter number if used instead of a RRF phase value
Double_t fRRFFreq
RRF frequency.
PDoubleVector fYmax
asymmetry/counts maximum
Bool_t fLifeTimeCorrection
needed for single histo. If yes, only the asymmetry is shown, otherweise the positron spectrum
Int_t fViewPacking
-1 -> use the run packing to generate the view, otherwise is fViewPacking for the binning of ALL runs...
Double_t fRRFPhase
RRF phase.
UInt_t fRRFPacking
rotating reference frame (RRF) packing
PDoubleVector fYmin
asymmetry/counts minimum
PDoubleVector fTmax
time maximum
PDoubleVector fTmin
time minimum