musrfit 1.10.0
PMusr.cpp
Go to the documentation of this file.
1/***************************************************************************
2
3 PMusr.cpp
4
5 Author: Andreas Suter
6 e-mail: andreas.suter@psi.ch
7
8***************************************************************************/
9
10/***************************************************************************
11 * Copyright (C) 2007-2026 by Andreas Suter *
12 * andreas.suter@psi.ch *
13 * *
14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. *
18 * *
19 * This program is distributed in the hope that it will be useful, *
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22 * GNU General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU General Public License *
25 * along with this program; if not, write to the *
26 * Free Software Foundation, Inc., *
27 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
28 ***************************************************************************/
29
30#include <cassert>
31#include <iostream>
32
33#include <boost/algorithm/string.hpp>
34using namespace boost;
35
36#include "TMath.h"
37
38#include "PMusr.h"
39
40//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
41// implementation PRunData
42//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
43
44//--------------------------------------------------------------------------
45// Constructor
46//--------------------------------------------------------------------------
51{
54 fX.clear(); // only used in non-muSR
55 fValue.clear();
56 fError.clear();
59 fXTheory.clear(); // only used in non-muSR
60 fTheory.clear();
61}
62
63//--------------------------------------------------------------------------
64// Destructor
65//--------------------------------------------------------------------------
70{
71 fX.clear(); // only used in non-muSR
72 fValue.clear();
73 fError.clear();
74 fXTheory.clear(); // only used in non-muSR
75 fTheory.clear();
76}
77
78//--------------------------------------------------------------------------
79// SetTheoryValue (public)
80//--------------------------------------------------------------------------
87void PRunData::SetTheoryValue(UInt_t idx, Double_t dval)
88{
89 if (idx > fTheory.size())
90 fTheory.resize(idx+1);
91
92 fTheory[idx] = dval;
93}
94
95//--------------------------------------------------------------------------
96// ReplaceTheory (public)
97//--------------------------------------------------------------------------
104{
105 fTheory = theo;
106}
107
108//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
109// implementation PNonMusrRawRunData
110//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
111
112//--------------------------------------------------------------------------
113// Constructor
114//--------------------------------------------------------------------------
119{
120 fFromAscii = true;
121 fLabels.clear();
122 fDataTags.clear();
123
124 for (UInt_t i=0; i<fData.size(); i++)
125 fData[i].clear();
126 fData.clear();
127
128 for (UInt_t i=0; i<fErrData.size(); i++)
129 fErrData[i].clear();
130 fErrData.clear();
131}
132
133//--------------------------------------------------------------------------
134// Destructor
135//--------------------------------------------------------------------------
140{
141 fLabels.clear();
142 fDataTags.clear();
143
144 for (UInt_t i=0; i<fData.size(); i++)
145 fData[i].clear();
146 fData.clear();
147
148 for (UInt_t i=0; i<fErrData.size(); i++)
149 fErrData[i].clear();
150 fErrData.clear();
151}
152
153//--------------------------------------------------------------------------
154// SetSize (public)
155//--------------------------------------------------------------------------
162void PNonMusrRawRunData::SetSize(const UInt_t size)
163{
164 // first clean up
165 for (UInt_t i=0; i<fData.size(); i++) {
166 fData[i].clear();
167 }
168 fData.clear();
169 for (UInt_t i=0; i<fErrData.size(); i++) {
170 fErrData[i].clear();
171 }
172 fErrData.clear();
173
174 // set size
175 fData.resize(size);
176 fErrData.resize(size);
177}
178
179//--------------------------------------------------------------------------
180// SetLabel (public)
181//--------------------------------------------------------------------------
189void PNonMusrRawRunData::SetLabel(const UInt_t idx, const TString str)
190{
191 if (idx >= fLabels.size()) {
192 std::cerr << std::endl << ">> PNonMusrRawRunData::SetLabel: **WARNING** idx=" << idx << " is out of range [0," << fLabels.size() << "[.";
193 std::cerr << std::endl;
194 return;
195 }
196 fLabels[idx] = str;
197}
198
199//--------------------------------------------------------------------------
200// AppendSubData (public)
201//--------------------------------------------------------------------------
209void PNonMusrRawRunData::AppendSubData(const UInt_t idx, const Double_t dval)
210{
211 if (idx >= fData.size()) {
212 std::cerr << std::endl << ">> PNonMusrRawRunData::AppendSubData: **WARNING** idx=" << idx << " is out of range [0," << fData.size() << "[.";
213 std::cerr << std::endl;
214 return;
215 }
216 fData[idx].push_back(dval);
217}
218
219//--------------------------------------------------------------------------
220// AppendSubErrData (public)
221//--------------------------------------------------------------------------
229void PNonMusrRawRunData::AppendSubErrData(const UInt_t idx, const Double_t dval)
230{
231 if (idx >= fErrData.size()) {
232 std::cerr << std::endl << ">> PNonMusrRawRunData::AppendSubErrData: **WARNING** idx=" << idx << " is out of range [0," << fErrData.size() << "[.";
233 std::cerr << std::endl;
234 return;
235 }
236 fErrData[idx].push_back(dval);
237}
238
239
240//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
241// implementation PRawRunDataSet
242//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
243
244//--------------------------------------------------------------------------
245// Constructor
246//--------------------------------------------------------------------------
254
255//--------------------------------------------------------------------------
256// Clear (public)
257//--------------------------------------------------------------------------
262{
263 fTitle = TString("n/a");
264 fName = TString("n/a");
265 fHistoNo = -1;
266 fTimeZeroBin = 0.0;
268 fFirstGoodBin = 0;
269 fLastGoodBin = 0;
270 fFirstBkgBin = 0;
271 fLastBkgBin = 0;
272 fData.clear();
273}
274
275//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
276// implementation PRawRunDataVector
277//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
278
279//--------------------------------------------------------------------------
280// IsPresent (public)
281//--------------------------------------------------------------------------
291Bool_t PRawRunDataVector::IsPresent(UInt_t histoNo)
292{
293 Bool_t found=false;
294
295 for (UInt_t i=0; i<fDataVec.size(); i++) {
296 if (fDataVec[i].GetHistoNo() == static_cast<Int_t>(histoNo)) {
297 found = true;
298 break;
299 }
300 }
301
302 return found;
303}
304
305//--------------------------------------------------------------------------
306// GetSet (public)
307//--------------------------------------------------------------------------
320{
321 PRawRunDataSet *result = nullptr;
322
323 if (idx >= fDataVec.size())
324 return result;
325
326 return &fDataVec[idx];
327}
328
329//--------------------------------------------------------------------------
330// Get (public)
331//--------------------------------------------------------------------------
342{
343 PRawRunDataSet *result = nullptr;
344
345 for (UInt_t i=0; i<fDataVec.size(); i++) {
346 if (fDataVec[i].GetHistoNo() == static_cast<Int_t>(histoNo)) {
347 result = &fDataVec[i];
348 break;
349 }
350 }
351
352 return result;
353}
354
355//--------------------------------------------------------------------------
356// operator[] (public)
357//--------------------------------------------------------------------------
368{
369 return Get(histoNo);
370}
371
372//--------------------------------------------------------------------------
373// GetData (public)
374//--------------------------------------------------------------------------
385{
386 PDoubleVector *result = nullptr;
387
388 for (UInt_t i=0; i<fDataVec.size(); i++) {
389 if (fDataVec[i].GetHistoNo() == static_cast<Int_t>(histoNo)) {
390 result = fDataVec[i].GetData();
391 break;
392 }
393 }
394
395 return result;
396}
397
398//--------------------------------------------------------------------------
399// GetT0Bin (public)
400//--------------------------------------------------------------------------
410Double_t PRawRunDataVector::GetT0Bin(UInt_t histoNo)
411{
412 Double_t result=-1.0; // undefined
413
414 for (UInt_t i=0; i<fDataVec.size(); i++) {
415 if (fDataVec[i].GetHistoNo() == static_cast<Int_t>(histoNo)) {
416 result = fDataVec[i].GetTimeZeroBin();
417 break;
418 }
419 }
420
421 return result;
422}
423
424//--------------------------------------------------------------------------
425// GetT0BinEstimated (public)
426//--------------------------------------------------------------------------
437{
438 Double_t result=PMUSR_UNDEFINED;
439
440 for (UInt_t i=0; i<fDataVec.size(); i++) {
441 if (fDataVec[i].GetHistoNo() == static_cast<Int_t>(histoNo)) {
442 result = fDataVec[i].GetTimeZeroBinEstimated();
443 break;
444 }
445 }
446
447 return result;
448}
449
450//--------------------------------------------------------------------------
451// GetBkgBin (public)
452//--------------------------------------------------------------------------
463{
464 PIntPair bkg(-1,-1);
465
466 for (UInt_t i=0; i<fDataVec.size(); i++) {
467 if (fDataVec[i].GetHistoNo() == static_cast<Int_t>(histoNo)) {
468 bkg.first = fDataVec[i].GetFirstBkgBin();
469 bkg.second = fDataVec[i].GetLastBkgBin();
470 break;
471 }
472 }
473
474 return bkg;
475}
476
477//--------------------------------------------------------------------------
478// GetGoodDataBin (public)
479//--------------------------------------------------------------------------
490{
491 PIntPair gdb(-1,-1);
492
493 for (UInt_t i=0; i<fDataVec.size(); i++) {
494 if (fDataVec[i].GetHistoNo() == static_cast<Int_t>(histoNo)) {
495 gdb.first = fDataVec[i].GetFirstGoodBin();
496 gdb.second = fDataVec[i].GetLastGoodBin();
497 break;
498 }
499 }
500
501 return gdb;
502}
503
504//--------------------------------------------------------------------------
505// Set (public)
506//--------------------------------------------------------------------------
516{
517 if (idx == -1) { // data set to be appended
518 fDataVec.push_back(dataSet);
519 } else {
520 if (idx >= static_cast<Int_t>(fDataVec.size()))
521 fDataVec.resize(idx+1);
522 fDataVec[idx] = dataSet;
523 }
524}
525
526//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
527// implementation PRawRunData
528//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
529
530//--------------------------------------------------------------------------
531// Constructor
532//--------------------------------------------------------------------------
537{
538 fVersion = TString("n/a");
539 fGenericValidatorURL = TString("n/a");
540 fSpecificValidatorURL = TString("n/a");
541 fGenerator = TString("n/a");
542 fComment = TString("n/a");
543 fFileName = TString("n/a");
544 fLaboratory = TString("n/a");
545 fBeamline = TString("n/a");
546 fInstrument = TString("n/a");
547 fMuonSource = TString("n/a");
548 fMuonSpecies = TString("n/a");
551 fRunName = TString("n/a");
552 fRunNumber = -1;
553 fRunTitle = TString("n/a");
554 fSetup = TString("n/a");
555 fStartTime = TString("n/a");
556 fStartDate = TString("n/a");
558 fStopTime = TString("n/a");
559 fStopDate = TString("n/a");
561 fCryo = TString("n/a");
562 fSample = TString("n/a");
563 fOrientation = TString("n/a");
564 fMagnet = TString("n/a");
569 fRedGreenOffset.push_back(0);
570}
571
572//--------------------------------------------------------------------------
573// Destructor
574//--------------------------------------------------------------------------
579{
580 fTemp.clear();
581 fRingAnode.clear();
582 fRedGreenOffset.clear();
583}
584
585//--------------------------------------------------------------------------
586// CalcStartDateTime (public)
587//--------------------------------------------------------------------------
595const time_t PRawRunData::CalcStartDateTime(bool &ok)
596{
597 time_t dt=0;
598 ok = true;
599 struct tm tmStruct;
600 char date_time[256];
601 snprintf(date_time, sizeof(date_time), "%s %s", fStartDate.Data(), fStartTime.Data());
602 char *p_char = strptime(date_time, "%Y-%m-%d %H:%M:%S", &tmStruct);
603 if (*p_char != '\0') {
604 ok = false;
605 return dt;
606 }
607 dt = mktime(&tmStruct);
608 return dt;
609}
610
611//--------------------------------------------------------------------------
612// CalcStopDateTime (public)
613//--------------------------------------------------------------------------
621const time_t PRawRunData::CalcStopDateTime(bool &ok)
622{
623 time_t dt=0;
624 ok = true;
625 struct tm tmStruct;
626 char date_time[256];
627 snprintf(date_time, sizeof(date_time), "%s %s", fStopDate.Data(), fStopTime.Data());
628 char *p_char = strptime(date_time, "%Y-%m-%d %H:%M:%S", &tmStruct);
629 if (*p_char != '\0') {
630 ok = false;
631 return dt;
632 }
633 dt = mktime(&tmStruct);
634 return dt;
635}
636
637//--------------------------------------------------------------------------
638// GetTemperature (public)
639//--------------------------------------------------------------------------
649const Double_t PRawRunData::GetTemperature(const UInt_t idx)
650{
651 if (idx >= fTemp.size()) {
652 std::cerr << std::endl << ">> PRawRunData::GetTemperature: **WARNING** idx=" << idx << " is out of range [0," << fTemp.size() << "[.";
653 std::cerr << std::endl;
654 return PMUSR_UNDEFINED;
655 }
656 return fTemp[idx].first;
657}
658
659//--------------------------------------------------------------------------
660// GetTempError (public)
661//--------------------------------------------------------------------------
671const Double_t PRawRunData::GetTempError(const UInt_t idx)
672{
673 if (idx >= fTemp.size()) {
674 std::cerr << std::endl << ">> PRawRunData::GetTempError: **WARNING** idx=" << idx << " is out of range [0," << fTemp.size() << "[.";
675 std::cerr << std::endl;
676 return PMUSR_UNDEFINED;
677 }
678 return fTemp[idx].second;
679}
680
681//--------------------------------------------------------------------------
682// GetRingAnode (public)
683//--------------------------------------------------------------------------
693const Double_t PRawRunData::GetRingAnode(const UInt_t idx)
694{
695 if (idx >= fRingAnode.size()) {
696 std::cerr << std::endl << ">> PRawRunData::GetRingAnode: **WARNING** idx=" << idx << " is out of range [0," << fRingAnode.size() << "[.";
697 std::cerr << std::endl;
698 return PMUSR_UNDEFINED;
699 }
700 return fRingAnode[idx];
701}
702
703//--------------------------------------------------------------------------
704// GetDataSet (public)
705//--------------------------------------------------------------------------
716PRawRunDataSet* PRawRunData::GetDataSet(const UInt_t idx, Bool_t wantHistoNo)
717{
718 if (wantHistoNo)
719 return fData[idx];
720 else
721 return fData.GetSet(idx);
722}
723
724//--------------------------------------------------------------------------
725// DeadTimeCorrectionReady (public)
726//--------------------------------------------------------------------------
735{
736 if ((fNumberOfGoodFrames > 0) && (fDeadTimeParam.size() > 0))
737 return true;
738 return false;
739}
740
741//--------------------------------------------------------------------------
742// SetRingAnode (public)
743//--------------------------------------------------------------------------
750void PRawRunData::SetRingAnode(const UInt_t idx, const Double_t dval)
751{
752 if (idx >= fRingAnode.size())
753 fRingAnode.resize(idx+1);
754 fRingAnode[idx] = dval;
755}
756
757//--------------------------------------------------------------------------
758// SetTemperature (public)
759//--------------------------------------------------------------------------
767void PRawRunData::SetTemperature(const UInt_t idx, const Double_t temp, const Double_t errTemp)
768{
769 if (idx >= fTemp.size()) {
770 fTemp.resize(idx+1);
771 }
772 fTemp[idx].first = temp;
773 fTemp[idx].second = errTemp;
774}
775
776//--------------------------------------------------------------------------
777// SetTempError (public)
778//--------------------------------------------------------------------------
785void PRawRunData::SetTempError(const UInt_t idx, const Double_t errTemp)
786{
787 if (idx >= fTemp.size()) {
788 fTemp.resize(idx+1);
789 }
790 fTemp[idx].first = PMUSR_UNDEFINED;
791 fTemp[idx].second = errTemp;
792}
793
794//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
795// implementation PMsrGlobalBlock
796//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
797
798//--------------------------------------------------------------------------
799// PMsrGlobalBlock
800//--------------------------------------------------------------------------
805{
806 fGlobalPresent = false;
807 fRRFFreq = RRF_FREQ_UNDEF; // rotating reference frequency in units given by fRRFUnitTag. Only needed for fittype 1
808 fRRFUnitTag = RRF_UNIT_UNDEF; // RRF unit tag. Default: undefined
809 fRRFPhase = 0.0;
810 fRRFPacking = -1; // undefined RRF packing/rebinning
811 fFitType = -1; // undefined fit type
812 for (UInt_t i=0; i<4; i++) {
813 fDataRange[i] = -1; // undefined data bin range
814 }
815 fFitRangeInBins = false; // default is that fit range is given in time NOT bins
816 fFitRange[0] = PMUSR_UNDEFINED; // undefined start fit range
817 fFitRange[1] = PMUSR_UNDEFINED; // undefined end fit range
818 fFitRangeOffset[0] = -1; // undefined start fit range offset
819 fFitRangeOffset[1] = -1; // undefined end fit range offset
820 fPacking = -1; // undefined packing/rebinning
821}
822
823//--------------------------------------------------------------------------
824// GetRRFFreq (public)
825//--------------------------------------------------------------------------
831Double_t PMsrGlobalBlock::GetRRFFreq(const char *unit)
832{
833 Double_t freq = 0.0;
834
835 // check that the units given make sense
836 TString unitStr = unit;
837 Int_t unitTag = RRF_UNIT_UNDEF;
838 if (!unitStr.CompareTo("MHz", TString::kIgnoreCase))
839 unitTag = RRF_UNIT_MHz;
840 else if (!unitStr.CompareTo("Mc", TString::kIgnoreCase))
841 unitTag = RRF_UNIT_Mcs;
842 else if (!unitStr.CompareTo("T", TString::kIgnoreCase))
843 unitTag = RRF_UNIT_T;
844 else
845 return RRF_FREQ_UNDEF;
846
847 // calc the conversion factor
848 if (unitTag == fRRFUnitTag)
849 freq = fRRFFreq;
850 else if ((unitTag == RRF_UNIT_MHz) && (fRRFUnitTag == RRF_UNIT_Mcs))
851 freq = fRRFFreq/TMath::TwoPi();
852 else if ((unitTag == RRF_UNIT_MHz) && (fRRFUnitTag == RRF_UNIT_T))
853 freq = fRRFFreq*1e4*GAMMA_BAR_MUON; // 1e4 need for T -> G since GAMMA_BAR_MUON is given in MHz/G
854 else if ((unitTag == RRF_UNIT_Mcs) && (fRRFUnitTag == RRF_UNIT_MHz))
855 freq = fRRFFreq*TMath::TwoPi();
856 else if ((unitTag == RRF_UNIT_Mcs) && (fRRFUnitTag == RRF_UNIT_T))
857 freq = fRRFFreq*1e4*TMath::TwoPi()*GAMMA_BAR_MUON; // 1e4 need for T -> G since GAMMA_BAR_MUON is given in MHz/G
858 else if ((unitTag == RRF_UNIT_T) && (fRRFUnitTag == RRF_UNIT_MHz))
859 freq = fRRFFreq/GAMMA_BAR_MUON*1e-4; // 1e-4 need for G -> T since GAMMA_BAR_MUON is given in MHz/G
860 else if ((unitTag == RRF_UNIT_T) && (fRRFUnitTag == RRF_UNIT_Mcs))
861 freq = fRRFFreq/(TMath::TwoPi()*GAMMA_BAR_MUON)*1e-4; // 1e-4 need for G -> T since GAMMA_BAR_MUON is given in MHz/G
862
863 return freq;
864}
865
866//--------------------------------------------------------------------------
867// SetRRFFreq (public)
868//--------------------------------------------------------------------------
875void PMsrGlobalBlock::SetRRFFreq(Double_t freq, const char *unit)
876{
877 // check that the units given make sense
878 TString unitStr = unit;
879 Int_t unitTag = RRF_UNIT_UNDEF;
880 if (!unitStr.CompareTo("MHz", TString::kIgnoreCase))
881 unitTag = RRF_UNIT_MHz;
882 else if (!unitStr.CompareTo("Mc", TString::kIgnoreCase))
883 unitTag = RRF_UNIT_Mcs;
884 else if (!unitStr.CompareTo("T", TString::kIgnoreCase))
885 unitTag = RRF_UNIT_T;
886 else {
887 std::cerr << std::endl << ">> PMsrGlobalBlock::SetRRFFreq: **ERROR** found undefined RRF unit '" << unit << "'!";
888 std::cerr << std::endl << ">> Will set RRF frequency to 0.0." << std::endl;
889 fRRFFreq = 0.0;
891 }
892
893 fRRFFreq = freq;
894 fRRFUnitTag = unitTag;
895}
896
897//--------------------------------------------------------------------------
898// GetRRFUnit (public)
899//--------------------------------------------------------------------------
904{
905 TString unit;
906
907 switch (fRRFUnitTag) {
908 case RRF_UNIT_UNDEF:
909 unit = TString("??");
910 break;
911 case RRF_UNIT_kHz:
912 unit = TString("kHz");
913 break;
914 case RRF_UNIT_MHz:
915 unit = TString("MHz");
916 break;
917 case RRF_UNIT_Mcs:
918 unit = TString("Mc");
919 break;
920 case RRF_UNIT_G:
921 unit = TString("G");
922 break;
923 case RRF_UNIT_T:
924 unit = TString("T");
925 break;
926 default:
927 unit = TString("??");
928 break;
929 }
930
931 return unit;
932}
933
934//--------------------------------------------------------------------------
935// SetRRFPacking (public)
936//--------------------------------------------------------------------------
943{
944 if (pack <= 0) {
945 std::cerr << std::endl << "PMsrGlobalBlock::SetRRFPacking: **WARNING** found RRF packing <= 0. Likely doesn't make any sense." << std::endl;
946 fRRFPacking = -1; // set to undefined
947 }
948
949 fRRFPacking = pack;
950}
951
952//--------------------------------------------------------------------------
953// GetDataRange (public)
954//--------------------------------------------------------------------------
965{
966 if (idx >= 4)
967 return -1;
968
969 return fDataRange[idx];
970}
971
972//--------------------------------------------------------------------------
973// SetDataRange (public)
974//--------------------------------------------------------------------------
981void PMsrGlobalBlock::SetDataRange(Int_t ival, Int_t idx)
982{
983 if (idx >= 4) {
984 std::cerr << std::endl << ">> PMsrGlobalBlock::SetDataRange: **WARNING** idx=" << idx << ", only idx=0..3 are sensible.";
985 std::cerr << std::endl;
986 return;
987 }
988
989 fDataRange[idx] = ival;
990}
991
992//--------------------------------------------------------------------------
993// GetT0Bin (public)
994//--------------------------------------------------------------------------
1004Double_t PMsrGlobalBlock::GetT0Bin(UInt_t idx)
1005{
1006 if (idx >= fT0.size())
1007 return -1;
1008
1009 return fT0[idx];
1010}
1011
1012//--------------------------------------------------------------------------
1013// SetT0Bin (public)
1014//--------------------------------------------------------------------------
1021void PMsrGlobalBlock::SetT0Bin(Double_t dval, Int_t idx)
1022{
1023 if (idx == -1) {
1024 fT0.push_back(dval);
1025 return;
1026 }
1027
1028 if (idx >= static_cast<Int_t>(fT0.size()))
1029 fT0.resize(idx+1);
1030
1031 fT0[idx] = dval;
1032}
1033
1034//--------------------------------------------------------------------------
1035// GetAddT0BinSize (public)
1036//--------------------------------------------------------------------------
1047{
1048 if (fAddT0.empty())
1049 return -1;
1050
1051 if (addRunIdx >= fAddT0.size())
1052 return -1;
1053
1054 return fAddT0[addRunIdx].size();
1055}
1056
1057//--------------------------------------------------------------------------
1058// GetAddT0Bin (public)
1059//--------------------------------------------------------------------------
1070Double_t PMsrGlobalBlock::GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx)
1071{
1072 if (fAddT0.empty())
1073 return -1.0;
1074
1075 if (addRunIdx >= fAddT0.size())
1076 return -1.0;
1077
1078 if (fAddT0[addRunIdx].empty())
1079 return -1.0;
1080
1081 if (histoIdx >= fAddT0[addRunIdx].size())
1082 return -1.0;
1083
1084 return fAddT0[addRunIdx][histoIdx];
1085}
1086
1087//--------------------------------------------------------------------------
1088// SetAddT0Bin (public)
1089//--------------------------------------------------------------------------
1097void PMsrGlobalBlock::SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx)
1098{
1099 if (addRunIdx >= fAddT0.size())
1100 fAddT0.resize(addRunIdx+1);
1101
1102 if (histoNoIdx >= fAddT0[addRunIdx].size())
1103 fAddT0[addRunIdx].resize(histoNoIdx+1);
1104
1105 fAddT0[addRunIdx][histoNoIdx] = dval;
1106}
1107
1108//--------------------------------------------------------------------------
1109// GetFitRange (public)
1110//--------------------------------------------------------------------------
1121{
1122 if (idx >= 2)
1123 return PMUSR_UNDEFINED;
1124
1125 return fFitRange[idx];
1126}
1127
1128//--------------------------------------------------------------------------
1129// SetFitRange (public)
1130//--------------------------------------------------------------------------
1137void PMsrGlobalBlock::SetFitRange(Double_t dval, UInt_t idx)
1138{
1139 if (idx >= 2)
1140 return;
1141
1142 fFitRange[idx] = dval;
1143}
1144
1145//--------------------------------------------------------------------------
1146// GetFitRangeOffset (public)
1147//--------------------------------------------------------------------------
1158{
1159 if (idx >= 2)
1160 return -1;
1161
1162 return fFitRangeOffset[idx];
1163}
1164
1165//--------------------------------------------------------------------------
1166// SetFitRangeOffset (public)
1167//--------------------------------------------------------------------------
1174void PMsrGlobalBlock::SetFitRangeOffset(Int_t ival, UInt_t idx)
1175{
1176 if (idx >= 2)
1177 return;
1178
1179 fFitRangeOffset[idx] = ival;
1180}
1181
1182//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1183// implementation PMsrRunBlock
1184//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1185
1186//--------------------------------------------------------------------------
1187// PMsrRunBlock
1188//--------------------------------------------------------------------------
1193{
1194 fFitType = -1; // undefined fit type
1195 fAlphaParamNo = -1; // undefined alpha parameter number
1196 fBetaParamNo = -1; // undefined beta parameter number
1197 fNormParamNo = -1; // undefined norm parameter number
1198 fBkgFitParamNo = -1; // undefined background parameter number
1199 fLifetimeParamNo = -1; // undefined lifetime parameter number
1200 fLifetimeCorrection = false; // lifetime correction == false by default (used in single histogram musrview)
1201 for (UInt_t i=0; i<2; i++) {
1204 }
1205 for (UInt_t i=0; i<4; i++) {
1206 fBkgRange[i] = -1; // undefined start background range
1207 fDataRange[i] = -1; // undefined start data range
1208 }
1209 fFitRangeInBins = false; // default is that fit range is given in time NOT bins
1210 fFitRange[0] = PMUSR_UNDEFINED; // undefined start fit range
1211 fFitRange[1] = PMUSR_UNDEFINED; // undefined end fit range
1212 fFitRangeOffset[0] = -1; // undefined start fit range offset
1213 fFitRangeOffset[1] = -1; // undefined end fit range offset
1214 fPacking = -1; // undefined packing
1215 fXYDataIndex[0] = -1; // undefined x data index (NonMusr)
1216 fXYDataIndex[1] = -1; // undefined y data index (NonMusr)
1217 fXYDataLabel[0] = TString(""); // undefined x data label (NonMusr)
1218 fXYDataLabel[1] = TString(""); // undefined y data label (NonMusr)
1219}
1220
1221//--------------------------------------------------------------------------
1222// ~PMsrRunBlock
1223//--------------------------------------------------------------------------
1228{
1229 fRunName.clear();
1230 fBeamline.clear();
1231 fInstitute.clear();
1232 fFileFormat.clear();
1233 fForwardHistoNo.clear();
1234 fBackwardHistoNo.clear();
1235 fMap.clear();
1236 fT0.clear();
1237 fParGlobal.clear();
1238 fMapGlobal.clear();
1239}
1240
1241//--------------------------------------------------------------------------
1242// CleanUp (public)
1243//--------------------------------------------------------------------------
1248{
1249 fFitType = -1; // undefined fit type
1250 fAlphaParamNo = -1; // undefined alpha parameter number
1251 fBetaParamNo = -1; // undefined beta parameter number
1252 fNormParamNo = -1; // undefined norm parameter number
1253 fBkgFitParamNo = -1; // undefined background parameter number
1254 fLifetimeParamNo = -1; // undefined lifetime parameter number
1255 fLifetimeCorrection = false; // lifetime correction == false by default (used in single histogram musrview)
1256 fBkgFix[0] = PMUSR_UNDEFINED; // undefined fixed background for forward
1257 fBkgFix[1] = PMUSR_UNDEFINED; // undefined fixed background for backward
1258 for (UInt_t i=0; i<4; i++) {
1259 fBkgRange[i] = -1; // undefined background range
1260 fDataRange[i] = -1; // undefined data range
1261 }
1262 fFitRangeInBins = false; // default is that fit range is given in time NOT bins
1263 fFitRange[0] = PMUSR_UNDEFINED; // undefined start fit range
1264 fFitRange[1] = PMUSR_UNDEFINED; // undefined end fit range
1265 fFitRangeOffset[0] = -1; // undefined start fit range offset
1266 fFitRangeOffset[1] = -1; // undefined end fit range offset
1267 fPacking = -1; // undefined packing
1268 fXYDataIndex[0] = -1; // undefined x data index (NonMusr)
1269 fXYDataIndex[1] = -1; // undefined y data index (NonMusr)
1270 fXYDataLabel[0] = TString(""); // undefined x data label (NonMusr)
1271 fXYDataLabel[1] = TString(""); // undefined y data label (NonMusr)
1272
1273 fRunName.clear();
1274 fBeamline.clear();
1275 fInstitute.clear();
1276 fFileFormat.clear();
1277 fForwardHistoNo.clear();
1278 fBackwardHistoNo.clear();
1279 fMap.clear();
1280 fT0.clear();
1281 for (UInt_t i=0; i<fAddT0.size(); i++)
1282 fAddT0[i].clear();
1283 fAddT0.clear();
1284
1285 fParGlobal.clear();
1286 fMapGlobal.clear();
1287}
1288
1289//--------------------------------------------------------------------------
1290// GetRunName (public)
1291//--------------------------------------------------------------------------
1301TString* PMsrRunBlock::GetRunName(UInt_t idx)
1302{
1303 if (idx>fRunName.size())
1304 return nullptr;
1305
1306 return &fRunName[idx];
1307}
1308
1309//--------------------------------------------------------------------------
1310// SetRunName (public)
1311//--------------------------------------------------------------------------
1318void PMsrRunBlock::SetRunName(TString &str, Int_t idx)
1319{
1320 if (idx == -1) {
1321 fRunName.push_back(str);
1322 return;
1323 }
1324
1325 if (idx >= static_cast<Int_t>(fRunName.size()))
1326 fRunName.resize(idx+1);
1327
1328 fRunName[idx] = str;
1329}
1330
1331//--------------------------------------------------------------------------
1332// GetBeamline (public)
1333//--------------------------------------------------------------------------
1343TString* PMsrRunBlock::GetBeamline(UInt_t idx)
1344{
1345 if (idx>fBeamline.size())
1346 return nullptr;
1347
1348 return &fBeamline[idx];
1349}
1350
1351//--------------------------------------------------------------------------
1352// SetBeamline (public)
1353//--------------------------------------------------------------------------
1360void PMsrRunBlock::SetBeamline(TString &str, Int_t idx)
1361{
1362 if (idx == -1) {
1363 fBeamline.push_back(str);
1364 return;
1365 }
1366
1367 if (idx >= static_cast<Int_t>(fBeamline.size()))
1368 fBeamline.resize(idx+1);
1369
1370 fBeamline[idx] = str;
1371}
1372
1373//--------------------------------------------------------------------------
1374// GetInstitute (public)
1375//--------------------------------------------------------------------------
1385TString* PMsrRunBlock::GetInstitute(UInt_t idx)
1386{
1387 if (idx>fInstitute.size())
1388 return nullptr;
1389
1390 return &fInstitute[idx];
1391}
1392
1393//--------------------------------------------------------------------------
1394// SetInstitute (public)
1395//--------------------------------------------------------------------------
1402void PMsrRunBlock::SetInstitute(TString &str, Int_t idx)
1403{
1404 if (idx == -1) {
1405 fInstitute.push_back(str);
1406 return;
1407 }
1408
1409 if (idx >= static_cast<Int_t>(fInstitute.size()))
1410 fInstitute.resize(idx+1);
1411
1412 fInstitute[idx] = str;
1413}
1414
1415//--------------------------------------------------------------------------
1416// GetFileFormat (public)
1417//--------------------------------------------------------------------------
1428{
1429 if (idx>fFileFormat.size())
1430 return nullptr;
1431
1432 return &fFileFormat[idx];
1433}
1434
1435//--------------------------------------------------------------------------
1436// SetFileFormat (public)
1437//--------------------------------------------------------------------------
1444void PMsrRunBlock::SetFileFormat(TString &str, Int_t idx)
1445{
1446 if (idx == -1) {
1447 fFileFormat.push_back(str);
1448 return;
1449 }
1450
1451 if (idx >= static_cast<Int_t>(fFileFormat.size()))
1452 fFileFormat.resize(idx+1);
1453
1454 fFileFormat[idx] = str;
1455}
1456
1457//--------------------------------------------------------------------------
1458// GetForwardHistoNo (public)
1459//--------------------------------------------------------------------------
1470{
1471 if (fForwardHistoNo.empty())
1472 return -1;
1473
1474 if (idx>fForwardHistoNo.size())
1475 return -1;
1476
1477 return fForwardHistoNo[idx];
1478}
1479
1480//--------------------------------------------------------------------------
1481// SetForwardHistoNo (public)
1482//--------------------------------------------------------------------------
1490void PMsrRunBlock::SetForwardHistoNo(Int_t histoNo, Int_t idx)
1491{
1492 if (idx == -1) { // i.e. append forward histo no
1493 fForwardHistoNo.push_back(histoNo);
1494 } else {
1495 if (idx >= static_cast<Int_t>(fForwardHistoNo.size()))
1496 fForwardHistoNo.resize(idx+1);
1497 fForwardHistoNo[idx] = histoNo;
1498 }
1499}
1500
1501//--------------------------------------------------------------------------
1502// GetBackwardHistoNo (public)
1503//--------------------------------------------------------------------------
1514{
1515 if (fBackwardHistoNo.empty())
1516 return -1;
1517
1518 if (idx>fBackwardHistoNo.size())
1519 return -1;
1520
1521 return fBackwardHistoNo[idx];
1522}
1523
1524//--------------------------------------------------------------------------
1525// SetBackwardHistoNo (public)
1526//--------------------------------------------------------------------------
1534void PMsrRunBlock::SetBackwardHistoNo(Int_t histoNo, Int_t idx)
1535{
1536 if (idx == -1) { // i.e. append forward histo no
1537 fBackwardHistoNo.push_back(histoNo);
1538 } else {
1539 if (idx >= static_cast<Int_t>(fBackwardHistoNo.size()))
1540 fBackwardHistoNo.resize(idx+1);
1541 fBackwardHistoNo[idx] = histoNo;
1542 }
1543}
1544
1545//--------------------------------------------------------------------------
1546// GetMap (public)
1547//--------------------------------------------------------------------------
1557Int_t PMsrRunBlock::GetMap(UInt_t idx)
1558{
1559 if (idx>fMap.size())
1560 return -1;
1561
1562 return fMap[idx];
1563}
1564
1565//--------------------------------------------------------------------------
1566// SetMap (public)
1567//--------------------------------------------------------------------------
1574void PMsrRunBlock::SetMap(Int_t mapVal, Int_t idx)
1575{
1576 if (idx == -1) {
1577 fMap.push_back(mapVal);
1578 return;
1579 }
1580
1581 if (idx >= static_cast<Int_t>(fMap.size()))
1582 fMap.resize(idx+1);
1583
1584 fMap[idx] = mapVal;
1585}
1586
1587//--------------------------------------------------------------------------
1588// GetBkgEstimated (public)
1589//--------------------------------------------------------------------------
1601{
1602 if (idx >= 2)
1603 return PMUSR_UNDEFINED;
1604
1605 return fBkgEstimated[idx];
1606}
1607
1608
1609//--------------------------------------------------------------------------
1610// SetBkgEstimated (public)
1611//--------------------------------------------------------------------------
1618void PMsrRunBlock::SetBkgEstimated(Double_t dval, Int_t idx)
1619{
1620 if (idx >= 2) {
1621 std::cerr << std::endl << ">> PMsrRunBlock::SetBkgEstimated: **WARNING** idx=" << idx << ", only idx=0,1 are sensible.";
1622 std::cerr << std::endl;
1623 return;
1624 }
1625
1626 fBkgEstimated[idx] = dval;
1627}
1628
1629//--------------------------------------------------------------------------
1630// GetBkgFix (public)
1631//--------------------------------------------------------------------------
1641Double_t PMsrRunBlock::GetBkgFix(UInt_t idx)
1642{
1643 if (idx >= 2)
1644 return PMUSR_UNDEFINED;
1645
1646 return fBkgFix[idx];
1647}
1648
1649//--------------------------------------------------------------------------
1650// SetBkgFix (public)
1651//--------------------------------------------------------------------------
1658void PMsrRunBlock::SetBkgFix(Double_t dval, Int_t idx)
1659{
1660 if (idx >= 2) {
1661 std::cerr << std::endl << ">> PMsrRunBlock::SetBkgFix: **WARNING** idx=" << idx << ", only idx=0,1 are sensible.";
1662 std::cerr << std::endl;
1663 return;
1664 }
1665
1666 fBkgFix[idx] = dval;
1667}
1668
1669//--------------------------------------------------------------------------
1670// GetBkgRange (public)
1671//--------------------------------------------------------------------------
1682{
1683 if (idx >= 4) {
1684 return -1;
1685 }
1686
1687 return fBkgRange[idx];
1688}
1689
1690//--------------------------------------------------------------------------
1691// SetBkgRange (public)
1692//--------------------------------------------------------------------------
1699void PMsrRunBlock::SetBkgRange(Int_t ival, Int_t idx)
1700{
1701 if (idx >= 4) {
1702 std::cerr << std::endl << ">> PMsrRunBlock::SetBkgRange: **WARNING** idx=" << idx << ", only idx=0..3 are sensible.";
1703 std::cerr << std::endl;
1704 return;
1705 }
1706
1707 fBkgRange[idx] = ival;
1708}
1709
1710
1711//--------------------------------------------------------------------------
1712// GetDataRange (public)
1713//--------------------------------------------------------------------------
1724{
1725 if (idx >= 4) {
1726 return -1;
1727 }
1728
1729 return fDataRange[idx];
1730}
1731
1732//--------------------------------------------------------------------------
1733// SetDataRange (public)
1734//--------------------------------------------------------------------------
1741void PMsrRunBlock::SetDataRange(Int_t ival, Int_t idx)
1742{
1743 if (idx >= 4) {
1744 std::cerr << std::endl << ">> PMsrRunBlock::SetDataRange: **WARNING** idx=" << idx << ", only idx=0..3 are sensible.";
1745 std::cerr << std::endl;
1746 return;
1747 }
1748
1749 fDataRange[idx] = ival;
1750}
1751
1752//--------------------------------------------------------------------------
1753// GetT0Bin (public)
1754//--------------------------------------------------------------------------
1764Double_t PMsrRunBlock::GetT0Bin(UInt_t idx)
1765{
1766 if (idx >= fT0.size())
1767 return -1;
1768
1769 return fT0[idx];
1770}
1771
1772//--------------------------------------------------------------------------
1773// SetT0Bin (public)
1774//--------------------------------------------------------------------------
1781void PMsrRunBlock::SetT0Bin(Double_t dval, Int_t idx)
1782{
1783 if (idx == -1) {
1784 fT0.push_back(dval);
1785 return;
1786 }
1787
1788 if (idx >= static_cast<Int_t>(fT0.size()))
1789 fT0.resize(idx+1);
1790
1791 fT0[idx] = dval;
1792}
1793
1794//--------------------------------------------------------------------------
1795// GetAddT0BinSize (public)
1796//--------------------------------------------------------------------------
1806Int_t PMsrRunBlock::GetAddT0BinSize(UInt_t addRunIdx)
1807{
1808 if (fAddT0.empty())
1809 return -1;
1810
1811 if (addRunIdx >= fAddT0.size())
1812 return -1;
1813
1814 return fAddT0[addRunIdx].size();
1815}
1816
1817//--------------------------------------------------------------------------
1818// GetAddT0Bin (public)
1819//--------------------------------------------------------------------------
1830Double_t PMsrRunBlock::GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx)
1831{
1832 if (fAddT0.empty())
1833 return -1.0;
1834
1835 if (addRunIdx >= fAddT0.size())
1836 return -1.0;
1837
1838 if (fAddT0[addRunIdx].empty())
1839 return -1.0;
1840
1841 if (histoIdx >= fAddT0[addRunIdx].size())
1842 return -1.0;
1843
1844 return fAddT0[addRunIdx][histoIdx];
1845}
1846
1847//--------------------------------------------------------------------------
1848// SetAddT0Bin (public)
1849//--------------------------------------------------------------------------
1857void PMsrRunBlock::SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx)
1858{
1859 if (addRunIdx >= fAddT0.size())
1860 fAddT0.resize(addRunIdx+1);
1861
1862 if (histoNoIdx >= fAddT0[addRunIdx].size())
1863 fAddT0[addRunIdx].resize(histoNoIdx+1);
1864
1865 fAddT0[addRunIdx][histoNoIdx] = dval;
1866}
1867
1868//--------------------------------------------------------------------------
1869// GetFitRange (public)
1870//--------------------------------------------------------------------------
1880Double_t PMsrRunBlock::GetFitRange(UInt_t idx)
1881{
1882 if (idx >= 2)
1883 return PMUSR_UNDEFINED;
1884
1885 return fFitRange[idx];
1886}
1887
1888//--------------------------------------------------------------------------
1889// SetFitRange (public)
1890//--------------------------------------------------------------------------
1897void PMsrRunBlock::SetFitRange(Double_t dval, UInt_t idx)
1898{
1899 if (idx >= 2)
1900 return;
1901
1902 fFitRange[idx] = dval;
1903}
1904
1905//--------------------------------------------------------------------------
1906// GetFitRangeOffset (public)
1907//--------------------------------------------------------------------------
1918{
1919 if (idx >= 2)
1920 return -1;
1921
1922 return fFitRangeOffset[idx];
1923}
1924
1925//--------------------------------------------------------------------------
1926// SetFitRangeOffset (public)
1927//--------------------------------------------------------------------------
1934void PMsrRunBlock::SetFitRangeOffset(Int_t ival, UInt_t idx)
1935{
1936 if (idx >= 2)
1937 return;
1938
1939 fFitRangeOffset[idx] = ival;
1940}
1941
1942//--------------------------------------------------------------------------
1943// SetParGlobal (public)
1944//--------------------------------------------------------------------------
1951void PMsrRunBlock::SetParGlobal(const TString &str, Int_t ival)
1952{
1953 fParGlobal[str] = ival; // will either create a new entry or overwrite an old one if the key "str" is present
1954 return;
1955}
1956
1957//--------------------------------------------------------------------------
1958// SetMapGlobal (public)
1959//--------------------------------------------------------------------------
1966void PMsrRunBlock::SetMapGlobal(UInt_t idx, Int_t ival)
1967{
1968 if (fMapGlobal.size() != fMap.size())
1969 fMapGlobal.resize(fMap.size(), -1);
1970 if (idx < fMap.size() && fMap[idx] > 0)
1971 fMapGlobal[idx] = ival;
1972 // else do nothing at the moment
1973 return;
1974}
1975
1976//--------------------------------------------------------------------------
1977// SetEstimatedAlpha (public)
1978//--------------------------------------------------------------------------
1985{
1986 fAlpha = dval;
1987}
1988
1989//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1990// implementation PStringNumberList
1991//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1992
1993//--------------------------------------------------------------------------
1994// Parse (public)
1995//--------------------------------------------------------------------------
2007bool PStringNumberList::Parse(std::string &errorMsg, bool ignoreFirstToken)
2008{
2009 bool result=true;
2010 std::vector<std::string> splitVec;
2011 int ival;
2012
2013 // before checking tokens, remove 'forbidden' " - " and " : "
2014 StripSpaces();
2015
2016 // split string into space separated tokens
2017 split(splitVec, fString, is_any_of(" "), token_compress_on);
2018
2019 unsigned int start=0;
2020 if (ignoreFirstToken)
2021 start=1;
2022
2023 for (unsigned int i=start; i<splitVec.size(); i++) {
2024 if (splitVec[i].length() != 0) { // ignore empty tokens
2025 if (splitVec[i].find("-") != std::string::npos) { // check for potential range
2026 std::vector<std::string> subSplitVec;
2027 // split potential nS-nE token
2028 split(subSplitVec, splitVec[i], is_any_of("-"), token_compress_on);
2029
2030 int start=-1, end=-1;
2031 unsigned int count=0;
2032 for (unsigned int j=0; j<subSplitVec.size(); j++) {
2033 if (subSplitVec[j].length() != 0) { // ignore empty tokens
2034 if (!IsNumber(subSplitVec[j])) {
2035 result = false;
2036 } else {
2037 count++;
2038 if (count == 1)
2039 start = atoi(subSplitVec[j].c_str());
2040 else if (count == 2)
2041 end = atoi(subSplitVec[j].c_str());
2042 else
2043 result = false;
2044 }
2045 }
2046 }
2047 if ((start < 0) || (end < 0)) { // check that there is a vaild start and end
2048 errorMsg = "**ERROR** start or end of a range is not valid";
2049 result = false;
2050 }
2051 if (result) { // no error, hence check start and end
2052 if (start > end) {
2053 int swap = end;
2054 std::cerr << "**WARNING** start=" << start << " > end=" << end << ", hence I will swap them" << std::endl;
2055 end = start;
2056 start = swap;
2057 }
2058 for (int j=start; j<=end; j++)
2059 fList.push_back(j);
2060 }
2061 } else if (splitVec[i].find(":") != std::string::npos) { // check for potential sequence
2062 std::vector<std::string> subSplitVec;
2063 // split potential rStart:rEnd:rStep token
2064 split(subSplitVec, splitVec[i], is_any_of(":"), token_compress_on);
2065
2066 int start=-1, end=-1, step=-1;
2067 unsigned int count=0;
2068 for (unsigned int j=0; j<subSplitVec.size(); j++) {
2069 if (subSplitVec[j].length() != 0) { // ignore empty tokens
2070 if (!IsNumber(subSplitVec[j])) {
2071 result = false;
2072 } else {
2073 count++;
2074 if (count == 1)
2075 start = atoi(subSplitVec[j].c_str());
2076 else if (count == 2)
2077 end = atoi(subSplitVec[j].c_str());
2078 else if (count == 3)
2079 step = atoi(subSplitVec[j].c_str());
2080 else
2081 result = false;
2082 }
2083 }
2084 }
2085 if ((start < 0) || (end < 0) || (step < 0)) { // check that there is a vaild start and end
2086 errorMsg = "**ERROR** start, end, or step of a sequence is not valid";
2087 result = false;
2088 }
2089 if (result) { // no error, hence check start and end
2090 if (start > end) {
2091 int swap = end;
2092 std::cerr << "**WARNING** start=" << start << " > end=" << end << ", hence I will swap them" << std::endl;
2093 end = start;
2094 start = swap;
2095 }
2096 for (int j=start; j<=end; j+=step)
2097 fList.push_back(j);
2098 }
2099 } else if (IsNumber(splitVec[i])) {
2100 ival = atoi(splitVec[i].c_str());
2101 fList.push_back(ival);
2102 } else {
2103 errorMsg = "**ERROR** invalid token: " + splitVec[i];
2104 result = false;
2105 }
2106 }
2107 }
2108
2109 return result;
2110}
2111
2112//--------------------------------------------------------------------------
2113// StripSpaces (private)
2114//--------------------------------------------------------------------------
2120{
2121 std::string str=fString;
2122 int pos=-1;
2123
2124 // backward scan
2125 for (int i=str.size(); i>=0; --i) { // check if first space is found
2126 if ((str[i] == ' ') && (pos == -1)) {
2127 pos = i;
2128 } else if ((str[i] == '-') || (str[i] == ':')) { // check for '-' or ':'
2129 if (pos != -1) {
2130 str.erase(i+1, pos-i);
2131 }
2132 } else if (str[i] != ' ') { // anything but different than a space leads to a reset of the pos counter
2133 pos = -1;
2134 }
2135 }
2136 // forward scan
2137 for (unsigned int i=0; i<str.size(); i++) { // check if first space is found
2138 if ((str[i] == ' ') && (pos == -1)) {
2139 pos = i;
2140 } else if ((str[i] == '-') || (str[i] == ':')) { // check for '-' or ':'
2141 if (pos != -1) {
2142 str.erase(pos, i-pos);
2143 i = pos;
2144 }
2145 } else if (str[i] != ' ') { // anything but different than a space leads to a reset of the pos counter
2146 pos = -1;
2147 }
2148 }
2149
2150 fString = str;
2151}
#define RRF_UNIT_MHz
Frequency in MHz (megahertz)
Definition PMusr.h:335
#define PMUSR_UNDEFINED
Definition PMusr.h:172
#define GAMMA_BAR_MUON
Definition PMusr.h:138
std::pair< Int_t, Int_t > PIntPair
Definition PMusr.h:373
#define RRF_UNIT_Mcs
Angular frequency in Mc/s (Mega-cycles per second)
Definition PMusr.h:337
#define RRF_UNIT_G
Equivalent magnetic field in Gauss (G)
Definition PMusr.h:339
#define RRF_UNIT_kHz
Frequency in kHz (kilohertz)
Definition PMusr.h:333
#define RRF_UNIT_T
Equivalent magnetic field in Tesla (T)
Definition PMusr.h:341
#define RRF_UNIT_UNDEF
RRF unit undefined.
Definition PMusr.h:331
std::vector< Double_t > PDoubleVector
Definition PMusr.h:385
#define RRF_FREQ_UNDEF
Definition PMusr.h:349
virtual void SetT0Bin(Double_t dval, Int_t idx=-1)
Definition PMusr.cpp:1021
Bool_t fFitRangeInBins
flag telling if fit range is given in time or in bins
Definition PMusr.h:1086
virtual void SetRRFFreq(Double_t freq, const char *unit)
Definition PMusr.cpp:875
virtual void SetFitRange(Double_t dval, UInt_t idx)
Definition PMusr.cpp:1137
Double_t fFitRange[2]
fit range in (us)
Definition PMusr.h:1087
Int_t fDataRange[4]
data bin range (fit type 0, 1, 2, 4)
Definition PMusr.h:1083
virtual Double_t GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx)
Definition PMusr.cpp:1070
Int_t fFitType
fit type: 0=single histo fit, 1=single histo RRF fit, 2=asymmetry fit, 4=mu^- single histo fit,...
Definition PMusr.h:1082
virtual Int_t GetAddT0BinSize(UInt_t addRunIdx)
Definition PMusr.cpp:1046
std::vector< PDoubleVector > fAddT0
addt0 bins (fit type 0, 1, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2,...
Definition PMusr.h:1085
virtual Double_t GetFitRange(UInt_t idx)
Definition PMusr.cpp:1120
Int_t fFitRangeOffset[2]
if fit range is given in bins it can have the form fit fgb+n0 lgb-n1. This variable holds the n0 and ...
Definition PMusr.h:1088
Bool_t fGlobalPresent
flag showing if a GLOBAL block is present at all.
Definition PMusr.h:1077
Int_t fRRFUnitTag
RRF unit tag.
Definition PMusr.h:1079
virtual Int_t GetDataRange(UInt_t idx)
Definition PMusr.cpp:964
virtual void SetDataRange(Int_t ival, Int_t idx)
Definition PMusr.cpp:981
Int_t fRRFPacking
RRF packing.
Definition PMusr.h:1081
virtual TString GetRRFUnit()
Definition PMusr.cpp:903
Double_t fRRFPhase
RRF phase in (°)
Definition PMusr.h:1080
PDoubleVector fT0
t0 bins (fit type 0, 1, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2, 4 -> f0,...
Definition PMusr.h:1084
Int_t fPacking
packing/rebinning
Definition PMusr.h:1089
virtual void SetRRFPacking(Int_t pack)
Definition PMusr.cpp:942
Double_t fRRFFreq
RRF frequency given in units of (MHz, Mc, T)
Definition PMusr.h:1078
virtual void SetFitRangeOffset(Int_t ival, UInt_t idx)
Definition PMusr.cpp:1174
virtual void SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx)
Definition PMusr.cpp:1097
virtual Int_t GetFitRangeOffset(UInt_t idx)
Definition PMusr.cpp:1157
virtual Double_t GetT0Bin(UInt_t idx=0)
Definition PMusr.cpp:1004
virtual Double_t GetRRFFreq(const char *unit)
Definition PMusr.cpp:831
PStringVector fInstitute
e.g. psi, ral, triumf (former: run format)
Definition PMusr.h:1202
virtual PIntVector * GetMap()
Definition PMusr.h:1138
Int_t fBkgRange[4]
background bin range (fit type 0, 2, 4)
Definition PMusr.h:1216
Int_t fNormParamNo
N0 parameter number (fit type 0)
Definition PMusr.h:1207
virtual TString * GetInstitute(UInt_t idx=0)
Definition PMusr.cpp:1385
Double_t fAlpha
estimated alpha value from F/B counts
Definition PMusr.h:1223
Double_t fBkgEstimated[2]
keeps estimated background values (if present)
Definition PMusr.h:1214
Int_t fAlphaParamNo
alpha parameter number (fit type 2, 4)
Definition PMusr.h:1205
virtual Int_t GetDataRange(UInt_t idx)
Definition PMusr.cpp:1723
virtual void SetFitRangeOffset(Int_t ival, UInt_t idx)
Definition PMusr.cpp:1934
virtual TString * GetFileFormat(UInt_t idx=0)
Definition PMusr.cpp:1427
virtual void SetBeamline(TString &str, Int_t idx=-1)
Definition PMusr.cpp:1360
virtual void SetBkgFix(Double_t dval, Int_t idx)
Definition PMusr.cpp:1658
virtual TString * GetBeamline(UInt_t idx=0)
Definition PMusr.cpp:1343
Int_t fDataRange[4]
data bin range (fit type 0, 2, 4)
Definition PMusr.h:1217
virtual Double_t GetFitRange(UInt_t idx)
Definition PMusr.cpp:1880
virtual Int_t GetAddT0BinSize(UInt_t addRunIdx)
Definition PMusr.cpp:1806
Int_t fLifetimeParamNo
muon lifetime parameter number (fit type 0)
Definition PMusr.h:1209
virtual Double_t GetBkgEstimated(UInt_t idx)
Definition PMusr.cpp:1600
virtual void SetFitRange(Double_t dval, UInt_t idx)
Definition PMusr.cpp:1897
virtual void SetBkgEstimated(Double_t dval, Int_t idx)
Definition PMusr.cpp:1618
PDoubleVector fT0
t0 bins (fit type 0, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2, 4 -> f0,...
Definition PMusr.h:1218
Int_t fBkgFitParamNo
background fit parameter number (fit type 0)
Definition PMusr.h:1208
virtual void CleanUp()
Definition PMusr.cpp:1247
virtual void SetFileFormat(TString &str, Int_t idx=-1)
Definition PMusr.cpp:1444
virtual void SetEstimatedAlpha(Double_t dval)
Definition PMusr.cpp:1984
virtual Double_t GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx)
Definition PMusr.cpp:1830
PStringVector fBeamline
e.g. mue4, mue1, pim3, emu, m15, ... (former: run type)
Definition PMusr.h:1201
Int_t fBetaParamNo
beta parameter number (fit type 2, 4)
Definition PMusr.h:1206
virtual TString * GetRunName(UInt_t idx=0)
Definition PMusr.cpp:1301
Bool_t fLifetimeCorrection
lifetime correction flag for viewing (fit type 0)
Definition PMusr.h:1210
virtual void SetMap(Int_t mapVal, Int_t idx=-1)
Definition PMusr.cpp:1574
TString fXYDataLabel[2]
used to get the indices via labels when using db-files (fit type 8)
Definition PMusr.h:1227
PStringVector fFileFormat
e.g. root, nexus, psi-bin, mud, ascii, db
Definition PMusr.h:1203
virtual void SetParGlobal(const TString &str, Int_t ival)
Definition PMusr.cpp:1951
PStringVector fRunName
name of the run file
Definition PMusr.h:1200
virtual void SetMapGlobal(UInt_t idx, Int_t ival)
Definition PMusr.cpp:1966
PIntVector fMapGlobal
here is stored if the maps used in the RUN block are global or not
Definition PMusr.h:1238
virtual Double_t GetBkgFix(UInt_t idx)
Definition PMusr.cpp:1641
virtual void SetT0Bin(Double_t dval, Int_t idx=-1)
Definition PMusr.cpp:1781
Int_t fXYDataIndex[2]
used to get the data indices when using db-files (fit type 8)
Definition PMusr.h:1226
virtual Int_t GetForwardHistoNo(UInt_t idx=0)
Definition PMusr.cpp:1469
Bool_t fFitRangeInBins
flag telling if fit range is given in time or in bins
Definition PMusr.h:1220
virtual Int_t GetFitRangeOffset(UInt_t idx)
Definition PMusr.cpp:1917
virtual void SetBackwardHistoNo(Int_t histoNo, Int_t idx=-1)
Definition PMusr.cpp:1534
virtual void SetDataRange(Int_t ival, Int_t idx)
Definition PMusr.cpp:1741
virtual Int_t GetBkgRange(UInt_t idx)
Definition PMusr.cpp:1681
virtual Int_t GetBackwardHistoNo(UInt_t idx=0)
Definition PMusr.cpp:1513
virtual void SetRunName(TString &str, Int_t idx=-1)
Definition PMusr.cpp:1318
std::map< TString, Int_t > fParGlobal
here is stored if the parameters used in the RUN block are global or not
Definition PMusr.h:1237
PIntVector fBackwardHistoNo
backward histogram number (fit type 2, 4)
Definition PMusr.h:1213
Double_t fFitRange[2]
fit range in (us)
Definition PMusr.h:1221
Double_t fBkgFix[2]
fixed background in (1/ns) (fit type 0, 2, 4)
Definition PMusr.h:1215
virtual ~PMsrRunBlock()
Definition PMusr.cpp:1227
virtual void SetBkgRange(Int_t ival, Int_t idx)
Definition PMusr.cpp:1699
PIntVector fMap
map vector needed to switch parameters for different runs within a single theory
Definition PMusr.h:1211
Int_t fFitRangeOffset[2]
if fit range is given in bins it can have the form fit fgb+n0 lgb-n1. This variable holds the n0 and ...
Definition PMusr.h:1222
virtual void SetInstitute(TString &str, Int_t idx=-1)
Definition PMusr.cpp:1402
Int_t fFitType
fit type: 0=single histo fit, 2=asymmetry fit, 4=mu^- single histo fit, 8=non muSR fit
Definition PMusr.h:1204
virtual Double_t GetT0Bin(UInt_t idx=0)
Definition PMusr.cpp:1764
PIntVector fForwardHistoNo
forward histogram number (fit type 0, 2, 4)
Definition PMusr.h:1212
virtual void SetForwardHistoNo(Int_t histoNo, Int_t idx=-1)
Definition PMusr.cpp:1490
Int_t fPacking
packing/rebinning
Definition PMusr.h:1224
virtual void SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx)
Definition PMusr.cpp:1857
std::vector< PDoubleVector > fAddT0
t0 bins for addrun's
Definition PMusr.h:1219
std::vector< PDoubleVector > fData
vector of all data
Definition PMusr.h:615
virtual void AppendSubErrData(const UInt_t idx, const Double_t dval)
Definition PMusr.cpp:229
PStringVector fLabels
vector of all labels (used for x-, y-axis title in view)
Definition PMusr.h:613
virtual ~PNonMusrRawRunData()
Definition PMusr.cpp:139
Bool_t fFromAscii
if true: data file was an ascii input file, otherwise it is a db/dat input file
Definition PMusr.h:612
virtual void AppendSubData(const UInt_t idx, const Double_t dval)
Definition PMusr.cpp:209
PStringVector fDataTags
vector of all data tags
Definition PMusr.h:614
virtual void SetSize(const UInt_t size)
Definition PMusr.cpp:162
std::vector< PDoubleVector > fErrData
vector of all data errors
Definition PMusr.h:616
virtual void SetLabel(const UInt_t idx, const TString str)
Definition PMusr.cpp:189
virtual void Clear()
Clears all data from this histogram set.
Definition PMusr.cpp:261
Int_t fLastGoodBin
keeps the last good bin of the data set
Definition PMusr.h:697
Int_t fFirstBkgBin
keeps the first background bin of the data set
Definition PMusr.h:698
Double_t fTimeZeroBin
keeps the time zero bin
Definition PMusr.h:694
TString fTitle
histogram title.
Definition PMusr.h:691
PDoubleVector fData
keeps the histogram data
Definition PMusr.h:700
Int_t fLastBkgBin
keeps the last background bin of the data set
Definition PMusr.h:699
Int_t fHistoNo
corresponds to the histogram number in the data file
Definition PMusr.h:693
Int_t fFirstGoodBin
keeps the first good bin of the data set
Definition PMusr.h:696
Double_t fTimeZeroBinEstimated
keeps the estimated time zero bin
Definition PMusr.h:695
TString fName
keeps the histogram name.
Definition PMusr.h:692
virtual PRawRunDataSet * GetSet(UInt_t idx)
Definition PMusr.cpp:319
virtual PRawRunDataSet * Get(UInt_t histoNo)
Definition PMusr.cpp:341
virtual Double_t GetT0BinEstimated(UInt_t histoNo)
Definition PMusr.cpp:436
std::vector< PRawRunDataSet > fDataVec
Definition PMusr.h:804
virtual PIntPair GetGoodDataBin(UInt_t histoNo)
Definition PMusr.cpp:489
virtual Double_t GetT0Bin(UInt_t histoNo)
Definition PMusr.cpp:410
virtual PRawRunDataSet * operator[](UInt_t histoNo)
Definition PMusr.cpp:367
virtual PDoubleVector * GetData(UInt_t histoNo)
Definition PMusr.cpp:384
virtual Bool_t IsPresent(UInt_t histoNo)
Definition PMusr.cpp:291
virtual PIntPair GetBkgBin(UInt_t histoNo)
Definition PMusr.cpp:462
virtual void Set(PRawRunDataSet dataSet, Int_t idx=-1)
Definition PMusr.cpp:515
TString fRunTitle
run title
Definition PMusr.h:941
virtual PRawRunDataSet * GetDataSet(const UInt_t idx, Bool_t wantHistoNo=true)
Definition PMusr.cpp:716
Double_t fMuonBeamMomentum
given in MeV/c, for LEM this is the momentum of the secondary beamline and NOT the momentum of the lo...
Definition PMusr.h:937
TString fVersion
keeps the version information of the data file
Definition PMusr.h:926
TString fSetup
description of the setup of this run
Definition PMusr.h:942
TString fStartTime
start time of the run
Definition PMusr.h:943
virtual void SetRingAnode(const UInt_t idx, const Double_t dval)
Definition PMusr.cpp:750
Int_t fRunNumber
run number
Definition PMusr.h:940
TString fStartDate
start date of the run
Definition PMusr.h:944
TString fFileName
keeps the name of the original data file
Definition PMusr.h:931
PRawRunDataVector fData
keeps the histos together with the histo related properties such as T0, first good bin,...
Definition PMusr.h:963
time_t fStopDateTimeSec
stop run given as time_t object
Definition PMusr.h:948
TString fStopTime
stop time of the run
Definition PMusr.h:946
TString fSample
description of the sample
Definition PMusr.h:950
virtual const PDoubleVector GetRingAnode()
Definition PMusr.h:866
TString fComment
keeps the data file comment
Definition PMusr.h:930
virtual const Double_t GetTempError(const UInt_t idx)
Definition PMusr.cpp:671
TString fBeamline
keeps the name of the be beamline, e.g. muE4, piM3.1, ...
Definition PMusr.h:933
PDoublePairVector fTemp
measured temperatures and standard deviations during the run
Definition PMusr.h:954
PIntVector fRedGreenOffset
keeps the Red/Green offsets
Definition PMusr.h:959
TString fMagnet
name of the sample magnet
Definition PMusr.h:952
virtual const Bool_t DeadTimeCorrectionReady()
Definition PMusr.cpp:734
TString fRunName
name of the run as found in the msr-file
Definition PMusr.h:939
Int_t fNumberOfGoodFrames
needed to correct dead times at pulsed sources
Definition PMusr.h:961
virtual void SetTemperature(const UInt_t idx, const Double_t temp, const Double_t errTemp)
Definition PMusr.cpp:767
virtual const time_t CalcStopDateTime(bool &ok)
Definition PMusr.cpp:621
virtual ~PRawRunData()
Definition PMusr.cpp:578
Double_t fEnergy
implantation energy of the muon
Definition PMusr.h:955
TString fGenericValidatorURL
keeps the generic validator MusrRoot URL
Definition PMusr.h:927
TString fGenerator
keeps the data file generator name
Definition PMusr.h:929
Double_t fField
magnetic field value in (G)
Definition PMusr.h:953
time_t fStartDateTimeSec
start run given as time_t object
Definition PMusr.h:945
virtual void SetTempError(const UInt_t idx, const Double_t errTemp)
Definition PMusr.cpp:785
std::vector< float > fDeadTimeParam
dead time parameter vector needed for pulsed sources
Definition PMusr.h:960
Double_t fTimeResolution
time resolution of the run in (ns)
Definition PMusr.h:958
Double_t fTransport
LEM transport settings (Moderator HV)
Definition PMusr.h:956
TString fCryo
name of the cryo
Definition PMusr.h:949
TString fMuonSource
keeps the type of muon source, e.g. continous surface beam, pulsed beam, low energy muon beam
Definition PMusr.h:935
Double_t fMuonSpinAngle
gives the muon spin angle in degrees (reference frame depends on the instrument)
Definition PMusr.h:938
TString fMuonSpecies
positive muon or negative muon
Definition PMusr.h:936
virtual const PDoublePairVector * GetTemperature() const
Definition PMusr.h:861
PDoubleVector fRingAnode
LEM ring anode HVs (L,R[,T,B])
Definition PMusr.h:957
TString fInstrument
keeps the name of the instrument, e.g. LEM, GPS, MUSR, EMU, ...
Definition PMusr.h:934
TString fLaboratory
keeps the name of the laboratory, e.g. PSI, ISIS, TRIUMF, JPARC
Definition PMusr.h:932
TString fStopDate
stop date of the run
Definition PMusr.h:947
virtual const time_t CalcStartDateTime(bool &ok)
Definition PMusr.cpp:595
TString fSpecificValidatorURL
keeps the instrument specific validator MusrRoot URL
Definition PMusr.h:928
TString fOrientation
description of the orientation
Definition PMusr.h:951
Double_t fTheoryTimeStep
time step of the theory, i.e. the time length of a bin
Definition PMusr.h:529
Double_t fTheoryTimeStart
start time of the theory
Definition PMusr.h:528
PDoubleVector fXTheory
x-axis vector. Only used for non-muSR
Definition PMusr.h:530
virtual ~PRunData()
Definition PMusr.cpp:69
PDoubleVector fX
x-axis vector. Only used for non-muSR
Definition PMusr.h:524
PDoubleVector fValue
data vector
Definition PMusr.h:525
Double_t fDataTimeStart
start time for the data set
Definition PMusr.h:522
PRunData()
Definition PMusr.cpp:50
PDoubleVector fTheory
theory vector
Definition PMusr.h:531
virtual void ReplaceTheory(const PDoubleVector &theo)
Definition PMusr.cpp:103
PDoubleVector fError
data error vector
Definition PMusr.h:526
Double_t fDataTimeStep
time step for the data set, i.e. the time length of a bin
Definition PMusr.h:523
virtual void SetTheoryValue(UInt_t i, Double_t dval)
Definition PMusr.cpp:87
std::string fString
Definition PMusr.h:1425
virtual void StripSpaces()
Definition PMusr.cpp:2119
PUIntVector fList
Definition PMusr.h:1427
virtual bool IsNumber(std::string &str)
Definition PMusr.h:1429
virtual bool Parse(std::string &errorMsg, bool ignoreFirstToken=false)
Definition PMusr.cpp:2007