musrfit  1.9.2
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-2023 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>
34 using namespace boost;
35 
36 #include "TMath.h"
37 
38 #include "PMusr.h"
39 
40 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
41 // implementation PRunData
42 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
43 
44 //--------------------------------------------------------------------------
45 // Constructor
46 //--------------------------------------------------------------------------
51 {
52  fDataTimeStart = PMUSR_UNDEFINED;
53  fDataTimeStep = PMUSR_UNDEFINED;
54  fX.clear(); // only used in non-muSR
55  fValue.clear();
56  fError.clear();
57  fTheoryTimeStart = PMUSR_UNDEFINED;
58  fTheoryTimeStep = PMUSR_UNDEFINED;
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 //--------------------------------------------------------------------------
87 void 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 //--------------------------------------------------------------------------
162 void 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 //--------------------------------------------------------------------------
189 void 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 //--------------------------------------------------------------------------
209 void 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 //--------------------------------------------------------------------------
229 void 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 //--------------------------------------------------------------------------
251 {
252  Clear();
253 }
254 
255 //--------------------------------------------------------------------------
256 // Clear (public)
257 //--------------------------------------------------------------------------
262 {
263  fName = TString("n/a");
264  fHistoNo = -1;
265  fTimeZeroBin = 0.0;
266  fTimeZeroBinEstimated = 0.0;
267  fFirstGoodBin = 0;
268  fLastGoodBin = 0;
269  fFirstBkgBin = 0;
270  fLastBkgBin = 0;
271  fData.clear();
272 }
273 
274 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
275 // implementation PRawRunDataVector
276 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
277 
278 //--------------------------------------------------------------------------
279 // IsPresent (public)
280 //--------------------------------------------------------------------------
290 Bool_t PRawRunDataVector::IsPresent(UInt_t histoNo)
291 {
292  Bool_t found=false;
293 
294  for (UInt_t i=0; i<fDataVec.size(); i++) {
295  if (fDataVec[i].GetHistoNo() == static_cast<Int_t>(histoNo)) {
296  found = true;
297  break;
298  }
299  }
300 
301  return found;
302 }
303 
304 //--------------------------------------------------------------------------
305 // GetSet (public)
306 //--------------------------------------------------------------------------
319 {
320  PRawRunDataSet *result = nullptr;
321 
322  if (idx >= fDataVec.size())
323  return result;
324 
325  return &fDataVec[idx];
326 }
327 
328 //--------------------------------------------------------------------------
329 // Get (public)
330 //--------------------------------------------------------------------------
341 {
342  PRawRunDataSet *result = nullptr;
343 
344  for (UInt_t i=0; i<fDataVec.size(); i++) {
345  if (fDataVec[i].GetHistoNo() == static_cast<Int_t>(histoNo)) {
346  result = &fDataVec[i];
347  break;
348  }
349  }
350 
351  return result;
352 }
353 
354 //--------------------------------------------------------------------------
355 // operator[] (public)
356 //--------------------------------------------------------------------------
367 {
368  return Get(histoNo);
369 }
370 
371 //--------------------------------------------------------------------------
372 // GetData (public)
373 //--------------------------------------------------------------------------
384 {
385  PDoubleVector *result = nullptr;
386 
387  for (UInt_t i=0; i<fDataVec.size(); i++) {
388  if (fDataVec[i].GetHistoNo() == static_cast<Int_t>(histoNo)) {
389  result = fDataVec[i].GetData();
390  break;
391  }
392  }
393 
394  return result;
395 }
396 
397 //--------------------------------------------------------------------------
398 // GetT0Bin (public)
399 //--------------------------------------------------------------------------
409 Double_t PRawRunDataVector::GetT0Bin(UInt_t histoNo)
410 {
411  Double_t result=-1.0; // undefined
412 
413  for (UInt_t i=0; i<fDataVec.size(); i++) {
414  if (fDataVec[i].GetHistoNo() == static_cast<Int_t>(histoNo)) {
415  result = fDataVec[i].GetTimeZeroBin();
416  break;
417  }
418  }
419 
420  return result;
421 }
422 
423 //--------------------------------------------------------------------------
424 // GetT0BinEstimated (public)
425 //--------------------------------------------------------------------------
435 Double_t PRawRunDataVector::GetT0BinEstimated(UInt_t histoNo)
436 {
437  Double_t result=PMUSR_UNDEFINED;
438 
439  for (UInt_t i=0; i<fDataVec.size(); i++) {
440  if (fDataVec[i].GetHistoNo() == static_cast<Int_t>(histoNo)) {
441  result = fDataVec[i].GetTimeZeroBinEstimated();
442  break;
443  }
444  }
445 
446  return result;
447 }
448 
449 //--------------------------------------------------------------------------
450 // GetBkgBin (public)
451 //--------------------------------------------------------------------------
462 {
463  PIntPair bkg(-1,-1);
464 
465  for (UInt_t i=0; i<fDataVec.size(); i++) {
466  if (fDataVec[i].GetHistoNo() == static_cast<Int_t>(histoNo)) {
467  bkg.first = fDataVec[i].GetFirstBkgBin();
468  bkg.second = fDataVec[i].GetLastBkgBin();
469  break;
470  }
471  }
472 
473  return bkg;
474 }
475 
476 //--------------------------------------------------------------------------
477 // GetGoodDataBin (public)
478 //--------------------------------------------------------------------------
489 {
490  PIntPair gdb(-1,-1);
491 
492  for (UInt_t i=0; i<fDataVec.size(); i++) {
493  if (fDataVec[i].GetHistoNo() == static_cast<Int_t>(histoNo)) {
494  gdb.first = fDataVec[i].GetFirstGoodBin();
495  gdb.second = fDataVec[i].GetLastGoodBin();
496  break;
497  }
498  }
499 
500  return gdb;
501 }
502 
503 //--------------------------------------------------------------------------
504 // Set (public)
505 //--------------------------------------------------------------------------
514 void PRawRunDataVector::Set(PRawRunDataSet dataSet, Int_t idx)
515 {
516  if (idx == -1) { // data set to be appended
517  fDataVec.push_back(dataSet);
518  } else {
519  if (idx >= static_cast<Int_t>(fDataVec.size()))
520  fDataVec.resize(idx+1);
521  fDataVec[idx] = dataSet;
522  }
523 }
524 
525 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
526 // implementation PRawRunData
527 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
528 
529 //--------------------------------------------------------------------------
530 // Constructor
531 //--------------------------------------------------------------------------
536 {
537  fVersion = TString("n/a");
538  fGenericValidatorURL = TString("n/a");
539  fSpecificValidatorURL = TString("n/a");
540  fGenerator = TString("n/a");
541  fComment = TString("n/a");
542  fFileName = TString("n/a");
543  fLaboratory = TString("n/a");
544  fBeamline = TString("n/a");
545  fInstrument = TString("n/a");
546  fMuonSource = TString("n/a");
547  fMuonSpecies = TString("n/a");
548  fMuonBeamMomentum = PMUSR_UNDEFINED;
549  fMuonSpinAngle = PMUSR_UNDEFINED;
550  fRunName = TString("n/a");
551  fRunNumber = -1;
552  fRunTitle = TString("n/a");
553  fSetup = TString("n/a");
554  fStartTime = TString("n/a");
555  fStartDate = TString("n/a");
556  fStartDateTimeSec = 0;
557  fStopTime = TString("n/a");
558  fStopDate = TString("n/a");
559  fStopDateTimeSec = 0;
560  fCryo = TString("n/a");
561  fSample = TString("n/a");
562  fOrientation = TString("n/a");
563  fMagnet = TString("n/a");
564  fField = PMUSR_UNDEFINED;
565  fEnergy = PMUSR_UNDEFINED;
566  fTransport = PMUSR_UNDEFINED;
567  fTimeResolution = PMUSR_UNDEFINED;
568  fRedGreenOffset.push_back(0);
569 }
570 
571 //--------------------------------------------------------------------------
572 // Destructor
573 //--------------------------------------------------------------------------
578 {
579  fTemp.clear();
580  fRingAnode.clear();
581  fRedGreenOffset.clear();
582 }
583 
584 //--------------------------------------------------------------------------
585 // GetTemperature (public)
586 //--------------------------------------------------------------------------
596 const Double_t PRawRunData::GetTemperature(const UInt_t idx)
597 {
598  if (idx >= fTemp.size()) {
599  std::cerr << std::endl << ">> PRawRunData::GetTemperature: **WARNING** idx=" << idx << " is out of range [0," << fTemp.size() << "[.";
600  std::cerr << std::endl;
601  return PMUSR_UNDEFINED;
602  }
603  return fTemp[idx].first;
604 }
605 
606 //--------------------------------------------------------------------------
607 // GetTempError (public)
608 //--------------------------------------------------------------------------
618 const Double_t PRawRunData::GetTempError(const UInt_t idx)
619 {
620  if (idx >= fTemp.size()) {
621  std::cerr << std::endl << ">> PRawRunData::GetTempError: **WARNING** idx=" << idx << " is out of range [0," << fTemp.size() << "[.";
622  std::cerr << std::endl;
623  return PMUSR_UNDEFINED;
624  }
625  return fTemp[idx].second;
626 }
627 
628 //--------------------------------------------------------------------------
629 // GetRingAnode (public)
630 //--------------------------------------------------------------------------
640 const Double_t PRawRunData::GetRingAnode(const UInt_t idx)
641 {
642  if (idx >= fRingAnode.size()) {
643  std::cerr << std::endl << ">> PRawRunData::GetRingAnode: **WARNING** idx=" << idx << " is out of range [0," << fRingAnode.size() << "[.";
644  std::cerr << std::endl;
645  return PMUSR_UNDEFINED;
646  }
647  return fRingAnode[idx];
648 }
649 
650 //--------------------------------------------------------------------------
651 // GetDataSet (public)
652 //--------------------------------------------------------------------------
663 PRawRunDataSet* PRawRunData::GetDataSet(const UInt_t idx, Bool_t wantHistoNo)
664 {
665  if (wantHistoNo)
666  return fData[idx];
667  else
668  return fData.GetSet(idx);
669 }
670 
671 
672 //--------------------------------------------------------------------------
673 // SetRingAnode (public)
674 //--------------------------------------------------------------------------
681 void PRawRunData::SetRingAnode(const UInt_t idx, const Double_t dval)
682 {
683  if (idx >= fRingAnode.size())
684  fRingAnode.resize(idx+1);
685  fRingAnode[idx] = dval;
686 }
687 
688 //--------------------------------------------------------------------------
689 // SetTemperature (public)
690 //--------------------------------------------------------------------------
698 void PRawRunData::SetTemperature(const UInt_t idx, const Double_t temp, const Double_t errTemp)
699 {
700  if (idx >= fTemp.size()) {
701  fTemp.resize(idx+1);
702  }
703  fTemp[idx].first = temp;
704  fTemp[idx].second = errTemp;
705 }
706 
707 //--------------------------------------------------------------------------
708 // SetTempError (public)
709 //--------------------------------------------------------------------------
716 void PRawRunData::SetTempError(const UInt_t idx, const Double_t errTemp)
717 {
718  if (idx >= fTemp.size()) {
719  fTemp.resize(idx+1);
720  }
721  fTemp[idx].first = PMUSR_UNDEFINED;
722  fTemp[idx].second = errTemp;
723 }
724 
725 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
726 // implementation PMsrGlobalBlock
727 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
728 
729 //--------------------------------------------------------------------------
730 // PMsrGlobalBlock
731 //--------------------------------------------------------------------------
736 {
737  fGlobalPresent = false;
738  fRRFFreq = RRF_FREQ_UNDEF; // rotating reference frequency in units given by fRRFUnitTag. Only needed for fittype 1
739  fRRFUnitTag = RRF_UNIT_UNDEF; // RRF unit tag. Default: undefined
740  fRRFPhase = 0.0;
741  fRRFPacking = -1; // undefined RRF packing/rebinning
742  fFitType = -1; // undefined fit type
743  for (UInt_t i=0; i<4; i++) {
744  fDataRange[i] = -1; // undefined data bin range
745  }
746  fFitRangeInBins = false; // default is that fit range is given in time NOT bins
747  fFitRange[0] = PMUSR_UNDEFINED; // undefined start fit range
748  fFitRange[1] = PMUSR_UNDEFINED; // undefined end fit range
749  fFitRangeOffset[0] = -1; // undefined start fit range offset
750  fFitRangeOffset[1] = -1; // undefined end fit range offset
751  fPacking = -1; // undefined packing/rebinning
752 }
753 
754 //--------------------------------------------------------------------------
755 // GetRRFFreq (public)
756 //--------------------------------------------------------------------------
762 Double_t PMsrGlobalBlock::GetRRFFreq(const char *unit)
763 {
764  Double_t freq = 0.0;
765 
766  // check that the units given make sense
767  TString unitStr = unit;
768  Int_t unitTag = RRF_UNIT_UNDEF;
769  if (!unitStr.CompareTo("MHz", TString::kIgnoreCase))
770  unitTag = RRF_UNIT_MHz;
771  else if (!unitStr.CompareTo("Mc", TString::kIgnoreCase))
772  unitTag = RRF_UNIT_Mcs;
773  else if (!unitStr.CompareTo("T", TString::kIgnoreCase))
774  unitTag = RRF_UNIT_T;
775  else
776  return RRF_FREQ_UNDEF;
777 
778  // calc the conversion factor
779  if (unitTag == fRRFUnitTag)
780  freq = fRRFFreq;
781  else if ((unitTag == RRF_UNIT_MHz) && (fRRFUnitTag == RRF_UNIT_Mcs))
782  freq = fRRFFreq/TMath::TwoPi();
783  else if ((unitTag == RRF_UNIT_MHz) && (fRRFUnitTag == RRF_UNIT_T))
784  freq = fRRFFreq*1e4*GAMMA_BAR_MUON; // 1e4 need for T -> G since GAMMA_BAR_MUON is given in MHz/G
785  else if ((unitTag == RRF_UNIT_Mcs) && (fRRFUnitTag == RRF_UNIT_MHz))
786  freq = fRRFFreq*TMath::TwoPi();
787  else if ((unitTag == RRF_UNIT_Mcs) && (fRRFUnitTag == RRF_UNIT_T))
788  freq = fRRFFreq*1e4*TMath::TwoPi()*GAMMA_BAR_MUON; // 1e4 need for T -> G since GAMMA_BAR_MUON is given in MHz/G
789  else if ((unitTag == RRF_UNIT_T) && (fRRFUnitTag == RRF_UNIT_MHz))
790  freq = fRRFFreq/GAMMA_BAR_MUON*1e-4; // 1e-4 need for G -> T since GAMMA_BAR_MUON is given in MHz/G
791  else if ((unitTag == RRF_UNIT_T) && (fRRFUnitTag == RRF_UNIT_Mcs))
792  freq = fRRFFreq/(TMath::TwoPi()*GAMMA_BAR_MUON)*1e-4; // 1e-4 need for G -> T since GAMMA_BAR_MUON is given in MHz/G
793 
794  return freq;
795 }
796 
797 //--------------------------------------------------------------------------
798 // SetRRFFreq (public)
799 //--------------------------------------------------------------------------
806 void PMsrGlobalBlock::SetRRFFreq(Double_t freq, const char *unit)
807 {
808  // check that the units given make sense
809  TString unitStr = unit;
810  Int_t unitTag = RRF_UNIT_UNDEF;
811  if (!unitStr.CompareTo("MHz", TString::kIgnoreCase))
812  unitTag = RRF_UNIT_MHz;
813  else if (!unitStr.CompareTo("Mc", TString::kIgnoreCase))
814  unitTag = RRF_UNIT_Mcs;
815  else if (!unitStr.CompareTo("T", TString::kIgnoreCase))
816  unitTag = RRF_UNIT_T;
817  else {
818  std::cerr << std::endl << ">> PMsrGlobalBlock::SetRRFFreq: **ERROR** found undefined RRF unit '" << unit << "'!";
819  std::cerr << std::endl << ">> Will set RRF frequency to 0.0." << std::endl;
820  fRRFFreq = 0.0;
821  fRRFUnitTag = RRF_UNIT_UNDEF;
822  }
823 
824  fRRFFreq = freq;
825  fRRFUnitTag = unitTag;
826 }
827 
828 //--------------------------------------------------------------------------
829 // GetRRFUnit (public)
830 //--------------------------------------------------------------------------
835 {
836  TString unit;
837 
838  switch (fRRFUnitTag) {
839  case RRF_UNIT_UNDEF:
840  unit = TString("??");
841  break;
842  case RRF_UNIT_kHz:
843  unit = TString("kHz");
844  break;
845  case RRF_UNIT_MHz:
846  unit = TString("MHz");
847  break;
848  case RRF_UNIT_Mcs:
849  unit = TString("Mc");
850  break;
851  case RRF_UNIT_G:
852  unit = TString("G");
853  break;
854  case RRF_UNIT_T:
855  unit = TString("T");
856  break;
857  default:
858  unit = TString("??");
859  break;
860  }
861 
862  return unit;
863 }
864 
865 //--------------------------------------------------------------------------
866 // SetRRFPacking (public)
867 //--------------------------------------------------------------------------
874 {
875  if (pack <= 0) {
876  std::cerr << std::endl << "PMsrGlobalBlock::SetRRFPacking: **WARNING** found RRF packing <= 0. Likely doesn't make any sense." << std::endl;
877  fRRFPacking = -1; // set to undefined
878  }
879 
880  fRRFPacking = pack;
881 }
882 
883 //--------------------------------------------------------------------------
884 // GetDataRange (public)
885 //--------------------------------------------------------------------------
896 {
897  if (idx >= 4)
898  return -1;
899 
900  return fDataRange[idx];
901 }
902 
903 //--------------------------------------------------------------------------
904 // SetDataRange (public)
905 //--------------------------------------------------------------------------
912 void PMsrGlobalBlock::SetDataRange(Int_t ival, Int_t idx)
913 {
914  if (idx >= 4) {
915  std::cerr << std::endl << ">> PMsrGlobalBlock::SetDataRange: **WARNING** idx=" << idx << ", only idx=0..3 are sensible.";
916  std::cerr << std::endl;
917  return;
918  }
919 
920  fDataRange[idx] = ival;
921 }
922 
923 //--------------------------------------------------------------------------
924 // GetT0Bin (public)
925 //--------------------------------------------------------------------------
935 Double_t PMsrGlobalBlock::GetT0Bin(UInt_t idx)
936 {
937  if (idx >= fT0.size())
938  return -1;
939 
940  return fT0[idx];
941 }
942 
943 //--------------------------------------------------------------------------
944 // SetT0Bin (public)
945 //--------------------------------------------------------------------------
952 void PMsrGlobalBlock::SetT0Bin(Double_t dval, Int_t idx)
953 {
954  if (idx == -1) {
955  fT0.push_back(dval);
956  return;
957  }
958 
959  if (idx >= static_cast<Int_t>(fT0.size()))
960  fT0.resize(idx+1);
961 
962  fT0[idx] = dval;
963 }
964 
965 //--------------------------------------------------------------------------
966 // GetAddT0BinSize (public)
967 //--------------------------------------------------------------------------
977 Int_t PMsrGlobalBlock::GetAddT0BinSize(UInt_t addRunIdx)
978 {
979  if (fAddT0.empty())
980  return -1;
981 
982  if (addRunIdx >= fAddT0.size())
983  return -1;
984 
985  return fAddT0[addRunIdx].size();
986 }
987 
988 //--------------------------------------------------------------------------
989 // GetAddT0Bin (public)
990 //--------------------------------------------------------------------------
1001 Double_t PMsrGlobalBlock::GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx)
1002 {
1003  if (fAddT0.empty())
1004  return -1.0;
1005 
1006  if (addRunIdx >= fAddT0.size())
1007  return -1.0;
1008 
1009  if (fAddT0[addRunIdx].empty())
1010  return -1.0;
1011 
1012  if (histoIdx >= fAddT0[addRunIdx].size())
1013  return -1.0;
1014 
1015  return fAddT0[addRunIdx][histoIdx];
1016 }
1017 
1018 //--------------------------------------------------------------------------
1019 // SetAddT0Bin (public)
1020 //--------------------------------------------------------------------------
1028 void PMsrGlobalBlock::SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx)
1029 {
1030  if (addRunIdx >= fAddT0.size())
1031  fAddT0.resize(addRunIdx+1);
1032 
1033  if (histoNoIdx >= fAddT0[addRunIdx].size())
1034  fAddT0[addRunIdx].resize(histoNoIdx+1);
1035 
1036  fAddT0[addRunIdx][histoNoIdx] = dval;
1037 }
1038 
1039 //--------------------------------------------------------------------------
1040 // GetFitRange (public)
1041 //--------------------------------------------------------------------------
1051 Double_t PMsrGlobalBlock::GetFitRange(UInt_t idx)
1052 {
1053  if (idx >= 2)
1054  return PMUSR_UNDEFINED;
1055 
1056  return fFitRange[idx];
1057 }
1058 
1059 //--------------------------------------------------------------------------
1060 // SetFitRange (public)
1061 //--------------------------------------------------------------------------
1068 void PMsrGlobalBlock::SetFitRange(Double_t dval, UInt_t idx)
1069 {
1070  if (idx >= 2)
1071  return;
1072 
1073  fFitRange[idx] = dval;
1074 }
1075 
1076 //--------------------------------------------------------------------------
1077 // GetFitRangeOffset (public)
1078 //--------------------------------------------------------------------------
1089 {
1090  if (idx >= 2)
1091  return -1;
1092 
1093  return fFitRangeOffset[idx];
1094 }
1095 
1096 //--------------------------------------------------------------------------
1097 // SetFitRangeOffset (public)
1098 //--------------------------------------------------------------------------
1105 void PMsrGlobalBlock::SetFitRangeOffset(Int_t ival, UInt_t idx)
1106 {
1107  if (idx >= 2)
1108  return;
1109 
1110  fFitRangeOffset[idx] = ival;
1111 }
1112 
1113 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1114 // implementation PMsrRunBlock
1115 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1116 
1117 //--------------------------------------------------------------------------
1118 // PMsrRunBlock
1119 //--------------------------------------------------------------------------
1124 {
1125  fFitType = -1; // undefined fit type
1126  fAlphaParamNo = -1; // undefined alpha parameter number
1127  fBetaParamNo = -1; // undefined beta parameter number
1128  fNormParamNo = -1; // undefined norm parameter number
1129  fBkgFitParamNo = -1; // undefined background parameter number
1130  fLifetimeParamNo = -1; // undefined lifetime parameter number
1131  fLifetimeCorrection = false; // lifetime correction == false by default (used in single histogram musrview)
1132  for (UInt_t i=0; i<2; i++) {
1133  fBkgEstimated[i] = PMUSR_UNDEFINED;
1134  fBkgFix[i] = PMUSR_UNDEFINED;
1135  }
1136  for (UInt_t i=0; i<4; i++) {
1137  fBkgRange[i] = -1; // undefined start background range
1138  fDataRange[i] = -1; // undefined start data range
1139  }
1140  fFitRangeInBins = false; // default is that fit range is given in time NOT bins
1141  fFitRange[0] = PMUSR_UNDEFINED; // undefined start fit range
1142  fFitRange[1] = PMUSR_UNDEFINED; // undefined end fit range
1143  fFitRangeOffset[0] = -1; // undefined start fit range offset
1144  fFitRangeOffset[1] = -1; // undefined end fit range offset
1145  fPacking = -1; // undefined packing
1146  fXYDataIndex[0] = -1; // undefined x data index (NonMusr)
1147  fXYDataIndex[1] = -1; // undefined y data index (NonMusr)
1148  fXYDataLabel[0] = TString(""); // undefined x data label (NonMusr)
1149  fXYDataLabel[1] = TString(""); // undefined y data label (NonMusr)
1150 }
1151 
1152 //--------------------------------------------------------------------------
1153 // ~PMsrRunBlock
1154 //--------------------------------------------------------------------------
1159 {
1160  fRunName.clear();
1161  fBeamline.clear();
1162  fInstitute.clear();
1163  fFileFormat.clear();
1164  fForwardHistoNo.clear();
1165  fBackwardHistoNo.clear();
1166  fMap.clear();
1167  fT0.clear();
1168  fParGlobal.clear();
1169  fMapGlobal.clear();
1170 }
1171 
1172 //--------------------------------------------------------------------------
1173 // CleanUp (public)
1174 //--------------------------------------------------------------------------
1179 {
1180  fFitType = -1; // undefined fit type
1181  fAlphaParamNo = -1; // undefined alpha parameter number
1182  fBetaParamNo = -1; // undefined beta parameter number
1183  fNormParamNo = -1; // undefined norm parameter number
1184  fBkgFitParamNo = -1; // undefined background parameter number
1185  fLifetimeParamNo = -1; // undefined lifetime parameter number
1186  fLifetimeCorrection = false; // lifetime correction == false by default (used in single histogram musrview)
1187  fBkgFix[0] = PMUSR_UNDEFINED; // undefined fixed background for forward
1188  fBkgFix[1] = PMUSR_UNDEFINED; // undefined fixed background for backward
1189  for (UInt_t i=0; i<4; i++) {
1190  fBkgRange[i] = -1; // undefined background range
1191  fDataRange[i] = -1; // undefined data range
1192  }
1193  fFitRangeInBins = false; // default is that fit range is given in time NOT bins
1194  fFitRange[0] = PMUSR_UNDEFINED; // undefined start fit range
1195  fFitRange[1] = PMUSR_UNDEFINED; // undefined end fit range
1196  fFitRangeOffset[0] = -1; // undefined start fit range offset
1197  fFitRangeOffset[1] = -1; // undefined end fit range offset
1198  fPacking = -1; // undefined packing
1199  fXYDataIndex[0] = -1; // undefined x data index (NonMusr)
1200  fXYDataIndex[1] = -1; // undefined y data index (NonMusr)
1201  fXYDataLabel[0] = TString(""); // undefined x data label (NonMusr)
1202  fXYDataLabel[1] = TString(""); // undefined y data label (NonMusr)
1203 
1204  fRunName.clear();
1205  fBeamline.clear();
1206  fInstitute.clear();
1207  fFileFormat.clear();
1208  fForwardHistoNo.clear();
1209  fBackwardHistoNo.clear();
1210  fMap.clear();
1211  fT0.clear();
1212  for (UInt_t i=0; i<fAddT0.size(); i++)
1213  fAddT0[i].clear();
1214  fAddT0.clear();
1215 
1216  fParGlobal.clear();
1217  fMapGlobal.clear();
1218 }
1219 
1220 //--------------------------------------------------------------------------
1221 // GetRunName (public)
1222 //--------------------------------------------------------------------------
1232 TString* PMsrRunBlock::GetRunName(UInt_t idx)
1233 {
1234  if (idx>fRunName.size())
1235  return nullptr;
1236 
1237  return &fRunName[idx];
1238 }
1239 
1240 //--------------------------------------------------------------------------
1241 // SetRunName (public)
1242 //--------------------------------------------------------------------------
1249 void PMsrRunBlock::SetRunName(TString &str, Int_t idx)
1250 {
1251  if (idx == -1) {
1252  fRunName.push_back(str);
1253  return;
1254  }
1255 
1256  if (idx >= static_cast<Int_t>(fRunName.size()))
1257  fRunName.resize(idx+1);
1258 
1259  fRunName[idx] = str;
1260 }
1261 
1262 //--------------------------------------------------------------------------
1263 // GetBeamline (public)
1264 //--------------------------------------------------------------------------
1274 TString* PMsrRunBlock::GetBeamline(UInt_t idx)
1275 {
1276  if (idx>fBeamline.size())
1277  return nullptr;
1278 
1279  return &fBeamline[idx];
1280 }
1281 
1282 //--------------------------------------------------------------------------
1283 // SetBeamline (public)
1284 //--------------------------------------------------------------------------
1291 void PMsrRunBlock::SetBeamline(TString &str, Int_t idx)
1292 {
1293  if (idx == -1) {
1294  fBeamline.push_back(str);
1295  return;
1296  }
1297 
1298  if (idx >= static_cast<Int_t>(fBeamline.size()))
1299  fBeamline.resize(idx+1);
1300 
1301  fBeamline[idx] = str;
1302 }
1303 
1304 //--------------------------------------------------------------------------
1305 // GetInstitute (public)
1306 //--------------------------------------------------------------------------
1316 TString* PMsrRunBlock::GetInstitute(UInt_t idx)
1317 {
1318  if (idx>fInstitute.size())
1319  return nullptr;
1320 
1321  return &fInstitute[idx];
1322 }
1323 
1324 //--------------------------------------------------------------------------
1325 // SetInstitute (public)
1326 //--------------------------------------------------------------------------
1333 void PMsrRunBlock::SetInstitute(TString &str, Int_t idx)
1334 {
1335  if (idx == -1) {
1336  fInstitute.push_back(str);
1337  return;
1338  }
1339 
1340  if (idx >= static_cast<Int_t>(fInstitute.size()))
1341  fInstitute.resize(idx+1);
1342 
1343  fInstitute[idx] = str;
1344 }
1345 
1346 //--------------------------------------------------------------------------
1347 // GetFileFormat (public)
1348 //--------------------------------------------------------------------------
1358 TString* PMsrRunBlock::GetFileFormat(UInt_t idx)
1359 {
1360  if (idx>fFileFormat.size())
1361  return nullptr;
1362 
1363  return &fFileFormat[idx];
1364 }
1365 
1366 //--------------------------------------------------------------------------
1367 // SetFileFormat (public)
1368 //--------------------------------------------------------------------------
1375 void PMsrRunBlock::SetFileFormat(TString &str, Int_t idx)
1376 {
1377  if (idx == -1) {
1378  fFileFormat.push_back(str);
1379  return;
1380  }
1381 
1382  if (idx >= static_cast<Int_t>(fFileFormat.size()))
1383  fFileFormat.resize(idx+1);
1384 
1385  fFileFormat[idx] = str;
1386 }
1387 
1388 //--------------------------------------------------------------------------
1389 // GetForwardHistoNo (public)
1390 //--------------------------------------------------------------------------
1401 {
1402  if (fForwardHistoNo.empty())
1403  return -1;
1404 
1405  if (idx>fForwardHistoNo.size())
1406  return -1;
1407 
1408  return fForwardHistoNo[idx];
1409 }
1410 
1411 //--------------------------------------------------------------------------
1412 // SetForwardHistoNo (public)
1413 //--------------------------------------------------------------------------
1421 void PMsrRunBlock::SetForwardHistoNo(Int_t histoNo, Int_t idx)
1422 {
1423  if (idx == -1) { // i.e. append forward histo no
1424  fForwardHistoNo.push_back(histoNo);
1425  } else {
1426  if (idx >= static_cast<Int_t>(fForwardHistoNo.size()))
1427  fForwardHistoNo.resize(idx+1);
1428  fForwardHistoNo[idx] = histoNo;
1429  }
1430 }
1431 
1432 //--------------------------------------------------------------------------
1433 // GetBackwardHistoNo (public)
1434 //--------------------------------------------------------------------------
1445 {
1446  if (fBackwardHistoNo.empty())
1447  return -1;
1448 
1449  if (idx>fBackwardHistoNo.size())
1450  return -1;
1451 
1452  return fBackwardHistoNo[idx];
1453 }
1454 
1455 //--------------------------------------------------------------------------
1456 // SetBackwardHistoNo (public)
1457 //--------------------------------------------------------------------------
1465 void PMsrRunBlock::SetBackwardHistoNo(Int_t histoNo, Int_t idx)
1466 {
1467  if (idx == -1) { // i.e. append forward histo no
1468  fBackwardHistoNo.push_back(histoNo);
1469  } else {
1470  if (idx >= static_cast<Int_t>(fBackwardHistoNo.size()))
1471  fBackwardHistoNo.resize(idx+1);
1472  fBackwardHistoNo[idx] = histoNo;
1473  }
1474 }
1475 
1476 //--------------------------------------------------------------------------
1477 // GetMap (public)
1478 //--------------------------------------------------------------------------
1488 Int_t PMsrRunBlock::GetMap(UInt_t idx)
1489 {
1490  if (idx>fMap.size())
1491  return -1;
1492 
1493  return fMap[idx];
1494 }
1495 
1496 //--------------------------------------------------------------------------
1497 // SetMap (public)
1498 //--------------------------------------------------------------------------
1505 void PMsrRunBlock::SetMap(Int_t mapVal, Int_t idx)
1506 {
1507  if (idx == -1) {
1508  fMap.push_back(mapVal);
1509  return;
1510  }
1511 
1512  if (idx >= static_cast<Int_t>(fMap.size()))
1513  fMap.resize(idx+1);
1514 
1515  fMap[idx] = mapVal;
1516 }
1517 
1518 //--------------------------------------------------------------------------
1519 // GetBkgEstimated (public)
1520 //--------------------------------------------------------------------------
1531 Double_t PMsrRunBlock::GetBkgEstimated(UInt_t idx)
1532 {
1533  if (idx >= 2)
1534  return PMUSR_UNDEFINED;
1535 
1536  return fBkgEstimated[idx];
1537 }
1538 
1539 
1540 //--------------------------------------------------------------------------
1541 // SetBkgEstimated (public)
1542 //--------------------------------------------------------------------------
1549 void PMsrRunBlock::SetBkgEstimated(Double_t dval, Int_t idx)
1550 {
1551  if (idx >= 2) {
1552  std::cerr << std::endl << ">> PMsrRunBlock::SetBkgEstimated: **WARNING** idx=" << idx << ", only idx=0,1 are sensible.";
1553  std::cerr << std::endl;
1554  return;
1555  }
1556 
1557  fBkgEstimated[idx] = dval;
1558 }
1559 
1560 //--------------------------------------------------------------------------
1561 // GetBkgFix (public)
1562 //--------------------------------------------------------------------------
1572 Double_t PMsrRunBlock::GetBkgFix(UInt_t idx)
1573 {
1574  if (idx >= 2)
1575  return PMUSR_UNDEFINED;
1576 
1577  return fBkgFix[idx];
1578 }
1579 
1580 //--------------------------------------------------------------------------
1581 // SetBkgFix (public)
1582 //--------------------------------------------------------------------------
1589 void PMsrRunBlock::SetBkgFix(Double_t dval, Int_t idx)
1590 {
1591  if (idx >= 2) {
1592  std::cerr << std::endl << ">> PMsrRunBlock::SetBkgFix: **WARNING** idx=" << idx << ", only idx=0,1 are sensible.";
1593  std::cerr << std::endl;
1594  return;
1595  }
1596 
1597  fBkgFix[idx] = dval;
1598 }
1599 
1600 //--------------------------------------------------------------------------
1601 // GetBkgRange (public)
1602 //--------------------------------------------------------------------------
1612 Int_t PMsrRunBlock::GetBkgRange(UInt_t idx)
1613 {
1614  if (idx >= 4) {
1615  return -1;
1616  }
1617 
1618  return fBkgRange[idx];
1619 }
1620 
1621 //--------------------------------------------------------------------------
1622 // SetBkgRange (public)
1623 //--------------------------------------------------------------------------
1630 void PMsrRunBlock::SetBkgRange(Int_t ival, Int_t idx)
1631 {
1632  if (idx >= 4) {
1633  std::cerr << std::endl << ">> PMsrRunBlock::SetBkgRange: **WARNING** idx=" << idx << ", only idx=0..3 are sensible.";
1634  std::cerr << std::endl;
1635  return;
1636  }
1637 
1638  fBkgRange[idx] = ival;
1639 }
1640 
1641 
1642 //--------------------------------------------------------------------------
1643 // GetDataRange (public)
1644 //--------------------------------------------------------------------------
1655 {
1656  if (idx >= 4) {
1657  return -1;
1658  }
1659 
1660  return fDataRange[idx];
1661 }
1662 
1663 //--------------------------------------------------------------------------
1664 // SetDataRange (public)
1665 //--------------------------------------------------------------------------
1672 void PMsrRunBlock::SetDataRange(Int_t ival, Int_t idx)
1673 {
1674  if (idx >= 4) {
1675  std::cerr << std::endl << ">> PMsrRunBlock::SetDataRange: **WARNING** idx=" << idx << ", only idx=0..3 are sensible.";
1676  std::cerr << std::endl;
1677  return;
1678  }
1679 
1680  fDataRange[idx] = ival;
1681 }
1682 
1683 //--------------------------------------------------------------------------
1684 // GetT0Bin (public)
1685 //--------------------------------------------------------------------------
1695 Double_t PMsrRunBlock::GetT0Bin(UInt_t idx)
1696 {
1697  if (idx >= fT0.size())
1698  return -1;
1699 
1700  return fT0[idx];
1701 }
1702 
1703 //--------------------------------------------------------------------------
1704 // SetT0Bin (public)
1705 //--------------------------------------------------------------------------
1712 void PMsrRunBlock::SetT0Bin(Double_t dval, Int_t idx)
1713 {
1714  if (idx == -1) {
1715  fT0.push_back(dval);
1716  return;
1717  }
1718 
1719  if (idx >= static_cast<Int_t>(fT0.size()))
1720  fT0.resize(idx+1);
1721 
1722  fT0[idx] = dval;
1723 }
1724 
1725 //--------------------------------------------------------------------------
1726 // GetAddT0BinSize (public)
1727 //--------------------------------------------------------------------------
1737 Int_t PMsrRunBlock::GetAddT0BinSize(UInt_t addRunIdx)
1738 {
1739  if (fAddT0.empty())
1740  return -1;
1741 
1742  if (addRunIdx >= fAddT0.size())
1743  return -1;
1744 
1745  return fAddT0[addRunIdx].size();
1746 }
1747 
1748 //--------------------------------------------------------------------------
1749 // GetAddT0Bin (public)
1750 //--------------------------------------------------------------------------
1761 Double_t PMsrRunBlock::GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx)
1762 {
1763  if (fAddT0.empty())
1764  return -1.0;
1765 
1766  if (addRunIdx >= fAddT0.size())
1767  return -1.0;
1768 
1769  if (fAddT0[addRunIdx].empty())
1770  return -1.0;
1771 
1772  if (histoIdx >= fAddT0[addRunIdx].size())
1773  return -1.0;
1774 
1775  return fAddT0[addRunIdx][histoIdx];
1776 }
1777 
1778 //--------------------------------------------------------------------------
1779 // SetAddT0Bin (public)
1780 //--------------------------------------------------------------------------
1788 void PMsrRunBlock::SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx)
1789 {
1790  if (addRunIdx >= fAddT0.size())
1791  fAddT0.resize(addRunIdx+1);
1792 
1793  if (histoNoIdx >= fAddT0[addRunIdx].size())
1794  fAddT0[addRunIdx].resize(histoNoIdx+1);
1795 
1796  fAddT0[addRunIdx][histoNoIdx] = dval;
1797 }
1798 
1799 //--------------------------------------------------------------------------
1800 // GetFitRange (public)
1801 //--------------------------------------------------------------------------
1811 Double_t PMsrRunBlock::GetFitRange(UInt_t idx)
1812 {
1813  if (idx >= 2)
1814  return PMUSR_UNDEFINED;
1815 
1816  return fFitRange[idx];
1817 }
1818 
1819 //--------------------------------------------------------------------------
1820 // SetFitRange (public)
1821 //--------------------------------------------------------------------------
1828 void PMsrRunBlock::SetFitRange(Double_t dval, UInt_t idx)
1829 {
1830  if (idx >= 2)
1831  return;
1832 
1833  fFitRange[idx] = dval;
1834 }
1835 
1836 //--------------------------------------------------------------------------
1837 // GetFitRangeOffset (public)
1838 //--------------------------------------------------------------------------
1849 {
1850  if (idx >= 2)
1851  return -1;
1852 
1853  return fFitRangeOffset[idx];
1854 }
1855 
1856 //--------------------------------------------------------------------------
1857 // SetFitRangeOffset (public)
1858 //--------------------------------------------------------------------------
1865 void PMsrRunBlock::SetFitRangeOffset(Int_t ival, UInt_t idx)
1866 {
1867  if (idx >= 2)
1868  return;
1869 
1870  fFitRangeOffset[idx] = ival;
1871 }
1872 
1873 //--------------------------------------------------------------------------
1874 // SetParGlobal (public)
1875 //--------------------------------------------------------------------------
1882 void PMsrRunBlock::SetParGlobal(const TString &str, Int_t ival)
1883 {
1884  fParGlobal[str] = ival; // will either create a new entry or overwrite an old one if the key "str" is present
1885  return;
1886 }
1887 
1888 //--------------------------------------------------------------------------
1889 // SetMapGlobal (public)
1890 //--------------------------------------------------------------------------
1897 void PMsrRunBlock::SetMapGlobal(UInt_t idx, Int_t ival)
1898 {
1899  if (fMapGlobal.size() != fMap.size())
1900  fMapGlobal.resize(fMap.size(), -1);
1901  if (idx < fMap.size() && fMap[idx] > 0)
1902  fMapGlobal[idx] = ival;
1903  // else do nothing at the moment
1904  return;
1905 }
1906 
1907 //--------------------------------------------------------------------------
1908 // SetEstimatedAlpha (public)
1909 //--------------------------------------------------------------------------
1916 {
1917  fAlpha = dval;
1918 }
1919 
1920 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1921 // implementation PStringNumberList
1922 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1923 
1924 //--------------------------------------------------------------------------
1925 // Parse (public)
1926 //--------------------------------------------------------------------------
1938 bool PStringNumberList::Parse(std::string &errorMsg, bool ignoreFirstToken)
1939 {
1940  bool result=true;
1941  std::vector<std::string> splitVec;
1942  int ival;
1943 
1944  // before checking tokens, remove 'forbidden' " - " and " : "
1945  StripSpaces();
1946 
1947  // split string into space separated tokens
1948  split(splitVec, fString, is_any_of(" "), token_compress_on);
1949 
1950  unsigned int start=0;
1951  if (ignoreFirstToken)
1952  start=1;
1953 
1954  for (unsigned int i=start; i<splitVec.size(); i++) {
1955  if (splitVec[i].length() != 0) { // ignore empty tokens
1956  if (splitVec[i].find("-") != std::string::npos) { // check for potential range
1957  std::vector<std::string> subSplitVec;
1958  // split potential nS-nE token
1959  split(subSplitVec, splitVec[i], is_any_of("-"), token_compress_on);
1960 
1961  int start=-1, end=-1;
1962  unsigned int count=0;
1963  for (unsigned int j=0; j<subSplitVec.size(); j++) {
1964  if (subSplitVec[j].length() != 0) { // ignore empty tokens
1965  if (!IsNumber(subSplitVec[j])) {
1966  result = false;
1967  } else {
1968  count++;
1969  if (count == 1)
1970  start = atoi(subSplitVec[j].c_str());
1971  else if (count == 2)
1972  end = atoi(subSplitVec[j].c_str());
1973  else
1974  result = false;
1975  }
1976  }
1977  }
1978  if ((start < 0) || (end < 0)) { // check that there is a vaild start and end
1979  errorMsg = "**ERROR** start or end of a range is not valid";
1980  result = false;
1981  }
1982  if (result) { // no error, hence check start and end
1983  if (start > end) {
1984  int swap = end;
1985  std::cerr << "**WARNING** start=" << start << " > end=" << end << ", hence I will swap them" << std::endl;
1986  end = start;
1987  start = swap;
1988  }
1989  for (int j=start; j<=end; j++)
1990  fList.push_back(j);
1991  }
1992  } else if (splitVec[i].find(":") != std::string::npos) { // check for potential sequence
1993  std::vector<std::string> subSplitVec;
1994  // split potential rStart:rEnd:rStep token
1995  split(subSplitVec, splitVec[i], is_any_of(":"), token_compress_on);
1996 
1997  int start=-1, end=-1, step=-1;
1998  unsigned int count=0;
1999  for (unsigned int j=0; j<subSplitVec.size(); j++) {
2000  if (subSplitVec[j].length() != 0) { // ignore empty tokens
2001  if (!IsNumber(subSplitVec[j])) {
2002  result = false;
2003  } else {
2004  count++;
2005  if (count == 1)
2006  start = atoi(subSplitVec[j].c_str());
2007  else if (count == 2)
2008  end = atoi(subSplitVec[j].c_str());
2009  else if (count == 3)
2010  step = atoi(subSplitVec[j].c_str());
2011  else
2012  result = false;
2013  }
2014  }
2015  }
2016  if ((start < 0) || (end < 0) || (step < 0)) { // check that there is a vaild start and end
2017  errorMsg = "**ERROR** start, end, or step of a sequence is not valid";
2018  result = false;
2019  }
2020  if (result) { // no error, hence check start and end
2021  if (start > end) {
2022  int swap = end;
2023  std::cerr << "**WARNING** start=" << start << " > end=" << end << ", hence I will swap them" << std::endl;
2024  end = start;
2025  start = swap;
2026  }
2027  for (int j=start; j<=end; j+=step)
2028  fList.push_back(j);
2029  }
2030  } else if (IsNumber(splitVec[i])) {
2031  ival = atoi(splitVec[i].c_str());
2032  fList.push_back(ival);
2033  } else {
2034  errorMsg = "**ERROR** invalid token: " + splitVec[i];
2035  result = false;
2036  }
2037  }
2038  }
2039 
2040  return result;
2041 }
2042 
2043 //--------------------------------------------------------------------------
2044 // StripSpaces (private)
2045 //--------------------------------------------------------------------------
2051 {
2052  std::string str=fString;
2053  int pos=-1;
2054 
2055  // backward scan
2056  for (int i=str.size(); i>=0; --i) { // check if first space is found
2057  if ((str[i] == ' ') && (pos == -1)) {
2058  pos = i;
2059  } else if ((str[i] == '-') || (str[i] == ':')) { // check for '-' or ':'
2060  if (pos != -1) {
2061  str.erase(i+1, pos-i);
2062  }
2063  } else if (str[i] != ' ') { // anything but different than a space leads to a reset of the pos counter
2064  pos = -1;
2065  }
2066  }
2067  // forward scan
2068  for (unsigned int i=0; i<str.size(); i++) { // check if first space is found
2069  if ((str[i] == ' ') && (pos == -1)) {
2070  pos = i;
2071  } else if ((str[i] == '-') || (str[i] == ':')) { // check for '-' or ':'
2072  if (pos != -1) {
2073  str.erase(pos, i-pos);
2074  i = pos;
2075  }
2076  } else if (str[i] != ' ') { // anything but different than a space leads to a reset of the pos counter
2077  pos = -1;
2078  }
2079  }
2080 
2081  fString = str;
2082 }
virtual PRawRunDataSet * Get(UInt_t histoNo)
Definition: PMusr.cpp:340
virtual ~PMsrRunBlock()
Definition: PMusr.cpp:1158
virtual TString * GetBeamline(UInt_t idx=0)
Definition: PMusr.cpp:1274
virtual Double_t GetT0BinEstimated(UInt_t histoNo)
Definition: PMusr.cpp:435
virtual TString GetRRFUnit()
Definition: PMusr.cpp:834
virtual void SetDataRange(Int_t ival, Int_t idx)
Definition: PMusr.cpp:1672
virtual Double_t GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx)
Definition: PMusr.cpp:1001
virtual Int_t GetDataRange(UInt_t idx)
Definition: PMusr.cpp:895
virtual Double_t GetT0Bin(UInt_t idx=0)
Definition: PMusr.cpp:935
virtual void SetFitRangeOffset(Int_t ival, UInt_t idx)
Definition: PMusr.cpp:1865
virtual void CleanUp()
Definition: PMusr.cpp:1178
virtual void SetFitRangeOffset(Int_t ival, UInt_t idx)
Definition: PMusr.cpp:1105
virtual TString * GetFileFormat(UInt_t idx=0)
Definition: PMusr.cpp:1358
virtual void SetBkgEstimated(Double_t dval, Int_t idx)
Definition: PMusr.cpp:1549
virtual void SetBackwardHistoNo(Int_t histoNo, Int_t idx=-1)
Definition: PMusr.cpp:1465
virtual Int_t GetFitRangeOffset(UInt_t idx)
Definition: PMusr.cpp:1088
virtual void SetRunName(TString &str, Int_t idx=-1)
Definition: PMusr.cpp:1249
virtual void SetBeamline(TString &str, Int_t idx=-1)
Definition: PMusr.cpp:1291
virtual void SetEstimatedAlpha(Double_t dval)
Definition: PMusr.cpp:1915
virtual const Double_t GetTempError(const UInt_t idx)
Definition: PMusr.cpp:618
virtual const PDoublePairVector * GetTemperature() const
Definition: PMusr.h:422
virtual void SetRingAnode(const UInt_t idx, const Double_t dval)
Definition: PMusr.cpp:681
virtual void SetTempError(const UInt_t idx, const Double_t errTemp)
Definition: PMusr.cpp:716
#define RRF_FREQ_UNDEF
Definition: PMusr.h:160
virtual PRawRunDataSet * operator[](UInt_t histoNo)
Definition: PMusr.cpp:366
virtual void SetParGlobal(const TString &str, Int_t ival)
Definition: PMusr.cpp:1882
virtual void Clear()
Definition: PMusr.cpp:261
#define RRF_UNIT_MHz
Definition: PMusr.h:155
virtual void SetMap(Int_t mapVal, Int_t idx=-1)
Definition: PMusr.cpp:1505
#define RRF_UNIT_kHz
Definition: PMusr.h:154
virtual Double_t GetT0Bin(UInt_t histoNo)
Definition: PMusr.cpp:409
virtual Double_t GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx)
Definition: PMusr.cpp:1761
virtual ~PNonMusrRawRunData()
Definition: PMusr.cpp:139
virtual Bool_t IsPresent(UInt_t histoNo)
Definition: PMusr.cpp:290
virtual ~PRunData()
Definition: PMusr.cpp:69
virtual void SetFileFormat(TString &str, Int_t idx=-1)
Definition: PMusr.cpp:1375
virtual void AppendSubErrData(const UInt_t idx, const Double_t dval)
Definition: PMusr.cpp:229
virtual Double_t GetT0Bin(UInt_t idx=0)
Definition: PMusr.cpp:1695
std::vector< Double_t > PDoubleVector
Definition: PMusr.h:196
virtual Double_t GetRRFFreq(const char *unit)
Definition: PMusr.cpp:762
virtual const PDoubleVector GetRingAnode()
Definition: PMusr.h:427
virtual Int_t GetBackwardHistoNo(UInt_t idx=0)
Definition: PMusr.cpp:1444
virtual PIntPair GetBkgBin(UInt_t histoNo)
Definition: PMusr.cpp:461
virtual void Set(PRawRunDataSet dataSet, Int_t idx=-1)
Definition: PMusr.cpp:514
virtual void SetT0Bin(Double_t dval, Int_t idx=-1)
Definition: PMusr.cpp:1712
#define RRF_UNIT_T
Definition: PMusr.h:158
virtual void SetForwardHistoNo(Int_t histoNo, Int_t idx=-1)
Definition: PMusr.cpp:1421
virtual PRawRunDataSet * GetSet(UInt_t idx)
Definition: PMusr.cpp:318
virtual bool Parse(std::string &errorMsg, bool ignoreFirstToken=false)
Definition: PMusr.cpp:1938
virtual Int_t GetAddT0BinSize(UInt_t addRunIdx)
Definition: PMusr.cpp:1737
virtual Int_t GetFitRangeOffset(UInt_t idx)
Definition: PMusr.cpp:1848
#define RRF_UNIT_G
Definition: PMusr.h:157
#define RRF_UNIT_Mcs
Definition: PMusr.h:156
virtual void SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx)
Definition: PMusr.cpp:1788
virtual void SetMapGlobal(UInt_t idx, Int_t ival)
Definition: PMusr.cpp:1897
virtual Double_t GetBkgFix(UInt_t idx)
Definition: PMusr.cpp:1572
virtual PDoubleVector * GetData(UInt_t histoNo)
Definition: PMusr.cpp:383
virtual void SetInstitute(TString &str, Int_t idx=-1)
Definition: PMusr.cpp:1333
virtual void StripSpaces()
Definition: PMusr.cpp:2050
virtual void SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx)
Definition: PMusr.cpp:1028
virtual void SetRRFPacking(Int_t pack)
Definition: PMusr.cpp:873
#define PMUSR_UNDEFINED
Definition: PMusr.h:89
virtual Int_t GetForwardHistoNo(UInt_t idx=0)
Definition: PMusr.cpp:1400
virtual void SetSize(const UInt_t size)
Definition: PMusr.cpp:162
virtual void SetT0Bin(Double_t dval, Int_t idx=-1)
Definition: PMusr.cpp:952
virtual Int_t GetBkgRange(UInt_t idx)
Definition: PMusr.cpp:1612
virtual void AppendSubData(const UInt_t idx, const Double_t dval)
Definition: PMusr.cpp:209
virtual void SetBkgRange(Int_t ival, Int_t idx)
Definition: PMusr.cpp:1630
virtual void SetFitRange(Double_t dval, UInt_t idx)
Definition: PMusr.cpp:1828
virtual void SetRRFFreq(Double_t freq, const char *unit)
Definition: PMusr.cpp:806
PRunData()
Definition: PMusr.cpp:50
virtual TString * GetInstitute(UInt_t idx=0)
Definition: PMusr.cpp:1316
virtual void SetLabel(const UInt_t idx, const TString str)
Definition: PMusr.cpp:189
virtual Int_t GetAddT0BinSize(UInt_t addRunIdx)
Definition: PMusr.cpp:977
virtual ~PRawRunData()
Definition: PMusr.cpp:577
virtual void SetFitRange(Double_t dval, UInt_t idx)
Definition: PMusr.cpp:1068
PRawRunData()
Definition: PMusr.cpp:535
virtual PIntVector * GetMap()
Definition: PMusr.h:650
#define RRF_UNIT_UNDEF
Definition: PMusr.h:153
virtual Int_t GetDataRange(UInt_t idx)
Definition: PMusr.cpp:1654
virtual PRawRunDataSet * GetDataSet(const UInt_t idx, Bool_t wantHistoNo=true)
Definition: PMusr.cpp:663
virtual void SetDataRange(Int_t ival, Int_t idx)
Definition: PMusr.cpp:912
virtual Double_t GetFitRange(UInt_t idx)
Definition: PMusr.cpp:1051
virtual PIntPair GetGoodDataBin(UInt_t histoNo)
Definition: PMusr.cpp:488
virtual Double_t GetBkgEstimated(UInt_t idx)
Definition: PMusr.cpp:1531
virtual void SetTemperature(const UInt_t idx, const Double_t temp, const Double_t errTemp)
Definition: PMusr.cpp:698
virtual void ReplaceTheory(const PDoubleVector &theo)
Definition: PMusr.cpp:103
#define GAMMA_BAR_MUON
Definition: PMusr.h:78
virtual void SetBkgFix(Double_t dval, Int_t idx)
Definition: PMusr.cpp:1589
virtual TString * GetRunName(UInt_t idx=0)
Definition: PMusr.cpp:1232
virtual Double_t GetFitRange(UInt_t idx)
Definition: PMusr.cpp:1811
std::pair< Int_t, Int_t > PIntPair
Definition: PMusr.h:184
virtual void SetTheoryValue(UInt_t i, Double_t dval)
Definition: PMusr.cpp:87