diff --git a/src/classes/PMsrHandler.cpp b/src/classes/PMsrHandler.cpp index 0659a28f..b9c0ed65 100644 --- a/src/classes/PMsrHandler.cpp +++ b/src/classes/PMsrHandler.cpp @@ -1767,16 +1767,18 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) if (tokens->GetEntries() < 2) { error = true; } else { - ostr = dynamic_cast(tokens->At(1)); - str = ostr->GetString(); - if (str.IsDigit()) { - dval = str.Atoi(); - if (dval > 0) - param.SetForwardHistoNo(dval); - else + for (Int_t i=1; iGetEntries(); i++) { + ostr = dynamic_cast(tokens->At(i)); + str = ostr->GetString(); + if (str.IsDigit()) { + dval = str.Atoi(); + if (dval > 0) + param.SetForwardHistoNo(dval); + else + error = true; + } else { error = true; - } else { - error = true; + } } } } @@ -1789,16 +1791,18 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) if (tokens->GetEntries() < 2) { error = true; } else { - ostr = dynamic_cast(tokens->At(1)); - str = ostr->GetString(); - if (str.IsDigit()) { - dval = str.Atoi(); - if (dval > 0) - param.SetBackwardHistoNo(dval); - else + for (Int_t i=1; iGetEntries(); i++) { + ostr = dynamic_cast(tokens->At(i)); + str = ostr->GetString(); + if (str.IsDigit()) { + dval = str.Atoi(); + if (dval > 0) + param.SetBackwardHistoNo(dval); + else + error = true; + } else { error = true; - } else { - error = true; + } } } } @@ -2775,10 +2779,39 @@ Bool_t PMsrHandler::HandlePlotEntry(PMsrLines &lines) } } - fPlots.push_back(param); + // check if runs listed in the plot block indeed to exist + for (UInt_t i=0; i static_cast(fRuns.size())) { + cerr << endl << ">> PMsrHandler::HandlePlotEntry(): **WARNING** found plot run number " << param.fRuns[i] << "."; + cerr << endl << ">> There are only " << fRuns.size() << " runs present, will ignore this run."; + cerr << endl; + param.fRuns.erase(param.fRuns.begin()+i); + i--; + } + if (param.fRuns[i] == 0) { + cerr << endl << ">> PMsrHandler::HandlePlotEntry(): **WARNING** found plot run number 0."; + cerr << endl << ">> Pot number needs to be > 0. Will ignore this entry."; + cerr << endl; + param.fRuns.erase(param.fRuns.begin()+i); + i--; + } + } + + if (param.fRuns.size() > 0) { + fPlots.push_back(param); + } else { + cerr << endl << ">> PMsrHandler::HandlePlotEntry: **ERROR** no valid PLOT block entries, will ignore the entire PLOT block."; + cerr << endl; + } } } + if (fPlots.size() == 0) { + error = true; + cerr << endl << ">> PMsrHandler::HandlePlotEntry: **ERROR** no valid PLOT block at all present. Fix this first!"; + cerr << endl; + } + if (error) { // print error message --iter1; cerr << endl << ">> PMsrHandler::HandlePlotEntry: **ERROR** in line " << iter1->fLineNo << ": " << iter1->fLine.Data(); diff --git a/src/classes/PMusr.cpp b/src/classes/PMusr.cpp index 813cbd15..0113375a 100644 --- a/src/classes/PMusr.cpp +++ b/src/classes/PMusr.cpp @@ -528,8 +528,6 @@ PMsrRunBlock::PMsrRunBlock() fPhaseParamNo = -1; // undefined phase parameter number fLifetimeParamNo = -1; // undefined lifetime parameter number fLifetimeCorrection = false; // lifetime correction == false by default (used in single histogram musrview) - fForwardHistoNo = -1; // undefined forward histogram number - fBackwardHistoNo = -1; // undefined backward histogram number fFitRange[0] = PMUSR_UNDEFINED; // undefined start fit range fFitRange[1] = PMUSR_UNDEFINED; // undefined end fit range fPacking = -1; // undefined packing @@ -551,6 +549,8 @@ PMsrRunBlock::~PMsrRunBlock() fBeamline.clear(); fInstitute.clear(); fFileFormat.clear(); + fForwardHistoNo.clear(); + fBackwardHistoNo.clear(); fMap.clear(); fBkgFix.clear(); fBkgRange.clear(); @@ -574,8 +574,6 @@ void PMsrRunBlock::CleanUp() fPhaseParamNo = -1; // undefined phase parameter number fLifetimeParamNo = -1; // undefined lifetime parameter number fLifetimeCorrection = true; // lifetime correction == true by default (used in single histogram musrview) - fForwardHistoNo = -1; // undefined forward histogram number - fBackwardHistoNo = -1; // undefined backward histogram number fFitRange[0] = PMUSR_UNDEFINED; // undefined start fit range fFitRange[1] = PMUSR_UNDEFINED; // undefined end fit range fPacking = -1; // undefined packing @@ -588,6 +586,8 @@ void PMsrRunBlock::CleanUp() fBeamline.clear(); fInstitute.clear(); fFileFormat.clear(); + fForwardHistoNo.clear(); + fBackwardHistoNo.clear(); fMap.clear(); fBkgFix.clear(); fBkgRange.clear(); @@ -723,6 +723,86 @@ void PMsrRunBlock::SetFileFormat(TString &str, UInt_t i) fFileFormat[i] = str; } +//-------------------------------------------------------------------------- +// GetForwardHistoNo +//-------------------------------------------------------------------------- +/** + *

