33 #include <boost/algorithm/string.hpp> 34 using namespace boost;
89 if (idx > fTheory.size())
90 fTheory.resize(idx+1);
124 for (UInt_t i=0; i<fData.size(); i++)
128 for (UInt_t i=0; i<fErrData.size(); i++)
144 for (UInt_t i=0; i<fData.size(); i++)
148 for (UInt_t i=0; i<fErrData.size(); i++)
165 for (UInt_t i=0; i<fData.size(); i++) {
169 for (UInt_t i=0; i<fErrData.size(); i++) {
176 fErrData.resize(size);
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;
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;
216 fData[idx].push_back(dval);
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;
236 fErrData[idx].push_back(dval);
263 fName = TString(
"n/a");
266 fTimeZeroBinEstimated = 0.0;
294 for (UInt_t i=0; i<fDataVec.size(); i++) {
295 if (fDataVec[i].GetHistoNo() ==
static_cast<Int_t
>(histoNo)) {
322 if (idx >= fDataVec.size())
325 return &fDataVec[idx];
344 for (UInt_t i=0; i<fDataVec.size(); i++) {
345 if (fDataVec[i].GetHistoNo() ==
static_cast<Int_t
>(histoNo)) {
346 result = &fDataVec[i];
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();
411 Double_t result=-1.0;
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();
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();
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();
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();
517 fDataVec.push_back(dataSet);
519 if (idx >= static_cast<Int_t>(fDataVec.size()))
520 fDataVec.resize(idx+1);
521 fDataVec[idx] = dataSet;
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");
550 fRunName = TString(
"n/a");
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");
568 fRedGreenOffset.push_back(0);
581 fRedGreenOffset.clear();
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;
603 return fTemp[idx].first;
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;
625 return fTemp[idx].second;
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;
647 return fRingAnode[idx];
668 return fData.GetSet(idx);
683 if (idx >= fRingAnode.size())
684 fRingAnode.resize(idx+1);
685 fRingAnode[idx] = dval;
700 if (idx >= fTemp.size()) {
703 fTemp[idx].first = temp;
704 fTemp[idx].second = errTemp;
718 if (idx >= fTemp.size()) {
722 fTemp[idx].second = errTemp;
737 fGlobalPresent =
false;
743 for (UInt_t i=0; i<4; i++) {
746 fFitRangeInBins =
false;
749 fFitRangeOffset[0] = -1;
750 fFitRangeOffset[1] = -1;
767 TString unitStr = unit;
769 if (!unitStr.CompareTo(
"MHz", TString::kIgnoreCase))
771 else if (!unitStr.CompareTo(
"Mc", TString::kIgnoreCase))
773 else if (!unitStr.CompareTo(
"T", TString::kIgnoreCase))
779 if (unitTag == fRRFUnitTag)
782 freq = fRRFFreq/TMath::TwoPi();
786 freq = fRRFFreq*TMath::TwoPi();
809 TString unitStr = unit;
811 if (!unitStr.CompareTo(
"MHz", TString::kIgnoreCase))
813 else if (!unitStr.CompareTo(
"Mc", TString::kIgnoreCase))
815 else if (!unitStr.CompareTo(
"T", TString::kIgnoreCase))
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;
825 fRRFUnitTag = unitTag;
838 switch (fRRFUnitTag) {
840 unit = TString(
"??");
843 unit = TString(
"kHz");
846 unit = TString(
"MHz");
849 unit = TString(
"Mc");
858 unit = TString(
"??");
876 std::cerr << std::endl <<
"PMsrGlobalBlock::SetRRFPacking: **WARNING** found RRF packing <= 0. Likely doesn't make any sense." << std::endl;
900 return fDataRange[idx];
915 std::cerr << std::endl <<
">> PMsrGlobalBlock::SetDataRange: **WARNING** idx=" << idx <<
", only idx=0..3 are sensible.";
916 std::cerr << std::endl;
920 fDataRange[idx] = ival;
937 if (idx >= fT0.size())
959 if (idx >= static_cast<Int_t>(fT0.size()))
982 if (addRunIdx >= fAddT0.size())
985 return fAddT0[addRunIdx].size();
1006 if (addRunIdx >= fAddT0.size())
1009 if (fAddT0[addRunIdx].empty())
1012 if (histoIdx >= fAddT0[addRunIdx].size())
1015 return fAddT0[addRunIdx][histoIdx];
1030 if (addRunIdx >= fAddT0.size())
1031 fAddT0.resize(addRunIdx+1);
1033 if (histoNoIdx >= fAddT0[addRunIdx].size())
1034 fAddT0[addRunIdx].resize(histoNoIdx+1);
1036 fAddT0[addRunIdx][histoNoIdx] = dval;
1056 return fFitRange[idx];
1073 fFitRange[idx] = dval;
1093 return fFitRangeOffset[idx];
1110 fFitRangeOffset[idx] = ival;
1129 fBkgFitParamNo = -1;
1130 fLifetimeParamNo = -1;
1131 fLifetimeCorrection =
false;
1132 for (UInt_t i=0; i<2; i++) {
1136 for (UInt_t i=0; i<4; i++) {
1140 fFitRangeInBins =
false;
1143 fFitRangeOffset[0] = -1;
1144 fFitRangeOffset[1] = -1;
1146 fXYDataIndex[0] = -1;
1147 fXYDataIndex[1] = -1;
1148 fXYDataLabel[0] = TString(
"");
1149 fXYDataLabel[1] = TString(
"");
1163 fFileFormat.clear();
1164 fForwardHistoNo.clear();
1165 fBackwardHistoNo.clear();
1184 fBkgFitParamNo = -1;
1185 fLifetimeParamNo = -1;
1186 fLifetimeCorrection =
false;
1189 for (UInt_t i=0; i<4; i++) {
1193 fFitRangeInBins =
false;
1196 fFitRangeOffset[0] = -1;
1197 fFitRangeOffset[1] = -1;
1199 fXYDataIndex[0] = -1;
1200 fXYDataIndex[1] = -1;
1201 fXYDataLabel[0] = TString(
"");
1202 fXYDataLabel[1] = TString(
"");
1207 fFileFormat.clear();
1208 fForwardHistoNo.clear();
1209 fBackwardHistoNo.clear();
1212 for (UInt_t i=0; i<fAddT0.size(); i++)
1234 if (idx>fRunName.size())
1237 return &fRunName[idx];
1252 fRunName.push_back(str);
1256 if (idx >= static_cast<Int_t>(fRunName.size()))
1257 fRunName.resize(idx+1);
1259 fRunName[idx] = str;
1276 if (idx>fBeamline.size())
1279 return &fBeamline[idx];
1294 fBeamline.push_back(str);
1298 if (idx >= static_cast<Int_t>(fBeamline.size()))
1299 fBeamline.resize(idx+1);
1301 fBeamline[idx] = str;
1318 if (idx>fInstitute.size())
1321 return &fInstitute[idx];
1336 fInstitute.push_back(str);
1340 if (idx >= static_cast<Int_t>(fInstitute.size()))
1341 fInstitute.resize(idx+1);
1343 fInstitute[idx] = str;
1360 if (idx>fFileFormat.size())
1363 return &fFileFormat[idx];
1378 fFileFormat.push_back(str);
1382 if (idx >= static_cast<Int_t>(fFileFormat.size()))
1383 fFileFormat.resize(idx+1);
1385 fFileFormat[idx] = str;
1402 if (fForwardHistoNo.empty())
1405 if (idx>fForwardHistoNo.size())
1408 return fForwardHistoNo[idx];
1424 fForwardHistoNo.push_back(histoNo);
1426 if (idx >= static_cast<Int_t>(fForwardHistoNo.size()))
1427 fForwardHistoNo.resize(idx+1);
1428 fForwardHistoNo[idx] = histoNo;
1446 if (fBackwardHistoNo.empty())
1449 if (idx>fBackwardHistoNo.size())
1452 return fBackwardHistoNo[idx];
1468 fBackwardHistoNo.push_back(histoNo);
1470 if (idx >= static_cast<Int_t>(fBackwardHistoNo.size()))
1471 fBackwardHistoNo.resize(idx+1);
1472 fBackwardHistoNo[idx] = histoNo;
1490 if (idx>fMap.size())
1508 fMap.push_back(mapVal);
1512 if (idx >= static_cast<Int_t>(fMap.size()))
1536 return fBkgEstimated[idx];
1552 std::cerr << std::endl <<
">> PMsrRunBlock::SetBkgEstimated: **WARNING** idx=" << idx <<
", only idx=0,1 are sensible.";
1553 std::cerr << std::endl;
1557 fBkgEstimated[idx] = dval;
1577 return fBkgFix[idx];
1592 std::cerr << std::endl <<
">> PMsrRunBlock::SetBkgFix: **WARNING** idx=" << idx <<
", only idx=0,1 are sensible.";
1593 std::cerr << std::endl;
1597 fBkgFix[idx] = dval;
1618 return fBkgRange[idx];
1633 std::cerr << std::endl <<
">> PMsrRunBlock::SetBkgRange: **WARNING** idx=" << idx <<
", only idx=0..3 are sensible.";
1634 std::cerr << std::endl;
1638 fBkgRange[idx] = ival;
1660 return fDataRange[idx];
1675 std::cerr << std::endl <<
">> PMsrRunBlock::SetDataRange: **WARNING** idx=" << idx <<
", only idx=0..3 are sensible.";
1676 std::cerr << std::endl;
1680 fDataRange[idx] = ival;
1697 if (idx >= fT0.size())
1715 fT0.push_back(dval);
1719 if (idx >= static_cast<Int_t>(fT0.size()))
1742 if (addRunIdx >= fAddT0.size())
1745 return fAddT0[addRunIdx].size();
1766 if (addRunIdx >= fAddT0.size())
1769 if (fAddT0[addRunIdx].empty())
1772 if (histoIdx >= fAddT0[addRunIdx].size())
1775 return fAddT0[addRunIdx][histoIdx];
1790 if (addRunIdx >= fAddT0.size())
1791 fAddT0.resize(addRunIdx+1);
1793 if (histoNoIdx >= fAddT0[addRunIdx].size())
1794 fAddT0[addRunIdx].resize(histoNoIdx+1);
1796 fAddT0[addRunIdx][histoNoIdx] = dval;
1816 return fFitRange[idx];
1833 fFitRange[idx] = dval;
1853 return fFitRangeOffset[idx];
1870 fFitRangeOffset[idx] = ival;
1884 fParGlobal[str] = ival;
1899 if (fMapGlobal.size() != fMap.size())
1900 fMapGlobal.resize(fMap.size(), -1);
1901 if (idx < fMap.size() && fMap[idx] > 0)
1902 fMapGlobal[idx] = ival;
1941 std::vector<std::string> splitVec;
1948 split(splitVec, fString, is_any_of(
" "), token_compress_on);
1950 unsigned int start=0;
1951 if (ignoreFirstToken)
1954 for (
unsigned int i=start; i<splitVec.size(); i++) {
1955 if (splitVec[i].length() != 0) {
1956 if (splitVec[i].find(
"-") != std::string::npos) {
1957 std::vector<std::string> subSplitVec;
1959 split(subSplitVec, splitVec[i], is_any_of(
"-"), token_compress_on);
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) {
1965 if (!IsNumber(subSplitVec[j])) {
1970 start = atoi(subSplitVec[j].c_str());
1971 else if (count == 2)
1972 end = atoi(subSplitVec[j].c_str());
1978 if ((start < 0) || (end < 0)) {
1979 errorMsg =
"**ERROR** start or end of a range is not valid";
1985 std::cerr <<
"**WARNING** start=" << start <<
" > end=" << end <<
", hence I will swap them" << std::endl;
1989 for (
int j=start; j<=end; j++)
1992 }
else if (splitVec[i].find(
":") != std::string::npos) {
1993 std::vector<std::string> subSplitVec;
1995 split(subSplitVec, splitVec[i], is_any_of(
":"), token_compress_on);
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) {
2001 if (!IsNumber(subSplitVec[j])) {
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());
2016 if ((start < 0) || (end < 0) || (step < 0)) {
2017 errorMsg =
"**ERROR** start, end, or step of a sequence is not valid";
2023 std::cerr <<
"**WARNING** start=" << start <<
" > end=" << end <<
", hence I will swap them" << std::endl;
2027 for (
int j=start; j<=end; j+=step)
2030 }
else if (IsNumber(splitVec[i])) {
2031 ival = atoi(splitVec[i].c_str());
2032 fList.push_back(ival);
2034 errorMsg =
"**ERROR** invalid token: " + splitVec[i];
2052 std::string str=fString;
2056 for (
int i=str.size(); i>=0; --i) {
2057 if ((str[i] ==
' ') && (pos == -1)) {
2059 }
else if ((str[i] ==
'-') || (str[i] ==
':')) {
2061 str.erase(i+1, pos-i);
2063 }
else if (str[i] !=
' ') {
2068 for (
unsigned int i=0; i<str.size(); i++) {
2069 if ((str[i] ==
' ') && (pos == -1)) {
2071 }
else if ((str[i] ==
'-') || (str[i] ==
':')) {
2073 str.erase(pos, i-pos);
2076 }
else if (str[i] !=
' ') {
virtual PRawRunDataSet * Get(UInt_t histoNo)
virtual TString * GetBeamline(UInt_t idx=0)
virtual Double_t GetT0BinEstimated(UInt_t histoNo)
virtual TString GetRRFUnit()
virtual void SetDataRange(Int_t ival, Int_t idx)
virtual Double_t GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx)
virtual Int_t GetDataRange(UInt_t idx)
virtual Double_t GetT0Bin(UInt_t idx=0)
virtual void SetFitRangeOffset(Int_t ival, UInt_t idx)
virtual void SetFitRangeOffset(Int_t ival, UInt_t idx)
virtual TString * GetFileFormat(UInt_t idx=0)
virtual void SetBkgEstimated(Double_t dval, Int_t idx)
virtual void SetBackwardHistoNo(Int_t histoNo, Int_t idx=-1)
virtual Int_t GetFitRangeOffset(UInt_t idx)
virtual void SetRunName(TString &str, Int_t idx=-1)
virtual void SetBeamline(TString &str, Int_t idx=-1)
virtual void SetEstimatedAlpha(Double_t dval)
virtual const Double_t GetTempError(const UInt_t idx)
virtual const PDoublePairVector * GetTemperature() const
virtual void SetRingAnode(const UInt_t idx, const Double_t dval)
virtual void SetTempError(const UInt_t idx, const Double_t errTemp)
virtual PRawRunDataSet * operator[](UInt_t histoNo)
virtual void SetParGlobal(const TString &str, Int_t ival)
virtual void SetMap(Int_t mapVal, Int_t idx=-1)
virtual Double_t GetT0Bin(UInt_t histoNo)
virtual Double_t GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx)
virtual ~PNonMusrRawRunData()
virtual Bool_t IsPresent(UInt_t histoNo)
virtual void SetFileFormat(TString &str, Int_t idx=-1)
virtual void AppendSubErrData(const UInt_t idx, const Double_t dval)
virtual Double_t GetT0Bin(UInt_t idx=0)
std::vector< Double_t > PDoubleVector
virtual Double_t GetRRFFreq(const char *unit)
virtual const PDoubleVector GetRingAnode()
virtual Int_t GetBackwardHistoNo(UInt_t idx=0)
virtual PIntPair GetBkgBin(UInt_t histoNo)
virtual void Set(PRawRunDataSet dataSet, Int_t idx=-1)
virtual void SetT0Bin(Double_t dval, Int_t idx=-1)
virtual void SetForwardHistoNo(Int_t histoNo, Int_t idx=-1)
virtual PRawRunDataSet * GetSet(UInt_t idx)
virtual bool Parse(std::string &errorMsg, bool ignoreFirstToken=false)
virtual Int_t GetAddT0BinSize(UInt_t addRunIdx)
virtual Int_t GetFitRangeOffset(UInt_t idx)
virtual void SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx)
virtual void SetMapGlobal(UInt_t idx, Int_t ival)
virtual Double_t GetBkgFix(UInt_t idx)
virtual PDoubleVector * GetData(UInt_t histoNo)
virtual void SetInstitute(TString &str, Int_t idx=-1)
virtual void StripSpaces()
virtual void SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx)
virtual void SetRRFPacking(Int_t pack)
virtual Int_t GetForwardHistoNo(UInt_t idx=0)
virtual void SetSize(const UInt_t size)
virtual void SetT0Bin(Double_t dval, Int_t idx=-1)
virtual Int_t GetBkgRange(UInt_t idx)
virtual void AppendSubData(const UInt_t idx, const Double_t dval)
virtual void SetBkgRange(Int_t ival, Int_t idx)
virtual void SetFitRange(Double_t dval, UInt_t idx)
virtual void SetRRFFreq(Double_t freq, const char *unit)
virtual TString * GetInstitute(UInt_t idx=0)
virtual void SetLabel(const UInt_t idx, const TString str)
virtual Int_t GetAddT0BinSize(UInt_t addRunIdx)
virtual void SetFitRange(Double_t dval, UInt_t idx)
virtual PIntVector * GetMap()
virtual Int_t GetDataRange(UInt_t idx)
virtual PRawRunDataSet * GetDataSet(const UInt_t idx, Bool_t wantHistoNo=true)
virtual void SetDataRange(Int_t ival, Int_t idx)
virtual Double_t GetFitRange(UInt_t idx)
virtual PIntPair GetGoodDataBin(UInt_t histoNo)
virtual Double_t GetBkgEstimated(UInt_t idx)
virtual void SetTemperature(const UInt_t idx, const Double_t temp, const Double_t errTemp)
virtual void ReplaceTheory(const PDoubleVector &theo)
virtual void SetBkgFix(Double_t dval, Int_t idx)
virtual TString * GetRunName(UInt_t idx=0)
virtual Double_t GetFitRange(UInt_t idx)
std::pair< Int_t, Int_t > PIntPair
virtual void SetTheoryValue(UInt_t i, Double_t dval)