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// GetDeadTimeParam (public)
705//--------------------------------------------------------------------------
720const Double_t PRawRunData::GetDeadTimeParam(const UInt_t histoNo)
721{
722 UInt_t idx = histoNo - 1;
723
724 if (fNoOfHistosPerPeriod > 0) // Red/Green (period) data
725 idx = (histoNo / PERIOD_HISTO_OFFSET) * fNoOfHistosPerPeriod + (histoNo % PERIOD_HISTO_OFFSET) - 1;
726
727 if (idx >= fDeadTimeParam.size()) {
728 std::cerr << std::endl << ">> PRawRunData::GetDeadTimeParam: **WARNING** histoNo=" << histoNo << " maps onto idx=" << idx;
729 std::cerr << " which is out of range [0," << fDeadTimeParam.size() << "[. Will not dead time correct this histogram.";
730 std::cerr << std::endl;
731 return 0.0;
732 }
733
734 return fDeadTimeParam[idx];
735}
736
737//--------------------------------------------------------------------------
738// GetDataSet (public)
739//--------------------------------------------------------------------------
750PRawRunDataSet* PRawRunData::GetDataSet(const UInt_t idx, Bool_t wantHistoNo)
751{
752 if (wantHistoNo)
753 return fData[idx];
754 else
755 return fData.GetSet(idx);
756}
757
758//--------------------------------------------------------------------------
759// DeadTimeCorrectionReady (public)
760//--------------------------------------------------------------------------
769{
770 if ((fNumberOfGoodFrames > 0) && (fDeadTimeParam.size() > 0))
771 return true;
772 return false;
773}
774
775//--------------------------------------------------------------------------
776// SetRingAnode (public)
777//--------------------------------------------------------------------------
784void PRawRunData::SetRingAnode(const UInt_t idx, const Double_t dval)
785{
786 if (idx >= fRingAnode.size())
787 fRingAnode.resize(idx+1);
788 fRingAnode[idx] = dval;
789}
790
791//--------------------------------------------------------------------------
792// SetTemperature (public)
793//--------------------------------------------------------------------------
801void PRawRunData::SetTemperature(const UInt_t idx, const Double_t temp, const Double_t errTemp)
802{
803 if (idx >= fTemp.size()) {
804 fTemp.resize(idx+1);
805 }
806 fTemp[idx].first = temp;
807 fTemp[idx].second = errTemp;
808}
809
810//--------------------------------------------------------------------------
811// SetTempError (public)
812//--------------------------------------------------------------------------
819void PRawRunData::SetTempError(const UInt_t idx, const Double_t errTemp)
820{
821 if (idx >= fTemp.size()) {
822 fTemp.resize(idx+1);
823 }
824 fTemp[idx].first = PMUSR_UNDEFINED;
825 fTemp[idx].second = errTemp;
826}
827
828//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
829// implementation PMsrGlobalBlock
830//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
831
832//--------------------------------------------------------------------------
833// PMsrGlobalBlock
834//--------------------------------------------------------------------------
839{
840 fGlobalPresent = false;
841 fRRFFreq = RRF_FREQ_UNDEF; // rotating reference frequency in units given by fRRFUnitTag. Only needed for fittype 1
842 fRRFUnitTag = RRF_UNIT_UNDEF; // RRF unit tag. Default: undefined
843 fRRFPhase = 0.0;
844 fRRFPacking = -1; // undefined RRF packing/rebinning
845 fFitType = -1; // undefined fit type
846 for (UInt_t i=0; i<4; i++) {
847 fDataRange[i] = -1; // undefined data bin range
848 }
849 fFitRangeInBins = false; // default is that fit range is given in time NOT bins
850 fFitRange[0] = PMUSR_UNDEFINED; // undefined start fit range
851 fFitRange[1] = PMUSR_UNDEFINED; // undefined end fit range
852 fFitRangeOffset[0] = -1; // undefined start fit range offset
853 fFitRangeOffset[1] = -1; // undefined end fit range offset
854 fPacking = -1; // undefined packing/rebinning
855}
856
857//--------------------------------------------------------------------------
858// GetRRFFreq (public)
859//--------------------------------------------------------------------------
865Double_t PMsrGlobalBlock::GetRRFFreq(const char *unit)
866{
867 Double_t freq = 0.0;
868
869 // check that the units given make sense
870 TString unitStr = unit;
871 Int_t unitTag = RRF_UNIT_UNDEF;
872 if (!unitStr.CompareTo("MHz", TString::kIgnoreCase))
873 unitTag = RRF_UNIT_MHz;
874 else if (!unitStr.CompareTo("Mc", TString::kIgnoreCase))
875 unitTag = RRF_UNIT_Mcs;
876 else if (!unitStr.CompareTo("T", TString::kIgnoreCase))
877 unitTag = RRF_UNIT_T;
878 else
879 return RRF_FREQ_UNDEF;
880
881 // calc the conversion factor
882 if (unitTag == fRRFUnitTag)
883 freq = fRRFFreq;
884 else if ((unitTag == RRF_UNIT_MHz) && (fRRFUnitTag == RRF_UNIT_Mcs))
885 freq = fRRFFreq/TMath::TwoPi();
886 else if ((unitTag == RRF_UNIT_MHz) && (fRRFUnitTag == RRF_UNIT_T))
887 freq = fRRFFreq*1e4*GAMMA_BAR_MUON; // 1e4 need for T -> G since GAMMA_BAR_MUON is given in MHz/G
888 else if ((unitTag == RRF_UNIT_Mcs) && (fRRFUnitTag == RRF_UNIT_MHz))
889 freq = fRRFFreq*TMath::TwoPi();
890 else if ((unitTag == RRF_UNIT_Mcs) && (fRRFUnitTag == RRF_UNIT_T))
891 freq = fRRFFreq*1e4*TMath::TwoPi()*GAMMA_BAR_MUON; // 1e4 need for T -> G since GAMMA_BAR_MUON is given in MHz/G
892 else if ((unitTag == RRF_UNIT_T) && (fRRFUnitTag == RRF_UNIT_MHz))
893 freq = fRRFFreq/GAMMA_BAR_MUON*1e-4; // 1e-4 need for G -> T since GAMMA_BAR_MUON is given in MHz/G
894 else if ((unitTag == RRF_UNIT_T) && (fRRFUnitTag == RRF_UNIT_Mcs))
895 freq = fRRFFreq/(TMath::TwoPi()*GAMMA_BAR_MUON)*1e-4; // 1e-4 need for G -> T since GAMMA_BAR_MUON is given in MHz/G
896
897 return freq;
898}
899
900//--------------------------------------------------------------------------
901// SetRRFFreq (public)
902//--------------------------------------------------------------------------
909void PMsrGlobalBlock::SetRRFFreq(Double_t freq, const char *unit)
910{
911 // check that the units given make sense
912 TString unitStr = unit;
913 Int_t unitTag = RRF_UNIT_UNDEF;
914 if (!unitStr.CompareTo("MHz", TString::kIgnoreCase))
915 unitTag = RRF_UNIT_MHz;
916 else if (!unitStr.CompareTo("Mc", TString::kIgnoreCase))
917 unitTag = RRF_UNIT_Mcs;
918 else if (!unitStr.CompareTo("T", TString::kIgnoreCase))
919 unitTag = RRF_UNIT_T;
920 else {
921 std::cerr << std::endl << ">> PMsrGlobalBlock::SetRRFFreq: **ERROR** found undefined RRF unit '" << unit << "'!";
922 std::cerr << std::endl << ">> Will set RRF frequency to 0.0." << std::endl;
923 fRRFFreq = 0.0;
925 }
926
927 fRRFFreq = freq;
928 fRRFUnitTag = unitTag;
929}
930
931//--------------------------------------------------------------------------
932// GetRRFUnit (public)
933//--------------------------------------------------------------------------
938{
939 TString unit;
940
941 switch (fRRFUnitTag) {
942 case RRF_UNIT_UNDEF:
943 unit = TString("??");
944 break;
945 case RRF_UNIT_kHz:
946 unit = TString("kHz");
947 break;
948 case RRF_UNIT_MHz:
949 unit = TString("MHz");
950 break;
951 case RRF_UNIT_Mcs:
952 unit = TString("Mc");
953 break;
954 case RRF_UNIT_G:
955 unit = TString("G");
956 break;
957 case RRF_UNIT_T:
958 unit = TString("T");
959 break;
960 default:
961 unit = TString("??");
962 break;
963 }
964
965 return unit;
966}
967
968//--------------------------------------------------------------------------
969// SetRRFPacking (public)
970//--------------------------------------------------------------------------
977{
978 if (pack <= 0) {
979 std::cerr << std::endl << "PMsrGlobalBlock::SetRRFPacking: **WARNING** found RRF packing <= 0. Likely doesn't make any sense." << std::endl;
980 fRRFPacking = -1; // set to undefined
981 }
982
983 fRRFPacking = pack;
984}
985
986//--------------------------------------------------------------------------
987// GetDataRange (public)
988//--------------------------------------------------------------------------
999{
1000 if (idx >= 4)
1001 return -1;
1002
1003 return fDataRange[idx];
1004}
1005
1006//--------------------------------------------------------------------------
1007// SetDataRange (public)
1008//--------------------------------------------------------------------------
1015void PMsrGlobalBlock::SetDataRange(Int_t ival, Int_t idx)
1016{
1017 if (idx >= 4) {
1018 std::cerr << std::endl << ">> PMsrGlobalBlock::SetDataRange: **WARNING** idx=" << idx << ", only idx=0..3 are sensible.";
1019 std::cerr << std::endl;
1020 return;
1021 }
1022
1023 fDataRange[idx] = ival;
1024}
1025
1026//--------------------------------------------------------------------------
1027// GetT0Bin (public)
1028//--------------------------------------------------------------------------
1038Double_t PMsrGlobalBlock::GetT0Bin(UInt_t idx)
1039{
1040 if (idx >= fT0.size())
1041 return -1;
1042
1043 return fT0[idx];
1044}
1045
1046//--------------------------------------------------------------------------
1047// SetT0Bin (public)
1048//--------------------------------------------------------------------------
1055void PMsrGlobalBlock::SetT0Bin(Double_t dval, Int_t idx)
1056{
1057 if (idx == -1) {
1058 fT0.push_back(dval);
1059 return;
1060 }
1061
1062 if (idx >= static_cast<Int_t>(fT0.size()))
1063 fT0.resize(idx+1);
1064
1065 fT0[idx] = dval;
1066}
1067
1068//--------------------------------------------------------------------------
1069// GetAddT0BinSize (public)
1070//--------------------------------------------------------------------------
1081{
1082 if (fAddT0.empty())
1083 return -1;
1084
1085 if (addRunIdx >= fAddT0.size())
1086 return -1;
1087
1088 return fAddT0[addRunIdx].size();
1089}
1090
1091//--------------------------------------------------------------------------
1092// GetAddT0Bin (public)
1093//--------------------------------------------------------------------------
1104Double_t PMsrGlobalBlock::GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx)
1105{
1106 if (fAddT0.empty())
1107 return -1.0;
1108
1109 if (addRunIdx >= fAddT0.size())
1110 return -1.0;
1111
1112 if (fAddT0[addRunIdx].empty())
1113 return -1.0;
1114
1115 if (histoIdx >= fAddT0[addRunIdx].size())
1116 return -1.0;
1117
1118 return fAddT0[addRunIdx][histoIdx];
1119}
1120
1121//--------------------------------------------------------------------------
1122// SetAddT0Bin (public)
1123//--------------------------------------------------------------------------
1131void PMsrGlobalBlock::SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx)
1132{
1133 if (addRunIdx >= fAddT0.size())
1134 fAddT0.resize(addRunIdx+1);
1135
1136 if (histoNoIdx >= fAddT0[addRunIdx].size())
1137 fAddT0[addRunIdx].resize(histoNoIdx+1);
1138
1139 fAddT0[addRunIdx][histoNoIdx] = dval;
1140}
1141
1142//--------------------------------------------------------------------------
1143// GetFitRange (public)
1144//--------------------------------------------------------------------------
1155{
1156 if (idx >= 2)
1157 return PMUSR_UNDEFINED;
1158
1159 return fFitRange[idx];
1160}
1161
1162//--------------------------------------------------------------------------
1163// SetFitRange (public)
1164//--------------------------------------------------------------------------
1171void PMsrGlobalBlock::SetFitRange(Double_t dval, UInt_t idx)
1172{
1173 if (idx >= 2)
1174 return;
1175
1176 fFitRange[idx] = dval;
1177}
1178
1179//--------------------------------------------------------------------------
1180// GetFitRangeOffset (public)
1181//--------------------------------------------------------------------------
1192{
1193 if (idx >= 2)
1194 return -1;
1195
1196 return fFitRangeOffset[idx];
1197}
1198
1199//--------------------------------------------------------------------------
1200// SetFitRangeOffset (public)
1201//--------------------------------------------------------------------------
1208void PMsrGlobalBlock::SetFitRangeOffset(Int_t ival, UInt_t idx)
1209{
1210 if (idx >= 2)
1211 return;
1212
1213 fFitRangeOffset[idx] = ival;
1214}
1215
1216//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1217// implementation PMsrRunBlock
1218//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1219
1220//--------------------------------------------------------------------------
1221// PMsrRunBlock
1222//--------------------------------------------------------------------------
1227{
1228 fFitType = -1; // undefined fit type
1229 fAlphaParamNo = -1; // undefined alpha parameter number
1230 fBetaParamNo = -1; // undefined beta parameter number
1231 fNormParamNo = -1; // undefined norm parameter number
1232 fBkgFitParamNo = -1; // undefined background parameter number
1233 fLifetimeParamNo = -1; // undefined lifetime parameter number
1234 fLifetimeCorrection = false; // lifetime correction == false by default (used in single histogram musrview)
1235 for (UInt_t i=0; i<2; i++) {
1238 }
1239 for (UInt_t i=0; i<4; i++) {
1240 fBkgRange[i] = -1; // undefined start background range
1241 fDataRange[i] = -1; // undefined start data range
1242 }
1243 fFitRangeInBins = false; // default is that fit range is given in time NOT bins
1244 fFitRange[0] = PMUSR_UNDEFINED; // undefined start fit range
1245 fFitRange[1] = PMUSR_UNDEFINED; // undefined end fit range
1246 fFitRangeOffset[0] = -1; // undefined start fit range offset
1247 fFitRangeOffset[1] = -1; // undefined end fit range offset
1248 fPacking = -1; // undefined packing
1249 fXYDataIndex[0] = -1; // undefined x data index (NonMusr)
1250 fXYDataIndex[1] = -1; // undefined y data index (NonMusr)
1251 fXYDataLabel[0] = TString(""); // undefined x data label (NonMusr)
1252 fXYDataLabel[1] = TString(""); // undefined y data label (NonMusr)
1253}
1254
1255//--------------------------------------------------------------------------
1256// ~PMsrRunBlock
1257//--------------------------------------------------------------------------
1262{
1263 fRunName.clear();
1264 fBeamline.clear();
1265 fInstitute.clear();
1266 fFileFormat.clear();
1267 fForwardHistoNo.clear();
1268 fBackwardHistoNo.clear();
1269 fMap.clear();
1270 fT0.clear();
1271 fParGlobal.clear();
1272 fMapGlobal.clear();
1273}
1274
1275//--------------------------------------------------------------------------
1276// CleanUp (public)
1277//--------------------------------------------------------------------------
1282{
1283 fFitType = -1; // undefined fit type
1284 fAlphaParamNo = -1; // undefined alpha parameter number
1285 fBetaParamNo = -1; // undefined beta parameter number
1286 fNormParamNo = -1; // undefined norm parameter number
1287 fBkgFitParamNo = -1; // undefined background parameter number
1288 fLifetimeParamNo = -1; // undefined lifetime parameter number
1289 fLifetimeCorrection = false; // lifetime correction == false by default (used in single histogram musrview)
1290 fBkgFix[0] = PMUSR_UNDEFINED; // undefined fixed background for forward
1291 fBkgFix[1] = PMUSR_UNDEFINED; // undefined fixed background for backward
1292 for (UInt_t i=0; i<4; i++) {
1293 fBkgRange[i] = -1; // undefined background range
1294 fDataRange[i] = -1; // undefined data range
1295 }
1296 fFitRangeInBins = false; // default is that fit range is given in time NOT bins
1297 fFitRange[0] = PMUSR_UNDEFINED; // undefined start fit range
1298 fFitRange[1] = PMUSR_UNDEFINED; // undefined end fit range
1299 fFitRangeOffset[0] = -1; // undefined start fit range offset
1300 fFitRangeOffset[1] = -1; // undefined end fit range offset
1301 fPacking = -1; // undefined packing
1302 fXYDataIndex[0] = -1; // undefined x data index (NonMusr)
1303 fXYDataIndex[1] = -1; // undefined y data index (NonMusr)
1304 fXYDataLabel[0] = TString(""); // undefined x data label (NonMusr)
1305 fXYDataLabel[1] = TString(""); // undefined y data label (NonMusr)
1306
1307 fRunName.clear();
1308 fBeamline.clear();
1309 fInstitute.clear();
1310 fFileFormat.clear();
1311 fForwardHistoNo.clear();
1312 fBackwardHistoNo.clear();
1313 fMap.clear();
1314 fT0.clear();
1315 for (UInt_t i=0; i<fAddT0.size(); i++)
1316 fAddT0[i].clear();
1317 fAddT0.clear();
1318
1319 fParGlobal.clear();
1320 fMapGlobal.clear();
1321}
1322
1323//--------------------------------------------------------------------------
1324// GetRunName (public)
1325//--------------------------------------------------------------------------
1335TString* PMsrRunBlock::GetRunName(UInt_t idx)
1336{
1337 if (idx>fRunName.size())
1338 return nullptr;
1339
1340 return &fRunName[idx];
1341}
1342
1343//--------------------------------------------------------------------------
1344// SetRunName (public)
1345//--------------------------------------------------------------------------
1352void PMsrRunBlock::SetRunName(TString &str, Int_t idx)
1353{
1354 if (idx == -1) {
1355 fRunName.push_back(str);
1356 return;
1357 }
1358
1359 if (idx >= static_cast<Int_t>(fRunName.size()))
1360 fRunName.resize(idx+1);
1361
1362 fRunName[idx] = str;
1363}
1364
1365//--------------------------------------------------------------------------
1366// GetBeamline (public)
1367//--------------------------------------------------------------------------
1377TString* PMsrRunBlock::GetBeamline(UInt_t idx)
1378{
1379 if (idx>fBeamline.size())
1380 return nullptr;
1381
1382 return &fBeamline[idx];
1383}
1384
1385//--------------------------------------------------------------------------
1386// SetBeamline (public)
1387//--------------------------------------------------------------------------
1394void PMsrRunBlock::SetBeamline(TString &str, Int_t idx)
1395{
1396 if (idx == -1) {
1397 fBeamline.push_back(str);
1398 return;
1399 }
1400
1401 if (idx >= static_cast<Int_t>(fBeamline.size()))
1402 fBeamline.resize(idx+1);
1403
1404 fBeamline[idx] = str;
1405}
1406
1407//--------------------------------------------------------------------------
1408// GetInstitute (public)
1409//--------------------------------------------------------------------------
1419TString* PMsrRunBlock::GetInstitute(UInt_t idx)
1420{
1421 if (idx>fInstitute.size())
1422 return nullptr;
1423
1424 return &fInstitute[idx];
1425}
1426
1427//--------------------------------------------------------------------------
1428// SetInstitute (public)
1429//--------------------------------------------------------------------------
1436void PMsrRunBlock::SetInstitute(TString &str, Int_t idx)
1437{
1438 if (idx == -1) {
1439 fInstitute.push_back(str);
1440 return;
1441 }
1442
1443 if (idx >= static_cast<Int_t>(fInstitute.size()))
1444 fInstitute.resize(idx+1);
1445
1446 fInstitute[idx] = str;
1447}
1448
1449//--------------------------------------------------------------------------
1450// GetFileFormat (public)
1451//--------------------------------------------------------------------------
1462{
1463 if (idx>fFileFormat.size())
1464 return nullptr;
1465
1466 return &fFileFormat[idx];
1467}
1468
1469//--------------------------------------------------------------------------
1470// SetFileFormat (public)
1471//--------------------------------------------------------------------------
1478void PMsrRunBlock::SetFileFormat(TString &str, Int_t idx)
1479{
1480 if (idx == -1) {
1481 fFileFormat.push_back(str);
1482 return;
1483 }
1484
1485 if (idx >= static_cast<Int_t>(fFileFormat.size()))
1486 fFileFormat.resize(idx+1);
1487
1488 fFileFormat[idx] = str;
1489}
1490
1491//--------------------------------------------------------------------------
1492// GetForwardHistoNo (public)
1493//--------------------------------------------------------------------------
1504{
1505 if (fForwardHistoNo.empty())
1506 return -1;
1507
1508 if (idx>fForwardHistoNo.size())
1509 return -1;
1510
1511 return fForwardHistoNo[idx];
1512}
1513
1514//--------------------------------------------------------------------------
1515// SetForwardHistoNo (public)
1516//--------------------------------------------------------------------------
1524void PMsrRunBlock::SetForwardHistoNo(Int_t histoNo, Int_t idx)
1525{
1526 if (idx == -1) { // i.e. append forward histo no
1527 fForwardHistoNo.push_back(histoNo);
1528 } else {
1529 if (idx >= static_cast<Int_t>(fForwardHistoNo.size()))
1530 fForwardHistoNo.resize(idx+1);
1531 fForwardHistoNo[idx] = histoNo;
1532 }
1533}
1534
1535//--------------------------------------------------------------------------
1536// GetBackwardHistoNo (public)
1537//--------------------------------------------------------------------------
1548{
1549 if (fBackwardHistoNo.empty())
1550 return -1;
1551
1552 if (idx>fBackwardHistoNo.size())
1553 return -1;
1554
1555 return fBackwardHistoNo[idx];
1556}
1557
1558//--------------------------------------------------------------------------
1559// SetBackwardHistoNo (public)
1560//--------------------------------------------------------------------------
1568void PMsrRunBlock::SetBackwardHistoNo(Int_t histoNo, Int_t idx)
1569{
1570 if (idx == -1) { // i.e. append forward histo no
1571 fBackwardHistoNo.push_back(histoNo);
1572 } else {
1573 if (idx >= static_cast<Int_t>(fBackwardHistoNo.size()))
1574 fBackwardHistoNo.resize(idx+1);
1575 fBackwardHistoNo[idx] = histoNo;
1576 }
1577}
1578
1579//--------------------------------------------------------------------------
1580// GetMap (public)
1581//--------------------------------------------------------------------------
1591Int_t PMsrRunBlock::GetMap(UInt_t idx)
1592{
1593 if (idx>fMap.size())
1594 return -1;
1595
1596 return fMap[idx];
1597}
1598
1599//--------------------------------------------------------------------------
1600// SetMap (public)
1601//--------------------------------------------------------------------------
1608void PMsrRunBlock::SetMap(Int_t mapVal, Int_t idx)
1609{
1610 if (idx == -1) {
1611 fMap.push_back(mapVal);
1612 return;
1613 }
1614
1615 if (idx >= static_cast<Int_t>(fMap.size()))
1616 fMap.resize(idx+1);
1617
1618 fMap[idx] = mapVal;
1619}
1620
1621//--------------------------------------------------------------------------
1622// GetBkgEstimated (public)
1623//--------------------------------------------------------------------------
1635{
1636 if (idx >= 2)
1637 return PMUSR_UNDEFINED;
1638
1639 return fBkgEstimated[idx];
1640}
1641
1642
1643//--------------------------------------------------------------------------
1644// SetBkgEstimated (public)
1645//--------------------------------------------------------------------------
1652void PMsrRunBlock::SetBkgEstimated(Double_t dval, Int_t idx)
1653{
1654 if (idx >= 2) {
1655 std::cerr << std::endl << ">> PMsrRunBlock::SetBkgEstimated: **WARNING** idx=" << idx << ", only idx=0,1 are sensible.";
1656 std::cerr << std::endl;
1657 return;
1658 }
1659
1660 fBkgEstimated[idx] = dval;
1661}
1662
1663//--------------------------------------------------------------------------
1664// GetBkgFix (public)
1665//--------------------------------------------------------------------------
1675Double_t PMsrRunBlock::GetBkgFix(UInt_t idx)
1676{
1677 if (idx >= 2)
1678 return PMUSR_UNDEFINED;
1679
1680 return fBkgFix[idx];
1681}
1682
1683//--------------------------------------------------------------------------
1684// SetBkgFix (public)
1685//--------------------------------------------------------------------------
1692void PMsrRunBlock::SetBkgFix(Double_t dval, Int_t idx)
1693{
1694 if (idx >= 2) {
1695 std::cerr << std::endl << ">> PMsrRunBlock::SetBkgFix: **WARNING** idx=" << idx << ", only idx=0,1 are sensible.";
1696 std::cerr << std::endl;
1697 return;
1698 }
1699
1700 fBkgFix[idx] = dval;
1701}
1702
1703//--------------------------------------------------------------------------
1704// GetBkgRange (public)
1705//--------------------------------------------------------------------------
1716{
1717 if (idx >= 4) {
1718 return -1;
1719 }
1720
1721 return fBkgRange[idx];
1722}
1723
1724//--------------------------------------------------------------------------
1725// SetBkgRange (public)
1726//--------------------------------------------------------------------------
1733void PMsrRunBlock::SetBkgRange(Int_t ival, Int_t idx)
1734{
1735 if (idx >= 4) {
1736 std::cerr << std::endl << ">> PMsrRunBlock::SetBkgRange: **WARNING** idx=" << idx << ", only idx=0..3 are sensible.";
1737 std::cerr << std::endl;
1738 return;
1739 }
1740
1741 fBkgRange[idx] = ival;
1742}
1743
1744
1745//--------------------------------------------------------------------------
1746// GetDataRange (public)
1747//--------------------------------------------------------------------------
1758{
1759 if (idx >= 4) {
1760 return -1;
1761 }
1762
1763 return fDataRange[idx];
1764}
1765
1766//--------------------------------------------------------------------------
1767// SetDataRange (public)
1768//--------------------------------------------------------------------------
1775void PMsrRunBlock::SetDataRange(Int_t ival, Int_t idx)
1776{
1777 if (idx >= 4) {
1778 std::cerr << std::endl << ">> PMsrRunBlock::SetDataRange: **WARNING** idx=" << idx << ", only idx=0..3 are sensible.";
1779 std::cerr << std::endl;
1780 return;
1781 }
1782
1783 fDataRange[idx] = ival;
1784}
1785
1786//--------------------------------------------------------------------------
1787// GetT0Bin (public)
1788//--------------------------------------------------------------------------
1798Double_t PMsrRunBlock::GetT0Bin(UInt_t idx)
1799{
1800 if (idx >= fT0.size())
1801 return -1;
1802
1803 return fT0[idx];
1804}
1805
1806//--------------------------------------------------------------------------
1807// SetT0Bin (public)
1808//--------------------------------------------------------------------------
1815void PMsrRunBlock::SetT0Bin(Double_t dval, Int_t idx)
1816{
1817 if (idx == -1) {
1818 fT0.push_back(dval);
1819 return;
1820 }
1821
1822 if (idx >= static_cast<Int_t>(fT0.size()))
1823 fT0.resize(idx+1);
1824
1825 fT0[idx] = dval;
1826}
1827
1828//--------------------------------------------------------------------------
1829// GetAddT0BinSize (public)
1830//--------------------------------------------------------------------------
1840Int_t PMsrRunBlock::GetAddT0BinSize(UInt_t addRunIdx)
1841{
1842 if (fAddT0.empty())
1843 return -1;
1844
1845 if (addRunIdx >= fAddT0.size())
1846 return -1;
1847
1848 return fAddT0[addRunIdx].size();
1849}
1850
1851//--------------------------------------------------------------------------
1852// GetAddT0Bin (public)
1853//--------------------------------------------------------------------------
1864Double_t PMsrRunBlock::GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx)
1865{
1866 if (fAddT0.empty())
1867 return -1.0;
1868
1869 if (addRunIdx >= fAddT0.size())
1870 return -1.0;
1871
1872 if (fAddT0[addRunIdx].empty())
1873 return -1.0;
1874
1875 if (histoIdx >= fAddT0[addRunIdx].size())
1876 return -1.0;
1877
1878 return fAddT0[addRunIdx][histoIdx];
1879}
1880
1881//--------------------------------------------------------------------------
1882// SetAddT0Bin (public)
1883//--------------------------------------------------------------------------
1891void PMsrRunBlock::SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx)
1892{
1893 if (addRunIdx >= fAddT0.size())
1894 fAddT0.resize(addRunIdx+1);
1895
1896 if (histoNoIdx >= fAddT0[addRunIdx].size())
1897 fAddT0[addRunIdx].resize(histoNoIdx+1);
1898
1899 fAddT0[addRunIdx][histoNoIdx] = dval;
1900}
1901
1902//--------------------------------------------------------------------------
1903// GetFitRange (public)
1904//--------------------------------------------------------------------------
1914Double_t PMsrRunBlock::GetFitRange(UInt_t idx)
1915{
1916 if (idx >= 2)
1917 return PMUSR_UNDEFINED;
1918
1919 return fFitRange[idx];
1920}
1921
1922//--------------------------------------------------------------------------
1923// SetFitRange (public)
1924//--------------------------------------------------------------------------
1931void PMsrRunBlock::SetFitRange(Double_t dval, UInt_t idx)
1932{
1933 if (idx >= 2)
1934 return;
1935
1936 fFitRange[idx] = dval;
1937}
1938
1939//--------------------------------------------------------------------------
1940// GetFitRangeOffset (public)
1941//--------------------------------------------------------------------------
1952{
1953 if (idx >= 2)
1954 return -1;
1955
1956 return fFitRangeOffset[idx];
1957}
1958
1959//--------------------------------------------------------------------------
1960// SetFitRangeOffset (public)
1961//--------------------------------------------------------------------------
1968void PMsrRunBlock::SetFitRangeOffset(Int_t ival, UInt_t idx)
1969{
1970 if (idx >= 2)
1971 return;
1972
1973 fFitRangeOffset[idx] = ival;
1974}
1975
1976//--------------------------------------------------------------------------
1977// SetParGlobal (public)
1978//--------------------------------------------------------------------------
1985void PMsrRunBlock::SetParGlobal(const TString &str, Int_t ival)
1986{
1987 fParGlobal[str] = ival; // will either create a new entry or overwrite an old one if the key "str" is present
1988 return;
1989}
1990
1991//--------------------------------------------------------------------------
1992// SetMapGlobal (public)
1993//--------------------------------------------------------------------------
2000void PMsrRunBlock::SetMapGlobal(UInt_t idx, Int_t ival)
2001{
2002 if (fMapGlobal.size() != fMap.size())
2003 fMapGlobal.resize(fMap.size(), -1);
2004 if (idx < fMap.size() && fMap[idx] > 0)
2005 fMapGlobal[idx] = ival;
2006 // else do nothing at the moment
2007 return;
2008}
2009
2010//--------------------------------------------------------------------------
2011// SetEstimatedAlpha (public)
2012//--------------------------------------------------------------------------
2019{
2020 fAlpha = dval;
2021}
2022
2023//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2024// implementation PStringNumberList
2025//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2026
2027//--------------------------------------------------------------------------
2028// Parse (public)
2029//--------------------------------------------------------------------------
2041bool PStringNumberList::Parse(std::string &errorMsg, bool ignoreFirstToken)
2042{
2043 bool result=true;
2044 std::vector<std::string> splitVec;
2045 int ival;
2046
2047 // before checking tokens, remove 'forbidden' " - " and " : "
2048 StripSpaces();
2049
2050 // split string into space separated tokens
2051 split(splitVec, fString, is_any_of(" "), token_compress_on);
2052
2053 unsigned int start=0;
2054 if (ignoreFirstToken)
2055 start=1;
2056
2057 for (unsigned int i=start; i<splitVec.size(); i++) {
2058 if (splitVec[i].length() != 0) { // ignore empty tokens
2059 if (splitVec[i].find("-") != std::string::npos) { // check for potential range
2060 std::vector<std::string> subSplitVec;
2061 // split potential nS-nE token
2062 split(subSplitVec, splitVec[i], is_any_of("-"), token_compress_on);
2063
2064 int start=-1, end=-1;
2065 unsigned int count=0;
2066 for (unsigned int j=0; j<subSplitVec.size(); j++) {
2067 if (subSplitVec[j].length() != 0) { // ignore empty tokens
2068 if (!IsNumber(subSplitVec[j])) {
2069 result = false;
2070 } else {
2071 count++;
2072 if (count == 1)
2073 start = atoi(subSplitVec[j].c_str());
2074 else if (count == 2)
2075 end = atoi(subSplitVec[j].c_str());
2076 else
2077 result = false;
2078 }
2079 }
2080 }
2081 if ((start < 0) || (end < 0)) { // check that there is a vaild start and end
2082 errorMsg = "**ERROR** start or end of a range is not valid";
2083 result = false;
2084 }
2085 if (result) { // no error, hence check start and end
2086 if (start > end) {
2087 int swap = end;
2088 std::cerr << "**WARNING** start=" << start << " > end=" << end << ", hence I will swap them" << std::endl;
2089 end = start;
2090 start = swap;
2091 }
2092 for (int j=start; j<=end; j++)
2093 fList.push_back(j);
2094 }
2095 } else if (splitVec[i].find(":") != std::string::npos) { // check for potential sequence
2096 std::vector<std::string> subSplitVec;
2097 // split potential rStart:rEnd:rStep token
2098 split(subSplitVec, splitVec[i], is_any_of(":"), token_compress_on);
2099
2100 int start=-1, end=-1, step=-1;
2101 unsigned int count=0;
2102 for (unsigned int j=0; j<subSplitVec.size(); j++) {
2103 if (subSplitVec[j].length() != 0) { // ignore empty tokens
2104 if (!IsNumber(subSplitVec[j])) {
2105 result = false;
2106 } else {
2107 count++;
2108 if (count == 1)
2109 start = atoi(subSplitVec[j].c_str());
2110 else if (count == 2)
2111 end = atoi(subSplitVec[j].c_str());
2112 else if (count == 3)
2113 step = atoi(subSplitVec[j].c_str());
2114 else
2115 result = false;
2116 }
2117 }
2118 }
2119 if ((start < 0) || (end < 0) || (step < 0)) { // check that there is a vaild start and end
2120 errorMsg = "**ERROR** start, end, or step of a sequence is not valid";
2121 result = false;
2122 }
2123 if (result) { // no error, hence check start and end
2124 if (start > end) {
2125 int swap = end;
2126 std::cerr << "**WARNING** start=" << start << " > end=" << end << ", hence I will swap them" << std::endl;
2127 end = start;
2128 start = swap;
2129 }
2130 for (int j=start; j<=end; j+=step)
2131 fList.push_back(j);
2132 }
2133 } else if (IsNumber(splitVec[i])) {
2134 ival = atoi(splitVec[i].c_str());
2135 fList.push_back(ival);
2136 } else {
2137 errorMsg = "**ERROR** invalid token: " + splitVec[i];
2138 result = false;
2139 }
2140 }
2141 }
2142
2143 return result;
2144}
2145
2146//--------------------------------------------------------------------------
2147// StripSpaces (private)
2148//--------------------------------------------------------------------------
2154{
2155 std::string str=fString;
2156 int pos=-1;
2157
2158 // backward scan
2159 for (int i=str.size(); i>=0; --i) { // check if first space is found
2160 if ((str[i] == ' ') && (pos == -1)) {
2161 pos = i;
2162 } else if ((str[i] == '-') || (str[i] == ':')) { // check for '-' or ':'
2163 if (pos != -1) {
2164 str.erase(i+1, pos-i);
2165 }
2166 } else if (str[i] != ' ') { // anything but different than a space leads to a reset of the pos counter
2167 pos = -1;
2168 }
2169 }
2170 // forward scan
2171 for (unsigned int i=0; i<str.size(); i++) { // check if first space is found
2172 if ((str[i] == ' ') && (pos == -1)) {
2173 pos = i;
2174 } else if ((str[i] == '-') || (str[i] == ':')) { // check for '-' or ':'
2175 if (pos != -1) {
2176 str.erase(pos, i-pos);
2177 i = pos;
2178 }
2179 } else if (str[i] != ' ') { // anything but different than a space leads to a reset of the pos counter
2180 pos = -1;
2181 }
2182 }
2183
2184 fString = str;
2185}
#define RRF_UNIT_MHz
Frequency in MHz (megahertz)
Definition PMusr.h:349
#define PMUSR_UNDEFINED
Definition PMusr.h:177
#define GAMMA_BAR_MUON
Definition PMusr.h:143
std::pair< Int_t, Int_t > PIntPair
Definition PMusr.h:387
#define PERIOD_HISTO_OFFSET
Definition PMusr.h:274
#define RRF_UNIT_Mcs
Angular frequency in Mc/s (Mega-cycles per second)
Definition PMusr.h:351
#define RRF_UNIT_G
Equivalent magnetic field in Gauss (G)
Definition PMusr.h:353
#define RRF_UNIT_kHz
Frequency in kHz (kilohertz)
Definition PMusr.h:347
#define RRF_UNIT_T
Equivalent magnetic field in Tesla (T)
Definition PMusr.h:355
#define RRF_UNIT_UNDEF
RRF unit undefined.
Definition PMusr.h:345
std::vector< Double_t > PDoubleVector
Definition PMusr.h:399
#define RRF_FREQ_UNDEF
Definition PMusr.h:363
virtual void SetT0Bin(Double_t dval, Int_t idx=-1)
Definition PMusr.cpp:1055
Bool_t fFitRangeInBins
flag telling if fit range is given in time or in bins
Definition PMusr.h:1104
virtual void SetRRFFreq(Double_t freq, const char *unit)
Definition PMusr.cpp:909
virtual void SetFitRange(Double_t dval, UInt_t idx)
Definition PMusr.cpp:1171
Double_t fFitRange[2]
fit range in (us)
Definition PMusr.h:1105
Int_t fDataRange[4]
data bin range (fit type 0, 1, 2, 4)
Definition PMusr.h:1101
virtual Double_t GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx)
Definition PMusr.cpp:1104
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:1100
virtual Int_t GetAddT0BinSize(UInt_t addRunIdx)
Definition PMusr.cpp:1080
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:1103
virtual Double_t GetFitRange(UInt_t idx)
Definition PMusr.cpp:1154
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:1106
Bool_t fGlobalPresent
flag showing if a GLOBAL block is present at all.
Definition PMusr.h:1095
Int_t fRRFUnitTag
RRF unit tag.
Definition PMusr.h:1097
virtual Int_t GetDataRange(UInt_t idx)
Definition PMusr.cpp:998
virtual void SetDataRange(Int_t ival, Int_t idx)
Definition PMusr.cpp:1015
Int_t fRRFPacking
RRF packing.
Definition PMusr.h:1099
virtual TString GetRRFUnit()
Definition PMusr.cpp:937
Double_t fRRFPhase
RRF phase in (°)
Definition PMusr.h:1098
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:1102
Int_t fPacking
packing/rebinning
Definition PMusr.h:1107
virtual void SetRRFPacking(Int_t pack)
Definition PMusr.cpp:976
Double_t fRRFFreq
RRF frequency given in units of (MHz, Mc, T)
Definition PMusr.h:1096
virtual void SetFitRangeOffset(Int_t ival, UInt_t idx)
Definition PMusr.cpp:1208
virtual void SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx)
Definition PMusr.cpp:1131
virtual Int_t GetFitRangeOffset(UInt_t idx)
Definition PMusr.cpp:1191
virtual Double_t GetT0Bin(UInt_t idx=0)
Definition PMusr.cpp:1038
virtual Double_t GetRRFFreq(const char *unit)
Definition PMusr.cpp:865
PStringVector fInstitute
e.g. psi, ral, triumf (former: run format)
Definition PMusr.h:1220
virtual PIntVector * GetMap()
Definition PMusr.h:1156
Int_t fBkgRange[4]
background bin range (fit type 0, 2, 4)
Definition PMusr.h:1234
Int_t fNormParamNo
N0 parameter number (fit type 0)
Definition PMusr.h:1225
virtual TString * GetInstitute(UInt_t idx=0)
Definition PMusr.cpp:1419
Double_t fAlpha
estimated alpha value from F/B counts
Definition PMusr.h:1241
Double_t fBkgEstimated[2]
keeps estimated background values (if present)
Definition PMusr.h:1232
Int_t fAlphaParamNo
alpha parameter number (fit type 2, 4)
Definition PMusr.h:1223
virtual Int_t GetDataRange(UInt_t idx)
Definition PMusr.cpp:1757
virtual void SetFitRangeOffset(Int_t ival, UInt_t idx)
Definition PMusr.cpp:1968
virtual TString * GetFileFormat(UInt_t idx=0)
Definition PMusr.cpp:1461
virtual void SetBeamline(TString &str, Int_t idx=-1)
Definition PMusr.cpp:1394
virtual void SetBkgFix(Double_t dval, Int_t idx)
Definition PMusr.cpp:1692
virtual TString * GetBeamline(UInt_t idx=0)
Definition PMusr.cpp:1377
Int_t fDataRange[4]
data bin range (fit type 0, 2, 4)
Definition PMusr.h:1235
virtual Double_t GetFitRange(UInt_t idx)
Definition PMusr.cpp:1914
virtual Int_t GetAddT0BinSize(UInt_t addRunIdx)
Definition PMusr.cpp:1840
Int_t fLifetimeParamNo
muon lifetime parameter number (fit type 0)
Definition PMusr.h:1227
virtual Double_t GetBkgEstimated(UInt_t idx)
Definition PMusr.cpp:1634
virtual void SetFitRange(Double_t dval, UInt_t idx)
Definition PMusr.cpp:1931
virtual void SetBkgEstimated(Double_t dval, Int_t idx)
Definition PMusr.cpp:1652
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:1236
Int_t fBkgFitParamNo
background fit parameter number (fit type 0)
Definition PMusr.h:1226
virtual void CleanUp()
Definition PMusr.cpp:1281
virtual void SetFileFormat(TString &str, Int_t idx=-1)
Definition PMusr.cpp:1478
virtual void SetEstimatedAlpha(Double_t dval)
Definition PMusr.cpp:2018
virtual Double_t GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx)
Definition PMusr.cpp:1864
PStringVector fBeamline
e.g. mue4, mue1, pim3, emu, m15, ... (former: run type)
Definition PMusr.h:1219
Int_t fBetaParamNo
beta parameter number (fit type 2, 4)
Definition PMusr.h:1224
virtual TString * GetRunName(UInt_t idx=0)
Definition PMusr.cpp:1335
Bool_t fLifetimeCorrection
lifetime correction flag for viewing (fit type 0)
Definition PMusr.h:1228
virtual void SetMap(Int_t mapVal, Int_t idx=-1)
Definition PMusr.cpp:1608
TString fXYDataLabel[2]
used to get the indices via labels when using db-files (fit type 8)
Definition PMusr.h:1245
PStringVector fFileFormat
e.g. root, nexus, psi-bin, mud, ascii, db
Definition PMusr.h:1221
virtual void SetParGlobal(const TString &str, Int_t ival)
Definition PMusr.cpp:1985
PStringVector fRunName
name of the run file
Definition PMusr.h:1218
virtual void SetMapGlobal(UInt_t idx, Int_t ival)
Definition PMusr.cpp:2000
PIntVector fMapGlobal
here is stored if the maps used in the RUN block are global or not
Definition PMusr.h:1256
virtual Double_t GetBkgFix(UInt_t idx)
Definition PMusr.cpp:1675
virtual void SetT0Bin(Double_t dval, Int_t idx=-1)
Definition PMusr.cpp:1815
Int_t fXYDataIndex[2]
used to get the data indices when using db-files (fit type 8)
Definition PMusr.h:1244
virtual Int_t GetForwardHistoNo(UInt_t idx=0)
Definition PMusr.cpp:1503
Bool_t fFitRangeInBins
flag telling if fit range is given in time or in bins
Definition PMusr.h:1238
virtual Int_t GetFitRangeOffset(UInt_t idx)
Definition PMusr.cpp:1951
virtual void SetBackwardHistoNo(Int_t histoNo, Int_t idx=-1)
Definition PMusr.cpp:1568
virtual void SetDataRange(Int_t ival, Int_t idx)
Definition PMusr.cpp:1775
virtual Int_t GetBkgRange(UInt_t idx)
Definition PMusr.cpp:1715
virtual Int_t GetBackwardHistoNo(UInt_t idx=0)
Definition PMusr.cpp:1547
virtual void SetRunName(TString &str, Int_t idx=-1)
Definition PMusr.cpp:1352
std::map< TString, Int_t > fParGlobal
here is stored if the parameters used in the RUN block are global or not
Definition PMusr.h:1255
PIntVector fBackwardHistoNo
backward histogram number (fit type 2, 4)
Definition PMusr.h:1231
Double_t fFitRange[2]
fit range in (us)
Definition PMusr.h:1239
Double_t fBkgFix[2]
fixed background in (1/ns) (fit type 0, 2, 4)
Definition PMusr.h:1233
virtual ~PMsrRunBlock()
Definition PMusr.cpp:1261
virtual void SetBkgRange(Int_t ival, Int_t idx)
Definition PMusr.cpp:1733
PIntVector fMap
map vector needed to switch parameters for different runs within a single theory
Definition PMusr.h:1229
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:1240
virtual void SetInstitute(TString &str, Int_t idx=-1)
Definition PMusr.cpp:1436
Int_t fFitType
fit type: 0=single histo fit, 2=asymmetry fit, 4=mu^- single histo fit, 8=non muSR fit
Definition PMusr.h:1222
virtual Double_t GetT0Bin(UInt_t idx=0)
Definition PMusr.cpp:1798
PIntVector fForwardHistoNo
forward histogram number (fit type 0, 2, 4)
Definition PMusr.h:1230
virtual void SetForwardHistoNo(Int_t histoNo, Int_t idx=-1)
Definition PMusr.cpp:1524
Int_t fPacking
packing/rebinning
Definition PMusr.h:1242
virtual void SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx)
Definition PMusr.cpp:1891
std::vector< PDoubleVector > fAddT0
t0 bins for addrun's
Definition PMusr.h:1237
std::vector< PDoubleVector > fData
vector of all data
Definition PMusr.h:629
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:627
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:626
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:628
virtual void SetSize(const UInt_t size)
Definition PMusr.cpp:162
std::vector< PDoubleVector > fErrData
vector of all data errors
Definition PMusr.h:630
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:711
Int_t fFirstBkgBin
keeps the first background bin of the data set
Definition PMusr.h:712
Double_t fTimeZeroBin
keeps the time zero bin
Definition PMusr.h:708
TString fTitle
histogram title.
Definition PMusr.h:705
PDoubleVector fData
keeps the histogram data
Definition PMusr.h:714
Int_t fLastBkgBin
keeps the last background bin of the data set
Definition PMusr.h:713
Int_t fHistoNo
corresponds to the histogram number in the data file
Definition PMusr.h:707
Int_t fFirstGoodBin
keeps the first good bin of the data set
Definition PMusr.h:710
Double_t fTimeZeroBinEstimated
keeps the estimated time zero bin
Definition PMusr.h:709
TString fName
keeps the histogram name.
Definition PMusr.h:706
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:818
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:958
virtual PRawRunDataSet * GetDataSet(const UInt_t idx, Bool_t wantHistoNo=true)
Definition PMusr.cpp:750
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:954
TString fVersion
keeps the version information of the data file
Definition PMusr.h:943
TString fSetup
description of the setup of this run
Definition PMusr.h:959
TString fStartTime
start time of the run
Definition PMusr.h:960
virtual void SetRingAnode(const UInt_t idx, const Double_t dval)
Definition PMusr.cpp:784
Int_t fRunNumber
run number
Definition PMusr.h:957
TString fStartDate
start date of the run
Definition PMusr.h:961
TString fFileName
keeps the name of the original data file
Definition PMusr.h:948
UInt_t fNoOfHistosPerPeriod
number of histos per period (Red/Green mode); 0 means the run has no periods
Definition PMusr.h:979
PRawRunDataVector fData
keeps the histos together with the histo related properties such as T0, first good bin,...
Definition PMusr.h:981
time_t fStopDateTimeSec
stop run given as time_t object
Definition PMusr.h:965
TString fStopTime
stop time of the run
Definition PMusr.h:963
TString fSample
description of the sample
Definition PMusr.h:967
virtual const PDoubleVector GetRingAnode()
Definition PMusr.h:880
TString fComment
keeps the data file comment
Definition PMusr.h:947
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:950
PDoublePairVector fTemp
measured temperatures and standard deviations during the run
Definition PMusr.h:971
PIntVector fRedGreenOffset
keeps the Red/Green offsets
Definition PMusr.h:976
TString fMagnet
name of the sample magnet
Definition PMusr.h:969
virtual const Bool_t DeadTimeCorrectionReady()
Definition PMusr.cpp:768
TString fRunName
name of the run as found in the msr-file
Definition PMusr.h:956
Int_t fNumberOfGoodFrames
needed to correct dead times at pulsed sources
Definition PMusr.h:978
virtual void SetTemperature(const UInt_t idx, const Double_t temp, const Double_t errTemp)
Definition PMusr.cpp:801
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:972
TString fGenericValidatorURL
keeps the generic validator MusrRoot URL
Definition PMusr.h:944
TString fGenerator
keeps the data file generator name
Definition PMusr.h:946
Double_t fField
magnetic field value in (G)
Definition PMusr.h:970
time_t fStartDateTimeSec
start run given as time_t object
Definition PMusr.h:962
virtual void SetTempError(const UInt_t idx, const Double_t errTemp)
Definition PMusr.cpp:819
std::vector< float > fDeadTimeParam
dead time parameter vector needed for pulsed sources
Definition PMusr.h:977
Double_t fTimeResolution
time resolution of the run in (ns)
Definition PMusr.h:975
Double_t fTransport
LEM transport settings (Moderator HV)
Definition PMusr.h:973
TString fCryo
name of the cryo
Definition PMusr.h:966
TString fMuonSource
keeps the type of muon source, e.g. continous surface beam, pulsed beam, low energy muon beam
Definition PMusr.h:952
Double_t fMuonSpinAngle
gives the muon spin angle in degrees (reference frame depends on the instrument)
Definition PMusr.h:955
virtual const std::vector< float > GetDeadTimeParam()
Definition PMusr.h:891
TString fMuonSpecies
positive muon or negative muon
Definition PMusr.h:953
virtual const PDoublePairVector * GetTemperature() const
Definition PMusr.h:875
PDoubleVector fRingAnode
LEM ring anode HVs (L,R[,T,B])
Definition PMusr.h:974
TString fInstrument
keeps the name of the instrument, e.g. LEM, GPS, MUSR, EMU, ...
Definition PMusr.h:951
TString fLaboratory
keeps the name of the laboratory, e.g. PSI, ISIS, TRIUMF, JPARC
Definition PMusr.h:949
TString fStopDate
stop date of the run
Definition PMusr.h:964
virtual const time_t CalcStartDateTime(bool &ok)
Definition PMusr.cpp:595
TString fSpecificValidatorURL
keeps the instrument specific validator MusrRoot URL
Definition PMusr.h:945
TString fOrientation
description of the orientation
Definition PMusr.h:968
Double_t fTheoryTimeStep
time step of the theory, i.e. the time length of a bin
Definition PMusr.h:543
Double_t fTheoryTimeStart
start time of the theory
Definition PMusr.h:542
PDoubleVector fXTheory
x-axis vector. Only used for non-muSR
Definition PMusr.h:544
virtual ~PRunData()
Definition PMusr.cpp:69
PDoubleVector fX
x-axis vector. Only used for non-muSR
Definition PMusr.h:538
PDoubleVector fValue
data vector
Definition PMusr.h:539
Double_t fDataTimeStart
start time for the data set
Definition PMusr.h:536
PRunData()
Definition PMusr.cpp:50
PDoubleVector fTheory
theory vector
Definition PMusr.h:545
virtual void ReplaceTheory(const PDoubleVector &theo)
Definition PMusr.cpp:103
PDoubleVector fError
data error vector
Definition PMusr.h:540
Double_t fDataTimeStep
time step for the data set, i.e. the time length of a bin
Definition PMusr.h:537
virtual void SetTheoryValue(UInt_t i, Double_t dval)
Definition PMusr.cpp:87
std::string fString
Definition PMusr.h:1443
virtual void StripSpaces()
Definition PMusr.cpp:2153
PUIntVector fList
Definition PMusr.h:1445
virtual bool IsNumber(std::string &str)
Definition PMusr.h:1447
virtual bool Parse(std::string &errorMsg, bool ignoreFirstToken=false)
Definition PMusr.cpp:2041