diff --git a/ChangeLog b/ChangeLog index 7d0ab59d..d3f17096 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ changes since 0.11.0 =================================== +NEW 2012-10-25 (i) add PRINT_LEVEL to the command block (0='nothing' to +3='everything'). This allows to tune the Minuit2 output. (ii) added the +possibilty to give the fit range in bins. For details see the docu. NEW 2012-09-24 add header information for printing. NEW 2012-05-31 added Noakes-Kalvius function (see A. Yaouanc and P. Dalmas de Reotiers, "Muon Spin Rotation, Relaxation, and Resonance" Oxford, Section 6.4.1.3). diff --git a/doc/html/user/MUSR/BmwLibs.html b/doc/html/user/MUSR/BmwLibs.html index 7e2f571d..0e82bbdc 100644 --- a/doc/html/user/MUSR/BmwLibs.html +++ b/doc/html/user/MUSR/BmwLibs.html @@ -1,6 +1,6 @@ - +
@@ -8,7 +8,7 @@ - + @@ -111,9 +111,7 @@ pre { - - - ++fit 0.2 8.5 +Which means that the fitting window will span from 0.2 to 8.5 microseconds.
fit fgb+<n0> lgb-<n1>,where fgb and lgb are label tags which refer to the 'first good bin' and the 'last good bin' defined either in the
data
tag of the run block, data file, are estimated based on T0. <n0> and <n1> are offsets (given in bins) allowing to change the fit window compared to the data window. An example: fit fgb+150 lgb-1332
all
the runs present in the msr file. FIT_RANGE RESET will restore to the original fit ranges as provided in the RUN block. If for each run of the msr file an individual fit range should be used, the third option applies. Here n has to correspond to the number of runs in the RUN block.
+As for the run block, there is a 2nd flavor how the FIT_RANGE can be changed, namely giving the fit range in bins, i.e. FIT_RANGE RESET | fgb+<n0> lgb-<n1> | fgb+<n00> lgb-<n01> fgb+<n10> lgb-<n11> ... fgb+<nN0> lgb-<nN1> where N is the number of available run blocks. The idea is inline with the above syntax and the syntax describe for the fit range (fit) of the RUN block.
+
A typical example could look like:COMMANDS FIT_RANGE 0.0 0.8 @@ -964,6 +966,15 @@ A typical example could look like:MINIMIZE MINOS SAVE +or ++ COMMANDS + FIT_RANGE fgb+15 lgb-1332 fgb+17 lgb-1330 + MINIMIZE + FIT_RANGE RESET + MINIMIZE + MINOS + SAVE@@ -1429,7 +1440,7 @@ For reporting bugs or requesting new features and improvements please use the -
musrfit
musrfit
on Different Platforms ROOT
folder so that the user has easy write access to this directory:
+ 1 : In case only a single user is working at the machine it might be considerable to change the ownership of the ROOT
folder so that the user has easy write access to this directory:
2 : When using GCC
≥ 4.2 please make sure that the environment variables USE_PARALLEL_MINUIT2 and USE_OPENMP are not set! Otherwise MINUIT2
will be compiled with parallelization support and cannot be used together with musrfit
afterwards since the musrfit
code is not fully thread-safe! When compiled with GCC
≥ 4.2 musrfit
itself will parallelize the χ2 calculation.
@@ -823,7 +821,7 @@ musrview test-histo-ROOT-NPP.msr
WKM
users Set the print level.
+ *
+ * \param lineNo the line number of the command block
+ *
+ * return: true if done, otherwise returns false.
+ */
+Bool_t PFitter::ExecutePrintLevel(UInt_t lineNo)
+{
+ cout << ">> PFitter::ExecutePrintLevel(): " << fCmdLines[lineNo].fLine.Data() << endl;
+
+ TObjArray *tokens = 0;
+ TObjString *ostr;
+ TString str;
+
+ tokens = fCmdLines[lineNo].fLine.Tokenize(", \t");
+
+ if (tokens->GetEntries() < 2) {
+ cerr << endl << "**ERROR** from PFitter::ExecutePrintLevel(): SYNTAX: PRINT_LEVEL Sets a value of the theory vector
@@ -92,7 +92,7 @@ void PRunData::SetTheoryValue(UInt_t idx, Double_t dval)
}
//--------------------------------------------------------------------------
-// ReplaceTheory
+// ReplaceTheory (public)
//--------------------------------------------------------------------------
/**
* Replaces the theory vector.
@@ -150,7 +150,7 @@ PNonMusrRawRunData::~PNonMusrRawRunData()
}
//--------------------------------------------------------------------------
-// SetLabel
+// SetLabel (public)
//--------------------------------------------------------------------------
/**
* Modifies a label at position idx. In case idx is larges than the number
@@ -170,7 +170,7 @@ void PNonMusrRawRunData::SetLabel(const UInt_t idx, const TString str)
}
//--------------------------------------------------------------------------
-// AppendSubData
+// AppendSubData (public)
//--------------------------------------------------------------------------
/**
* Modifies the data set at position idx. In case idx is larger than the number
@@ -190,7 +190,7 @@ void PNonMusrRawRunData::AppendSubData(const UInt_t idx, const Double_t dval)
}
//--------------------------------------------------------------------------
-// AppendSubErrData
+// AppendSubErrData (public)
//--------------------------------------------------------------------------
/**
* Modifies the error-data set at position idx. In case idx is larger than the number
@@ -555,7 +555,7 @@ PRawRunData::~PRawRunData()
}
//--------------------------------------------------------------------------
-// GetTemperature
+// GetTemperature (public)
//--------------------------------------------------------------------------
/**
* Returns the temperature of a muSR run.
@@ -577,7 +577,7 @@ const Double_t PRawRunData::GetTemperature(const UInt_t idx)
}
//--------------------------------------------------------------------------
-// GetTempError
+// GetTempError (public)
//--------------------------------------------------------------------------
/**
* Returns the error estimate of the temperature of a muSR run.
@@ -599,7 +599,7 @@ const Double_t PRawRunData::GetTempError(const UInt_t idx)
}
//--------------------------------------------------------------------------
-// GetRingAnode
+// GetRingAnode (public)
//--------------------------------------------------------------------------
/**
* Returns the value of a ring anode high voltage. (idx = 0: RAL, 1: RAR, 2: RAT, 3: RAB)
@@ -621,7 +621,7 @@ const Double_t PRawRunData::GetRingAnode(const UInt_t idx)
}
//--------------------------------------------------------------------------
-// GetDataSet
+// GetDataSet (public)
//--------------------------------------------------------------------------
/**
* Returns a raw muSR run data set.
@@ -643,7 +643,7 @@ PRawRunDataSet* PRawRunData::GetDataSet(const UInt_t idx, Bool_t wantHistoNo)
//--------------------------------------------------------------------------
-// SetRingAnode
+// SetRingAnode (public)
//--------------------------------------------------------------------------
/**
* Store the ring anode value at index position idx.
@@ -659,7 +659,7 @@ void PRawRunData::SetRingAnode(const UInt_t idx, const Double_t dval)
}
//--------------------------------------------------------------------------
-// SetTemperature
+// SetTemperature (public)
//--------------------------------------------------------------------------
/**
* Store the temperature with its error at index position idx.
@@ -678,7 +678,7 @@ void PRawRunData::SetTemperature(const UInt_t idx, const Double_t temp, const Do
}
//--------------------------------------------------------------------------
-// SetTempError
+// SetTempError (public)
//--------------------------------------------------------------------------
/**
* Store the temperature error at index position idx.
@@ -722,8 +722,11 @@ PMsrRunBlock::PMsrRunBlock()
fBkgRange[i] = -1; // undefined start background range
fDataRange[i] = -1; // undefined start data range
}
+ fFitRangeInBins = false; // default is that fit range is given in time NOT bins
fFitRange[0] = PMUSR_UNDEFINED; // undefined start fit range
fFitRange[1] = PMUSR_UNDEFINED; // undefined end fit range
+ fFitRangeOffset[0] = 0; // undefined start fit range offset
+ fFitRangeOffset[1] = 0; // undefined end fit range offset
fPacking = -1; // undefined packing
fXYDataIndex[0] = -1; // undefined x data index (NonMusr)
fXYDataIndex[1] = -1; // undefined y data index (NonMusr)
@@ -752,7 +755,7 @@ PMsrRunBlock::~PMsrRunBlock()
}
//--------------------------------------------------------------------------
-// CleanUp
+// CleanUp (public)
//--------------------------------------------------------------------------
/**
* Clean up data structure.
@@ -772,8 +775,11 @@ void PMsrRunBlock::CleanUp()
fBkgRange[i] = -1; // undefined background range
fDataRange[i] = -1; // undefined data range
}
+ fFitRangeInBins = false; // default is that fit range is given in time NOT bins
fFitRange[0] = PMUSR_UNDEFINED; // undefined start fit range
fFitRange[1] = PMUSR_UNDEFINED; // undefined end fit range
+ fFitRangeOffset[0] = 0; // undefined start fit range offset
+ fFitRangeOffset[1] = 0; // undefined end fit range offset
fPacking = -1; // undefined packing
fXYDataIndex[0] = -1; // undefined x data index (NonMusr)
fXYDataIndex[1] = -1; // undefined y data index (NonMusr)
@@ -797,7 +803,7 @@ void PMsrRunBlock::CleanUp()
}
//--------------------------------------------------------------------------
-// GetRunName
+// GetRunName (public)
//--------------------------------------------------------------------------
/**
* get run name at position idx
@@ -817,7 +823,7 @@ TString* PMsrRunBlock::GetRunName(UInt_t idx)
}
//--------------------------------------------------------------------------
-// SetRunName
+// SetRunName (public)
//--------------------------------------------------------------------------
/**
* set run name at position idx
@@ -839,7 +845,7 @@ void PMsrRunBlock::SetRunName(TString &str, Int_t idx)
}
//--------------------------------------------------------------------------
-// GetBeamline
+// GetBeamline (public)
//--------------------------------------------------------------------------
/**
* get beamline name at position idx
@@ -859,7 +865,7 @@ TString* PMsrRunBlock::GetBeamline(UInt_t idx)
}
//--------------------------------------------------------------------------
-// SetBeamline
+// SetBeamline (public)
//--------------------------------------------------------------------------
/**
* set beamline name at position idx
@@ -881,7 +887,7 @@ void PMsrRunBlock::SetBeamline(TString &str, Int_t idx)
}
//--------------------------------------------------------------------------
-// GetInstitute
+// GetInstitute (public)
//--------------------------------------------------------------------------
/**
* get institute name at position idx
@@ -901,7 +907,7 @@ TString* PMsrRunBlock::GetInstitute(UInt_t idx)
}
//--------------------------------------------------------------------------
-// SetInstitute
+// SetInstitute (public)
//--------------------------------------------------------------------------
/**
* set institute name at position idx
@@ -923,7 +929,7 @@ void PMsrRunBlock::SetInstitute(TString &str, Int_t idx)
}
//--------------------------------------------------------------------------
-// GetFileFormat
+// GetFileFormat (public)
//--------------------------------------------------------------------------
/**
* get file format name at position idx
@@ -943,7 +949,7 @@ TString* PMsrRunBlock::GetFileFormat(UInt_t idx)
}
//--------------------------------------------------------------------------
-// SetFileFormat
+// SetFileFormat (public)
//--------------------------------------------------------------------------
/**
* set file format name at position idx
@@ -965,7 +971,7 @@ void PMsrRunBlock::SetFileFormat(TString &str, Int_t idx)
}
//--------------------------------------------------------------------------
-// GetForwardHistoNo
+// GetForwardHistoNo (public)
//--------------------------------------------------------------------------
/**
* get forward histogram value at position idx
@@ -988,7 +994,7 @@ Int_t PMsrRunBlock::GetForwardHistoNo(UInt_t idx)
}
//--------------------------------------------------------------------------
-// SetForwardHistoNo
+// SetForwardHistoNo (public)
//--------------------------------------------------------------------------
/**
* set forward histogram value at index idx
@@ -1009,7 +1015,7 @@ void PMsrRunBlock::SetForwardHistoNo(Int_t histoNo, Int_t idx)
}
//--------------------------------------------------------------------------
-// GetBackwardHistoNo
+// GetBackwardHistoNo (public)
//--------------------------------------------------------------------------
/**
* get backward histogram value at position idx
@@ -1032,7 +1038,7 @@ Int_t PMsrRunBlock::GetBackwardHistoNo(UInt_t idx)
}
//--------------------------------------------------------------------------
-// SetBackwardHistoNo
+// SetBackwardHistoNo (public)
//--------------------------------------------------------------------------
/**
* set backward histogram value at position pos
@@ -1053,7 +1059,7 @@ void PMsrRunBlock::SetBackwardHistoNo(Int_t histoNo, Int_t idx)
}
//--------------------------------------------------------------------------
-// GetMap
+// GetMap (public)
//--------------------------------------------------------------------------
/**
* get map value at position idx
@@ -1073,7 +1079,7 @@ Int_t PMsrRunBlock::GetMap(UInt_t idx)
}
//--------------------------------------------------------------------------
-// SetMap
+// SetMap (public)
//--------------------------------------------------------------------------
/**
* set map value at position idx
@@ -1095,7 +1101,7 @@ void PMsrRunBlock::SetMap(Int_t mapVal, Int_t idx)
}
//--------------------------------------------------------------------------
-// GetBkgEstimated
+// GetBkgEstimated (public)
//--------------------------------------------------------------------------
/**
* get estimated background value at position idx. If not present,
@@ -1117,7 +1123,7 @@ Double_t PMsrRunBlock::GetBkgEstimated(UInt_t idx)
//--------------------------------------------------------------------------
-// SetBkgEstimated
+// SetBkgEstimated (public)
//--------------------------------------------------------------------------
/**
* set estimated background value at position idx
@@ -1137,7 +1143,7 @@ void PMsrRunBlock::SetBkgEstimated(Double_t dval, Int_t idx)
}
//--------------------------------------------------------------------------
-// GetBkgFix
+// GetBkgFix (public)
//--------------------------------------------------------------------------
/**
* get background fixed value at position idx
@@ -1157,7 +1163,7 @@ Double_t PMsrRunBlock::GetBkgFix(UInt_t idx)
}
//--------------------------------------------------------------------------
-// SetBkgFix
+// SetBkgFix (public)
//--------------------------------------------------------------------------
/**
* set background fixed value at position idx
@@ -1177,7 +1183,7 @@ void PMsrRunBlock::SetBkgFix(Double_t dval, Int_t idx)
}
//--------------------------------------------------------------------------
-// GetBkgRange
+// GetBkgRange (public)
//--------------------------------------------------------------------------
/**
* get background range at position idx
@@ -1198,7 +1204,7 @@ Int_t PMsrRunBlock::GetBkgRange(UInt_t idx)
}
//--------------------------------------------------------------------------
-// SetBkgRange
+// SetBkgRange (public)
//--------------------------------------------------------------------------
/**
* set background range element at position idx
@@ -1219,7 +1225,7 @@ void PMsrRunBlock::SetBkgRange(Int_t ival, Int_t idx)
//--------------------------------------------------------------------------
-// GetDataRange
+// GetDataRange (public)
//--------------------------------------------------------------------------
/**
* get data range at position idx
@@ -1240,7 +1246,7 @@ Int_t PMsrRunBlock::GetDataRange(UInt_t idx)
}
//--------------------------------------------------------------------------
-// SetDataRange
+// SetDataRange (public)
//--------------------------------------------------------------------------
/**
* set data range element at position idx
@@ -1260,7 +1266,7 @@ void PMsrRunBlock::SetDataRange(Int_t ival, Int_t idx)
}
//--------------------------------------------------------------------------
-// GetT0Bin
+// GetT0Bin (public)
//--------------------------------------------------------------------------
/**
* get T0 bin at position idx
@@ -1280,7 +1286,7 @@ Double_t PMsrRunBlock::GetT0Bin(UInt_t idx)
}
//--------------------------------------------------------------------------
-// SetT0Bin
+// SetT0Bin (public)
//--------------------------------------------------------------------------
/**
* set T0 bin at position idx
@@ -1302,7 +1308,7 @@ void PMsrRunBlock::SetT0Bin(Double_t dval, Int_t idx)
}
//--------------------------------------------------------------------------
-// GetAddT0BinSize
+// GetAddT0BinSize (public)
//--------------------------------------------------------------------------
/**
* get add T0 size of the addrun at index addRunIdx
@@ -1325,7 +1331,7 @@ Int_t PMsrRunBlock::GetAddT0BinSize(UInt_t addRunIdx)
}
//--------------------------------------------------------------------------
-// GetAddT0Bin
+// GetAddT0Bin (public)
//--------------------------------------------------------------------------
/**
* get add T0 of the addrun (index addRunIdx) at index histoIdx
@@ -1355,7 +1361,7 @@ Double_t PMsrRunBlock::GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx)
}
//--------------------------------------------------------------------------
-// SetAddT0Bin
+// SetAddT0Bin (public)
//--------------------------------------------------------------------------
/**
* set add T0 bin of the addrun at index histoNoIdx
@@ -1376,7 +1382,7 @@ void PMsrRunBlock::SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoId
}
//--------------------------------------------------------------------------
-// GetFitRange
+// GetFitRange (public)
//--------------------------------------------------------------------------
/**
* get fit range value at position idx. idx: 0=fit range start, 1=fit range end.
@@ -1396,7 +1402,7 @@ Double_t PMsrRunBlock::GetFitRange(UInt_t idx)
}
//--------------------------------------------------------------------------
-// SetFitRange
+// SetFitRange (public)
//--------------------------------------------------------------------------
/**
* set fit range value at position idx
@@ -1413,7 +1419,44 @@ void PMsrRunBlock::SetFitRange(Double_t dval, UInt_t idx)
}
//--------------------------------------------------------------------------
-// SetParGlobal
+// GetFitRangeOffset (public)
+//--------------------------------------------------------------------------
+/**
+ * get fit range offset value at position idx. idx: 0=fit range offset start, 1=fit range offset end.
+ *
+ * return:
+ * - fit range offset value, if idx is within proper boundaries
+ * - -1, otherwise
+ *
+ * \param idx index of the fit range value to be returned
+ */
+Int_t PMsrRunBlock::GetFitRangeOffset(UInt_t idx)
+{
+ if (idx >= 2)
+ return -1;
+
+ return fFitRangeOffset[idx];
+}
+
+//--------------------------------------------------------------------------
+// SetFitRangeOffset (public)
+//--------------------------------------------------------------------------
+/**
+ * set fit range offset value at position idx. Illegale values will be ignored.
+ *
+ * \param ival value to be set
+ * \param idx index of the fit range value to be set
+ */
+void PMsrRunBlock::SetFitRangeOffset(Int_t ival, UInt_t idx)
+{
+ if (idx >= 2)
+ return;
+
+ fFitRangeOffset[idx] = ival;
+}
+
+//--------------------------------------------------------------------------
+// SetParGlobal (public)
//--------------------------------------------------------------------------
/**
* store the information that a certain parameter used in the block is global
@@ -1428,7 +1471,7 @@ void PMsrRunBlock::SetParGlobal(const TString &str, Int_t ival)
}
//--------------------------------------------------------------------------
-// SetMapGlobal
+// SetMapGlobal (public)
//--------------------------------------------------------------------------
/**
* store the information that a certain mapped parameter in the block is global
diff --git a/src/classes/PRunAsymmetry.cpp b/src/classes/PRunAsymmetry.cpp
index 9b9babc0..58c6740e 100644
--- a/src/classes/PRunAsymmetry.cpp
+++ b/src/classes/PRunAsymmetry.cpp
@@ -42,6 +42,10 @@
#include Calculate chi-square.
@@ -236,7 +250,7 @@ Double_t PRunAsymmetry::CalcChiSquareExpected(const std::vector NOT IMPLEMENTED!!
@@ -266,7 +280,97 @@ UInt_t PRunAsymmetry::GetNoOfFitBins()
}
//--------------------------------------------------------------------------
-// CalcNoOfFitBins (private)
+// SetFitRangeBin (public)
+//--------------------------------------------------------------------------
+/**
+ * Allows to change the fit range on the fly. Used in the COMMAND block.
+ * The syntax of the string is: FIT_RANGE fgb[+n00] lgb[-n01] [fgb[+n10] lgb[-n11] ... fgb[+nN0] lgb[-nN1]].
+ * If only one pair of fgb/lgb is given, it is used for all runs in the RUN block section.
+ * If multiple fgb/lgb's are given, the number N has to be the number of RUN blocks in
+ * the msr-file.
+ *
+ * nXY are offsets which can be used to shift, limit the fit range.
+ *
+ * \param fitRange string containing the necessary information.
+ */
+void PRunAsymmetry::SetFitRangeBin(const TString fitRange)
+{
+ TObjArray *tok = 0;
+ TObjString *ostr = 0;
+ TString str;
+ Ssiz_t idx = -1;
+ Int_t offset = 0;
+
+ tok = fitRange.Tokenize(" \t");
+
+ if (tok->GetEntries() == 3) { // structure FIT_RANGE fgb+n0 lgb-n1
+ // handle fgb+n0 entry
+ ostr = (TObjString*) tok->At(1);
+ str = ostr->GetString();
+ // check if there is an offset present
+ idx = str.First("+");
+ if (idx != -1) { // offset present
+ str.Remove(0, idx+1);
+ if (str.IsFloat()) // if str is a valid number, convert is to an integer
+ offset = str.Atoi();
+ }
+ fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution;
+
+ // handle lgb-n1 entry
+ ostr = (TObjString*) tok->At(2);
+ str = ostr->GetString();
+ // check if there is an offset present
+ idx = str.First("-");
+ if (idx != -1) { // offset present
+ str.Remove(0, idx+1);
+ if (str.IsFloat()) // if str is a valid number, convert is to an integer
+ offset = str.Atoi();
+ }
+ fFitEndTime = (fGoodBins[1] - offset - fT0s[0]) * fTimeResolution;
+ } else if ((tok->GetEntries() > 3) && (tok->GetEntries() % 2 == 1)) { // structure FIT_RANGE fgb[+n00] lgb[-n01] [fgb[+n10] lgb[-n11] ... fgb[+nN0] lgb[-nN1]]
+ Int_t pos = 2*(fRunNo+1)-1;
+
+ if (pos + 1 >= tok->GetEntries()) {
+ cerr << endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'";
+ cerr << endl << ">> will ignore it. Sorry ..." << endl;
+ } else {
+ // handle fgb+n0 entry
+ ostr = (TObjString*) tok->At(pos);
+ str = ostr->GetString();
+ // check if there is an offset present
+ idx = str.First("+");
+ if (idx != -1) { // offset present
+ str.Remove(0, idx+1);
+ if (str.IsFloat()) // if str is a valid number, convert is to an integer
+ offset = str.Atoi();
+ }
+ fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution;
+
+ // handle lgb-n1 entry
+ ostr = (TObjString*) tok->At(pos+1);
+ str = ostr->GetString();
+ // check if there is an offset present
+ idx = str.First("-");
+ if (idx != -1) { // offset present
+ str.Remove(0, idx+1);
+ if (str.IsFloat()) // if str is a valid number, convert is to an integer
+ offset = str.Atoi();
+ }
+ fFitEndTime = (fGoodBins[1] - offset - fT0s[0]) * fTimeResolution;
+ }
+ } else { // error
+ cerr << endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'";
+ cerr << endl << ">> will ignore it. Sorry ..." << endl;
+ }
+
+ // clean up
+ if (tok) {
+ delete tok;
+ }
+}
+
+//--------------------------------------------------------------------------
+// CalcNoOfFitBins (protected)
//--------------------------------------------------------------------------
/**
* Calculate the number of fitted bins for the current fit range.
@@ -288,7 +392,7 @@ void PRunAsymmetry::CalcNoOfFitBins()
}
//--------------------------------------------------------------------------
-// CalcTheory
+// CalcTheory (protected)
//--------------------------------------------------------------------------
/**
* Calculate theory for a given set of fit-parameters.
@@ -344,7 +448,7 @@ void PRunAsymmetry::CalcTheory()
}
//--------------------------------------------------------------------------
-// PrepareData
+// PrepareData (protected)
//--------------------------------------------------------------------------
/**
* Prepare data for fitting or viewing. What is already processed at this stage:
@@ -682,7 +786,7 @@ Bool_t PRunAsymmetry::PrepareData()
}
//--------------------------------------------------------------------------
-// SubtractFixBkg
+// SubtractFixBkg (private)
//--------------------------------------------------------------------------
/**
* Subtracts a fixed background from the raw data. The background is given
@@ -722,7 +826,7 @@ Bool_t PRunAsymmetry::SubtractFixBkg()
}
//--------------------------------------------------------------------------
-// SubtractEstimatedBkg
+// SubtractEstimatedBkg (private)
//--------------------------------------------------------------------------
/**
* Subtracts the background which is estimated from a given interval (typically before t0).
@@ -835,7 +939,7 @@ Bool_t PRunAsymmetry::SubtractEstimatedBkg()
}
//--------------------------------------------------------------------------
-// PrepareFitData
+// PrepareFitData (protected)
//--------------------------------------------------------------------------
/**
* Take the pre-processed data (i.e. grouping and addrun are preformed) and form the asymmetry for fitting.
@@ -936,6 +1040,19 @@ Bool_t PRunAsymmetry::PrepareFitData(PRawRunData* runData, UInt_t histoNo[2])
cerr << endl;
}
+ // if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now
+ if (fRunInfo->IsFitRangeInBin()) {
+ fFitStartTime = (fRunInfo->GetDataRange(0) + fRunInfo->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt
+ fFitEndTime = (fRunInfo->GetDataRange(1) - fRunInfo->GetFitRangeOffset(1) - fT0s[0]) * fTimeResolution; // (lgb-n1-t0)*dt
+ // write these times back into the data structure. This way it is available when writting the log-file
+ fRunInfo->SetFitRange(fFitStartTime, 0);
+ fRunInfo->SetFitRange(fFitEndTime, 1);
+ }
+
+ // keep good bins for potential latter use
+ fGoodBins[0] = start[0];
+ fGoodBins[1] = end[0];
+
// everything looks fine, hence fill packed forward and backward histo
PRunData forwardPacked;
PRunData backwardPacked;
@@ -1032,7 +1149,7 @@ Bool_t PRunAsymmetry::PrepareFitData(PRawRunData* runData, UInt_t histoNo[2])
}
//--------------------------------------------------------------------------
-// PrepareViewData
+// PrepareViewData (protected)
//--------------------------------------------------------------------------
/**
* Take the pre-processed data (i.e. grouping and addrun are preformed) and form the asymmetry for view representation.
@@ -1141,6 +1258,12 @@ Bool_t PRunAsymmetry::PrepareViewData(PRawRunData* runData, UInt_t histoNo[2])
}
}
+ // if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now
+ if (fRunInfo->IsFitRangeInBin()) {
+ fFitStartTime = (fRunInfo->GetDataRange(0) + fRunInfo->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt
+ fFitEndTime = (fRunInfo->GetDataRange(1) - fRunInfo->GetFitRangeOffset(1) - fT0s[0]) * fTimeResolution; // (lgb-n1-t0)*dt
+ }
+
// everything looks fine, hence fill packed forward and backward histo
PRunData forwardPacked;
PRunData backwardPacked;
@@ -1289,7 +1412,7 @@ Bool_t PRunAsymmetry::PrepareViewData(PRawRunData* runData, UInt_t histoNo[2])
}
//--------------------------------------------------------------------------
-// PrepareRRFViewData
+// PrepareRRFViewData (protected)
//--------------------------------------------------------------------------
/**
* Prepares the RRF data set for visual representation. This is done the following way:
diff --git a/src/classes/PRunDataHandler.cpp b/src/classes/PRunDataHandler.cpp
index 792dd0d7..931645f0 100644
--- a/src/classes/PRunDataHandler.cpp
+++ b/src/classes/PRunDataHandler.cpp
@@ -82,22 +82,68 @@ using namespace std;
#define A2M_WKM 7
#define A2M_ASCII 8
+#define PHR_INIT_ALL 0
+#define PHR_INIT_MSR 1
+#define PHR_INIT_ANY2MANY 2
+
//--------------------------------------------------------------------------
// Constructor
//--------------------------------------------------------------------------
/**
- * Constructor, reading the data histogramm files.
- *
- * \param msrInfo pointer to the msr-file handler
+ * Empty Constructor
*/
-PRunDataHandler::PRunDataHandler(PAny2ManyInfo *any2ManyInfo) : fAny2ManyInfo(any2ManyInfo)
+PRunDataHandler::PRunDataHandler()
{
- fDataPath.clear();
- // read files
- if (!ReadWriteFilesList()) // couldn't read file
- fAllDataAvailable = false;
- else
- fAllDataAvailable = true;
+ Init();
+}
+
+//--------------------------------------------------------------------------
+// Constructor
+//--------------------------------------------------------------------------
+/**
+ * Constructor which just reads a single muSR data file.
+ *
+ * \param fileName
+ * \param fileFormat
+ */
+PRunDataHandler::PRunDataHandler(TString fileName, const TString fileFormat) : fFileFormat(fileFormat)
+{
+ Init();
+
+ FileExistsCheck(fileName);
+}
+
+//--------------------------------------------------------------------------
+// Constructor
+//--------------------------------------------------------------------------
+/**
+ * Constructor which just reads a single muSR data file.
+ *
+ * \param fileName
+ * \param fileFormat
+ * \param dataPath
+ */
+PRunDataHandler::PRunDataHandler(TString fileName, const TString fileFormat, const PStringVector dataPath) : fDataPath(dataPath), fFileFormat(fileFormat)
+{
+ Init();
+
+ FileExistsCheck(fileName);
+}
+
+//--------------------------------------------------------------------------
+// Constructor
+//--------------------------------------------------------------------------
+/**
+ * Constructor which just writes a single muSR data file.
+ *
+ * \param fileName
+ * \param fileFormat
+ * \param dataPath
+ * \param runData
+ */
+PRunDataHandler::PRunDataHandler(TString fileName, const TString fileFormat, const TString dataPath, PRawRunData &runData)
+{
+ Init();
}
//--------------------------------------------------------------------------
@@ -108,14 +154,24 @@ PRunDataHandler::PRunDataHandler(PAny2ManyInfo *any2ManyInfo) : fAny2ManyInfo(an
*
* \param msrInfo pointer to the msr-file handler
*/
+PRunDataHandler::PRunDataHandler(PAny2ManyInfo *any2ManyInfo) : fAny2ManyInfo(any2ManyInfo)
+{
+ Init(PHR_INIT_ANY2MANY);
+}
+
+//--------------------------------------------------------------------------
+// Constructor
+//--------------------------------------------------------------------------
+/**
+ * Constructor, reading the data histogramm files.
+ *
+ * \param any2ManyInfo pointer to the PAny2ManyInfo structure needed to convert data
+ * \param dataPath contains all data search paths.
+ */
PRunDataHandler::PRunDataHandler(PAny2ManyInfo *any2ManyInfo, const PStringVector dataPath) :
fAny2ManyInfo(any2ManyInfo), fDataPath(dataPath)
{
- // read files
- if (!ReadWriteFilesList()) // couldn't read file
- fAllDataAvailable = false;
- else
- fAllDataAvailable = true;
+ Init(PHR_INIT_ANY2MANY);
}
//--------------------------------------------------------------------------
@@ -128,11 +184,7 @@ PRunDataHandler::PRunDataHandler(PAny2ManyInfo *any2ManyInfo, const PStringVecto
*/
PRunDataHandler::PRunDataHandler(PMsrHandler *msrInfo) : fMsrInfo(msrInfo)
{
- // read files
- if (!ReadFilesMsr()) // couldn't read file
- fAllDataAvailable = false;
- else
- fAllDataAvailable = true;
+ Init(PHR_INIT_MSR);
}
//--------------------------------------------------------------------------
@@ -148,11 +200,7 @@ PRunDataHandler::PRunDataHandler(PMsrHandler *msrInfo) : fMsrInfo(msrInfo)
PRunDataHandler::PRunDataHandler(PMsrHandler *msrInfo, const PStringVector dataPath) :
fMsrInfo(msrInfo), fDataPath(dataPath)
{
- // read files
- if (!ReadFilesMsr()) // couldn't read file
- fAllDataAvailable = false;
- else
- fAllDataAvailable = true;
+ Init(PHR_INIT_MSR);
}
//--------------------------------------------------------------------------
@@ -163,6 +211,7 @@ PRunDataHandler::PRunDataHandler(PMsrHandler *msrInfo, const PStringVector dataP
*/
PRunDataHandler::~PRunDataHandler()
{
+ fDataPath.clear();
fData.clear();
}
@@ -170,7 +219,7 @@ PRunDataHandler::~PRunDataHandler()
// GetRunData
//--------------------------------------------------------------------------
/**
- * Checks if runName is found.
+ * Checks if runName is found, and if so return these data.
*
* return:
* - if data are found: pointer to the data.
@@ -194,7 +243,87 @@ PRawRunData* PRunDataHandler::GetRunData(const TString &runName)
}
//--------------------------------------------------------------------------
-// ReadFilesMsr
+// ReadData
+//--------------------------------------------------------------------------
+/**
+ * Read data. Used to read data, either msr-file triggered, or a single
+ * explicit data file should be read.
+ */
+void PRunDataHandler::ReadData()
+{
+ if (fMsrInfo) { // i.e. msr-file triggered
+ if (!ReadFilesMsr()) // couldn't read file
+ fAllDataAvailable = false;
+ else
+ fAllDataAvailable = true;
+ } else if (!fRunPathName.IsWhitespace()) { // i.e. file name triggered
+ cerr << endl << "debug>> fFileFormat=\"" << fFileFormat << "\"" << endl;
+ if ((fFileFormat == "MusrRoot") || (fFileFormat == "musrroot")) {
+ fAllDataAvailable = ReadRootFile();
+ } else if ((fFileFormat == "NeXus") || (fFileFormat == "nexus")) {
+ fAllDataAvailable = ReadNexusFile();
+ } else if ((fFileFormat == "PsiBin") || (fFileFormat == "psibin")) {
+ fAllDataAvailable = ReadPsiBinFile();
+ } else if ((fFileFormat == "Mud") || (fFileFormat == "mud")) {
+ fAllDataAvailable = ReadMudFile();
+ } else if ((fFileFormat == "Wkm") || (fFileFormat == "wkm")) {
+ fAllDataAvailable = ReadWkmFile();
+ } else {
+ cerr << endl << ">> PRunDataHandler::ReadData(): **ERROR** unkown file format \"" << fFileFormat << "\" found." << endl;
+ fAllDataAvailable = false;
+ }
+ } else {
+ cerr << endl << ">> PRunDataHandler::ReadData(): **ERROR** Couldn't read files." << endl;
+ fAllDataAvailable = false;
+ }
+}
+
+//--------------------------------------------------------------------------
+// ConvertData
+//--------------------------------------------------------------------------
+/**
+ * Read data and convert it. This routine is used by any2many.
+ */
+void PRunDataHandler::ConvertData()
+{
+ if (!ReadWriteFilesList()) // couldn't read file
+ fAllDataAvailable = false;
+ else
+ fAllDataAvailable = true;
+}
+
+//--------------------------------------------------------------------------
+// WriteData
+//--------------------------------------------------------------------------
+/**
+ * Write data. This routine is used to write a single file.
+ */
+void PRunDataHandler::WriteData()
+{
+
+}
+
+//--------------------------------------------------------------------------
+// Init (private)
+//--------------------------------------------------------------------------
+/**
+ * Common initializer.
+ */
+void PRunDataHandler::Init(const Int_t tag)
+{
+ if ((tag==PHR_INIT_ALL) || (tag==PHR_INIT_ANY2MANY))
+ fMsrInfo = 0;
+ if ((tag==PHR_INIT_ALL) || (tag==PHR_INIT_MSR))
+ fAny2ManyInfo = 0;
+ fAllDataAvailable = false;
+ if (tag!=PHR_INIT_ALL)
+ fFileFormat = TString("");
+ fRunName = TString("");
+ fRunPathName = TString("");
+}
+
+//--------------------------------------------------------------------------
+// ReadFilesMsr (private)
//--------------------------------------------------------------------------
/**
* The main read file routine which is filtering what read sub-routine
@@ -283,7 +412,7 @@ Bool_t PRunDataHandler::ReadFilesMsr()
}
//--------------------------------------------------------------------------
-// ReadWriteFilesList
+// ReadWriteFilesList (private)
//--------------------------------------------------------------------------
/**
* The main read file routine which is filtering what read sub-routine
@@ -762,7 +891,7 @@ void PRunDataHandler::TestFileName(TString &runName, const TString &ext)
}
//--------------------------------------------------------------------------
-// FileExistsCheck
+// FileExistsCheck (private)
//--------------------------------------------------------------------------
/**
* Checks if a given data file exists.
@@ -972,7 +1101,7 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx)
}
//--------------------------------------------------------------------------
-// FileExistsCheck
+// FileExistsCheck (private)
//--------------------------------------------------------------------------
/**
* Checks if a given data file exists. Used for the any2many program.
@@ -1069,7 +1198,76 @@ Bool_t PRunDataHandler::FileExistsCheck(const Bool_t fileName, const Int_t idx)
}
//--------------------------------------------------------------------------
-// ReadRootFile
+// FileExistsCheck (private)
+//--------------------------------------------------------------------------
+/**
+ * Checks if a given data file exists. Used for the any2many program.
+ *
+ * return:
+ * - true if data file exists,
+ * - otherwise false.
+ *
+ * \param fileName file name
+ */
+Bool_t PRunDataHandler::FileExistsCheck(const TString fileName)
+{
+ TString pathName("???");
+ TString str("");
+
+ // check if the file is in the local directory
+ if (gSystem->AccessPathName(fileName) != true) { // found in the local dir
+ pathName = fileName;
+ }
+ // check if the file is found in the directory given in the startup file
+ if (pathName.CompareTo("???") == 0) { // not found in local directory search
+ for (UInt_t i=0; i Reads both, the "old" LEM-data ROOT-files with TLemRunHeader, and the more general
@@ -1738,7 +1936,7 @@ Bool_t PRunDataHandler::ReadRootFile()
}
//--------------------------------------------------------------------------
-// ReadNexusFile
+// ReadNexusFile (private)
//--------------------------------------------------------------------------
/**
* Will read the NeXuS File Format as soon as PSI will have an implementation.
@@ -2105,7 +2303,7 @@ Bool_t PRunDataHandler::ReadNexusFile()
}
//--------------------------------------------------------------------------
-// ReadWkmFile
+// ReadWkmFile (private)
//--------------------------------------------------------------------------
/**
* Reads, for backwards compatibility, the ascii-wkm-file data format.
@@ -2411,7 +2609,7 @@ Bool_t PRunDataHandler::ReadWkmFile()
}
//--------------------------------------------------------------------------
-// ReadPsiBinFile
+// ReadPsiBinFile (private)
//--------------------------------------------------------------------------
/**
* Reads the old-fashioned PSI-BIN data-files. The MuSR_td_PSI_bin class
@@ -2659,7 +2857,7 @@ Bool_t PRunDataHandler::ReadPsiBinFile()
}
//--------------------------------------------------------------------------
-// ReadMudFile
+// ReadMudFile (private)
//--------------------------------------------------------------------------
/**
* Reads the triumf mud-file format.
@@ -2977,7 +3175,7 @@ Bool_t PRunDataHandler::ReadMudFile()
}
//--------------------------------------------------------------------------
-// ReadMduAsciiFile
+// ReadMduAsciiFile (private)
//--------------------------------------------------------------------------
/**
* Reads the mdu ascii files (PSI). Needed to work around PSI-BIN limitations.
@@ -3280,7 +3478,7 @@ Bool_t PRunDataHandler::ReadMduAsciiFile()
}
//--------------------------------------------------------------------------
-// ReadAsciiFile
+// ReadAsciiFile (private)
//--------------------------------------------------------------------------
/**
* Reads ascii files. Intended for the nonMuSR data.
@@ -3517,7 +3715,7 @@ Bool_t PRunDataHandler::ReadAsciiFile()
}
//--------------------------------------------------------------------------
-// ReadDBFile
+// ReadDBFile (private)
//--------------------------------------------------------------------------
/**
* Reads triumf db-files. Intended for the nonMuSR data.
@@ -3966,7 +4164,7 @@ Bool_t PRunDataHandler::ReadDBFile()
}
//--------------------------------------------------------------------------
-// WriteMusrRootFile
+// WriteMusrRootFile (private)
//--------------------------------------------------------------------------
/**
* Write the MusrRoot file format. Only the required entries will be handled.
@@ -4208,7 +4406,7 @@ Bool_t PRunDataHandler::WriteMusrRootFile(TString fln)
}
//--------------------------------------------------------------------------
-// WriteRootFile
+// WriteRootFile (private)
//--------------------------------------------------------------------------
/**
* Write the PSI LEM root-file format.
@@ -4392,7 +4590,7 @@ Bool_t PRunDataHandler::WriteRootFile(TString fln)
}
//--------------------------------------------------------------------------
-// WriteNexusFile
+// WriteNexusFile (private)
//--------------------------------------------------------------------------
/**
* Write the nexus-file format.
@@ -4737,7 +4935,7 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln)
}
//--------------------------------------------------------------------------
-// WriteWkmFile
+// WriteWkmFile (private)
//--------------------------------------------------------------------------
/**
* Write the wkm-file format.
@@ -4878,7 +5076,7 @@ Bool_t PRunDataHandler::WriteWkmFile(TString fln)
}
//--------------------------------------------------------------------------
-// WritePsiBinFile
+// WritePsiBinFile (private)
//--------------------------------------------------------------------------
/**
* Write the psi-bin-file format.
@@ -5099,7 +5297,7 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln)
}
//--------------------------------------------------------------------------
-// WriteMudFile
+// WriteMudFile (private)
//--------------------------------------------------------------------------
/**
* Write the mud-file format.
@@ -5259,7 +5457,7 @@ Bool_t PRunDataHandler::WriteMudFile(TString fln)
}
//--------------------------------------------------------------------------
-// WriteAsciiFile
+// WriteAsciiFile (private)
//--------------------------------------------------------------------------
/**
* Write the ascii-file format.
diff --git a/src/classes/PRunListCollection.cpp b/src/classes/PRunListCollection.cpp
index 80b2acf3..bed6bd1e 100644
--- a/src/classes/PRunListCollection.cpp
+++ b/src/classes/PRunListCollection.cpp
@@ -131,8 +131,34 @@ Bool_t PRunListCollection::Add(Int_t runNo, EPMusrHandleTag tag)
// SetFitRange (public)
//--------------------------------------------------------------------------
/**
- * Set the current fit range. If fitRange.size()==1 the given fit range will be used for all the runs,
- * otherwise fitRange.size()==the number of runs in the msr-file, and for each run there will be an induvidual
+ * Set the current fit range in bins. The string has the structure:
+ * 'fit_range fgb0+n00 lgb0-n01 [fgb1+n10 lgb-n11 fgb2+n20 lgb2-n21 .. fgbN+nN0 lgbN-nN1]'
+ * where fgb is the first good bin, lgb is the last good bin. nXY are offsets in bins.
+ * N is the number of runs in the msr-file.
+ *
+ * This means there are 2 options: (i) a globle fit range in bins for all runs in the
+ * msr-file, or (ii) each run block in the msr-file needs its individual range.
+ *
+ * \param fitRange string holding the fit range(s).
+ */
+void PRunListCollection::SetFitRange(const TString fitRange)
+{
+ for (UInt_t i=0; i Set the current fit range in time. If fitRange.size()==1 the given fit range will be used for all the runs,
+ * otherwise fitRange.size()==the number of runs in the msr-file, and for each run there will be an individual
* fit range.
*
* \param fitRange vector holding the fit range(s).
diff --git a/src/classes/PRunMuMinus.cpp b/src/classes/PRunMuMinus.cpp
index 19d91db0..5ceb342a 100644
--- a/src/classes/PRunMuMinus.cpp
+++ b/src/classes/PRunMuMinus.cpp
@@ -30,6 +30,11 @@
***************************************************************************/
#include Allows to change the fit range on the fly. Used in the COMMAND block.
+ * The syntax of the string is: FIT_RANGE fgb[+n00] lgb[-n01] [fgb[+n10] lgb[-n11] ... fgb[+nN0] lgb[-nN1]].
+ * If only one pair of fgb/lgb is given, it is used for all runs in the RUN block section.
+ * If multiple fgb/lgb's are given, the number N has to be the number of RUN blocks in
+ * the msr-file.
+ *
+ * nXY are offsets which can be used to shift, limit the fit range.
+ *
+ * \param fitRange string containing the necessary information.
+ */
+void PRunMuMinus::SetFitRangeBin(const TString fitRange)
+{
+ TObjArray *tok = 0;
+ TObjString *ostr = 0;
+ TString str;
+ Ssiz_t idx = -1;
+ Int_t offset = 0;
+
+ tok = fitRange.Tokenize(" \t");
+
+ if (tok->GetEntries() == 3) { // structure FIT_RANGE fgb+n0 lgb-n1
+ // handle fgb+n0 entry
+ ostr = (TObjString*) tok->At(1);
+ str = ostr->GetString();
+ // check if there is an offset present
+ idx = str.First("+");
+ if (idx != -1) { // offset present
+ str.Remove(0, idx+1);
+ if (str.IsFloat()) // if str is a valid number, convert is to an integer
+ offset = str.Atoi();
+ }
+ fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution;
+
+ // handle lgb-n1 entry
+ ostr = (TObjString*) tok->At(2);
+ str = ostr->GetString();
+ // check if there is an offset present
+ idx = str.First("-");
+ if (idx != -1) { // offset present
+ str.Remove(0, idx+1);
+ if (str.IsFloat()) // if str is a valid number, convert is to an integer
+ offset = str.Atoi();
+ }
+ fFitEndTime = (fGoodBins[1] - offset - fT0s[0]) * fTimeResolution;
+ } else if ((tok->GetEntries() > 3) && (tok->GetEntries() % 2 == 1)) { // structure FIT_RANGE fgb[+n00] lgb[-n01] [fgb[+n10] lgb[-n11] ... fgb[+nN0] lgb[-nN1]]
+ Int_t pos = 2*(fRunNo+1)-1;
+
+ if (pos + 1 >= tok->GetEntries()) {
+ cerr << endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'";
+ cerr << endl << ">> will ignore it. Sorry ..." << endl;
+ } else {
+ // handle fgb+n0 entry
+ ostr = (TObjString*) tok->At(pos);
+ str = ostr->GetString();
+ // check if there is an offset present
+ idx = str.First("+");
+ if (idx != -1) { // offset present
+ str.Remove(0, idx+1);
+ if (str.IsFloat()) // if str is a valid number, convert is to an integer
+ offset = str.Atoi();
+ }
+ fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution;
+
+ // handle lgb-n1 entry
+ ostr = (TObjString*) tok->At(pos+1);
+ str = ostr->GetString();
+ // check if there is an offset present
+ idx = str.First("-");
+ if (idx != -1) { // offset present
+ str.Remove(0, idx+1);
+ if (str.IsFloat()) // if str is a valid number, convert is to an integer
+ offset = str.Atoi();
+ }
+ fFitEndTime = (fGoodBins[1] - offset - fT0s[0]) * fTimeResolution;
+ }
+ } else { // error
+ cerr << endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'";
+ cerr << endl << ">> will ignore it. Sorry ..." << endl;
+ }
+
+ // clean up
+ if (tok) {
+ delete tok;
+ }
+}
+
//--------------------------------------------------------------------------
// CalcNoOfFitBins (private)
//--------------------------------------------------------------------------
@@ -594,6 +699,19 @@ Bool_t PRunMuMinus::PrepareFitData(PRawRunData* runData, const UInt_t histoNo)
return false;
}
+ // if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now
+ if (fRunInfo->IsFitRangeInBin()) {
+ fFitStartTime = (fRunInfo->GetDataRange(0) + fRunInfo->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt
+ fFitEndTime = (fRunInfo->GetDataRange(1) - fRunInfo->GetFitRangeOffset(1) - fT0s[0]) * fTimeResolution; // (lgb-n1-t0)*dt
+ // write these times back into the data structure. This way it is available when writting the log-file
+ fRunInfo->SetFitRange(fFitStartTime, 0);
+ fRunInfo->SetFitRange(fFitEndTime, 1);
+ }
+
+ // keep good bins for potential latter use
+ fGoodBins[0] = start;
+ fGoodBins[1] = end;
+
// everything looks fine, hence fill data set
Int_t t0 = (Int_t)fT0s[0];
Double_t value = 0.0;
@@ -695,6 +813,12 @@ Bool_t PRunMuMinus::PrepareRawViewData(PRawRunData* runData, const UInt_t histoN
return false;
}
+ // if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now
+ if (fRunInfo->IsFitRangeInBin()) {
+ fFitStartTime = (fRunInfo->GetDataRange(0) + fRunInfo->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt
+ fFitEndTime = (fRunInfo->GetDataRange(1) - fRunInfo->GetFitRangeOffset(1) - fT0s[0]) * fTimeResolution; // (lgb-n1-t0)*dt
+ }
+
// everything looks fine, hence fill data set
Int_t t0 = (Int_t)fT0s[0];
Double_t value = 0.0;
diff --git a/src/classes/PRunSingleHisto.cpp b/src/classes/PRunSingleHisto.cpp
index d8a20ae1..8eedde23 100644
--- a/src/classes/PRunSingleHisto.cpp
+++ b/src/classes/PRunSingleHisto.cpp
@@ -58,6 +58,12 @@ PRunSingleHisto::PRunSingleHisto() : PRunBase()
{
fScaleN0AndBkg = true;
fNoOfFitBins = 0;
+ fBackground = 0;
+
+ // the 2 following variables are need in case fit range is given in bins, and since
+ // the fit range can be changed in the command block, these variables need to be accessible
+ fGoodBins[0] = -1;
+ fGoodBins[1] = -1;
}
//--------------------------------------------------------------------------
@@ -76,6 +82,11 @@ PRunSingleHisto::PRunSingleHisto(PMsrHandler *msrInfo, PRunDataHandler *rawData,
fScaleN0AndBkg = IsScaleN0AndBkg();
fNoOfFitBins = 0;
+ // the 2 following variables are need in case fit range is given in bins, and since
+ // the fit range can be changed in the command block, these variables need to be accessible
+ fGoodBins[0] = -1;
+ fGoodBins[1] = -1;
+
if (!PrepareData()) {
cerr << endl << ">> PRunSingleHisto::PRunSingleHisto: **SEVERE ERROR**: Couldn't prepare data for fitting!";
cerr << endl << ">> This is very bad :-(, will quit ...";
@@ -461,7 +472,97 @@ UInt_t PRunSingleHisto::GetNoOfFitBins()
}
//--------------------------------------------------------------------------
-// CalcNoOfFitBins (private)
+// SetFitRangeBin (public)
+//--------------------------------------------------------------------------
+/**
+ * Allows to change the fit range on the fly. Used in the COMMAND block.
+ * The syntax of the string is: FIT_RANGE fgb[+n00] lgb[-n01] [fgb[+n10] lgb[-n11] ... fgb[+nN0] lgb[-nN1]].
+ * If only one pair of fgb/lgb is given, it is used for all runs in the RUN block section.
+ * If multiple fgb/lgb's are given, the number N has to be the number of RUN blocks in
+ * the msr-file.
+ *
+ * nXY are offsets which can be used to shift, limit the fit range.
+ *
+ * \param fitRange string containing the necessary information.
+ */
+void PRunSingleHisto::SetFitRangeBin(const TString fitRange)
+{
+ TObjArray *tok = 0;
+ TObjString *ostr = 0;
+ TString str;
+ Ssiz_t idx = -1;
+ Int_t offset = 0;
+
+ tok = fitRange.Tokenize(" \t");
+
+ if (tok->GetEntries() == 3) { // structure FIT_RANGE fgb+n0 lgb-n1
+ // handle fgb+n0 entry
+ ostr = (TObjString*) tok->At(1);
+ str = ostr->GetString();
+ // check if there is an offset present
+ idx = str.First("+");
+ if (idx != -1) { // offset present
+ str.Remove(0, idx+1);
+ if (str.IsFloat()) // if str is a valid number, convert is to an integer
+ offset = str.Atoi();
+ }
+ fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution;
+
+ // handle lgb-n1 entry
+ ostr = (TObjString*) tok->At(2);
+ str = ostr->GetString();
+ // check if there is an offset present
+ idx = str.First("-");
+ if (idx != -1) { // offset present
+ str.Remove(0, idx+1);
+ if (str.IsFloat()) // if str is a valid number, convert is to an integer
+ offset = str.Atoi();
+ }
+ fFitEndTime = (fGoodBins[1] - offset - fT0s[0]) * fTimeResolution;
+ } else if ((tok->GetEntries() > 3) && (tok->GetEntries() % 2 == 1)) { // structure FIT_RANGE fgb[+n00] lgb[-n01] [fgb[+n10] lgb[-n11] ... fgb[+nN0] lgb[-nN1]]
+ Int_t pos = 2*(fRunNo+1)-1;
+
+ if (pos + 1 >= tok->GetEntries()) {
+ cerr << endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'";
+ cerr << endl << ">> will ignore it. Sorry ..." << endl;
+ } else {
+ // handle fgb+n0 entry
+ ostr = (TObjString*) tok->At(pos);
+ str = ostr->GetString();
+ // check if there is an offset present
+ idx = str.First("+");
+ if (idx != -1) { // offset present
+ str.Remove(0, idx+1);
+ if (str.IsFloat()) // if str is a valid number, convert is to an integer
+ offset = str.Atoi();
+ }
+ fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution;
+
+ // handle lgb-n1 entry
+ ostr = (TObjString*) tok->At(pos+1);
+ str = ostr->GetString();
+ // check if there is an offset present
+ idx = str.First("-");
+ if (idx != -1) { // offset present
+ str.Remove(0, idx+1);
+ if (str.IsFloat()) // if str is a valid number, convert is to an integer
+ offset = str.Atoi();
+ }
+ fFitEndTime = (fGoodBins[1] - offset - fT0s[0]) * fTimeResolution;
+ }
+ } else { // error
+ cerr << endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'";
+ cerr << endl << ">> will ignore it. Sorry ..." << endl;
+ }
+
+ // clean up
+ if (tok) {
+ delete tok;
+ }
+}
+
+//--------------------------------------------------------------------------
+// CalcNoOfFitBins (protected)
//--------------------------------------------------------------------------
/**
* Calculate the number of fitted bins for the current fit range.
@@ -483,7 +584,7 @@ void PRunSingleHisto::CalcNoOfFitBins()
}
//--------------------------------------------------------------------------
-// PrepareData (private)
+// PrepareData (protected)
//--------------------------------------------------------------------------
/**
* Prepare data for fitting or viewing. What is already processed at this stage:
@@ -653,7 +754,7 @@ Bool_t PRunSingleHisto::PrepareData()
}
}
- // set forward/backward histo data of the first group
+ // set forward histo data of the first group
fForward.resize(forward[0].size());
for (UInt_t i=0; i Take the pre-processed data (i.e. grouping and addrun are preformed) and form the histogram for viewing
@@ -888,6 +1003,12 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi
return false;
}
+ // if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now
+ if (fRunInfo->IsFitRangeInBin()) {
+ fFitStartTime = (fRunInfo->GetDataRange(0) + fRunInfo->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt
+ fFitEndTime = (fRunInfo->GetDataRange(1) - fRunInfo->GetFitRangeOffset(1) - fT0s[0]) * fTimeResolution; // (lgb-n1-t0)*dt
+ }
+
// everything looks fine, hence fill data set
Int_t t0 = (Int_t)fT0s[0];
Double_t value = 0.0;
@@ -997,7 +1118,7 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi
}
//--------------------------------------------------------------------------
-// PrepareViewData (private)
+// PrepareViewData (protected)
//--------------------------------------------------------------------------
/**
* Take the pre-processed data (i.e. grouping and addrun are preformed) and form the histogram for viewing
@@ -1085,6 +1206,12 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo
return false;
}
+ // if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now
+ if (fRunInfo->IsFitRangeInBin()) {
+ fFitStartTime = (fRunInfo->GetDataRange(0) + fRunInfo->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt
+ fFitEndTime = (fRunInfo->GetDataRange(1) - fRunInfo->GetFitRangeOffset(1) - fT0s[0]) * fTimeResolution; // (lgb-n1-t0)*dt
+ }
+
// everything looks fine, hence fill data set
// feed the parameter vector
diff --git a/src/include/PFitter.h b/src/include/PFitter.h
index e1c79089..1979e9d1 100644
--- a/src/include/PFitter.h
+++ b/src/include/PFitter.h
@@ -81,6 +81,7 @@ class PFitter
Bool_t fConverged; ///< flag. true: the fit has converged.
Bool_t fChisqOnly; ///< flag. true: calculate chi^2 only (no fitting).
Bool_t fUseChi2; ///< flag. true: chi^2 fit. false: log-max-likelihood
+ UInt_t fPrintLevel; ///< tag, showing the level of messages whished. 0=minimum, 1=standard, 2=maximum
UInt_t fStrategy; ///< fitting strategy (see minuit2 manual).
@@ -119,6 +120,7 @@ class PFitter
Bool_t ExecuteMinimize();
Bool_t ExecuteMinos();
Bool_t ExecutePlot();
+ Bool_t ExecutePrintLevel(UInt_t lineNo);
Bool_t ExecuteRelease(UInt_t lineNo);
Bool_t ExecuteRestore();
Bool_t ExecuteScan();
diff --git a/src/include/PMusr.h b/src/include/PMusr.h
index e2e01cf4..ea3e2f4c 100644
--- a/src/include/PMusr.h
+++ b/src/include/PMusr.h
@@ -559,7 +559,9 @@ class PMsrRunBlock {
virtual UInt_t GetAddT0BinEntries() { return fAddT0.size(); }
virtual Int_t GetAddT0BinSize(UInt_t addRunIdx);
virtual Double_t GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx);
+ virtual Bool_t IsFitRangeInBin() { return fFitRangeInBins; }
virtual Double_t GetFitRange(UInt_t idx);
+ virtual Int_t GetFitRangeOffset(UInt_t idx);
virtual Int_t GetPacking() { return fPacking; }
virtual Int_t GetXDataIndex() { return fXYDataIndex[0]; }
virtual Int_t GetYDataIndex() { return fXYDataIndex[1]; }
@@ -588,7 +590,9 @@ class PMsrRunBlock {
virtual void SetDataRange(Int_t ival, Int_t idx);
virtual void SetT0Bin(Double_t dval, Int_t idx=-1);
virtual void SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx);
+ virtual void SetFitRangeInBins(Bool_t bval) { fFitRangeInBins = bval; }
virtual void SetFitRange(Double_t dval, UInt_t idx);
+ virtual void SetFitRangeOffset(Int_t ival, UInt_t idx);
virtual void SetPacking(Int_t ival) { fPacking = ival; }
virtual void SetXDataIndex(Int_t ival) { fXYDataIndex[0] = ival; }
virtual void SetYDataIndex(Int_t ival) { fXYDataIndex[1] = ival; }
@@ -618,7 +622,9 @@ class PMsrRunBlock {
Int_t fDataRange[4]; ///< data bin range (fit type 0, 2, 4)
PDoubleVector fT0; ///< t0 bins (fit type 0, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2, 4 -> f0, b0, f1, b1, ...
vector