get forward histogram value at position i + * + * \param i index of the forward histogram value to be returned + */ +Int_t PMsrRunBlock::GetForwardHistoNo(UInt_t i) +{ + if (fForwardHistoNo.empty()) + return -1; + + if (i>fForwardHistoNo.size()) + return -1; + + return fForwardHistoNo[i]; +} + +//-------------------------------------------------------------------------- +// SetForwardHistoNo +//-------------------------------------------------------------------------- +/** + *

set forward histogram value at position pos + * + * \param histoNo histogram value + * \param idx index whithin the fForwardHistoNo vector where to set the value. + * If idx == -1, then append the value to the vector. + */ +void PMsrRunBlock::SetForwardHistoNo(Int_t histoNo, Int_t idx) +{ + if (idx == -1) { // i.e. append forward histo no + fForwardHistoNo.push_back(histoNo); + } else { + if (idx >= static_cast(fForwardHistoNo.size())) + fForwardHistoNo.resize(idx+1); + fForwardHistoNo[idx] = histoNo; + } +} + +//-------------------------------------------------------------------------- +// GetBackwardHistoNo +//-------------------------------------------------------------------------- +/** + *

get backward histogram value at position i + * + * \param i index of the map value to be returned + */ +Int_t PMsrRunBlock::GetBackwardHistoNo(UInt_t i) +{ + if (fBackwardHistoNo.empty()) + return -1; + + if (i>fBackwardHistoNo.size()) + return -1; + + return fBackwardHistoNo[i]; +} + +//-------------------------------------------------------------------------- +// SetBackwardHistoNo +//-------------------------------------------------------------------------- +/** + *

set backward histogram value at position pos + * + * \param histoNo histogram value + * \param idx index whithin the fBackwardHistoNo vector where to set the value. + * If idx == -1, then append the value to the vector. + */ +void PMsrRunBlock::SetBackwardHistoNo(Int_t histoNo, Int_t idx) +{ + if (idx == -1) { // i.e. append forward histo no + fBackwardHistoNo.push_back(histoNo); + } else { + if (idx >= static_cast(fBackwardHistoNo.size())) + fBackwardHistoNo.resize(idx+1); + fBackwardHistoNo[idx] = histoNo; + } +} + //-------------------------------------------------------------------------- // GetMap //-------------------------------------------------------------------------- diff --git a/src/include/PMusr.h b/src/include/PMusr.h index 854819a9..2679c785 100644 --- a/src/include/PMusr.h +++ b/src/include/PMusr.h @@ -157,7 +157,13 @@ typedef vector PDoubleVector; /** *

*/ -typedef vector< pair > PDoublePairVector; +typedef pair PDoublePair; + +//------------------------------------------------------------- +/** + *

+ */ +typedef vector PDoublePairVector; //------------------------------------------------------------- /** @@ -395,8 +401,8 @@ class PMsrRunBlock { virtual Bool_t IsLifetimeCorrected() { return fLifetimeCorrection; } virtual PIntVector* GetMap() { return &fMap; } virtual Int_t GetMap(UInt_t idx); - virtual Int_t GetForwardHistoNo() { return fForwardHistoNo; } - virtual Int_t GetBackwardHistoNo() { return fBackwardHistoNo; } + virtual Int_t GetForwardHistoNo(UInt_t i=0); + virtual Int_t GetBackwardHistoNo(UInt_t i=0); virtual UInt_t GetBkgFixSize() { return fBkgFix.size(); } virtual Double_t GetBkgFix(UInt_t i=0); virtual UInt_t GetBkgRangeSize() { return fBkgRange.size(); } @@ -430,8 +436,8 @@ class PMsrRunBlock { virtual void SetLifetimeCorrection(Bool_t bval) { fLifetimeCorrection = bval; } virtual void AppendMap(Int_t ival) { fMap.push_back(ival); } virtual void SetMap(Int_t mapVal, UInt_t idx); - virtual void SetForwardHistoNo(Int_t ival) { fForwardHistoNo = ival; } - virtual void SetBackwardHistoNo(Int_t ival) { fBackwardHistoNo = ival; } + virtual void SetForwardHistoNo(Int_t histoNo, Int_t idx=-1); + virtual void SetBackwardHistoNo(Int_t histoNo, Int_t idx=-1); virtual void AppendBkgFix(Double_t dval) { fBkgFix.push_back(dval); } virtual void SetBkgFix(Double_t dval, UInt_t idx); virtual void AppendBkgRange(Int_t ival) { fBkgRange.push_back(ival); } @@ -461,8 +467,8 @@ class PMsrRunBlock { Int_t fLifetimeParamNo; ///< muon lifetime parameter number (fit type 0) Bool_t fLifetimeCorrection; ///< lifetime correction flag for viewing (fit type 0) PIntVector fMap; ///< map vector needed to switch parameters for different runs within a single theory - Int_t fForwardHistoNo; ///< forward histogram number (fit type 0, 2, 4) - Int_t fBackwardHistoNo; ///< backward histogram number (fit type 2, 4) + PIntVector fForwardHistoNo; ///< forward histogram number (fit type 0, 2, 4) + PIntVector fBackwardHistoNo; ///< backward histogram number (fit type 2, 4) PDoubleVector fBkgFix; ///< fixed background in (1/ns) (fit type 0, 2, 4) PIntVector fBkgRange; ///< background bin range (fit type 0, 2, 4) PIntVector fDataRange; ///< data bin range (fit type 0, 2, 4)