38#include <TObjString.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 TObjArray *tokens =
nullptr;
455 TObjString *ostr =
nullptr;
456 Bool_t found =
false;
457 Bool_t statisticBlockFound =
false;
458 Bool_t partialStatisticBlockFound =
true;
461 for (UInt_t i=0; i<
fRuns.size(); i++) {
462 t0TagMissing.push_back(
true);
464 std::vector<PBoolVector> addt0TagMissing;
466 for (UInt_t i=0; i<
fRuns.size(); i++) {
468 for (UInt_t j=0; j<
fRuns[i].GetAddT0BinEntries(); j++)
469 bvec.push_back(
true);
470 addt0TagMissing.push_back(bvec);
473 for (UInt_t i=0; i<
fRuns.size(); i++) {
474 backgroundTagMissing.push_back(
true);
477 for (UInt_t i=0; i<
fRuns.size(); i++) {
478 dataTagMissing.push_back(
true);
482 Int_t addT0Counter = 0;
483 Int_t addT0GlobalCounter = 0;
490 fin.open(
fFileName.Data(), std::iostream::in);
491 if (!fin.is_open()) {
499 if (str.BeginsWith(
"RUN")) {
507 if (str.BeginsWith(
"t0"))
508 t0TagMissing[runNo] =
false;
509 else if (str.BeginsWith(
"background"))
510 backgroundTagMissing[runNo] =
false;
511 else if (str.BeginsWith(
"data"))
512 dataTagMissing[runNo] =
false;
519 while (
fFileName.Index(
".", idx+1) != -1) {
527 logFileName.Remove(idx+1);
528 logFileName +=
"mlog";
531 fin.open(
fFileName.Data(), std::iostream::in);
532 if (!fin.is_open()) {
537 fout.open(logFileName.Data(), std::iostream::out);
538 if (!fout.is_open()) {
554 if (str.BeginsWith(
"FITPARAMETER")) {
556 }
else if (str.BeginsWith(
"THEORY")) {
558 fout << str.Data() << std::endl;
560 }
else if (str.BeginsWith(
"FUNCTIONS")) {
562 fout << str.Data() << std::endl;
564 }
else if (str.BeginsWith(
"GLOBAL")) {
566 fout << str.Data() << std::endl;
568 }
else if (str.BeginsWith(
"RUN")) {
573 }
else if (str.BeginsWith(
"COMMANDS")) {
575 fout << str.Data() << std::endl;
577 }
else if (str.BeginsWith(
"FOURIER")) {
579 fout << str.Data() << std::endl;
581 }
else if (str.BeginsWith(
"PLOT")) {
584 }
else if (str.BeginsWith(
"STATISTIC")) {
592 fout <<
fTitle.Data() << std::endl;
594 fout << str.Data() << std::endl;
597 tokens = str.Tokenize(
" \t");
598 if (tokens->GetEntries() == 0) {
599 fout << str.Data() << std::endl;
601 ostr =
dynamic_cast<TObjString*
>(tokens->At(0));
602 sstr = ostr->GetString();
603 if (sstr.IsDigit()) {
604 number = sstr.Atoi();
607 assert ((number >= 0) && (number < (Int_t)
fParam.size()));
610 fout << std::right <<
fParam[number].fNo;
614 fout << std::left <<
fParam[number].fName.Data();
617 if (
fParam[number].fStep == 0.0)
626 neededWidth = neededPrec + 3;
627 fout.width(neededWidth);
628 fout.setf(std::ios::fixed, std::ios::floatfield);
629 fout.precision(neededPrec);
630 fout << std::left <<
fParam[number].fValue;
634 fout.setf(std::ios::fixed);
635 if (
fParam[number].fStep == 0.0)
637 fout.precision(neededPrec);
638 fout << std::left <<
fParam[number].fStep;
641 fout.setf(std::ios::fixed);
642 fout.precision(neededPrec);
643 if ((
fParam[number].fNoOfParams == 5) || (
fParam[number].fNoOfParams == 7))
644 if (
fParam[number].fPosErrorPresent && (
fParam[number].fStep != 0))
645 fout << std::left <<
fParam[number].fPosError;
647 fout << std::left <<
"none";
649 fout << std::left <<
"none";
651 fout.unsetf(std::ios::floatfield);
653 if (
fParam[number].fNoOfParams > 5) {
655 fout.precision(prec);
656 if (
fParam[number].fLowerBoundaryPresent)
657 fout << std::left <<
fParam[number].fLowerBoundary;
659 fout << std::left <<
"none";
662 fout.precision(prec);
663 if (
fParam[number].fUpperBoundaryPresent)
664 fout << std::left <<
fParam[number].fUpperBoundary;
666 fout << std::left <<
"none";
671 fout << str.Data() << std::endl;
679 for (UInt_t i=0; i<
fTheory.size(); i++) {
680 if (
fTheory[i].fLineNo == lineNo) {
681 fout <<
fTheory[i].fLine.Data() << std::endl;
686 fout << str.Data() << std::endl;
691 sstr.Remove(TString::kLeading,
' ');
692 if (str.BeginsWith(
"fun")) {
697 fout << sstr.Data() << std::endl;
700 fout << str.Data() << std::endl;
705 if (sstr.BeginsWith(
"fittype")) {
707 switch (
fGlobal.GetFitType()) {
715 fout << std::left <<
"fittype" <<
MSR_FITTYPE_ASYM <<
" (asymmetry fit)" << std::endl ;
724 fout << std::left <<
"fittype" <<
MSR_FITTYPE_BNMR <<
" (beta-NMR fit)" << std::endl ;
734 fout << std::left <<
"rrf_freq ";
737 fout.precision(neededPrec);
738 fout << std::left << std::fixed <<
fGlobal.GetRRFFreq(
fGlobal.GetRRFUnit().Data());
739 fout <<
" " <<
fGlobal.GetRRFUnit();
743 fout <<
"rrf_phase ";
745 fout << std::left <<
fGlobal.GetRRFPhase();
749 fout <<
"rrf_packing ";
751 fout << std::left <<
fGlobal.GetRRFPacking();
753 }
else if (sstr.BeginsWith(
"data")) {
755 fout << std::left <<
"data";
756 for (UInt_t j=0; j<4; j++) {
757 if (
fGlobal.GetDataRange(j) > 0) {
759 fout << std::left <<
fGlobal.GetDataRange(j);
763 }
else if (sstr.BeginsWith(
"t0")) {
765 fout << std::left <<
"t0";
766 for (UInt_t j=0; j<
fGlobal.GetT0BinSize(); j++) {
769 fout.setf(std::ios::fixed,std::ios::floatfield);
770 fout << std::left <<
fGlobal.GetT0Bin(j);
773 }
else if (sstr.BeginsWith(
"addt0")) {
775 fout << std::left <<
"addt0";
776 for (Int_t j=0; j<
fGlobal.GetAddT0BinSize(addT0GlobalCounter); j++) {
779 fout.setf(std::ios::fixed,std::ios::floatfield);
780 fout << std::left <<
fGlobal.GetAddT0Bin(addT0GlobalCounter, j);
783 addT0GlobalCounter++;
784 }
else if (sstr.BeginsWith(
"fit")) {
786 fout << std::left <<
"fit";
787 if (
fGlobal.IsFitRangeInBin()) {
789 if (
fGlobal.GetFitRangeOffset(0) > 0)
790 fout <<
"+" <<
fGlobal.GetFitRangeOffset(0);
792 if (
fGlobal.GetFitRangeOffset(1) > 0)
793 fout <<
"-" <<
fGlobal.GetFitRangeOffset(1);
797 fout.precision(neededPrec);
798 fout <<
" # in time: " <<
fGlobal.GetFitRange(0) <<
".." <<
fGlobal.GetFitRange(1) <<
" (usec)";
800 for (UInt_t j=0; j<2; j++) {
801 if (
fGlobal.GetFitRange(j) == -1)
805 fout.width(neededWidth);
806 fout.precision(neededPrec);
807 fout << std::left << std::fixed <<
fGlobal.GetFitRange(j);
813 }
else if (sstr.BeginsWith(
"packing")) {
815 fout << std::left <<
"packing";
816 fout <<
fGlobal.GetPacking() << std::endl;
817 }
else if (sstr.BeginsWith(
"deadtime-cor")) {
819 fout << std::left <<
"deadtime-cor";
820 fout <<
fGlobal.GetDeadTimeCorrection() << std::endl;
822 fout << str.Data() << std::endl;
827 sstr.Remove(TString::kLeading,
' ');
828 if (sstr.BeginsWith(
"RUN")) {
830 fout <<
"RUN " <<
fRuns[runNo].GetRunName()->Data() <<
" ";
831 pstr =
fRuns[runNo].GetBeamline();
832 if (pstr ==
nullptr) {
833 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **ERROR** Couldn't obtain beamline data." << std::endl;
837 fout << pstr->Data() <<
" ";
838 pstr =
fRuns[runNo].GetInstitute();
839 if (pstr ==
nullptr) {
840 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **ERROR** Couldn't obtain institute data." << std::endl;
844 fout << pstr->Data() <<
" ";
845 pstr =
fRuns[runNo].GetFileFormat();
846 if (pstr ==
nullptr) {
847 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **ERROR** Couldn't obtain file format data." << std::endl;
851 fout << pstr->Data() <<
" (name beamline institute data-file-format)" << std::endl;
852 }
else if (sstr.BeginsWith(
"ADDRUN")) {
854 fout <<
"ADDRUN " <<
fRuns[runNo].GetRunName(addRunNo)->Data() <<
" ";
855 pstr =
fRuns[runNo].GetBeamline(addRunNo);
856 if (pstr ==
nullptr) {
857 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **ERROR** Couldn't obtain beamline data (addrun)." << std::endl;
861 fout << pstr->Data() <<
" ";
862 pstr =
fRuns[runNo].GetInstitute(addRunNo);
863 if (pstr ==
nullptr) {
864 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **ERROR** Couldn't obtain institute data (addrun)." << std::endl;
868 fout << pstr->Data() <<
" ";
869 pstr =
fRuns[runNo].GetFileFormat(addRunNo);
870 if (pstr ==
nullptr) {
871 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **ERROR** Couldn't obtain file format data (addrun)." << std::endl;
875 fout << pstr->Data() <<
" (name beamline institute data-file-format)" << std::endl;
876 }
else if (sstr.BeginsWith(
"fittype")) {
878 switch (
fRuns[runNo].GetFitType()) {
886 fout << std::left <<
"fittype" <<
MSR_FITTYPE_ASYM <<
" (asymmetry fit)" << std::endl ;
895 fout << std::left <<
"fittype" <<
MSR_FITTYPE_BNMR <<
" (beta-NMR fit)" << std::endl ;
903 }
else if (sstr.BeginsWith(
"alpha ")) {
905 fout << std::left <<
"alpha";
910 fout <<
fRuns[runNo].GetAlphaParamNo();
912 }
else if (sstr.BeginsWith(
"beta ")) {
914 fout << std::left <<
"beta";
918 fout <<
fRuns[runNo].GetBetaParamNo();
920 }
else if (sstr.BeginsWith(
"norm")) {
922 fout << std::left <<
"norm";
927 fout <<
fRuns[runNo].GetNormParamNo();
929 }
else if (sstr.BeginsWith(
"backgr.fit")) {
931 fout << std::left <<
"backgr.fit";
932 fout <<
fRuns[runNo].GetBkgFitParamNo() << std::endl;
933 }
else if (sstr.BeginsWith(
"lifetime ")) {
935 fout << std::left <<
"lifetime";
936 fout <<
fRuns[runNo].GetLifetimeParamNo() << std::endl;
937 }
else if (sstr.BeginsWith(
"lifetimecorrection")) {
939 }
else if (sstr.BeginsWith(
"map")) {
941 for (UInt_t j=0; j<
fRuns[runNo].GetMap()->size(); j++) {
943 fout << std::right <<
fRuns[runNo].GetMap(j);
946 if (
fRuns[runNo].GetMap()->size() < 10) {
947 for (UInt_t j=
fRuns[runNo].GetMap()->size(); j<10; j++)
951 }
else if (sstr.BeginsWith(
"forward")) {
952 if (
fRuns[runNo].GetForwardHistoNoSize() == 0) {
953 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **WARNING** 'forward' tag without any data found!";
954 std::cerr << std::endl <<
">> Something is VERY fishy, please check your msr-file carfully." << std::endl;
958 for (UInt_t i=0; i<
fRuns[runNo].GetForwardHistoNoSize(); i++)
959 forward.push_back(
fRuns[runNo].GetForwardHistoNo(i));
962 fout << result.Data() << std::endl;
964 }
else if (sstr.BeginsWith(
"backward")) {
965 if (
fRuns[runNo].GetBackwardHistoNoSize() == 0) {
966 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **WARNING** 'backward' tag without any data found!";
967 std::cerr << std::endl <<
">> Something is VERY fishy, please check your msr-file carfully." << std::endl;
971 for (UInt_t i=0; i<
fRuns[runNo].GetBackwardHistoNoSize(); i++)
972 backward.push_back(
fRuns[runNo].GetBackwardHistoNo(i));
975 fout << result.Data() << std::endl;
977 }
else if (sstr.BeginsWith(
"backgr.fix")) {
979 fout << std::left <<
"backgr.fix";
980 for (UInt_t j=0; j<2; j++) {
982 fout.precision(prec);
984 fout << std::left <<
fRuns[runNo].GetBkgFix(j);
988 }
else if (sstr.BeginsWith(
"background")) {
989 backgroundTagMissing[runNo] =
false;
991 fout << std::left <<
"background";
992 for (UInt_t j=0; j<4; j++) {
993 if (
fRuns[runNo].GetBkgRange(j) > 0) {
995 fout << std::left <<
fRuns[runNo].GetBkgRange(j);
1000 if ((Int_t)log10(
fRuns[runNo].GetBkgEstimated(0))+1 >= 4)
1002 fout <<
" # estimated bkg: ";
1004 fout.precision(precision);
1005 fout <<
fRuns[runNo].GetBkgEstimated(0);
1009 fout.precision(precision);
1010 fout <<
fRuns[runNo].GetBkgEstimated(1);
1014 }
else if (sstr.BeginsWith(
"data")) {
1015 dataTagMissing[runNo] =
false;
1017 fout << std::left <<
"data";
1018 for (UInt_t j=0; j<4; j++) {
1019 if (
fRuns[runNo].GetDataRange(j) > 0) {
1021 fout << std::left <<
fRuns[runNo].GetDataRange(j);
1025 }
else if (sstr.BeginsWith(
"t0")) {
1026 t0TagMissing[runNo] =
false;
1028 fout << std::left <<
"t0";
1029 for (UInt_t j=0; j<
fRuns[runNo].GetT0BinSize(); j++) {
1032 fout.setf(std::ios::fixed,std::ios::floatfield);
1033 fout << std::left <<
fRuns[runNo].GetT0Bin(j);
1036 }
else if (sstr.BeginsWith(
"addt0")) {
1037 addt0TagMissing[runNo][addT0Counter] =
false;
1038 if (
fRuns[runNo].GetAddT0BinSize(addT0Counter) <=0) {
1039 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **WARNING** 'addt0' tag without any data found!";
1040 std::cerr << std::endl <<
">> Something is VERY fishy, please check your msr-file carfully." << std::endl;
1043 fout << std::left <<
"addt0";
1044 for (Int_t j=0; j<
fRuns[runNo].GetAddT0BinSize(addT0Counter); j++) {
1047 fout.setf(std::ios::fixed,std::ios::floatfield);
1048 fout << std::left <<
fRuns[runNo].GetAddT0Bin(addT0Counter, j);
1053 }
else if (sstr.BeginsWith(
"xy-data")) {
1054 if (
fRuns[runNo].GetXDataIndex() != -1) {
1056 fout << std::left <<
"xy-data";
1059 fout << std::left << std::fixed <<
fRuns[runNo].GetXDataIndex();
1062 fout << std::left << std::fixed <<
fRuns[runNo].GetYDataIndex();
1064 }
else if (!
fRuns[runNo].GetXDataLabel()->IsWhitespace()) {
1066 fout << std::left <<
"xy-data";
1068 fout << std::left << std::fixed <<
fRuns[runNo].GetXDataLabel()->Data();
1071 fout << std::left << std::fixed <<
fRuns[runNo].GetYDataLabel()->Data();
1074 }
else if (sstr.BeginsWith(
"fit")) {
1077 if (t0TagMissing[runNo] &&
fRuns[runNo].GetInstitute()->CompareTo(
"isis", TString::kIgnoreCase)) {
1078 if (
fRuns[runNo].GetT0BinSize() > 0) {
1080 fout << std::left <<
"t0";
1081 for (UInt_t j=0; j<
fRuns[runNo].GetT0BinSize(); j++) {
1084 fout.setf(std::ios::fixed,std::ios::floatfield);
1085 fout << std::left <<
fRuns[runNo].GetT0Bin(j);
1090 for (UInt_t i=0; i<
fRuns[runNo].GetAddT0BinEntries(); i++) {
1091 if (addt0TagMissing[runNo][i] &&
fRuns[runNo].GetInstitute()->CompareTo(
"isis", TString::kIgnoreCase)) {
1092 if (
fRuns[runNo].GetAddT0BinSize(i) > 0) {
1094 fout << std::left <<
"addt0";
1095 for (Int_t j=0; j<
fRuns[runNo].GetAddT0BinSize(i); j++) {
1098 fout.setf(std::ios::fixed,std::ios::floatfield);
1099 fout << std::left <<
fRuns[runNo].GetAddT0Bin(i, j);
1105 if (backgroundTagMissing[runNo]) {
1106 if (
fRuns[runNo].GetBkgRange(0) >= 0) {
1108 fout << std::left <<
"background";
1109 for (UInt_t j=0; j<4; j++) {
1110 if (
fRuns[runNo].GetBkgRange(j) > 0) {
1112 fout << std::left <<
fRuns[runNo].GetBkgRange(j);
1118 if (dataTagMissing[runNo]) {
1119 if (
fRuns[runNo].GetDataRange(0) >= 0) {
1121 fout << std::left <<
"data";
1122 for (UInt_t j=0; j<4; j++) {
1123 if (
fRuns[runNo].GetDataRange(j) > 0) {
1125 fout << std::left <<
fRuns[runNo].GetDataRange(j);
1133 fout << std::left <<
"fit";
1134 if (
fRuns[runNo].IsFitRangeInBin()) {
1136 if (
fRuns[runNo].GetFitRangeOffset(0) > 0)
1137 fout <<
"+" <<
fRuns[runNo].GetFitRangeOffset(0);
1139 if (
fRuns[runNo].GetFitRangeOffset(1) > 0)
1140 fout <<
"-" <<
fRuns[runNo].GetFitRangeOffset(1);
1144 fout.precision(neededPrec);
1145 fout <<
" # in time: " <<
fRuns[runNo].GetFitRange(0) <<
".." <<
fRuns[runNo].GetFitRange(1) <<
" (usec)";
1147 for (UInt_t j=0; j<2; j++) {
1148 if (
fRuns[runNo].GetFitRange(j) == -1)
1152 fout.width(neededWidth);
1153 fout.precision(neededPrec);
1154 fout << std::left << std::fixed <<
fRuns[runNo].GetFitRange(j);
1160 }
else if (sstr.BeginsWith(
"packing")) {
1162 fout << std::left <<
"packing";
1163 fout <<
fRuns[runNo].GetPacking() << std::endl;
1164 }
else if (sstr.BeginsWith(
"deadtime-cor")) {
1166 fout << std::left <<
"deadtime-cor";
1167 fout <<
fRuns[runNo].GetDeadTimeCorrection() << std::endl;
1169 fout << str.Data() << std::endl;
1173 fout << str.Data() << std::endl;
1177 sstr.Remove(TString::kLeading,
' ');
1178 if (sstr.BeginsWith(
"units")) {
1189 fout <<
" # units either 'Gauss', 'Tesla', 'MHz', or 'Mc/s'";
1191 }
else if (sstr.BeginsWith(
"fourier_power")) {
1192 fout <<
"fourier_power " <<
fFourier.fFourierPower << std::endl;
1193 }
else if (sstr.BeginsWith(
"dc-corrected")) {
1194 fout <<
"dc-corrected ";
1196 fout <<
"true" << std::endl;
1198 fout <<
"false" << std::endl;
1199 }
else if (sstr.BeginsWith(
"apodization")) {
1200 fout <<
"apodization ";
1210 fout <<
" # NONE, WEAK, MEDIUM, STRONG";
1212 }
else if (sstr.BeginsWith(
"plot")) {
1219 fout <<
"REAL_AND_IMAG";
1225 fout <<
"PHASE_OPT_REAL";
1227 fout <<
" # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE, PHASE_OPT_REAL";
1229 }
else if (sstr.BeginsWith(
"phase")) {
1230 if (
fFourier.fPhaseParamNo.size() > 0) {
1232 fout <<
"phase " << phaseParamStr << std::endl;
1233 }
else if (
fFourier.fPhase.size() > 0) {
1235 for (UInt_t i=0; i<
fFourier.fPhase.size()-1; i++) {
1236 fout <<
fFourier.fPhase[i] <<
", ";
1240 }
else if (sstr.BeginsWith(
"range_for_phase_correction")) {
1241 fout <<
"range_for_phase_correction " <<
fFourier.fRangeForPhaseCorrection[0] <<
" " <<
fFourier.fRangeForPhaseCorrection[1] << std::endl;
1242 }
else if (sstr.BeginsWith(
"range ")) {
1243 fout.setf(std::ios::fixed,std::ios::floatfield);
1247 fout.precision(neededPrec);
1248 fout <<
"range " <<
fFourier.fPlotRange[0] <<
" " <<
fFourier.fPlotRange[1] << std::endl;
1250 fout << str.Data() << std::endl;
1255 sstr.Remove(TString::kLeading,
' ');
1256 if (sstr.BeginsWith(
"PLOT")) {
1257 switch (
fPlots[plotNo].fPlotType) {
1259 fout <<
"PLOT " <<
fPlots[plotNo].fPlotType <<
" (single histo plot)" << std::endl;
1262 fout <<
"PLOT " <<
fPlots[plotNo].fPlotType <<
" (single histo RRF plot)" << std::endl;
1265 fout <<
"PLOT " <<
fPlots[plotNo].fPlotType <<
" (asymmetry plot)" << std::endl;
1268 fout <<
"PLOT " <<
fPlots[plotNo].fPlotType <<
" (asymmetry RRF plot)" << std::endl;
1271 fout <<
"PLOT " <<
fPlots[plotNo].fPlotType <<
" (mu minus plot)" << std::endl;
1274 fout <<
"PLOT " <<
fPlots[plotNo].fPlotType <<
" (beta-NMR asymmetry plot)" << std::endl;
1277 fout <<
"PLOT " <<
fPlots[plotNo].fPlotType <<
" (non muSR plot)" << std::endl;
1282 if (
fPlots[plotNo].fLifeTimeCorrection) {
1283 fout <<
"lifetimecorrection" << std::endl;
1285 }
else if (sstr.BeginsWith(
"lifetimecorrection")) {
1289 }
else if (sstr.BeginsWith(
"runs")) {
1292 for (UInt_t j=0; j<
fPlots[plotNo].fRuns.size(); j++) {
1294 fout <<
fPlots[plotNo].fRuns[j];
1297 }
else if (sstr.BeginsWith(
"range")) {
1300 fout.precision(neededPrec);
1301 fout <<
fPlots[plotNo].fTmin[0];
1304 fout.precision(neededPrec);
1305 fout <<
fPlots[plotNo].fTmax[0];
1306 if (
fPlots[plotNo].fYmin.size() > 0) {
1309 fout.precision(neededPrec);
1310 fout <<
fPlots[plotNo].fYmin[0] <<
" ";
1312 fout.precision(neededPrec);
1313 fout <<
fPlots[plotNo].fYmax[0];
1317 fout << str.Data() << std::endl;
1321 statisticBlockFound =
true;
1323 sstr.Remove(TString::kLeading,
' ');
1324 if (sstr.BeginsWith(
"STATISTIC")) {
1326 fout <<
"STATISTIC --- " << dt.AsSQLString() << std::endl;
1327 }
else if (sstr.BeginsWith(
"chisq") || sstr.BeginsWith(
"maxLH")) {
1328 partialStatisticBlockFound =
false;
1335 fout << str.Data() << std::endl;
1337 std::cout << std::endl << str.Data() << std::endl;
1342 str.Form(
" expected chisq = %.1lf, NDF = %d, expected chisq/NDF = %lf",
1345 str.Form(
" expected maxLH = %.1lf, NDF = %d, expected maxLH/NDF = %lf",
1350 fout << str.Data() << std::endl;
1353 std::cout << std::endl << str.Data() << std::endl;
1355 for (UInt_t i=0; i<
fStatistic.fMinExpectedPerHisto.size(); i++) {
1358 str.Form(
" run block %d: (NDF/red.chisq/red.chisq_e) = (%d/%lf/%lf)",
1361 str.Form(
" run block %d: (NDF/red.maxLH/red.maxLH_e) = (%d/%lf/%lf)",
1366 fout << str.Data() << std::endl;
1370 std::cout << str.Data() << std::endl;
1373 }
else if (
fStatistic.fNdfPerHisto.size() > 1) {
1374 for (UInt_t i=0; i<
fStatistic.fNdfPerHisto.size(); i++) {
1376 str.Form(
" run block %d: (NDF/red.chisq) = (%d/%lf)",
1379 str.Form(
" run block %d: (NDF/maxLH.chisq) = (%d/%lf)",
1384 fout << str.Data() << std::endl;
1388 std::cout << str.Data() << std::endl;
1392 fout <<
"*** FIT DID NOT CONVERGE ***" << std::endl;
1394 std::cout << std::endl <<
"*** FIT DID NOT CONVERGE ***" << std::endl;
1396 }
else if (sstr.BeginsWith(
"*** FIT DID NOT CONVERGE ***")) {
1397 partialStatisticBlockFound =
false;
1404 fout << str.Data() << std::endl;
1406 std::cout << std::endl << str.Data() << std::endl;
1411 str.Form(
" expected chisq = %.1lf, NDF = %d, expected chisq/NDF = %lf",
1414 str.Form(
" expected maxLH = %.1lf, NDF = %d, expected maxLH/NDF = %lf",
1419 fout << str.Data() << std::endl;
1422 std::cout << str.Data() << std::endl;
1424 for (UInt_t i=0; i<
fStatistic.fMinExpectedPerHisto.size(); i++) {
1427 str.Form(
" run block %d: (NDF/red.chisq/red.chisq_e) = (%d/%lf/%lf)",
1430 str.Form(
" run block %d: (NDF/red.maxLH/red.maxLH_e) = (%d/%lf/%lf)",
1435 fout << str.Data() << std::endl;
1439 std::cout << str.Data() << std::endl;
1442 }
else if (
fStatistic.fNdfPerHisto.size() > 1) {
1443 for (UInt_t i=0; i<
fStatistic.fNdfPerHisto.size(); i++) {
1445 str.Form(
" run block %d: (NDF/red.chisq) = (%d/%lf)",
1448 str.Form(
" run block %d: (NDF/red.maxLH) = (%d/%lf)",
1453 fout << str.Data() << std::endl;
1457 std::cout << str.Data() << std::endl;
1461 fout <<
"*** FIT DID NOT CONVERGE ***" << std::endl;
1463 std::cout << std::endl <<
"*** FIT DID NOT CONVERGE ***" << std::endl;
1466 if (str.Length() > 0) {
1468 sstr.Remove(TString::kLeading,
' ');
1469 if (!sstr.BeginsWith(
"expected chisq") && !sstr.BeginsWith(
"expected maxLH") && !sstr.BeginsWith(
"run block"))
1470 fout << str.Data() << std::endl;
1483 if (!statisticBlockFound) {
1484 partialStatisticBlockFound =
false;
1485 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **WARNING** no STATISTIC block present, will write a default one" << std::endl;
1486 fout <<
"###############################################################" << std::endl;
1488 fout <<
"STATISTIC --- " << dt.AsSQLString() << std::endl;
1495 fout << str.Data() << std::endl;
1497 std::cout << std::endl << str.Data() << std::endl;
1502 str.Form(
" expected chisq = %.1lf, NDF = %d, expected chisq/NDF = %lf",
1505 str.Form(
" expected maxLH = %.1lf, NDF = %d, expected maxLH/NDF = %lf",
1510 fout << str.Data() << std::endl;
1513 std::cout << str.Data() << std::endl;
1515 for (UInt_t i=0; i<
fStatistic.fMinExpectedPerHisto.size(); i++) {
1518 str.Form(
" run block %d: (NDF/red.chisq/red.chisq_e) = (%d/%lf/%lf)",
1521 str.Form(
" run block %d: (NDF/red.maxLH/red.maxLH_e) = (%d/%lf/%lf)",
1526 fout << str.Data() << std::endl;
1530 std::cout << str.Data() << std::endl;
1533 }
else if (
fStatistic.fNdfPerHisto.size() > 1) {
1534 for (UInt_t i=0; i<
fStatistic.fNdfPerHisto.size(); i++) {
1536 str.Form(
" run block %d: (NDF/red.chisq) = (%d/%lf)",
1539 str.Form(
" run block %d: (NDF/red.maxLH) = (%d/%lf)",
1544 fout << str.Data() << std::endl;
1548 std::cout << str.Data() << std::endl;
1552 fout <<
"*** FIT DID NOT CONVERGE ***" << std::endl;
1554 std::cout << std::endl <<
"*** FIT DID NOT CONVERGE ***" << std::endl;
1559 if (partialStatisticBlockFound) {
1560 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrLogFile: **WARNING** garbage STATISTIC block present in the msr-input file.";
1561 std::cerr << std::endl <<
">> ** WILL ADD SOME SENSIBLE STUFF, BUT YOU HAVE TO CHECK IT SINCE I AM **NOT** REMOVING THE GARBAGE! **" << std::endl;
1563 fout <<
"STATISTIC --- " << dt.AsSQLString() << std::endl;
1570 fout << str.Data() << std::endl;
1572 std::cout << std::endl << str.Data() << std::endl;
1577 str.Form(
" expected chisq = %.1lf, NDF = %d, expected chisq/NDF = %lf",
1580 str.Form(
" expected maxLH = %.1lf, NDF = %d, expected maxLH/NDF = %lf",
1585 fout << str.Data() << std::endl;
1588 std::cout << str.Data() << std::endl;
1590 for (UInt_t i=0; i<
fStatistic.fMinExpectedPerHisto.size(); i++) {
1593 str.Form(
" run block %d: (NDF/red.chisq/red.chisq_e) =(%d/%lf/%lf)",
1596 str.Form(
" run block %d: (NDF/red.maxLH/red.maxLH_e) =(%d/%lf/%lf)",
1601 fout << str.Data() << std::endl;
1605 std::cout << str.Data() << std::endl;
1608 }
else if (
fStatistic.fNdfPerHisto.size() > 1) {
1609 for (UInt_t i=0; i<
fStatistic.fNdfPerHisto.size(); i++) {
1611 str.Form(
" run block %d: (NDF/red.chisq) = (%d/%lf)",
1614 str.Form(
" run block %d: (NDF/red.maxLH) = (%d/%lf)",
1619 fout << str.Data() << std::endl;
1623 std::cout << str.Data() << std::endl;
1627 fout <<
"*** FIT DID NOT CONVERGE (4) ***" << std::endl;
1629 std::cout << std::endl <<
"*** FIT DID NOT CONVERGE ***" << std::endl;
1638 t0TagMissing.clear();
1639 backgroundTagMissing.clear();
1640 dataTagMissing.clear();
1696 std::map<UInt_t, TString> *commentsTHE, \
1697 std::map<UInt_t, TString> *commentsFUN, \
1698 std::map<UInt_t, TString> *commentsRUN)
1700 const UInt_t prec = 6;
1701 const TString hline =
"###############################################################";
1703 std::map<UInt_t, TString>::iterator iter;
1707 std::ofstream fout(filename);
1713 fout <<
fTitle.Data() << std::endl;
1714 fout << hline.Data() << std::endl;
1717 fout <<
"FITPARAMETER" << std::endl;
1718 fout <<
"# No Name Value Step Pos_Error Boundaries" << std::endl;
1720 for (i = 0; i <
fParam.size(); ++i) {
1722 iter = commentsPAR->find(i+1);
1723 if (iter != commentsPAR->end()) {
1725 fout <<
"# " << iter->second.Data() << std::endl;
1727 commentsPAR->erase(iter);
1732 fout << std::right <<
fParam[i].fNo;
1736 fout << std::left <<
fParam[i].fName.Data();
1740 fout.precision(prec);
1741 fout << std::left <<
fParam[i].fValue;
1745 fout.precision(prec);
1746 fout << std::left <<
fParam[i].fStep;
1749 fout.precision(prec);
1750 if ((
fParam[i].fNoOfParams == 5) || (
fParam[i].fNoOfParams == 7))
1751 if (
fParam[i].fPosErrorPresent && (
fParam[i].fStep != 0))
1752 fout << std::left <<
fParam[i].fPosError;
1754 fout << std::left <<
"none";
1756 fout << std::left <<
"none";
1759 if (
fParam[i].fNoOfParams > 5) {
1761 fout.precision(prec);
1762 if (
fParam[i].fLowerBoundaryPresent)
1763 fout << std::left <<
fParam[i].fLowerBoundary;
1765 fout << std::left <<
"none";
1768 fout.precision(prec);
1769 if (
fParam[i].fUpperBoundaryPresent)
1770 fout << std::left <<
fParam[i].fUpperBoundary;
1772 fout << std::left <<
"none";
1777 if (commentsPAR && !commentsPAR->empty()) {
1779 for(iter = commentsPAR->begin(); iter != commentsPAR->end(); ++iter) {
1780 fout <<
"# " << iter->second.Data() << std::endl;
1782 commentsPAR->clear();
1785 fout << hline.Data() << std::endl;
1788 fout <<
"THEORY" << std::endl;
1790 for (i = 1; i <
fTheory.size(); ++i) {
1792 iter = commentsTHE->find(i);
1793 if (iter != commentsTHE->end()) {
1795 fout <<
"# " << iter->second.Data() << std::endl;
1797 commentsTHE->erase(iter);
1800 fout <<
fTheory[i].fLine.Data() << std::endl;
1802 if (commentsTHE && !commentsTHE->empty()) {
1804 for(iter = commentsTHE->begin(); iter != commentsTHE->end(); ++iter) {
1805 fout <<
"# " << iter->second.Data() << std::endl;
1807 commentsTHE->clear();
1810 fout << hline.Data() << std::endl;
1816 fout <<
"FUNCTIONS" << std::endl;
1820 iter = commentsFUN->find(i);
1821 if (iter != commentsFUN->end()) {
1823 fout <<
"# " << iter->second.Data() << std::endl;
1825 commentsFUN->erase(iter);
1828 fout <<
fFunctions[i].fLine.Data() << std::endl;
1830 if (commentsFUN && !commentsFUN->empty()) {
1832 for(iter = commentsFUN->begin(); iter != commentsFUN->end(); ++iter) {
1833 fout <<
"# " << iter->second.Data() << std::endl;
1835 commentsFUN->clear();
1838 fout << hline.Data() << std::endl;
1842 fout <<
"GLOBAL" << std::endl;
1845 if (
fGlobal.GetFitType() != -1) {
1847 switch (
fGlobal.GetFitType()) {
1855 fout << std::left <<
"fittype" <<
MSR_FITTYPE_ASYM <<
" (asymmetry fit)" << std::endl ;
1858 fout << std::left <<
"fittype" <<
MSR_FITTYPE_ASYM_RRF <<
" (asymmetry RRF fit)" << std::endl ;
1864 fout << std::left <<
"fittype" <<
MSR_FITTYPE_BNMR <<
" (beta-NMR fit)" << std::endl ;
1877 fout << std::left <<
"rrf_freq ";
1879 fout << std::left <<
fGlobal.GetRRFFreq(
fGlobal.GetRRFUnit().Data());
1880 fout <<
" " <<
fGlobal.GetRRFUnit();
1885 fout <<
"rrf_phase ";
1887 fout << std::left <<
fGlobal.GetRRFPhase();
1892 fout <<
"rrf_packing ";
1894 fout << std::left <<
fGlobal.GetRRFPacking();
1899 if ((
fGlobal.GetDataRange(0) != -1) || (
fGlobal.GetDataRange(1) != -1) || (
fGlobal.GetDataRange(2) != -1) || (
fGlobal.GetDataRange(3) != -1)) {
1901 fout << std::left <<
"data";
1902 for (UInt_t j=0; j<4; ++j) {
1903 if (
fGlobal.GetDataRange(j) > 0) {
1905 fout << std::left <<
fGlobal.GetDataRange(j);
1912 if (
fGlobal.GetT0BinSize() > 0) {
1914 fout << std::left <<
"t0";
1915 for (UInt_t j=0; j<
fGlobal.GetT0BinSize(); ++j) {
1918 fout.setf(std::ios::fixed,std::ios::floatfield);
1919 fout << std::left <<
fGlobal.GetT0Bin(j);
1925 for (UInt_t j = 0; j <
fGlobal.GetAddT0BinEntries(); ++j) {
1926 if (
fGlobal.GetAddT0BinSize(j) > 0) {
1928 fout << std::left <<
"addt0";
1929 for (Int_t k=0; k<
fGlobal.GetAddT0BinSize(j); ++k) {
1932 fout.setf(std::ios::fixed,std::ios::floatfield);
1933 fout << std::left <<
fGlobal.GetAddT0Bin(j, k);
1940 if ( (
fGlobal.IsFitRangeInBin() &&
fGlobal.GetFitRangeOffset(0) != -1) ||
1943 fout << std::left <<
"fit";
1944 if (
fGlobal.IsFitRangeInBin()) {
1946 if (
fGlobal.GetFitRangeOffset(0) > 0)
1947 fout <<
"+" <<
fGlobal.GetFitRangeOffset(0);
1949 if (
fGlobal.GetFitRangeOffset(1) > 0)
1950 fout <<
"-" <<
fGlobal.GetFitRangeOffset(1);
1952 for (UInt_t j=0; j<2; j++) {
1953 if (
fGlobal.GetFitRange(j) == -1)
1955 UInt_t neededWidth = 7;
1957 fout.width(neededWidth);
1958 fout.precision(neededPrec);
1959 fout << std::left << std::fixed <<
fGlobal.GetFitRange(j);
1968 if (
fGlobal.GetPacking() != -1) {
1970 fout << std::left <<
"packing";
1971 fout <<
fGlobal.GetPacking() << std::endl;
1974 fout << std::endl << hline.Data() << std::endl;
1978 for (i = 0; i <
fRuns.size(); ++i) {
1980 iter = commentsRUN->find(i + 1);
1981 if (iter != commentsRUN->end()) {
1984 fout <<
"# " << iter->second.Data() << std::endl;
1986 commentsRUN->erase(iter);
1989 fout <<
"RUN " <<
fRuns[i].GetRunName()->Data() <<
" ";
1990 pstr =
fRuns[i].GetBeamline();
1991 if (pstr ==
nullptr) {
1992 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrFile: **ERROR** Couldn't obtain beamline data." << std::endl;
1996 fout << pstr->Data() <<
" ";
1997 pstr =
fRuns[i].GetInstitute();
1998 if (pstr ==
nullptr) {
1999 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrFile: **ERROR** Couldn't obtain institute data." << std::endl;
2003 fout << pstr->Data() <<
" ";
2004 pstr =
fRuns[i].GetFileFormat();
2005 if (pstr ==
nullptr) {
2006 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrFile: **ERROR** Couldn't obtain file format data." << std::endl;
2010 fout << pstr->Data() <<
" (name beamline institute data-file-format)" << std::endl;
2013 for (UInt_t j = 1; j <
fRuns[i].GetRunNameSize(); ++j) {
2014 fout <<
"ADDRUN " <<
fRuns[i].GetRunName(j)->Data() <<
" ";
2015 pstr =
fRuns[i].GetBeamline(j);
2016 if (pstr ==
nullptr) {
2017 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrFile: **ERROR** Couldn't obtain beamline data (addrun)." << std::endl;
2021 fout << pstr->Data() <<
" ";
2022 pstr =
fRuns[i].GetInstitute(j);
2023 if (pstr ==
nullptr) {
2024 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrFile: **ERROR** Couldn't obtain institute data (addrun)." << std::endl;
2028 fout << pstr->Data() <<
" ";
2029 pstr =
fRuns[i].GetFileFormat(j);
2030 if (pstr ==
nullptr) {
2031 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrFile: **ERROR** Couldn't obtain file format data (addrun)." << std::endl;
2035 fout << pstr->Data() <<
" (name beamline institute data-file-format)" << std::endl;
2039 if (
fRuns[i].GetFitType() != -1) {
2041 switch (
fRuns[i].GetFitType()) {
2049 fout << std::left <<
"fittype" <<
MSR_FITTYPE_ASYM <<
" (asymmetry fit)" << std::endl ;
2052 fout << std::left <<
"fittype" <<
MSR_FITTYPE_ASYM_RRF <<
" (asymmetry RRF fit)" << std::endl ;
2058 fout << std::left <<
"fittype" <<
MSR_FITTYPE_BNMR <<
" (beta-NMR fit)" << std::endl ;
2069 if (
fRuns[i].GetAlphaParamNo() != -1) {
2071 fout << std::left <<
"alpha";
2076 fout <<
fRuns[i].GetAlphaParamNo();
2081 if (
fRuns[i].GetBetaParamNo() != -1) {
2083 fout << std::left <<
"beta";
2088 fout <<
fRuns[i].GetBetaParamNo();
2093 if (
fRuns[i].GetNormParamNo() != -1) {
2095 fout << std::left <<
"norm";
2100 fout <<
fRuns[i].GetNormParamNo();
2105 if (
fRuns[i].GetBkgFitParamNo() != -1) {
2107 fout << std::left <<
"backgr.fit";
2108 fout <<
fRuns[i].GetBkgFitParamNo() << std::endl;
2112 if (
fRuns[i].GetLifetimeParamNo() != -1) {
2114 fout << std::left <<
"lifetime";
2115 fout <<
fRuns[i].GetLifetimeParamNo() << std::endl;
2120 fout <<
"lifetimecorrection" << std::endl;
2125 for (UInt_t j=0; j<
fRuns[i].GetMap()->size(); ++j) {
2127 fout << std::right <<
fRuns[i].GetMap(j);
2130 if (
fRuns[i].GetMap()->size() < 10) {
2131 for (UInt_t j=
fRuns[i].GetMap()->size(); j<10; ++j)
2137 if (
fRuns[i].GetForwardHistoNoSize() == 0) {
2138 std::cerr << std::endl <<
">> PMsrHandler::WriteMsrFile: **WARNING** No 'forward' data found!";
2139 std::cerr << std::endl <<
">> Something is VERY fishy, please check your msr-file carfully." << std::endl;
2142 fout << std::left <<
"forward";
2143 for (UInt_t j=0; j<
fRuns[i].GetForwardHistoNoSize(); ++j) {
2145 fout <<
fRuns[i].GetForwardHistoNo(j);
2151 if (
fRuns[i].GetBackwardHistoNoSize() > 0) {
2153 fout << std::left <<
"backward";
2154 for (UInt_t j=0; j<
fRuns[i].GetBackwardHistoNoSize(); ++j) {
2156 fout <<
fRuns[i].GetBackwardHistoNo(j);
2164 fout << std::left <<
"backgr.fix";
2165 for (UInt_t j=0; j<2; ++j) {
2167 fout.precision(prec);
2169 fout << std::left <<
fRuns[i].GetBkgFix(j);
2176 if ((
fRuns[i].GetBkgRange(0) != -1) || (
fRuns[i].GetBkgRange(1) != -1) || (
fRuns[i].GetBkgRange(2) != -1) || (
fRuns[i].GetBkgRange(3) != -1)) {
2178 fout << std::left <<
"background";
2179 for (UInt_t j=0; j<4; ++j) {
2180 if (
fRuns[i].GetBkgRange(j) > 0) {
2182 fout << std::left <<
fRuns[i].GetBkgRange(j);
2189 if ((
fRuns[i].GetDataRange(0) != -1) || (
fRuns[i].GetDataRange(1) != -1) || (
fRuns[i].GetDataRange(2) != -1) || (
fRuns[i].GetDataRange(3) != -1)) {
2191 fout << std::left <<
"data";
2192 for (UInt_t j=0; j<4; ++j) {
2193 if (
fRuns[i].GetDataRange(j) > 0) {
2195 fout << std::left <<
fRuns[i].GetDataRange(j);
2202 if (
fRuns[i].GetT0BinSize() > 0) {
2204 fout << std::left <<
"t0";
2205 for (UInt_t j=0; j<
fRuns[i].GetT0BinSize(); ++j) {
2208 fout.setf(std::ios::fixed,std::ios::floatfield);
2209 fout << std::left <<
fRuns[i].GetT0Bin(j);
2215 if (
fRuns[i].GetAddT0BinEntries() > 0) {
2216 for (UInt_t j = 0; j <
fRuns[i].GetRunNameSize() - 1; ++j) {
2217 if (
fRuns[i].GetAddT0BinSize(j) > 0) {
2219 fout << std::left <<
"addt0";
2220 for (Int_t k=0; k<
fRuns[i].GetAddT0BinSize(j); ++k) {
2223 fout.setf(std::ios::fixed,std::ios::floatfield);
2224 fout << std::left <<
fRuns[i].GetAddT0Bin(j, k);
2232 if (
fRuns[i].GetXDataIndex() != -1) {
2234 fout << std::left <<
"xy-data";
2237 fout << std::left << std::fixed <<
fRuns[i].GetXDataIndex();
2240 fout << std::left << std::fixed <<
fRuns[i].GetYDataIndex();
2242 }
else if (!
fRuns[i].GetXDataLabel()->IsWhitespace()) {
2244 fout << std::left <<
"xy-data";
2246 fout << std::left << std::fixed <<
fRuns[i].GetXDataLabel()->Data();
2249 fout << std::left << std::fixed <<
fRuns[i].GetYDataLabel()->Data();
2254 if ( (
fRuns[i].IsFitRangeInBin() &&
fRuns[i].GetFitRangeOffset(0) != -1) ||
2257 fout << std::left <<
"fit";
2258 if (
fRuns[i].IsFitRangeInBin()) {
2260 if (
fRuns[i].GetFitRangeOffset(0) > 0)
2261 fout <<
"+" <<
fRuns[i].GetFitRangeOffset(0);
2263 if (
fRuns[i].GetFitRangeOffset(1) > 0)
2264 fout <<
"-" <<
fRuns[i].GetFitRangeOffset(1);
2266 for (UInt_t j=0; j<2; j++) {
2267 if (
fRuns[i].GetFitRange(j) == -1)
2269 UInt_t neededWidth = 7;
2271 fout.width(neededWidth);
2272 fout.precision(neededPrec);
2273 fout << std::left << std::fixed <<
fRuns[i].GetFitRange(j);
2282 if (
fRuns[i].GetPacking() != -1) {
2284 fout << std::left <<
"packing";
2285 fout <<
fRuns[i].GetPacking() << std::endl;
2291 if (commentsRUN && !commentsRUN->empty()) {
2292 for(iter = commentsRUN->begin(); iter != commentsRUN->end(); ++iter) {
2293 fout <<
"# " << iter->second.Data() << std::endl;
2296 commentsRUN->clear();
2298 fout << hline.Data() << std::endl;
2301 fout <<
"COMMANDS" << std::endl;
2302 for (i = 0; i <
fCommands.size(); ++i) {
2303 if (
fCommands[i].fLine.BeginsWith(
"SET BATCH") ||
fCommands[i].fLine.BeginsWith(
"END RETURN"))
2306 fout <<
fCommands[i].fLine.Data() << std::endl;
2309 fout << hline.Data() << std::endl;
2312 if (
fFourier.fFourierBlockPresent) {
2313 fout <<
"FOURIER" << std::endl;
2327 fout <<
" # units either 'Gauss', 'Tesla', 'MHz', or 'Mc/s'";
2332 if (
fFourier.fFourierPower != -1) {
2333 fout <<
"fourier_power " <<
fFourier.fFourierPower << std::endl;
2338 fout <<
"apodization ";
2348 fout <<
" # NONE, WEAK, MEDIUM, STRONG";
2360 fout <<
"REAL_AND_IMAG";
2366 fout <<
"PHASE_OPT_REAL";
2368 fout <<
" # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE, PHASE_OPT_REAL";
2373 if (
fFourier.fPhaseParamNo.size() > 0) {
2375 fout <<
"phase " << phaseParamStr << std::endl;
2376 }
else if (
fFourier.fPhase.size() > 0) {
2378 for (UInt_t i=0; i<
fFourier.fPhase.size()-1; i++) {
2379 fout <<
fFourier.fPhase[i] <<
", ";
2385 if ((
fFourier.fRangeForPhaseCorrection[0] != -1.0) || (
fFourier.fRangeForPhaseCorrection[1] != -1.0)) {
2386 fout <<
"range_for_phase_correction " <<
fFourier.fRangeForPhaseCorrection[0] <<
" " <<
fFourier.fRangeForPhaseCorrection[1] << std::endl;
2390 if ((
fFourier.fPlotRange[0] != -1.0) || (
fFourier.fPlotRange[1] != -1.0)) {
2391 fout.setf(std::ios::fixed,std::ios::floatfield);
2395 fout.precision(neededPrec);
2396 fout <<
"range " <<
fFourier.fPlotRange[0] <<
" " <<
fFourier.fPlotRange[1] << std::endl;
2405 fout << hline.Data() << std::endl;
2409 for (i = 0; i <
fPlots.size(); ++i) {
2410 switch (
fPlots[i].fPlotType) {
2412 fout <<
"PLOT " <<
fPlots[i].fPlotType <<
" (single histo plot)" << std::endl;
2415 fout <<
"PLOT " <<
fPlots[i].fPlotType <<
" (single histo RRF plot)" << std::endl;
2418 fout <<
"PLOT " <<
fPlots[i].fPlotType <<
" (asymmetry plot)" << std::endl;
2421 fout <<
"PLOT " <<
fPlots[i].fPlotType <<
" (asymmetry RRF plot)" << std::endl;
2424 fout <<
"PLOT " <<
fPlots[i].fPlotType <<
" (mu minus plot)" << std::endl;
2427 fout <<
"PLOT " <<
fPlots[i].fPlotType <<
" (beta-NMR asymmetry plot)" << std::endl;
2430 fout <<
"PLOT " <<
fPlots[i].fPlotType <<
" (non muSR plot)" << std::endl;
2439 for (UInt_t j=0; j<
fPlots[i].fRuns.size(); ++j) {
2441 fout <<
fPlots[i].fRuns[j];
2446 if ((
fPlots[i].fTmin.size() == 1) && (
fPlots[i].fTmax.size() == 1)) {
2449 fout <<
fPlots[i].fTmin[0] <<
" " <<
fPlots[i].fTmax[0];
2450 }
else if ((
fPlots[i].fTmin.size() > 1) && (
fPlots[i].fTmax.size() > 1)) {
2451 fout <<
"sub_ranges ";
2453 for (UInt_t j=0; j <
fPlots[i].fTmin.size(); ++j) {
2454 fout <<
" " <<
fPlots[i].fTmin[j] <<
" " <<
fPlots[i].fTmax[j];
2457 if (!
fPlots[i].fYmin.empty() && !
fPlots[i].fYmax.empty()) {
2458 fout <<
" " <<
fPlots[i].fYmin[0] <<
" " <<
fPlots[i].fYmax[0];
2463 if (
fPlots[i].fUseFitRanges) {
2464 if (!
fPlots[i].fYmin.empty() && !
fPlots[i].fYmax.empty())
2465 fout <<
"use_fit_ranges " <<
fPlots[i].fYmin[0] <<
" " <<
fPlots[i].fYmax[0] << std::endl;
2467 fout <<
"use_fit_ranges" << std::endl;
2471 if (
fPlots[i].fViewPacking != -1) {
2472 fout <<
"view_packing " <<
fPlots[i].fViewPacking << std::endl;
2477 fout <<
"logx" << std::endl;
2482 fout <<
"logy" << std::endl;
2486 if (
fPlots[i].fLifeTimeCorrection) {
2487 fout <<
"lifetimecorrection" << std::endl;
2491 if (
fPlots[i].fRRFPacking) {
2492 fout <<
"rrf_packing " <<
fPlots[i].fRRFPacking << std::endl;
2496 if (
fPlots[i].fRRFFreq) {
2497 fout <<
"rrf_freq " <<
fPlots[i].fRRFFreq <<
" ";
2498 switch (
fPlots[i].fRRFUnit) {
2521 if (
fPlots[i].fRRFPhaseParamNo > 0) {
2522 fout <<
"rrf_phase par" <<
fPlots[i].fRRFPhaseParamNo << std::endl;
2523 }
else if (
fPlots[i].fRRFPhase) {
2524 fout <<
"rrf_phase " <<
fPlots[i].fRRFPhase << std::endl;
2530 fout << hline.Data() << std::endl;
2535 fout <<
"STATISTIC --- " << dt.AsSQLString() << std::endl;
2542 str +=
", chisq/NDF = ";
2544 fout << str.Data() << std::endl;
2550 str +=
", maxLH/NDF = ";
2552 fout << str.Data() << std::endl;
2555 fout <<
"*** FIT DID NOT CONVERGE ***" << std::endl;
2582 if (idx >=
fParam.size()) {
2585 fLastErrorMsg <<
">> PMsrHandler::SetMsrParamValue(): **ERROR** idx = " << idx <<
" is >= than the number of fit parameters " <<
fParam.size() <<
"\n";
2590 fParam[idx].fValue = value;
2611 if (idx >=
fParam.size()) {
2614 fLastErrorMsg <<
">> PMsrHandler::SetMsrParamValue(): **ERROR** idx = " << idx <<
" is larger than the number of parameters " <<
fParam.size() <<
"\n";
2619 fParam[idx].fStep = value;
2639 if (idx >=
fParam.size()) {
2642 fLastErrorMsg <<
">> PMsrHandler::SetMsrParamPosErrorPresent(): **ERROR** idx = " << idx <<
" is larger than the number of parameters " <<
fParam.size() <<
"\n";
2647 fParam[idx].fPosErrorPresent = value;
2667 if (idx >=
fParam.size()) {
2670 fLastErrorMsg <<
">> PMsrHandler::SetMsrParamPosError(): **ERROR** idx = " << idx <<
" is larger than the number of parameters " <<
fParam.size() <<
"\n";
2675 fParam[idx].fPosErrorPresent =
true;
2676 fParam[idx].fPosError = value;
2693 if (runNo >=
fRuns.size()) {
2696 fLastErrorMsg <<
">> PMsrHandler::SetMsrT0Entry: **ERROR** runNo = " << runNo <<
", is out of valid range 0.." <<
fRuns.size() <<
"\n";
2701 if (idx >=
fRuns[runNo].GetT0BinSize()) {
2702 std::cerr << std::endl <<
">> PMsrHandler::SetMsrT0Entry: **WARNING** idx = " << idx <<
", is out of valid range 0.." <<
fRuns[runNo].GetT0BinSize();
2703 std::cerr << std::endl <<
">> Will add it anyway.";
2704 std::cerr << std::endl;
2707 fRuns[runNo].SetT0Bin(bin, idx);
2723 if (runNo >=
fRuns.size()) {
2726 fLastErrorMsg <<
">> PMsrHandler::SetMsrAddT0Entry: **ERROR** runNo = " << runNo <<
", is out of valid range 0.." <<
fRuns.size() <<
"\n";
2731 if (addRunIdx >=
fRuns[runNo].GetAddT0BinEntries()) {
2732 std::cerr << std::endl <<
">> PMsrHandler::SetMsrAddT0Entry: **WARNING** addRunIdx = " << addRunIdx <<
", is out of valid range 0.." <<
fRuns[runNo].GetAddT0BinEntries();
2733 std::cerr << std::endl <<
">> Will add it anyway.";
2734 std::cerr << std::endl;
2737 if (
static_cast<Int_t
>(histoIdx) >
fRuns[runNo].GetAddT0BinSize(addRunIdx)) {
2738 std::cerr << std::endl <<
">> PMsrHandler::SetMsrAddT0Entry: **WARNING** histoIdx = " << histoIdx <<
", is out of valid range 0.." <<
fRuns[runNo].GetAddT0BinSize(addRunIdx);
2739 std::cerr << std::endl <<
">> Will add it anyway.";
2740 std::cerr << std::endl;
2743 fRuns[runNo].SetAddT0Bin(bin, addRunIdx, histoIdx);
2758 if (runNo >=
fRuns.size()) {
2761 fLastErrorMsg <<
">> PMsrHandler::SetMsrDataRangeEntry: **ERROR** runNo = " << runNo <<
", is out of valid range 0.." <<
fRuns.size() <<
"\n";
2766 fRuns[runNo].SetDataRange(bin, idx);
2781 if (runNo >=
fRuns.size()) {
2784 fLastErrorMsg <<
">> PMsrHandler::SetMsrBkgRangeEntry: **ERROR** runNo = " << runNo <<
", is out of valid range 0.." <<
fRuns.size() <<
"\n";
2789 fRuns[runNo].SetBkgRange(bin, idx);
2810 if (paramNo >=
fParam.size())
2843 Bool_t error =
false;
2845 PMsrLines::iterator iter;
2847 TObjArray *tokens =
nullptr;
2848 TObjString *ostr =
nullptr;
2852 iter = lines.begin();
2853 while ((iter != lines.end()) && !error) {
2858 param.
fName = TString(
"");
2868 tokens = iter->fLine.Tokenize(
" \t");
2872 fLastErrorMsg <<
">> PMsrHandler::HandleFitParameterEntry: **SEVERE ERROR** Couldn't tokenize Parameters in line " << iter->fLineNo <<
"\n";
2878 if ((tokens->GetEntries() < 4) || (tokens->GetEntries() > 7) || (tokens->GetEntries() == 6)) {
2882 ostr =
dynamic_cast<TObjString*
>(tokens->At(0));
2883 str = ostr->GetString();
2885 param.
fNo = str.Atoi();
2890 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
2891 str = ostr->GetString();
2895 ostr =
dynamic_cast<TObjString*
>(tokens->At(2));
2896 str = ostr->GetString();
2898 param.
fValue =
static_cast<Double_t
>(str.Atof());
2903 ostr =
dynamic_cast<TObjString*
>(tokens->At(3));
2904 str = ostr->GetString();
2906 param.
fStep =
static_cast<Double_t
>(str.Atof());
2911 if (tokens->GetEntries() == 4) {
2916 if (tokens->GetEntries() == 5) {
2920 ostr =
dynamic_cast<TObjString*
>(tokens->At(4));
2921 str = ostr->GetString();
2922 if (str.IsFloat()) {
2924 param.
fPosError =
static_cast<Double_t
>(str.Atof());
2927 if (!str.CompareTo(
"none", TString::kIgnoreCase))
2935 if (tokens->GetEntries() == 7) {
2939 ostr =
dynamic_cast<TObjString*
>(tokens->At(4));
2940 str = ostr->GetString();
2941 if (str.IsFloat()) {
2943 param.
fPosError =
static_cast<Double_t
>(str.Atof());
2946 if (!str.CompareTo(
"none", TString::kIgnoreCase))
2953 ostr =
dynamic_cast<TObjString*
>(tokens->At(5));
2954 str = ostr->GetString();
2956 if (!str.CompareTo(
"none", TString::kIgnoreCase)) {
2959 if (str.IsFloat()) {
2968 ostr =
dynamic_cast<TObjString*
>(tokens->At(6));
2969 str = ostr->GetString();
2971 if (!str.CompareTo(
"none", TString::kIgnoreCase)) {
2974 if (str.IsFloat()) {
2993 fLastErrorMsg <<
">> PMsrHandler::HandleFitParameterEntry: **ERROR** in line " << iter->fLineNo <<
":\n";
2995 fLastErrorMsg <<
">> A Fit Parameter line needs to have the following form:\n";
2997 fLastErrorMsg <<
">> No Name Value Step/Error [Lower_Boundary Upper_Boundary]\n\n";
2999 fLastErrorMsg <<
">> No Name Value Step/Neg_Error Pos_Error [Lower_Boundary Upper_Boundary]\n\n";
3000 fLastErrorMsg <<
">> No: the parameter number (an Int_t)\n";
3001 fLastErrorMsg <<
">> Name: the name of the parameter (less than 256 character)\n";
3002 fLastErrorMsg <<
">> Value: the starting value of the parameter (a Double_t)\n";
3004 fLastErrorMsg <<
">> Step/Neg_Error: the starting step value in a fit (a Double_t), or\n";
3005 fLastErrorMsg <<
">> the symmetric error (MIGRAD, SIMPLEX), or\n";
3007 fLastErrorMsg <<
">> Pos_Error: the positive error (MINOS), (a Double_t or \"none\")\n";
3008 fLastErrorMsg <<
">> Lower_Boundary: the lower boundary allowed for the fit parameter (a Double_t or \"none\")\n";
3009 fLastErrorMsg <<
">> Upper_Boundary: the upper boundary allowed for the fit parameter (a Double_t or \"none\")\n";
3025 for (UInt_t i=0; i<
fParam.size(); i++) {
3026 if (
fParam[i].fNo !=
static_cast<Int_t
>(i)+1) {
3030 fLastErrorMsg <<
">> PMsrHandler::HandleFitParameterEntry: **ERROR**\n";
3031 fLastErrorMsg <<
">> Sorry, you are assuming to much from this program, it cannot\n";
3032 fLastErrorMsg <<
">> handle none subsequent numbered parameters yet or in the near future.\n";
3034 fLastErrorMsg <<
">> parameter number " <<
fParam[i].fNo <<
", at paramter position " << i+1 <<
".\n";
3097 if ((
fFuncHandler->GetNoOfFuncs() == 0) && !lines.empty()) {
3098 std::cerr << std::endl <<
">> PMsrHandler::HandleFunctionsEntry: **WARNING** empty FUNCTIONS block found!";
3099 std::cerr << std::endl;
3119 PMsrLines::iterator iter;
3122 Bool_t error =
false;
3125 TObjArray *tokens =
nullptr;
3126 TObjString *ostr =
nullptr;
3128 Double_t dval = 0.0;
3129 UInt_t addT0Counter = 0;
3134 iter = lines.begin();
3135 while ((iter != lines.end()) && !error) {
3138 Ssiz_t idx = str.Index(
"#");
3143 tokens = str.Tokenize(
" \t");
3147 fLastErrorMsg <<
">> PMsrHandler::HandleGlobalEntry: **SEVERE ERROR** Couldn't tokenize line " << iter->fLineNo <<
"\n\n";
3152 if (iter->fLine.BeginsWith(
"fittype", TString::kIgnoreCase)) {
3153 if (tokens->GetEntries() < 2) {
3156 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3157 str = ostr->GetString();
3158 if (str.IsDigit()) {
3159 Int_t fittype = str.Atoi();
3175 }
else if (iter->fLine.BeginsWith(
"rrf_freq", TString::kIgnoreCase)) {
3176 if (tokens->GetEntries() < 3) {
3179 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3180 str = ostr->GetString();
3181 if (str.IsFloat()) {
3187 ostr =
dynamic_cast<TObjString*
>(tokens->At(2));
3188 str = ostr->GetString();
3194 }
else if (iter->fLine.BeginsWith(
"rrf_packing", TString::kIgnoreCase)) {
3195 if (tokens->GetEntries() < 2) {
3198 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3199 str = ostr->GetString();
3200 if (str.IsDigit()) {
3211 }
else if (iter->fLine.BeginsWith(
"rrf_phase", TString::kIgnoreCase)) {
3212 if (tokens->GetEntries() < 2) {
3215 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3216 str = ostr->GetString();
3217 if (str.IsFloat()) {
3224 }
else if (iter->fLine.BeginsWith(
"data", TString::kIgnoreCase)) {
3225 if (tokens->GetEntries() < 3) {
3228 for (Int_t i=1; i<tokens->GetEntries(); i++) {
3229 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
3230 str = ostr->GetString();
3231 if (str.IsDigit()) {
3243 }
else if (iter->fLine.BeginsWith(
"t0", TString::kIgnoreCase)) {
3244 if (tokens->GetEntries() < 2) {
3247 for (Int_t i=1; i<tokens->GetEntries(); i++) {
3248 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
3249 str = ostr->GetString();
3250 if (str.IsFloat()) {
3261 }
else if (iter->fLine.BeginsWith(
"addt0", TString::kIgnoreCase)) {
3262 if (tokens->GetEntries() < 2) {
3265 for (Int_t i=1; i<tokens->GetEntries(); i++) {
3266 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
3267 str = ostr->GetString();
3268 if (str.IsFloat()) {
3280 }
else if (iter->fLine.BeginsWith(
"fit", TString::kIgnoreCase)) {
3281 if (tokens->GetEntries() < 3) {
3284 if (iter->fLine.Contains(
"fgb", TString::kIgnoreCase)) {
3286 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3287 str = ostr->GetString();
3288 Ssiz_t idx = str.First(
"+");
3289 TString numStr = str;
3291 numStr.Remove(0,idx+1);
3292 if (numStr.IsFloat()) {
3301 ostr =
dynamic_cast<TObjString*
>(tokens->At(2));
3302 str = ostr->GetString();
3303 idx = str.First(
"-");
3306 numStr.Remove(0,idx+1);
3307 if (numStr.IsFloat()) {
3318 for (Int_t i=1; i<3; i++) {
3319 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
3320 str = ostr->GetString();
3328 }
else if (iter->fLine.BeginsWith(
"packing", TString::kIgnoreCase)) {
3329 if (tokens->GetEntries() < 2) {
3332 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3333 str = ostr->GetString();
3334 if (str.IsDigit()) {
3345 }
else if (iter->fLine.BeginsWith(
"deadtime-cor", TString::kIgnoreCase)) {
3346 if (tokens->GetEntries() < 2) {
3349 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3350 str = ostr->GetString();
3351 if (!str.CompareTo(
"no", TString::kIgnoreCase) ||
3352 !str.CompareTo(
"file", TString::kIgnoreCase) ||
3353 !str.CompareTo(
"estimate", TString::kIgnoreCase)) {
3374 fLastErrorMsg <<
">> PMsrHandler::HandleGlobalEntry: **ERROR** in line " << iter->fLineNo <<
":\n";
3376 fLastErrorMsg <<
">> GLOBAL block syntax is too complex to print it here. Please check the manual.\n";
3399 PMsrLines::iterator iter;
3401 Bool_t first =
true;
3402 Bool_t error =
false;
3403 Bool_t runLinePresent =
false;
3406 TObjArray *tokens =
nullptr;
3407 TObjString *ostr =
nullptr;
3409 UInt_t addT0Counter = 0;
3414 iter = lines.begin();
3415 while ((iter != lines.end()) && !error) {
3418 Ssiz_t idx = str.Index(
"#");
3421 idx = str.Index(
"(");
3426 tokens = str.Tokenize(
" \t");
3430 fLastErrorMsg <<
">> PMsrHandler::HandleRunEntry: **SEVERE ERROR** Couldn't tokenize Parameters in line " << iter->fLineNo <<
"\n\n";
3438 line.Remove(TString::kLeading,
' ');
3441 if (line.BeginsWith(
"run", TString::kIgnoreCase)) {
3443 runLinePresent =
true;
3446 fRuns.push_back(param);
3454 if (tokens->GetEntries() < 5) {
3459 for (Int_t i=1; i<tokens->GetEntries()-3; i++) {
3460 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
3461 str += ostr->GetString();
3462 if (i<tokens->GetEntries()-4)
3463 str += TString(
" ");
3467 ostr =
dynamic_cast<TObjString*
>(tokens->At(tokens->GetEntries()-3));
3468 str = ostr->GetString();
3471 ostr =
dynamic_cast<TObjString*
>(tokens->At(tokens->GetEntries()-2));
3472 str = ostr->GetString();
3475 ostr =
dynamic_cast<TObjString*
>(tokens->At(tokens->GetEntries()-1));
3476 str = ostr->GetString();
3484 if (line.BeginsWith(
"addrun", TString::kIgnoreCase)) {
3486 if (!runLinePresent) {
3489 fLastErrorMsg <<
">> PMsrHandler::HandleRunEntry: **ERROR** Found ADDRUN without prior RUN, or\n";
3490 fLastErrorMsg <<
">> ADDRUN lines intercepted by other stuff. All this is not allowed!\n";
3491 fLastErrorMsg <<
">> error in line " << iter->fLineNo <<
"\n";
3498 if (tokens->GetEntries() < 5) {
3502 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3503 str = ostr->GetString();
3506 ostr =
dynamic_cast<TObjString*
>(tokens->At(2));
3507 str = ostr->GetString();
3510 ostr =
dynamic_cast<TObjString*
>(tokens->At(3));
3511 str = ostr->GetString();
3514 ostr =
dynamic_cast<TObjString*
>(tokens->At(4));
3515 str = ostr->GetString();
3521 if (line.BeginsWith(
"fittype", TString::kIgnoreCase)) {
3523 runLinePresent =
false;
3525 if (tokens->GetEntries() < 2) {
3528 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3529 str = ostr->GetString();
3530 if (str.IsDigit()) {
3531 Int_t fittype = str.Atoi();
3550 if (line.BeginsWith(
"alpha", TString::kIgnoreCase)) {
3552 runLinePresent =
false;
3554 if (tokens->GetEntries() < 2) {
3557 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3558 str = ostr->GetString();
3559 if (str.IsDigit()) {
3565 }
else if (str.Contains(
"fun")) {
3578 if (line.BeginsWith(
"beta", TString::kIgnoreCase)) {
3580 runLinePresent =
false;
3582 if (tokens->GetEntries() < 2) {
3585 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3586 str = ostr->GetString();
3587 if (str.IsDigit()) {
3593 }
else if (str.Contains(
"fun")) {
3606 if (line.BeginsWith(
"norm", TString::kIgnoreCase)) {
3608 runLinePresent =
false;
3610 if (tokens->GetEntries() < 2) {
3613 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3614 str = ostr->GetString();
3615 if (str.IsDigit()) {
3617 }
else if (str.Contains(
"fun")) {
3630 if (line.BeginsWith(
"backgr.fit", TString::kIgnoreCase)) {
3632 runLinePresent =
false;
3634 if (tokens->GetEntries() < 2) {
3637 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3638 str = ostr->GetString();
3639 if (str.IsDigit()) {
3652 if (line.BeginsWith(
"lifetime ", TString::kIgnoreCase)) {
3654 runLinePresent =
false;
3656 if (tokens->GetEntries() < 2) {
3659 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3660 str = ostr->GetString();
3661 if (str.IsDigit()) {
3674 if (line.BeginsWith(
"lifetimecorrection", TString::kIgnoreCase)) {
3676 runLinePresent =
false;
3682 if (line.BeginsWith(
"map", TString::kIgnoreCase)) {
3684 runLinePresent =
false;
3686 for (Int_t i=1; i<tokens->GetEntries(); i++) {
3687 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
3688 str = ostr->GetString();
3689 if (str.IsDigit()) {
3701 for (UInt_t i=0; i<param.
GetMap()->size(); i++) {
3702 if ((param.
GetMap(i) < 0) || (param.
GetMap(i) >
static_cast<Int_t
>(
fParam.size()))) {
3705 fLastErrorMsg <<
">> PMsrHandler::HandleRunEntry: **SEVERE ERROR** map value " << param.
GetMap(i) <<
" in line " << iter->fLineNo <<
" is out of range!\n";
3715 if (line.BeginsWith(
"forward", TString::kIgnoreCase)) {
3717 runLinePresent =
false;
3719 if (tokens->GetEntries() < 2) {
3724 std::unique_ptr<PStringNumberList> rl = std::make_unique<PStringNumberList>(str.Data());
3725 std::string errorMsg(
"");
3726 if (rl->Parse(errorMsg,
true)) {
3727 group = rl->GetList();
3728 for (UInt_t i=0; i<group.size(); i++) {
3739 if (line.BeginsWith(
"backward", TString::kIgnoreCase)) {
3741 runLinePresent =
false;
3743 if (tokens->GetEntries() < 2) {
3748 std::unique_ptr<PStringNumberList> rl = std::make_unique<PStringNumberList>(str.Data());
3749 std::string errorMsg(
"");
3750 if (rl->Parse(errorMsg,
true)) {
3751 group = rl->GetList();
3752 for (UInt_t i=0; i<group.size(); i++) {
3763 if (line.BeginsWith(
"backgr.fix", TString::kIgnoreCase)) {
3765 runLinePresent =
false;
3767 if (tokens->GetEntries() < 2) {
3770 for (Int_t i=1; i<tokens->GetEntries(); i++) {
3771 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
3772 str = ostr->GetString();
3782 if (line.BeginsWith(
"background", TString::kIgnoreCase)) {
3784 runLinePresent =
false;
3786 if ((tokens->GetEntries() < 3) || (tokens->GetEntries() % 2 != 1)) {
3789 for (Int_t i=1; i<tokens->GetEntries(); i++) {
3790 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
3791 str = ostr->GetString();
3792 if (str.IsDigit()) {
3806 if (line.BeginsWith(
"data", TString::kIgnoreCase)) {
3808 runLinePresent =
false;
3810 if ((tokens->GetEntries() < 3) || (tokens->GetEntries() % 2 != 1)) {
3813 for (Int_t i=1; i<tokens->GetEntries(); i++) {
3814 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
3815 str = ostr->GetString();
3816 if (str.IsDigit()) {
3830 if (line.BeginsWith(
"t0", TString::kIgnoreCase)) {
3832 runLinePresent =
false;
3834 if (tokens->GetEntries() < 2) {
3837 for (Int_t i=1; i<tokens->GetEntries(); i++) {
3838 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
3839 str = ostr->GetString();
3840 if (str.IsFloat()) {
3854 if (line.BeginsWith(
"addt0", TString::kIgnoreCase)) {
3856 runLinePresent =
false;
3858 if (tokens->GetEntries() < 2) {
3861 for (Int_t i=1; i<tokens->GetEntries(); i++) {
3862 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
3863 str = ostr->GetString();
3864 if (str.IsFloat()) {
3880 if (line.BeginsWith(
"fit ", TString::kIgnoreCase)) {
3882 runLinePresent =
false;
3884 if (tokens->GetEntries() < 3) {
3887 if (iter->fLine.Contains(
"fgb", TString::kIgnoreCase)) {
3889 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3890 str = ostr->GetString();
3891 Ssiz_t idx = str.First(
"+");
3892 TString numStr = str;
3894 numStr.Remove(0,idx+1);
3895 if (numStr.IsFloat()) {
3904 ostr =
dynamic_cast<TObjString*
>(tokens->At(2));
3905 str = ostr->GetString();
3906 idx = str.First(
"-");
3909 numStr.Remove(0,idx+1);
3910 if (numStr.IsFloat()) {
3922 for (Int_t i=1; i<3; i++) {
3923 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
3924 str = ostr->GetString();
3935 if (line.BeginsWith(
"packing", TString::kIgnoreCase)) {
3937 runLinePresent =
false;
3939 if (tokens->GetEntries() != 2) {
3942 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3943 str = ostr->GetString();
3944 if (str.IsDigit()) {
3957 if (iter->fLine.BeginsWith(
"deadtime-cor", TString::kIgnoreCase)) {
3959 runLinePresent =
false;
3961 if (tokens->GetEntries() < 2) {
3964 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3965 str = ostr->GetString();
3966 if (!str.CompareTo(
"no", TString::kIgnoreCase) ||
3967 !str.CompareTo(
"file", TString::kIgnoreCase) ||
3968 !str.CompareTo(
"estimate", TString::kIgnoreCase)) {
3978 if (line.BeginsWith(
"xy-data", TString::kIgnoreCase)) {
3980 runLinePresent =
false;
3982 if (tokens->GetEntries() != 3) {
3985 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
3986 str = ostr->GetString();
3987 if (str.IsDigit()) {
3989 ostr =
dynamic_cast<TObjString*
>(tokens->At(2));
3990 str = ostr->GetString();
3991 if (str.IsDigit()) {
4002 ostr =
dynamic_cast<TObjString*
>(tokens->At(2));
4003 str = ostr->GetString();
4022 fLastErrorMsg <<
">> PMsrHandler::HandleRunEntry: **ERROR** in line " << iter->fLineNo <<
":\n";
4024 fLastErrorMsg <<
">> RUN block syntax is too complex to print it here. Please check the manual.\n";
4027 fRuns.push_back(param);
4054 Int_t found, no_found=-1;
4057 Char_t *cstr, filterStr[32];
4058 cstr =
new Char_t[str.Sizeof()];
4059 strncpy(cstr, str.Data(), str.Sizeof());
4060 snprintf(filterStr,
sizeof(filterStr),
"%s%%d", filter);
4063 found = sscanf(cstr, filterStr, &no_found);
4065 if (no_found < 1000)
4066 no = no_found + offset;
4074 if ((no_found < 0) || (no_found > 1000))
4097 PMsrLines::iterator iter;
4099 if (lines.empty()) {
4100 std::cerr << std::endl <<
">> PMsrHandler::HandleCommandsEntry(): **WARNING**: There is no COMMAND block! Do you really want this?";
4101 std::cerr << std::endl;
4104 for (iter = lines.begin(); iter != lines.end(); ++iter) {
4105 if (!iter->fLine.BeginsWith(
"COMMANDS"))
4131 for (UInt_t i=0; i<2; i++) {
4150 Ssiz_t idx = str.First(
'#');
4154 truncStr.Resize(idx-1);
4174 Bool_t result =
true;
4176 TObjArray *tok = str.Tokenize(
" ,;\t");
4177 if (tok ==
nullptr) {
4180 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseValueVector: **ERROR** couldn't tokenize Fourier phase line.\n\n";
4186 if (tok->GetEntries() < 2) {
4192 TObjString *ostr =
nullptr;
4194 for (Int_t i=1; i<tok->GetEntries(); i++) {
4195 ostr =
dynamic_cast<TObjString*
>(tok->At(i));
4196 sstr = ostr->GetString();
4197 if (sstr.IsFloat()) {
4198 fourier.
fPhase.push_back(sstr.Atof());
4204 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseValueVector: **ERROR** in Fourier phase line.\n";
4205 fLastErrorMsg <<
">> Attempt to mix val, parX? This is currently not supported.\n\n";
4239 Bool_t result =
true;
4242 TObjArray *tok = str.Tokenize(
" ,;\t");
4243 if (tok ==
nullptr) {
4246 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseParVector: **ERROR** couldn't tokenize Fourier phase line.\n\n";
4252 if (tok->GetEntries() < 2) {
4259 for (Int_t i=1; i<tok->GetEntries(); i++) {
4260 TObjString *ostr =
dynamic_cast<TObjString*
>(tok->At(i));
4261 sstr = ostr->GetString();
4262 if (!sstr.BeginsWith(
"par")) {
4265 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseParVector: **ERROR** found unhandable token '" << sstr <<
"'\n";
4272 if (sstr.BeginsWith(
"parR")) {
4277 if (sstr.BeginsWith(
"par(")) {
4286 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseParVector: **ERROR** found multiple parR's! Only one reference phase is accepted.\n";
4293 if (result !=
false) {
4294 for (Int_t i=1; i<tok->GetEntries(); i++) {
4295 TObjString *ostr =
dynamic_cast<TObjString*
>(tok->At(i));
4296 sstr = ostr->GetString();
4298 if (sstr.BeginsWith(
"parR")) {
4301 sstr.Remove(0, rmNoOf);
4302 if (sstr.IsDigit()) {
4309 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseParVector: **ERROR** found token '" << ostr->GetString() <<
"' which is not parX with X an integer.\n";
4352 wstr = wstr.Strip(TString::kLeading,
' ');
4355 if (!wstr.BeginsWith(
"par(") && !wstr.BeginsWith(
"parR(")) {
4358 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** token should start with 'par(' or 'parR(', found: '" << wstr <<
"' -> ERROR\n";
4364 Bool_t relativePhase =
false;
4365 if (wstr.BeginsWith(
"parR(")) {
4367 relativePhase =
true;
4369 wstr.Remove(0, noOf);
4372 wstr = wstr.Strip(TString::kTrailing,
' ');
4375 Ssiz_t idx=wstr.Last(
')');
4376 wstr.Remove(idx, wstr.Length()-idx);
4379 TObjArray *tok = wstr.Tokenize(
",;");
4380 if (tok ==
nullptr) {
4383 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** tokenize failed.\n";
4390 if (tok->GetEntries() != 3) {
4393 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** wrong syntax for the expected par(X0, offset, #param).\n";
4400 Int_t x0, offset, noParam;
4403 TObjString *ostr =
dynamic_cast<TObjString*
>(tok->At(0));
4404 wstr = ostr->GetString();
4405 if (wstr.IsDigit()) {
4410 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** X0='" << wstr <<
"' is not an integer.\n";
4418 ostr =
dynamic_cast<TObjString*
>(tok->At(1));
4419 wstr = ostr->GetString();
4420 if (wstr.IsDigit()) {
4421 offset = wstr.Atoi();
4425 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** offset='" << wstr <<
"' is not an integer.\n";
4433 ostr =
dynamic_cast<TObjString*
>(tok->At(2));
4434 wstr = ostr->GetString();
4435 if (wstr.IsDigit()) {
4436 noParam = wstr.Atoi();
4440 fLastErrorMsg <<
">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** #Param='" << wstr <<
"' is not an integer.\n";
4453 for (Int_t i=0; i<noParam; i++)
4478 Bool_t error =
false;
4489 PMsrLines::iterator iter;
4491 TObjArray *tokens =
nullptr;
4492 TObjString *ostr =
nullptr;
4493 TString str, pcStr=TString(
"");
4497 iter = lines.begin();
4498 while ((iter != lines.end()) && !error) {
4500 tokens = iter->fLine.Tokenize(
" \t");
4504 fLastErrorMsg <<
">> PMsrHandler::HandleFourierEntry: **SEVERE ERROR** Couldn't tokenize Parameters in line " << iter->fLineNo <<
"\n\n";
4509 if (iter->fLine.BeginsWith(
"units", TString::kIgnoreCase)) {
4510 if (tokens->GetEntries() < 2) {
4514 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
4515 str = ostr->GetString();
4516 if (!str.CompareTo(
"gauss", TString::kIgnoreCase)) {
4518 }
else if (!str.CompareTo(
"tesla", TString::kIgnoreCase)) {
4520 }
else if (!str.CompareTo(
"mhz", TString::kIgnoreCase)) {
4522 }
else if (!str.CompareTo(
"mc/s", TString::kIgnoreCase)) {
4529 }
else if (iter->fLine.BeginsWith(
"fourier_power", TString::kIgnoreCase)) {
4530 if (tokens->GetEntries() < 2) {
4534 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
4535 str = ostr->GetString();
4536 if (str.IsDigit()) {
4538 if ((ival >= 0) && (ival <= 20)) {
4549 }
else if (iter->fLine.BeginsWith(
"dc-corrected", TString::kIgnoreCase)) {
4550 if (tokens->GetEntries() < 2) {
4554 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
4555 str = ostr->GetString();
4556 if (!str.CompareTo(
"true", TString::kIgnoreCase) || !str.CompareTo(
"1")) {
4558 }
else if (!str.CompareTo(
"false", TString::kIgnoreCase) || !str.CompareTo(
"0")) {
4565 }
else if (iter->fLine.BeginsWith(
"apodization", TString::kIgnoreCase)) {
4566 if (tokens->GetEntries() < 2) {
4570 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
4571 str = ostr->GetString();
4572 if (!str.CompareTo(
"none", TString::kIgnoreCase)) {
4574 }
else if (!str.CompareTo(
"weak", TString::kIgnoreCase)) {
4576 }
else if (!str.CompareTo(
"medium", TString::kIgnoreCase)) {
4578 }
else if (!str.CompareTo(
"strong", TString::kIgnoreCase)) {
4585 }
else if (iter->fLine.BeginsWith(
"plot", TString::kIgnoreCase)) {
4586 if (tokens->GetEntries() < 2) {
4590 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
4591 str = ostr->GetString();
4592 if (!str.CompareTo(
"real", TString::kIgnoreCase)) {
4594 }
else if (!str.CompareTo(
"imag", TString::kIgnoreCase)) {
4596 }
else if (!str.CompareTo(
"real_and_imag", TString::kIgnoreCase)) {
4598 }
else if (!str.CompareTo(
"power", TString::kIgnoreCase)) {
4600 }
else if (!str.CompareTo(
"phase", TString::kIgnoreCase)) {
4602 }
else if (!str.CompareTo(
"phase_opt_real", TString::kIgnoreCase)) {
4609 }
else if (iter->fLine.BeginsWith(
"phase", TString::kIgnoreCase)) {
4610 if (tokens->GetEntries() < 2) {
4640 if (!result || error) {
4650 fLastErrorMsg <<
">> PMsrHandler::HandleFourierEntry: found Fourier parameter entry par" << fourier.
fPhaseParamNo[i] <<
" > #Param = " <<
fParam.size() <<
"\n";
4660 Double_t phaseRef = 0.0;
4675 }
else if (iter->fLine.BeginsWith(
"range_for_phase_correction", TString::kIgnoreCase)) {
4679 pcStr = iter->fLine;
4680 }
else if (iter->fLine.BeginsWith(
"range", TString::kIgnoreCase)) {
4681 if (tokens->GetEntries() < 3) {
4685 for (UInt_t i=0; i<2; i++) {
4686 ostr =
dynamic_cast<TObjString*
>(tokens->At(i+1));
4687 str = ostr->GetString();
4688 if (str.IsFloat()) {
4696 }
else if (!iter->fLine.BeginsWith(
"fourier", TString::kIgnoreCase) && !iter->fLine.BeginsWith(
"#") &&
4697 !iter->fLine.IsWhitespace() && (iter->fLine.Length() != 0)) {
4718 if ((pcStr.Length() != 0) && !error) {
4720 tokens = pcStr.Tokenize(
" \t");
4722 switch (tokens->GetEntries()) {
4724 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
4725 str = ostr->GetString();
4726 if (!str.CompareTo(
"all", TString::kIgnoreCase)) {
4734 for (UInt_t i=0; i<2; i++) {
4735 ostr =
dynamic_cast<TObjString*
>(tokens->At(i+1));
4736 str = ostr->GetString();
4737 if (str.IsFloat()) {
4759 fLastErrorMsg <<
">> PMsrHandler::HandleFourierEntry: **ERROR** in line " << iter->fLineNo <<
":\n\n";
4761 fLastErrorMsg <<
">> FOURIER block syntax, parameters in [] are optinal:\n\n";
4764 fLastErrorMsg <<
">> [fourier_power n # n is a number such that zero padding up to 2^n will be used]\n";
4768 fLastErrorMsg <<
">> [apodization none | weak | medium | strong]\n";
4769 fLastErrorMsg <<
">> [plot real | imag | real_and_imag | power | phase | phase_opt_real]\n";
4770 fLastErrorMsg <<
">> [phase valList | parList | parIterList [# comment]]\n";
4771 fLastErrorMsg <<
">> valList : val [sep val ... sep val]. sep=' ,;\\t'\n";
4772 fLastErrorMsg <<
">> parList : parX0 [sep parX1 ... sep parXn], Xi is the parameter number\n";
4773 fLastErrorMsg <<
">> parList : parRX0 sep parX1 ... sep parXn, parRX0 is the reference phase, e.g. parR3\n";
4774 fLastErrorMsg <<
">> parIterList : par(X0,offset,#param), with X0=first parameter number\n";
4775 fLastErrorMsg <<
">> offset=parameter offset, #param=number of phase parameters.\n";
4776 fLastErrorMsg <<
">> [range_for_phase_correction min max | all]\n";
4800 Bool_t error =
false;
4804 PMsrLines::iterator iter1;
4805 PMsrLines::iterator iter2;
4806 TObjArray *tokens =
nullptr;
4807 TObjString *ostr =
nullptr;
4810 if (lines.empty()) {
4811 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry(): **WARNING**: There is no PLOT block! Do you really want this?";
4812 std::cerr << std::endl;
4815 iter1 = lines.begin();
4816 while ((iter1 != lines.end()) && !error) {
4822 param.
fLogX =
false;
4823 param.
fLogY =
false;
4825 param.
fRuns.clear();
4826 param.
fTmin.clear();
4827 param.
fTmax.clear();
4828 param.
fYmin.clear();
4829 param.
fYmax.clear();
4839 for ( ; iter2 != lines.end(); ++iter2) {
4840 if (iter2->fLine.Contains(
"PLOT"))
4845 while ((iter1 != iter2) && !error) {
4846 TString line = iter1->fLine;
4847 if (line.First(
'#') != -1)
4848 line.Resize(line.First(
'#'));
4850 if (line.Contains(
"PLOT")) {
4851 tokens = line.Tokenize(
" \t");
4855 fLastErrorMsg <<
">> PMsrHandler::HandlePlotEntry: **SEVERE ERROR** Couldn't tokenize PLOT in line " << iter1->fLineNo <<
"\n\n";
4859 if (tokens->GetEntries() < 2) {
4862 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
4863 str = ostr->GetString();
4874 }
else if (line.Contains(
"lifetimecorrection", TString::kIgnoreCase)) {
4876 }
else if (line.Contains(
"runs", TString::kIgnoreCase)) {
4878 std::unique_ptr<PStringNumberList> rl;
4879 std::string errorMsg;
4892 rl = std::make_unique<PStringNumberList>(line.Data());
4893 if (!rl->Parse(errorMsg,
true)) {
4896 fLastErrorMsg <<
">> PMsrHandler::HandlePlotEntry: **SEVERE ERROR** Couldn't tokenize PLOT in line " << iter1->fLineNo <<
"\n";
4901 runList = rl->GetList();
4902 for (UInt_t i=0; i<runList.size(); i++) {
4903 run = TComplex(runList[i], -1.0);
4904 param.
fRuns.push_back(run);
4913 }
else if (line.Contains(
"range ", TString::kIgnoreCase)) {
4915 param.
fTmin.clear();
4916 param.
fTmax.clear();
4917 param.
fYmin.clear();
4918 param.
fYmax.clear();
4920 tokens = line.Tokenize(
" \t");
4922 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry: **SEVERE ERROR** Couldn't tokenize PLOT in line " << iter1->fLineNo;
4923 std::cerr << std::endl << std::endl;
4926 if ((tokens->GetEntries() != 3) && (tokens->GetEntries() != 5)) {
4931 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
4932 str = ostr->GetString();
4934 param.
fTmin.push_back(
static_cast<Double_t
>(str.Atof()));
4939 ostr =
dynamic_cast<TObjString*
>(tokens->At(2));
4940 str = ostr->GetString();
4942 param.
fTmax.push_back(
static_cast<Double_t
>(str.Atof()));
4946 if (tokens->GetEntries() == 5) {
4949 ostr =
dynamic_cast<TObjString*
>(tokens->At(3));
4950 str = ostr->GetString();
4952 param.
fYmin.push_back(
static_cast<Double_t
>(str.Atof()));
4957 ostr =
dynamic_cast<TObjString*
>(tokens->At(4));
4958 str = ostr->GetString();
4960 param.
fYmax.push_back(
static_cast<Double_t
>(str.Atof()));
4970 }
else if (line.Contains(
"sub_ranges", TString::kIgnoreCase)) {
4972 param.
fTmin.clear();
4973 param.
fTmax.clear();
4974 param.
fYmin.clear();
4975 param.
fYmax.clear();
4977 tokens = line.Tokenize(
" \t");
4979 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry: **SEVERE ERROR** Couldn't tokenize PLOT in line " << iter1->fLineNo;
4980 std::cerr << std::endl << std::endl;
4983 if ((tokens->GetEntries() !=
static_cast<Int_t
>(2*param.
fRuns.size() + 1)) && (tokens->GetEntries() !=
static_cast<Int_t
>(2*param.
fRuns.size() + 3))) {
4987 for (UInt_t i=0; i<param.
fRuns.size(); i++) {
4990 ostr =
dynamic_cast<TObjString*
>(tokens->At(2*i+1));
4991 str = ostr->GetString();
4993 param.
fTmin.push_back(
static_cast<Double_t
>(str.Atof()));
4998 ostr =
dynamic_cast<TObjString*
>(tokens->At(2*i+2));
4999 str = ostr->GetString();
5001 param.
fTmax.push_back(
static_cast<Double_t
>(str.Atof()));
5007 if (tokens->GetEntries() ==
static_cast<Int_t
>(2*param.
fRuns.size() + 3)) {
5010 ostr =
dynamic_cast<TObjString*
>(tokens->At(2*param.
fRuns.size()+1));
5011 str = ostr->GetString();
5013 param.
fYmin.push_back(
static_cast<Double_t
>(str.Atof()));
5018 ostr =
dynamic_cast<TObjString*
>(tokens->At(2*param.
fRuns.size()+2));
5019 str = ostr->GetString();
5021 param.
fYmax.push_back(
static_cast<Double_t
>(str.Atof()));
5032 }
else if (line.Contains(
"use_fit_ranges", TString::kIgnoreCase)) {
5036 tokens = line.Tokenize(
" \t");
5038 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry: **SEVERE ERROR** Couldn't tokenize PLOT in line " << iter1->fLineNo;
5039 std::cerr << std::endl << std::endl;
5043 if (tokens->GetEntries() == 3) {
5045 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
5046 str = ostr->GetString();
5048 param.
fYmin.push_back(
static_cast<Double_t
>(str.Atof()));
5053 ostr =
dynamic_cast<TObjString*
>(tokens->At(2));
5054 str = ostr->GetString();
5056 param.
fYmax.push_back(
static_cast<Double_t
>(str.Atof()));
5061 if ((tokens->GetEntries() != 1) && (tokens->GetEntries() != 3)) {
5062 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry: **WARNING** use_fit_ranges with undefined additional parameters in line " << iter1->fLineNo;
5063 std::cerr << std::endl <<
">> Will ignore this PLOT block command line, sorry.";
5064 std::cerr << std::endl <<
">> Proper syntax: use_fit_ranges [ymin ymax]";
5065 std::cerr << std::endl <<
">> Found: '" << iter1->fLine.Data() <<
"'" << std::endl;
5073 }
else if (iter1->fLine.Contains(
"logx", TString::kIgnoreCase)) {
5075 }
else if (iter1->fLine.Contains(
"logy", TString::kIgnoreCase)) {
5077 }
else if (iter1->fLine.Contains(
"lifetimecorrection", TString::kIgnoreCase)) {
5079 }
else if (iter1->fLine.Contains(
"view_packing", TString::kIgnoreCase)) {
5080 tokens = iter1->fLine.Tokenize(
" \t");
5082 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry: **SEVERE ERROR** Couldn't tokenize view_packing in line " << iter1->fLineNo;
5083 std::cerr << std::endl << std::endl;
5086 if (tokens->GetEntries() != 2) {
5089 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
5090 str = ostr->GetString();
5091 if (str.IsDigit()) {
5092 Int_t val = str.Atoi();
5107 }
else if (iter1->fLine.Contains(
"rrf_freq", TString::kIgnoreCase)) {
5110 tokens = iter1->fLine.Tokenize(
" \t");
5112 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry: **SEVERE ERROR** Couldn't tokenize rrf_freq in line " << iter1->fLineNo;
5113 std::cerr << std::endl << std::endl;
5116 if (tokens->GetEntries() != 3) {
5120 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
5121 str = ostr->GetString();
5122 if (str.IsFloat()) {
5128 ostr =
dynamic_cast<TObjString*
>(tokens->At(2));
5129 str = ostr->GetString();
5130 if (str.Contains(
"kHz", TString::kIgnoreCase))
5132 else if (str.Contains(
"MHz", TString::kIgnoreCase))
5134 else if (str.Contains(
"Mc/s", TString::kIgnoreCase))
5136 else if (str.Contains(
"G", TString::kIgnoreCase))
5138 else if (str.Contains(
"T", TString::kIgnoreCase))
5148 }
else if (iter1->fLine.Contains(
"rrf_phase", TString::kIgnoreCase)) {
5151 tokens = iter1->fLine.Tokenize(
" \t");
5153 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry: **SEVERE ERROR** Couldn't tokenize rrf_phase in line " << iter1->fLineNo;
5154 std::cerr << std::endl << std::endl;
5157 if (tokens->GetEntries() != 2) {
5161 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
5162 str = ostr->GetString();
5163 if (str.IsFloat()) {
5166 if (str.BeginsWith(
"par", TString::kIgnoreCase)) {
5170 if (
static_cast<Int_t
>(
fParam.size()) < no) {
5189 }
else if (iter1->fLine.Contains(
"rrf_packing", TString::kIgnoreCase)) {
5191 tokens = iter1->fLine.Tokenize(
" \t");
5193 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry: **SEVERE ERROR** Couldn't tokenize rrf_packing in line " << iter1->fLineNo;
5194 std::cerr << std::endl << std::endl;
5197 if (tokens->GetEntries() != 2) {
5201 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
5202 str = ostr->GetString();
5203 if (str.IsDigit()) {
5225 if (param.
fRuns.empty()) {
5228 if ((param.
fTmin.size() > 0) || (param.
fTmax.size() > 0)) {
5229 for (UInt_t i=0; i<param.
fTmin.size(); i++) {
5231 keep = param.
fTmin[i];
5233 param.
fTmax[i] = keep;
5238 if ((param.
fYmin.size() > 0) || (param.
fYmax.size() > 0)) {
5239 for (UInt_t i=0; i<param.
fYmin.size(); i++) {
5241 keep = param.
fYmin[i];
5243 param.
fYmax[i] = keep;
5251 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry(): **ERROR** found RRF frequency but no required RRF packing.";
5252 std::cerr << std::endl <<
">> Will ignore the RRF option.";
5253 std::cerr << std::endl;
5259 for (UInt_t i=0; i<param.
fRuns.size(); i++) {
5260 if (param.
fRuns[i] >
static_cast<Int_t
>(
fRuns.size())) {
5261 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry(): **WARNING** found plot run number " << param.
fRuns[i] <<
".";
5262 std::cerr << std::endl <<
">> There are only " <<
fRuns.size() <<
" runs present, will ignore this run.";
5263 std::cerr << std::endl;
5267 if (param.
fRuns[i] == 0) {
5268 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry(): **WARNING** found plot run number 0.";
5269 std::cerr << std::endl <<
">> Pot number needs to be > 0. Will ignore this entry.";
5270 std::cerr << std::endl;
5276 if (param.
fRuns.size() > 0) {
5279 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry: **ERROR** no valid PLOT block entries, will ignore the entire PLOT block.";
5280 std::cerr << std::endl;
5285 if (
fPlots.size() == 0) {
5287 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry: **ERROR** no valid PLOT block at all present. Fix this first!";
5288 std::cerr << std::endl;
5293 std::cerr << std::endl <<
">> PMsrHandler::HandlePlotEntry: **ERROR** in line " << iter1->fLineNo <<
": " << iter1->fLine.Data();
5294 std::cerr << std::endl <<
">> A PLOT block needs to have the following structure:";
5295 std::cerr << std::endl;
5296 std::cerr << std::endl <<
">> PLOT <plot_type>";
5297 std::cerr << std::endl <<
">> runs <run_list>";
5298 std::cerr << std::endl <<
">> [range tmin tmax [ymin ymax]]";
5299 std::cerr << std::endl <<
">> [sub_ranges tmin1 tmax1 tmin2 tmax2 ... tminN tmaxN [ymin ymax]";
5300 std::cerr << std::endl <<
">> [logx | logy]";
5301 std::cerr << std::endl <<
">> [use_fit_ranges [ymin ymax]]";
5302 std::cerr << std::endl <<
">> [view_packing n]";
5303 std::cerr << std::endl;
5304 std::cerr << std::endl <<
">> where <plot_type> is: 0=single histo,";
5305 std::cerr << std::endl <<
">> 1=RRF single histo,";
5306 std::cerr << std::endl <<
">> 2=forward-backward asym,";
5307 std::cerr << std::endl <<
">> 3=forward-backward RRF asym,";
5308 std::cerr << std::endl <<
">> 4=mu minus single histo,";
5309 std::cerr << std::endl <<
">> 5=forward-backward beta-NMR asym,";
5310 std::cerr << std::endl <<
">> 8=non muSR.";
5311 std::cerr << std::endl <<
">> <run_list> is the list of runs, e.g. runs 1 3";
5312 std::cerr << std::endl <<
">> range is optional";
5313 std::cerr << std::endl <<
">> sub_ranges (if present) will plot the N given runs each on its own sub-range";
5314 std::cerr << std::endl <<
">> logx, logy (if present) will present the x-, y-axis in log-scale";
5315 std::cerr << std::endl <<
">> use_fit_ranges (if present) will plot each run on its fit-range";
5316 std::cerr << std::endl <<
">> view_packing n (if present) will bin all data by n (> 0) rather than the binning of the fit";
5317 std::cerr << std::endl;
5320 param.
fRuns.clear();
5345 if (lines.empty()) {
5346 std::cerr << std::endl <<
">> PMsrHandler::HandleStatisticEntry: **WARNING** There is no STATISTIC block! Do you really want this?";
5347 std::cerr << std::endl;
5359 for (UInt_t i=0; i<lines.size(); i++) {
5361 tstr = lines[i].fLine;
5362 tstr.Remove(TString::kLeading,
' ');
5363 if (tstr.Length() > 0) {
5364 if (!tstr.BeginsWith(
"#") && !tstr.BeginsWith(
"STATISTIC") && !tstr.BeginsWith(
"chisq") &&
5365 !tstr.BeginsWith(
"maxLH") && !tstr.BeginsWith(
"*** FIT DID NOT CONVERGE ***") &&
5366 !tstr.BeginsWith(
"expected chisq") && !tstr.BeginsWith(
"expected maxLH") &&
5367 !tstr.BeginsWith(
"run block")) {
5368 std::cerr << std::endl <<
">> PMsrHandler::HandleStatisticEntry: **SYNTAX ERROR** in line " << lines[i].fLineNo;
5369 std::cerr << std::endl <<
">> '" << lines[i].fLine.Data() <<
"'";
5370 std::cerr << std::endl <<
">> not a valid STATISTIC block line";
5371 std::cerr << std::endl <<
">> If you do not understand this, just remove the STATISTIC block, musrfit will recreate after fitting";
5372 std::cerr << std::endl << std::endl;
5379 if (lines[i].fLine.Contains(
"STATISTIC")) {
5380 status = sscanf(lines[i].fLine.Data(),
"STATISTIC --- %s%s", date, time);
5382 fStatistic.fDate = TString(date)+TString(
", ")+TString(time);
5384 fStatistic.fDate = TString(
"????-??-??, ??:??:??");
5388 if (lines[i].fLine.Contains(
"chisq =")) {
5389 if (lines[i].fLine.Contains(
"expected")) {
5390 strncpy(str, lines[i].fLine.Data(),
sizeof(str));
5391 status = sscanf(str+lines[i].fLine.Index(
"chisq = ")+8,
"%lf", &dval);
5399 strncpy(str, lines[i].fLine.Data(),
sizeof(str));
5400 status = sscanf(str+lines[i].fLine.Index(
"chisq = ")+8,
"%lf", &dval);
5409 if (lines[i].fLine.Contains(
"maxLH =")) {
5411 strncpy(str, lines[i].fLine.Data(),
sizeof(str));
5412 status = sscanf(str+lines[i].fLine.Index(
"maxLH = ")+8,
"%lf", &dval);
5420 if (lines[i].fLine.Contains(
", NDF =")) {
5421 strncpy(str, lines[i].fLine.Data(),
sizeof(str));
5422 status = sscanf(str+lines[i].fLine.Index(
", NDF = ")+8,
"%u", &ival);
5447 UInt_t noOfFitParameters = 0;
5451 TObjArray *tokens =
nullptr;
5452 TObjString *ostr =
nullptr;
5458 if (idx >=
fRuns.size()) {
5459 std::cerr << std::endl <<
">> PMsrHandler::GetNoOfFitParameters() **ERROR** idx=" << idx <<
", out of range fRuns.size()=" <<
fRuns.size();
5460 std::cerr << std::endl;
5465 if (
fRuns[idx].GetNormParamNo() != -1) {
5467 paramVector.push_back(
fRuns[idx].GetNormParamNo());
5473 if (
fRuns[idx].GetBkgFitParamNo() != -1)
5474 paramVector.push_back(
fRuns[idx].GetBkgFitParamNo());
5477 if (
fRuns[idx].GetAlphaParamNo() != -1) {
5479 paramVector.push_back(
fRuns[idx].GetAlphaParamNo());
5485 if (
fRuns[idx].GetBetaParamNo() != -1) {
5487 paramVector.push_back(
fRuns[idx].GetBetaParamNo());
5494 for (UInt_t i=0; i<
fTheory.size(); i++) {
5497 pos = str.Index(
'#');
5501 tokens = str.Tokenize(
" \t");
5505 paramVector.clear();
5509 for (Int_t j=0; j<tokens->GetEntries(); j++) {
5510 ostr =
dynamic_cast<TObjString*
>(tokens->At(j));
5511 str = ostr->GetString();
5513 if (str.IsDigit()) {
5515 paramVector.push_back(dval);
5519 if (str.Contains(
"map")) {
5520 status = sscanf(str.Data(),
"map%d", &dval);
5522 mapVector.push_back(dval);
5527 if (str.Contains(
"fun")) {
5528 status = sscanf(str.Data(),
"fun%d", &dval);
5530 funVector.push_back(dval);
5540 for (UInt_t i=0; i<funVector.size(); i++) {
5545 if (dval == funVector[i])
5552 std::cerr << std::endl <<
">> PMsrHandler::GetNoOfFitParameters() **ERROR** couldn't find fun" << funVector[i];
5553 std::cerr << std::endl << std::endl;
5558 paramVector.clear();
5565 pos = str.Index(
'#');
5570 tokens = str.Tokenize(
" \t");
5574 paramVector.clear();
5579 for (Int_t j=0; j<tokens->GetEntries(); j++) {
5580 ostr =
dynamic_cast<TObjString*
>(tokens->At(j));
5581 str = ostr->GetString();
5584 if (str.BeginsWith(
"par")) {
5585 status = sscanf(str.Data(),
"par%d", &dval);
5587 paramVector.push_back(dval);
5591 if (str.BeginsWith(
"map")) {
5592 status = sscanf(str.Data(),
"map%d", &dval);
5594 mapVector.push_back(dval);
5600 for (UInt_t i=0; i<mapVector.size(); i++) {
5601 paramVector.push_back(
fRuns[idx].GetMap(mapVector[i]-1));
5606 param.push_back(paramVector[0]);
5607 for (UInt_t i=0; i<paramVector.size(); i++) {
5608 for (k=0; k<param.size(); k++) {
5609 if (param[k] == paramVector[i])
5612 if (k == param.size())
5613 param.push_back(paramVector[i]);
5617 for (UInt_t i=0; i<param.size(); i++) {
5618 if (
fParam[param[i]-1].fStep != 0.0)
5619 noOfFitParameters++;
5626 paramVector.clear();
5628 return noOfFitParameters;
5646 PMsrLines::iterator iter;
5647 TObjArray *tokens =
nullptr;
5648 TObjString *ostr =
nullptr;
5653 for (UInt_t i=0; i<
fParam.size(); i++)
5657 for (iter = theory.begin(); iter != theory.end(); ++iter) {
5660 if (str.First(
'#') != -1)
5661 str.Resize(str.First(
'#'));
5667 tokens = str.Tokenize(
" \t");
5672 for (Int_t i=0; i<tokens->GetEntries(); i++) {
5673 ostr =
dynamic_cast<TObjString*
>(tokens->At(i));
5674 str = ostr->GetString();
5675 if (str.IsDigit()) {
5677 if ((ival > 0) && (ival <
static_cast<Int_t
>(
fParam.size())+1)) {
5680 }
else if (str.Contains(
"map")) {
5683 }
else if (str.Contains(
"fun")) {
5697 for (iter = funcs.begin(); iter != funcs.end(); ++iter) {
5700 if (str.First(
'#') != -1)
5701 str.Resize(str.First(
'#'));
5706 tokens = str.Tokenize(
" /t");
5711 ostr =
dynamic_cast<TObjString*
>(tokens->At(0));
5712 str = ostr->GetString();
5719 for (UInt_t i=0; i<fun.size(); i++) {
5720 if (fun[i] == funNo) {
5724 while (sstr.Index(
"par") != -1) {
5725 memset(sval, 0,
sizeof(sval));
5726 sstr = &sstr[sstr.Index(
"par")+3];
5727 for (Int_t j=0; j<sstr.Sizeof(); j++) {
5728 if (!isdigit(sstr[j]))
5732 sscanf(sval,
"%d", &ival);
5738 while (sstr.Index(
"map") != -1) {
5739 memset(sval, 0,
sizeof(sval));
5740 sstr = &sstr[sstr.Index(
"map")+3];
5741 for (Int_t j=0; j<sstr.Sizeof(); j++) {
5742 if (!isdigit(sstr[j]))
5746 sscanf(sval,
"%d", &ival);
5750 for (pos=0; pos<map.size(); pos++) {
5751 if (ival == map[pos])
5754 if (pos == map.size()) {
5755 map.push_back(ival);
5771 for (iter = run.begin(); iter != run.end(); ++iter) {
5774 if (str.First(
'#') != -1)
5775 str.Resize(str.First(
'#'));
5781 if (str.Contains(
"alpha") || str.Contains(
"beta") ||
5782 str.Contains(
"alpha2") || str.Contains(
"beta2") ||
5783 str.Contains(
"norm") || str.Contains(
"backgr.fit") ||
5784 str.Contains(
"lifetime ")) {
5786 tokens = str.Tokenize(
" \t");
5789 if (tokens->GetEntries()<2)
5792 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
5793 str = ostr->GetString();
5795 if (str.IsDigit()) {
5800 if (str.Contains(
"fun")) {
5814 if (str.Contains(
"map")) {
5816 tokens = str.Tokenize(
" \t");
5821 for (UInt_t i=0; i<map.size(); i++) {
5824 if (map[i] < tokens->GetEntries()) {
5825 ostr =
dynamic_cast<TObjString*
>(tokens->At(map[i]));
5826 str = ostr->GetString();
5827 if (str.IsDigit()) {
5845 for (iter = funcs.begin(); iter != funcs.end(); ++iter) {
5848 if (str.First(
'#') != -1)
5849 str.Resize(str.First(
'#'));
5854 tokens = str.Tokenize(
" /t");
5859 ostr =
dynamic_cast<TObjString*
>(tokens->At(0));
5860 str = ostr->GetString();
5867 for (UInt_t i=0; i<fun.size(); i++) {
5868 if (fun[i] == funNo) {
5872 while (sstr.Index(
"par") != -1) {
5873 memset(sval, 0,
sizeof(sval));
5874 sstr = &sstr[sstr.Index(
"par")+3];
5875 for (Int_t j=0; j<sstr.Sizeof(); j++) {
5876 if (!isdigit(sstr[j]))
5880 sscanf(sval,
"%d", &ival);
5886 while (sstr.Index(
"map") != -1) {
5887 memset(sval, 0,
sizeof(sval));
5888 sstr = &sstr[sstr.Index(
"map")+3];
5889 for (Int_t j=0; j<sstr.Sizeof(); j++) {
5890 if (!isdigit(sstr[j]))
5894 sscanf(sval,
"%d", &ival);
5898 for (pos=0; pos<map.size(); pos++) {
5899 if (ival == map[pos])
5902 if (
static_cast<UInt_t
>(pos) == map.size()) {
5903 map.push_back(ival);
5918 for (iter = run.begin(); iter != run.end(); ++iter) {
5921 if (str.First(
'#') != -1)
5922 str.Resize(str.First(
'#'));
5928 if (str.Contains(
"map")) {
5930 tokens = str.Tokenize(
" \t");
5935 for (UInt_t i=0; i<map.size(); i++) {
5938 if (map[i] < tokens->GetEntries()) {
5939 ostr =
dynamic_cast<TObjString*
>(tokens->At(map[i]));
5940 str = ostr->GetString();
5941 if (str.IsDigit()) {
5959 for (UInt_t i=0; i<
fParam.size(); i++) {
5961 if (
fParam[i].fStep != 0.0) {
5962 std::cerr << std::endl <<
">> **WARNING** : Parameter No " << i+1 <<
" is not used at all, will fix it" << std::endl;
5989 for (UInt_t i=0; i<
fRuns.size(); i++) {
5991 fitType =
fRuns[i].GetFitType();
5992 if (fitType == -1) {
5993 fitType =
fGlobal.GetFitType();
5994 if (fitType == -1) {
5995 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** fittype is neither defined in RUN block number " << i+1 <<
", nor in the GLOBAL block." << std::endl;
6001 Int_t detectorGroups = 1;
6006 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6007 std::cerr << std::endl <<
">> Norm parameter number not defined. Necessary for single histogram fits." << std::endl;
6014 if (
fRuns[i].GetNormParamNo() >
static_cast<Int_t
>(
fParam.size())) {
6015 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6016 std::cerr << std::endl <<
">> Norm parameter number " <<
fRuns[i].GetNormParamNo() <<
" is larger than the number of fit parameters (" <<
fParam.size() <<
").";
6017 std::cerr << std::endl <<
">> Consider to check the manual ;-)" << std::endl;
6022 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6023 std::cerr << std::endl <<
">> Norm parameter function number " <<
fRuns[i].GetNormParamNo()-
MSR_PARAM_FUN_OFFSET <<
" is larger than the number of functions (" <<
GetNoOfFuncs() <<
").";
6024 std::cerr << std::endl <<
">> Consider to check the manual ;-)" << std::endl;
6030 if (
fRuns[i].GetForwardHistoNo() == -1) {
6031 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6032 std::cerr << std::endl <<
">> forward parameter number not defined. Necessary for single histogram fits." << std::endl;
6038 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6039 std::cerr << std::endl <<
">> forward histogram number " <<
fRuns[i].GetNormParamNo() <<
" is larger than the number of fit parameters (" <<
fParam.size() <<
").";
6040 std::cerr << std::endl <<
">> Consider to check the manual ;-)" << std::endl;
6047 if (!
fGlobal.IsFitRangeInBin()) {
6049 std::cerr << std::endl <<
"PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6050 std::cerr << std::endl <<
" Fit range is not defined. Necessary for single histogram fits." << std::endl;
6057 detectorGroups =
fRuns[i].GetForwardHistoNoSize();
6058 if ((
fRuns[i].GetT0BinSize() > detectorGroups) || (
fGlobal.GetT0BinSize() > detectorGroups)) {
6059 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6060 if (
fRuns[i].GetT0BinSize() > detectorGroups)
6061 std::cerr << std::endl <<
">> In RUN Block " << i+1 <<
": found " <<
fRuns[i].GetT0BinSize() <<
" T0 entries. Expecting max. " << detectorGroups <<
" entries.";
6062 if (
fGlobal.GetT0BinSize() > 1)
6063 std::cerr << std::endl <<
">> In GLOBAL block: found " <<
fGlobal.GetT0BinSize() <<
" T0 entries. Expecting max. " << detectorGroups <<
" entries. Needs to be fixed.";
6064 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;
6069 if ((
fRuns[i].GetPacking() == -1) && (
fGlobal.GetPacking() == -1)) {
6070 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **WARNING** in RUN block number " << i+1;
6071 std::cerr << std::endl <<
">> Packing is neither defined here, nor in the GLOBAL block, will set it to 1." << std::endl;
6072 fRuns[i].SetPacking(1);
6077 if (
fRuns[i].GetForwardHistoNo() == -1) {
6078 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6079 std::cerr << std::endl <<
">> forward parameter number not defined. Necessary for single histogram RRF fits." << std::endl;
6085 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6086 std::cerr << std::endl <<
">> forward histogram number " <<
fRuns[i].GetNormParamNo() <<
" is larger than the number of fit parameters (" <<
fParam.size() <<
").";
6087 std::cerr << std::endl <<
">> Consider to check the manual ;-)" << std::endl;
6094 if (!
fGlobal.IsFitRangeInBin()) {
6096 std::cerr << std::endl <<
"PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6097 std::cerr << std::endl <<
" Fit range is not defined. Necessary for single histogram fits." << std::endl;
6104 detectorGroups =
fRuns[i].GetForwardHistoNoSize();
6105 if ((
fRuns[i].GetT0BinSize() > detectorGroups) || (
fGlobal.GetT0BinSize() > detectorGroups)) {
6106 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6107 if (
fRuns[i].GetT0BinSize() > detectorGroups)
6108 std::cerr << std::endl <<
">> In RUN Block " << i+1 <<
": found " <<
fRuns[i].GetT0BinSize() <<
" T0 entries. Expecting max. " << detectorGroups <<
" entries.";
6109 if (
fGlobal.GetT0BinSize() > 1)
6110 std::cerr << std::endl <<
">> In GLOBAL block: found " <<
fGlobal.GetT0BinSize() <<
" T0 entries. Expecting max. " << detectorGroups <<
" entries. Needs to be fixed.";
6111 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;
6116 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** no RRF frequency found in the GLOBAL block." << std::endl;
6120 if (
fGlobal.GetRRFPacking() == -1) {
6121 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** no RRF packing found in the GLOBAL block." << std::endl;
6128 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6129 std::cerr << std::endl <<
">> alpha parameter number missing which is needed for an asymmetry fit.";
6130 std::cerr << std::endl <<
">> Consider to check the manual ;-)" << std::endl;
6134 if (
fRuns[i].GetForwardHistoNo() == -1) {
6135 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6136 std::cerr << std::endl <<
">> forward histogram number not defined. Necessary for asymmetry fits." << std::endl;
6140 if (
fRuns[i].GetBackwardHistoNo() == -1) {
6141 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6142 std::cerr << std::endl <<
">> backward histogram number not defined. Necessary for asymmetry fits." << std::endl;
6146 if (!
fRuns[i].IsFitRangeInBin()) {
6149 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6150 std::cerr << std::endl <<
">> Fit range is not defined, also NOT present in the GLOBAL block. Necessary for asymmetry fits." << std::endl;
6156 detectorGroups = 2*
fRuns[i].GetForwardHistoNoSize();
6157 if (detectorGroups < 2*
fRuns[i].GetBackwardHistoNoSize())
6158 detectorGroups = 2*
fRuns[i].GetBackwardHistoNoSize();
6159 if ((
fRuns[i].GetT0BinSize() > detectorGroups) || (
fGlobal.GetT0BinSize() > detectorGroups)) {
6160 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6161 if (
fRuns[i].GetT0BinSize() > detectorGroups)
6162 std::cerr << std::endl <<
">> In RUN Block " << i+1 <<
": found " <<
fRuns[i].GetT0BinSize() <<
" T0 entries. Expecting max. " << detectorGroups <<
" entries.";
6163 if (
fGlobal.GetT0BinSize() > 1)
6164 std::cerr << std::endl <<
">> In GLOBAL block: found " <<
fGlobal.GetT0BinSize() <<
" T0 entries. Expecting max. " << detectorGroups <<
" entries. Needs to be fixed.";
6165 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;
6169 if ((
fRuns[i].GetPacking() == -1) && (
fGlobal.GetPacking() == -1)) {
6170 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **WARNING** in RUN block number " << i+1;
6171 std::cerr << std::endl <<
">> Packing is neither defined here, nor in the GLOBAL block, will set it to 1." << std::endl;
6172 fRuns[i].SetPacking(1);
6184 if (
fRuns[i].GetForwardHistoNo() == -1) {
6185 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6186 std::cerr << std::endl <<
">> forward histogram number not defined. Necessary for asymmetry fits." << std::endl;
6190 if (
fRuns[i].GetBackwardHistoNo() == -1) {
6191 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6192 std::cerr << std::endl <<
">> backward histogram number not defined. Necessary for asymmetry fits." << std::endl;
6196 if (!
fRuns[i].IsFitRangeInBin()) {
6199 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6200 std::cerr << std::endl <<
">> Fit range is not defined, also NOT present in the GLOBAL block. Necessary for asymmetry fits." << std::endl;
6206 if ((
fRuns[i].GetT0BinSize() > 2*
fRuns[i].GetForwardHistoNoSize()) &&
6207 (
fGlobal.GetT0BinSize() > 2*
fRuns[i].GetForwardHistoNoSize())) {
6208 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6209 std::cerr << std::endl <<
">> Found " <<
fRuns[i].GetT0BinSize() <<
" T0 entries. Expecting only " << 2*
fRuns[i].GetForwardHistoNoSize() <<
" in forward. Needs to be fixed." << std::endl;
6210 std::cerr << std::endl <<
">> In GLOBAL block: " <<
fGlobal.GetT0BinSize() <<
" T0 entries. Expecting only " << 2*
fRuns[i].GetForwardHistoNoSize() <<
". Needs to be fixed." << std::endl;
6213 if ((
fRuns[i].GetT0BinSize() > 2*
fRuns[i].GetBackwardHistoNoSize()) &&
6214 (
fGlobal.GetT0BinSize() > 2*
fRuns[i].GetBackwardHistoNoSize())) {
6215 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6216 std::cerr << std::endl <<
">> Found " <<
fRuns[i].GetT0BinSize() <<
" T0 entries. Expecting only " << 2*
fRuns[i].GetBackwardHistoNoSize() <<
" in backward. Needs to be fixed." << std::endl;
6217 std::cerr << std::endl <<
">> In GLOBAL block: " <<
fGlobal.GetT0BinSize() <<
" T0 entries. Expecting only " << 2*
fRuns[i].GetBackwardHistoNoSize() <<
". Needs to be fixed." << std::endl;
6221 if ((
fRuns[i].GetPacking() == -1) && (
fGlobal.GetPacking() == -1)) {
6222 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **WARNING** in RUN block number " << i+1;
6223 std::cerr << std::endl <<
">> Packing is neither defined here, nor in the GLOBAL block, will set it to 1." << std::endl;
6224 fRuns[i].SetPacking(1);
6230 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6231 std::cerr << std::endl <<
">> alpha parameter number missing which is needed for an asymmetry RRF fit.";
6232 std::cerr << std::endl <<
">> Consider to check the manual ;-)" << std::endl;
6236 if (
fRuns[i].GetForwardHistoNo() == -1) {
6237 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6238 std::cerr << std::endl <<
">> forward histogram number not defined. Necessary for asymmetry RRF fits." << std::endl;
6242 if (
fRuns[i].GetBackwardHistoNo() == -1) {
6243 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6244 std::cerr << std::endl <<
">> backward histogram number not defined. Necessary for asymmetry RRF fits." << std::endl;
6248 if (!
fRuns[i].IsFitRangeInBin()) {
6251 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6252 std::cerr << std::endl <<
">> Fit range is not defined, also NOT present in the GLOBAL block. Necessary for asymmetry RRF fits." << std::endl;
6258 detectorGroups = 2*
fRuns[i].GetForwardHistoNoSize();
6259 if (detectorGroups < 2*
fRuns[i].GetBackwardHistoNoSize())
6260 detectorGroups = 2*
fRuns[i].GetBackwardHistoNoSize();
6261 if ((
fRuns[i].GetT0BinSize() > detectorGroups) || (
fGlobal.GetT0BinSize() > detectorGroups)) {
6262 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6263 if (
fRuns[i].GetT0BinSize() > detectorGroups)
6264 std::cerr << std::endl <<
">> In RUN Block " << i+1 <<
": found " <<
fRuns[i].GetT0BinSize() <<
" T0 entries. Expecting max. " << detectorGroups <<
" entries.";
6265 if (
fGlobal.GetT0BinSize() > 1)
6266 std::cerr << std::endl <<
">> In GLOBAL block: found " <<
fGlobal.GetT0BinSize() <<
" T0 entries. Expecting max. " << detectorGroups <<
" entries. Needs to be fixed.";
6267 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;
6272 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** no RRF frequency found in the GLOBAL block." << std::endl;
6276 if (
fGlobal.GetRRFPacking() == -1) {
6277 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** no RRF packing found in the GLOBAL block." << std::endl;
6286 if ((
fRuns[i].GetXDataIndex() == -1) && (
fRuns[i].GetXDataLabel()->Length() == 0)) {
6287 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6288 std::cerr << std::endl <<
">> xy-data is missing. Necessary for non muSR fits." << std::endl;
6294 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
6295 std::cerr << std::endl <<
">> Fit range is not defined, neither in the RUN block, nor in the GLOBAL block.";
6296 std::cerr << std::endl <<
">> Necessary for non muSR fits." << std::endl;
6301 if (
fRuns[i].GetPacking() == -1) {
6302 if (
fGlobal.GetPacking() == -1) {
6303 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **WARNING** in RUN block number " << i+1;
6304 std::cerr << std::endl <<
">> Packing is not defined, will set it to 1." << std::endl;
6305 fRuns[i].SetPacking(1);
6310 std::cerr << std::endl <<
">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** fittype " << fitType <<
" undefined." << std::endl;
6335 Bool_t unique =
true;
6337 for (UInt_t i=0; i<
fParam.size()-1; i++) {
6338 for (UInt_t j=i+1; j<
fParam.size(); j++) {
6364 Bool_t result =
true;
6370 TObjArray *tokens =
nullptr;
6371 TObjString *ostr =
nullptr;
6377 for (UInt_t i=0; i<
fTheory.size(); i++) {
6378 if (
fTheory[i].fLine.Contains(
"map", TString::kIgnoreCase)) {
6380 tokens =
fTheory[i].fLine.Tokenize(
" \t");
6381 for (Int_t j=0; j<tokens->GetEntries(); j++) {
6382 ostr =
dynamic_cast<TObjString*
>(tokens->At(j));
6383 str = ostr->GetString();
6384 if (str.Contains(
"map", TString::kIgnoreCase)) {
6386 mapVec.push_back(no);
6387 mapBlock.push_back(0);
6388 mapLineNo.push_back(
fTheory[i].fLineNo);
6402 if (
fFunctions[i].fLine.Contains(
"map", TString::kIgnoreCase)) {
6404 tokens =
fFunctions[i].fLine.Tokenize(
" \t");
6405 for (Int_t j=0; j<tokens->GetEntries(); j++) {
6406 ostr =
dynamic_cast<TObjString*
>(tokens->At(j));
6407 str = ostr->GetString();
6408 if (str.Contains(
"map", TString::kIgnoreCase)) {
6410 mapVec.push_back(no);
6411 mapBlock.push_back(1);
6426 for (UInt_t i=0; i<mapVec.size(); i++) {
6428 for (UInt_t j=0; j<
fRuns.size(); j++) {
6439 std::cerr << std::endl <<
">> PMsrHandler::CheckMaps: **ERROR** map" << mapVec[i]-
MSR_PARAM_MAP_OFFSET <<
" found in the ";
6440 if (mapBlock[i] == 0)
6441 std::cerr <<
"theory-block ";
6443 std::cerr <<
"functions-block ";
6444 std::cerr <<
"in line " << mapLineNo[i] <<
" is not present in the run-block!";
6445 std::cerr << std::endl;
6447 std::cerr << std::endl <<
">> by the way: map must be > 0 ...";
6448 std::cerr << std::endl;
6474 Bool_t result =
true;
6483 TObjArray *tokens =
nullptr;
6484 TObjString *ostr =
nullptr;
6490 for (UInt_t i=0; i<
fTheory.size(); i++) {
6491 if (
fTheory[i].fLine.Contains(
"fun", TString::kIgnoreCase)) {
6493 tokens =
fTheory[i].fLine.Tokenize(
" \t");
6494 for (Int_t j=0; j<tokens->GetEntries(); j++) {
6495 ostr =
dynamic_cast<TObjString*
>(tokens->At(j));
6496 str = ostr->GetString();
6497 if (str.Contains(
"fun", TString::kIgnoreCase)) {
6499 funVec.push_back(no);
6500 funBlock.push_back(0);
6501 funLineBlockNo.push_back(
fTheory[i].fLineNo);
6514 for (UInt_t i=0; i<
fRuns.size(); i++) {
6516 funVec.push_back(
fRuns[i].GetNormParamNo());
6517 funBlock.push_back(1);
6518 funLineBlockNo.push_back(i+1);
6524 for (UInt_t i=0; i<funVec.size(); i++) {
6530 str = TString(
"fun");
6532 if (
fFunctions[j].fLine.Contains(str, TString::kIgnoreCase)) {
6539 std::cerr << std::endl <<
">> PMsrHandler::CheckFuncs: **ERROR** fun" << funVec[i]-
MSR_PARAM_FUN_OFFSET <<
" found in the ";
6540 if (funBlock[i] == 0)
6541 std::cerr <<
"theory-block in line " << funLineBlockNo[i] <<
" is not present in the functions-block!";
6543 std::cerr <<
"run-block No " << funLineBlockNo[i] <<
" (norm) is not present in the functions-block!";
6544 std::cerr << std::endl;
6551 funLineBlockNo.clear();
6568 Bool_t result =
true;
6570 for (UInt_t i=0; i<
fRuns.size(); i++) {
6572 if (
fRuns[i].GetForwardHistoNoSize() > 1) {
6573 for (UInt_t j=0; j<
fRuns[i].GetForwardHistoNoSize(); j++) {
6574 for (UInt_t k=j+1; k<
fRuns[i].GetForwardHistoNoSize(); k++) {
6575 if (
fRuns[i].GetForwardHistoNo(j) ==
fRuns[i].GetForwardHistoNo(k)) {
6576 std::cerr << std::endl <<
">> PMsrHandler::CheckHistoGrouping: **WARNING** grouping identical histograms!!";
6577 std::cerr << std::endl <<
">> run no " << i+1 <<
", forward histo " << j+1 <<
" == forward histo " << k+1 <<
".";
6578 std::cerr << std::endl <<
">> this really doesn't make any sense, but you are the boss.";
6579 std::cerr << std::endl;
6585 if (
fRuns[i].GetBackwardHistoNoSize() > 1) {
6586 for (UInt_t j=0; j<
fRuns[i].GetBackwardHistoNoSize(); j++) {
6587 for (UInt_t k=j+1; k<
fRuns[i].GetBackwardHistoNoSize(); k++) {
6588 if (
fRuns[i].GetBackwardHistoNo(j) ==
fRuns[i].GetBackwardHistoNo(k)) {
6589 std::cerr << std::endl <<
">> PMsrHandler::CheckHistoGrouping: **WARNING** grouping identical histograms!!";
6590 std::cerr << std::endl <<
">> run no " << i+1 <<
", backward histo " << j+1 <<
" == backward histo " << k+1 <<
".";
6591 std::cerr << std::endl <<
">> this really doesn't make any sense, but you are the boss.";
6592 std::cerr << std::endl;
6614 Bool_t result =
true;
6616 for (UInt_t i=0; i<
fRuns.size(); i++) {
6617 if (
fRuns[i].GetRunNameSize() > 1) {
6619 if (
fRuns[i].GetAddT0BinEntries() != 0) {
6620 if (
fRuns[i].GetAddT0BinEntries() !=
fRuns[i].GetRunNameSize()-1) {
6623 fLastErrorMsg <<
">> PMsrHandler::CheckAddRunParameters: **ERROR** # of addt0 != # of addruns.\n";
6647 for (UInt_t i=0; i<
fRuns.size(); i++) {
6652 fLastErrorMsg <<
">> PMsrHandler::CheckMaxLikelihood: **WARNING**: Maximum Log Likelihood Fit is only implemented\n";
6653 fLastErrorMsg <<
">> for Single Histogram and Mu Minus Fits. Will fall back to Chi Square Fit.\n";
6654 std::cerr << std::endl << std::endl;
6671 Bool_t result =
true;
6672 Int_t fittype =
fGlobal.GetFitType();
6676 if (fittype != -1) {
6679 std::cerr << std::endl <<
">> PMsrHandler::CheckRRFSettings: **ERROR** found GLOBAL fittype " << fittype <<
" and";
6680 std::cerr << std::endl <<
">> RRF settings in the GLOBAL section. This is NOT compatible. Fix it first.";
6684 for (UInt_t i=0; i<
fRuns.size(); i++) {
6685 fittype =
fRuns[i].GetFitType();
6688 std::cerr << std::endl <<
">> PMsrHandler::CheckRRFSettings: **ERROR** found RUN with fittype " << fittype <<
" and";
6689 std::cerr << std::endl <<
">> RRF settings in the GLOBAL section. This is NOT compatible. Fix it first.";
6696 if (
fGlobal.GetRRFPacking() != -1) {
6697 std::cerr << std::endl <<
">> PMsrHandler::CheckRRFSettings: **WARNING** found in the GLOBAL section rrf_packing, without";
6698 std::cerr << std::endl <<
">> rrf_freq. Doesn't make any sense. Will drop rrf_packing";
6699 std::cerr << std::endl << std::endl;
6702 if (
fGlobal.GetRRFPhase() != 0.0) {
6703 std::cerr << std::endl <<
">> PMsrHandler::CheckRRFSettings: **WARNING** found in the GLOBAL section rrf_phase, without";
6704 std::cerr << std::endl <<
">> rrf_freq. Doesn't make any sense. Will drop rrf_phase";
6705 std::cerr << std::endl << std::endl;
6717 fittype =
fGlobal.GetFitType();
6721 std::cerr << std::endl <<
">> PMsrHandler::CheckRRFSettings: **ERROR** RRF fit chosen, but";
6722 std::cerr << std::endl <<
">> no RRF frequency found in the GLOBAL section! Fix it.";
6725 if (
fGlobal.GetRRFPacking() == -1) {
6726 std::cerr << std::endl <<
">> PMsrHandler::CheckRRFSettings: **ERROR** RRF fit chosen, but";
6727 std::cerr << std::endl <<
">> no RRF packing found in the GLOBAL section! Fix it.";
6731 UInt_t rrfFitCounter = 0;
6732 for (UInt_t i=0; i<
fRuns.size(); i++) {
6733 fittype =
fRuns[i].GetFitType();
6739 if (rrfFitCounter !=
fRuns.size()) {
6740 std::cerr << std::endl <<
">> PMsrHandler::CheckRRFSettings: **ERROR** #Runs (" <<
fRuns.size() <<
") != # RRF fits found (" << rrfFitCounter <<
")";
6741 std::cerr << std::endl <<
">> This is currently not supported.";
6745 std::cerr << std::endl <<
">> PMsrHandler::CheckRRFSettings: **ERROR** RRF fit chosen, but";
6746 std::cerr << std::endl <<
">> no RRF frequency found in the GLOBAL section! Fix it.";
6749 if (
fGlobal.GetRRFPacking() == -1) {
6750 std::cerr << std::endl <<
">> PMsrHandler::CheckRRFSettings: **ERROR** RRF fit chosen, but";
6751 std::cerr << std::endl <<
">> no RRF packing found in the GLOBAL section! Fix it.";
6770 if (!
fFourier.fFourierBlockPresent)
6782 fLastErrorMsg <<
">> PMsrHandler::ReadMsrFile: **ERROR** if more than one phase is given in the Fourier block,\n";
6783 fLastErrorMsg <<
">> it needs to correspond to the number of runs in the Plot block!\n";
6785 fLastErrorMsg <<
">> number of runs in the PLOT block: " <<
fPlots[0].fRuns.size() <<
"\n";
6793 if ((
fFourier.fPhase.size() == 0) && (
fFourier.fPhaseParamNo.size() == 0)) {
6796 fLastErrorMsg <<
">> PMsrHandler::ReadMsrFile: **ERROR** for FOURIER plot != POWER,\n";
6797 fLastErrorMsg <<
">> phases need to be defined in the FOURIER block!\n";
6800 fLastErrorMsg <<
">> where parR7 is the reference phase, and the others the relative phases.\n";
6801 fLastErrorMsg <<
">> I.e. phase of run 2: parR7 + par9, etc.\n";
6825 if (!detector.CompareTo(
"forward", TString::kIgnoreCase)) {
6826 for (UInt_t i=0; i<
fRuns[runNo].GetForwardHistoNoSize(); i++)
6827 grouping.push_back(
fRuns[runNo].GetForwardHistoNo(i));
6829 }
else if (!detector.CompareTo(
"backward", TString::kIgnoreCase)) {
6830 for (UInt_t i=0; i<
fRuns[runNo].GetBackwardHistoNoSize(); i++)
6831 grouping.push_back(
fRuns[runNo].GetBackwardHistoNo(i));
6834 groupingStr =
"**ERROR** unkown detector. Allow forward/backward.";
6874 for (UInt_t i=0; i<precLimit; i++) {
6875 if (
static_cast<Int_t
>(dval*pow(10.0,
static_cast<Double_t
>(i))) != 0) {
6881 if (prec == precLimit) {
6882 std::cerr << std::endl <<
">> PMsrHandler::NeededPrecision(): **WARNING** precision limit of " << precLimit <<
", requested.";
6901 UInt_t lastSignificant = 2;
6902 UInt_t decimalPoint = 0;
6906 snprintf(str,
sizeof(str),
"%lf", dval);
6909 for (UInt_t i=0; i<strlen(str); i++) {
6910 if (str[i] ==
'.') {
6917 for (Int_t i=strlen(str)-1; i>=0; i--) {
6918 if (str[i] !=
'0') {
6919 if ((
static_cast<UInt_t
>(i)-decimalPoint) < precLimit)
6920 lastSignificant =
static_cast<UInt_t
>(i)-decimalPoint;
6922 lastSignificant = precLimit;
6927 return lastSignificant;
6943 if (includeDetector) {
6944 result = str + TString(
" ");
6945 if (str == TString(
"forward"))
6951 if (group.size()==0)
6957 if (j+1 < group.size()) {
6958 while (group[j]+1 == group[j+1]) {
6960 if (j == group.size()-1)
6975 }
while (i<group.size());
6991 TString formatStr(
"par%d, par%d");
6993 if (
fFourier.fPhaseParamNo.size() == 0)
6996 Int_t phaseRef =
fFourier.fPhaseRef;
6998 if (
fFourier.fPhaseParamNo.size() == 1) {
6999 str = TString::Format(
"par%d",
fFourier.fPhaseParamNo[0]);
7000 }
else if (
fFourier.fPhaseParamNo.size() == 2) {
7001 if (phaseRef ==
fFourier.fPhaseParamNo[0])
7002 formatStr =
"parR%d, par%d";
7003 if (phaseRef ==
fFourier.fPhaseParamNo[1])
7004 formatStr =
"par%d, parR%d";
7005 str = TString::Format(formatStr,
fFourier.fPhaseParamNo[0],
fFourier.fPhaseParamNo[1]);
7007 Bool_t phaseIter =
true;
7011 for (Int_t i=2; i<
fFourier.fPhaseParamNo.size(); i++) {
7019 if (phaseRef != -1) {
7020 str = TString::Format(
"parR(%d, %d, %lu)",
fFourier.fPhaseParamNo[0], offset,
fFourier.fPhaseParamNo.size());
7022 str = TString::Format(
"par(%d, %d, %lu)",
fFourier.fPhaseParamNo[0], offset,
fFourier.fPhaseParamNo.size());
7026 for (Int_t i=0; i<
fFourier.fPhaseParamNo.size()-1; i++) {
7027 if (phaseRef ==
fFourier.fPhaseParamNo[i]) {
7059 for (UInt_t i=0; i<
fPlots.size(); i++) {
7060 for (UInt_t j=0; j<
fPlots[i].fRuns.size(); j++) {
7061 idx =
fPlots[i].fRuns[j]-1;
7062 if (
fRuns[idx].IsLifetimeCorrected()) {
7063 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