transferred lifetimecorrection from RUN block to the PLOT block. More work towards a working GLOBAL block
This commit is contained in:
parent
918f1eb110
commit
075c259971
@ -50,7 +50,7 @@ using namespace std;
|
||||
*
|
||||
* \param fileName name of a msr-file.
|
||||
*/
|
||||
PMsrHandler::PMsrHandler(const Char_t *fileName, const Bool_t fourierOnly, PStartupOptions *startupOptions) :
|
||||
PMsrHandler::PMsrHandler(const Char_t *fileName, PStartupOptions *startupOptions, const Bool_t fourierOnly) :
|
||||
fFourierOnly(fourierOnly), fStartupOptions(startupOptions), fFileName(fileName)
|
||||
{
|
||||
// init variables
|
||||
@ -311,10 +311,10 @@ Int_t PMsrHandler::ReadMsrFile()
|
||||
if (!CheckAddRunParameters())
|
||||
result = PMUSR_MSR_SYNTAX_ERROR;
|
||||
|
||||
// check if the user wants to use max likelihood with asymmetry/non-muSR fit (which is not implemented)
|
||||
if (result == PMUSR_SUCCESS)
|
||||
CheckMaxLikelihood();
|
||||
|
||||
if (result == PMUSR_SUCCESS) {
|
||||
CheckMaxLikelihood(); // check if the user wants to use max likelihood with asymmetry/non-muSR fit (which is not implemented)
|
||||
CheckLegacyLifetimecorrection(); // check if lifetimecorrection is found in RUN blocks, if yes transfer it to PLOT blocks
|
||||
}
|
||||
|
||||
// clean up
|
||||
fit_parameter.clear();
|
||||
@ -604,7 +604,6 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
}
|
||||
break;
|
||||
case MSR_TAG_GLOBAL:
|
||||
// STILL QUITE A FEW ITEMS MISSING !!!!!!
|
||||
sstr = str;
|
||||
if (sstr.BeginsWith("fittype")) {
|
||||
fout.width(16);
|
||||
@ -625,13 +624,58 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
break;
|
||||
}
|
||||
} else if (sstr.BeginsWith("data")) {
|
||||
// STILL MISSING
|
||||
fout.width(16);
|
||||
fout << left << "data";
|
||||
for (UInt_t j=0; j<4; j++) {
|
||||
if (fGlobal.GetDataRange(j) > 0) {
|
||||
fout.width(8);
|
||||
fout << left << fGlobal.GetDataRange(j);
|
||||
}
|
||||
}
|
||||
fout << endl;
|
||||
} else if (sstr.BeginsWith("t0")) {
|
||||
// STILL MISSING
|
||||
fout.width(16);
|
||||
fout << left << "t0";
|
||||
for (UInt_t j=0; j<fGlobal.GetT0BinSize(); j++) {
|
||||
fout.width(8);
|
||||
fout.precision(1);
|
||||
fout.setf(ios::fixed,ios::floatfield);
|
||||
fout << left << fGlobal.GetT0Bin(j);
|
||||
}
|
||||
fout << endl;
|
||||
} else if (sstr.BeginsWith("fit")) {
|
||||
// STILL MISSING
|
||||
fout.width(16);
|
||||
fout << left << "fit";
|
||||
if (fGlobal.IsFitRangeInBin()) { // fit range given in bins
|
||||
fout << "fgb";
|
||||
if (fGlobal.GetFitRangeOffset(0) > 0)
|
||||
fout << "+" << fGlobal.GetFitRangeOffset(0);
|
||||
fout << " lgb";
|
||||
if (fGlobal.GetFitRangeOffset(1) > 0)
|
||||
fout << "-" << fGlobal.GetFitRangeOffset(1);
|
||||
neededPrec = LastSignificant(fGlobal.GetFitRange(0));
|
||||
if (LastSignificant(fGlobal.GetFitRange(1)) > neededPrec)
|
||||
neededPrec = LastSignificant(fGlobal.GetFitRange(1));
|
||||
fout.precision(neededPrec);
|
||||
fout << " # in time: " << fGlobal.GetFitRange(0) << ".." << fGlobal.GetFitRange(1) << " (usec)";
|
||||
} else { // fit range given in time
|
||||
for (UInt_t j=0; j<2; j++) {
|
||||
if (fGlobal.GetFitRange(j) == -1)
|
||||
break;
|
||||
neededWidth = 7;
|
||||
neededPrec = LastSignificant(fGlobal.GetFitRange(j));
|
||||
fout.width(neededWidth);
|
||||
fout.precision(neededPrec);
|
||||
fout << left << fixed << fGlobal.GetFitRange(j);
|
||||
if (j==0)
|
||||
fout << " ";
|
||||
}
|
||||
}
|
||||
fout << endl;
|
||||
} else if (sstr.BeginsWith("packing")) {
|
||||
// STILL MISSING
|
||||
fout.width(16);
|
||||
fout << left << "packing";
|
||||
fout << fGlobal.GetPacking() << endl;
|
||||
} else {
|
||||
fout << str.Data() << endl;
|
||||
}
|
||||
@ -731,9 +775,13 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
fout << left << "lifetime";
|
||||
fout << fRuns[runNo].GetLifetimeParamNo() << endl;
|
||||
} else if (sstr.BeginsWith("lifetimecorrection")) {
|
||||
if ((fRuns[runNo].IsLifetimeCorrected()) && (fRuns[runNo].GetFitType() == MSR_FITTYPE_SINGLE_HISTO)) {
|
||||
/* obsolate, hence do nothing here
|
||||
if ((fRuns[runNo].IsLifetimeCorrected()) &&
|
||||
((fRuns[runNo].GetFitType() == MSR_FITTYPE_SINGLE_HISTO) ||
|
||||
(fGlobal.GetFitType() == MSR_FITTYPE_SINGLE_HISTO))) {
|
||||
fout << "lifetimecorrection" << endl;
|
||||
}
|
||||
*/
|
||||
} else if (sstr.BeginsWith("map")) {
|
||||
fout << "map ";
|
||||
for (UInt_t j=0; j<fRuns[runNo].GetMap()->size(); j++) {
|
||||
@ -940,7 +988,7 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
if (LastSignificant(fRuns[runNo].GetFitRange(1)) > neededPrec)
|
||||
neededPrec = LastSignificant(fRuns[runNo].GetFitRange(1));
|
||||
fout.precision(neededPrec);
|
||||
fout << " # in time: " << fRuns[runNo].GetFitRange(0) << ".." << fRuns[runNo].GetFitRange(1) << " in (usec)";
|
||||
fout << " # in time: " << fRuns[runNo].GetFitRange(0) << ".." << fRuns[runNo].GetFitRange(1) << " (usec)";
|
||||
} else { // fit range given in time
|
||||
for (UInt_t j=0; j<2; j++) {
|
||||
if (fRuns[runNo].GetFitRange(j) == -1)
|
||||
@ -1054,6 +1102,13 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (fPlots[plotNo].fLifeTimeCorrection) {
|
||||
fout << "lifetimecorrection" << endl;
|
||||
}
|
||||
} else if (sstr.BeginsWith("lifetimecorrection")) {
|
||||
// do nothing, since it is already handled in the lines above.
|
||||
// The reason why this handled that oddly is due to legacy issues
|
||||
// of this flag, i.e. transfer from RUN -> PLOT
|
||||
} else if (sstr.BeginsWith("runs")) {
|
||||
fout << "runs ";
|
||||
fout.precision(0);
|
||||
@ -2707,7 +2762,6 @@ Bool_t PMsrHandler::HandleGlobalEntry(PMsrLines &lines)
|
||||
} else { // n0 == 0
|
||||
global.SetFitRangeOffset(0, 0);
|
||||
}
|
||||
|
||||
if (!error)
|
||||
global.SetFitRangeInBins(true);
|
||||
} else { // fit given in time, i.e. fit <start> <end>, where <start>, <end> are given as doubles
|
||||
@ -2766,6 +2820,8 @@ Bool_t PMsrHandler::HandleGlobalEntry(PMsrLines &lines)
|
||||
cout << endl << "debug> Global: t0's : ";
|
||||
for (UInt_t i=0; i<fGlobal.GetT0BinSize(); i++)
|
||||
cout << fGlobal.GetT0Bin(i) << ", ";
|
||||
cout << endl << "debug> Global: fit in bin: " << fGlobal.IsFitRangeInBin();
|
||||
cout << endl << "debug> Global: fit offset: " << fGlobal.GetFitRangeOffset(0) << ", " << fGlobal.GetFitRangeOffset(1);
|
||||
cout << endl << "debug> Global: fit : " << fGlobal.GetFitRange(0) << ", " << fGlobal.GetFitRange(1);
|
||||
cout << endl << "debug> Global: packing : " << fGlobal.GetPacking();
|
||||
cout << endl;
|
||||
@ -3736,6 +3792,7 @@ Bool_t PMsrHandler::HandlePlotEntry(PMsrLines &lines)
|
||||
|
||||
// initialize param structure
|
||||
param.fPlotType = -1;
|
||||
param.fLifeTimeCorrection = false;
|
||||
param.fUseFitRanges = false; // i.e. if not overwritten use the range info of the plot block
|
||||
param.fLogX = false; // i.e. if not overwritten use linear x-axis
|
||||
param.fLogY = false; // i.e. if not overwritten use linear y-axis
|
||||
@ -3784,6 +3841,8 @@ Bool_t PMsrHandler::HandlePlotEntry(PMsrLines &lines)
|
||||
delete tokens;
|
||||
tokens = 0;
|
||||
}
|
||||
} else if (iter1->fLine.Contains("lifetimecorrection", TString::kIgnoreCase)) {
|
||||
param.fLifeTimeCorrection = true;
|
||||
} else if (iter1->fLine.Contains("runs", TString::kIgnoreCase)) { // handle plot runs
|
||||
TComplex run;
|
||||
switch (param.fPlotType) {
|
||||
@ -4937,12 +4996,14 @@ Bool_t PMsrHandler::CheckRunBlockIntegrity()
|
||||
}
|
||||
}
|
||||
// check fit range
|
||||
if (!fRuns[i].IsFitRangeInBin()) { // fit range given as times in usec
|
||||
if (!fRuns[i].IsFitRangeInBin()) { // fit range given as times in usec (RUN block)
|
||||
if ((fRuns[i].GetFitRange(0) == PMUSR_UNDEFINED) || (fRuns[i].GetFitRange(1) == PMUSR_UNDEFINED)) { // check fit range in RUN block
|
||||
if ((fGlobal.GetFitRange(0) == PMUSR_UNDEFINED) || (fGlobal.GetFitRange(1) == PMUSR_UNDEFINED)) { // check fit range in GLOBAL block
|
||||
cerr << endl << "PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
|
||||
cerr << endl << " Fit range is not defined. Necessary for single histogram fits." << endl;
|
||||
return false;
|
||||
if (!fGlobal.IsFitRangeInBin()) { // fit range given as times in usec (GLOBAL block)
|
||||
if ((fGlobal.GetFitRange(0) == PMUSR_UNDEFINED) || (fGlobal.GetFitRange(1) == PMUSR_UNDEFINED)) { // check fit range in GLOBAL block
|
||||
cerr << endl << "PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
|
||||
cerr << endl << " Fit range is not defined. Necessary for single histogram fits." << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5380,7 +5441,7 @@ void PMsrHandler::CheckMaxLikelihood()
|
||||
{
|
||||
if (!fStatistic.fChisq) {
|
||||
for (UInt_t i=0; i<fRuns.size(); i++) {
|
||||
if (fRuns[i].GetFitType() != MSR_FITTYPE_SINGLE_HISTO) {
|
||||
if ((fRuns[i].GetFitType() != MSR_FITTYPE_SINGLE_HISTO) && (fGlobal.GetFitType() != MSR_FITTYPE_SINGLE_HISTO)) {
|
||||
cerr << endl << ">> PMsrHandler::CheckMaxLikelihood: **WARNING**: Maximum Log Likelihood Fit is only implemented";
|
||||
cerr << endl << ">> for Single Histogram Fit. Will fall back to Chi Square Fit.";
|
||||
cerr << endl << endl;
|
||||
@ -5647,4 +5708,26 @@ void PMsrHandler::MakeDetectorGroupingString(TString str, PIntVector &group, TSt
|
||||
} while (i<group.size());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// CheckLegacyLifetimecorrection (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Checks for lifetimecorrection flags in the RUN-blocks and if present,
|
||||
* transfer it to the PLOT-blocks. This is needed since originally the lifetimecorrection
|
||||
* was (miss)placed in the RUN-blocks rather than in the PLOT-blocks where it
|
||||
* most naturally would have been expected.
|
||||
*/
|
||||
void PMsrHandler::CheckLegacyLifetimecorrection()
|
||||
{
|
||||
UInt_t idx=0;
|
||||
for (UInt_t i=0; i<fPlots.size(); i++) {
|
||||
for (UInt_t j=0; j<fPlots[i].fRuns.size(); j++) {
|
||||
idx = fPlots[i].fRuns[j];
|
||||
if (fRuns[idx].IsLifetimeCorrected()) {
|
||||
fPlots[i].fLifeTimeCorrection = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// end ---------------------------------------------------------------------
|
||||
|
@ -596,6 +596,9 @@ void PMusrCanvas::UpdateDataTheoryPad()
|
||||
UInt_t runNo;
|
||||
PMsrPlotStructure plotInfo = fMsrHandler->GetMsrPlotList()->at(fPlotNumber);
|
||||
PMsrRunList runs = *fMsrHandler->GetMsrRunList();
|
||||
PMsrGlobalBlock *globalBlock = fMsrHandler->GetMsrGlobal();
|
||||
|
||||
Int_t fitType = globalBlock->GetFitType();
|
||||
|
||||
fPlotType = plotInfo.fPlotType;
|
||||
for (UInt_t i=0; i<plotInfo.fRuns.size(); i++) {
|
||||
@ -608,9 +611,14 @@ void PMusrCanvas::UpdateDataTheoryPad()
|
||||
}
|
||||
// check that the plottype and the fittype do correspond
|
||||
runNo = (UInt_t)plotInfo.fRuns[i]-1;
|
||||
if (fPlotType != runs[runNo].GetFitType()) {
|
||||
if (runs[runNo].GetFitType() != -1) { // fit type found in RUN block, hence overwrite the GLOBAL block
|
||||
fitType = runs[runNo].GetFitType();
|
||||
}
|
||||
if (fitType) {
|
||||
fValid = false;
|
||||
cerr << endl << "PMusrCanvas::UpdateDataTheoryPad: **ERROR** plottype = " << fPlotType << ", fittype = " << runs[runNo].GetFitType() << ", however they have to correspond!";
|
||||
cerr << endl << "PMusrCanvas::UpdateDataTheoryPad: **ERROR** plottype = " << fPlotType;
|
||||
cerr << ", fittype = " << runs[runNo].GetFitType() << "(RUN block)/";
|
||||
cerr << "fittype = " << globalBlock->GetFitType() << "(GLOBAL block). However, they have to correspond!";
|
||||
cerr << endl;
|
||||
return;
|
||||
}
|
||||
@ -622,7 +630,10 @@ void PMusrCanvas::UpdateDataTheoryPad()
|
||||
data = 0;
|
||||
runNo = (UInt_t)plotInfo.fRuns[i]-1;
|
||||
// get data depending on the fittype
|
||||
switch (runs[runNo].GetFitType()) {
|
||||
if (runs[runNo].GetFitType() != -1) { // fit type found in RUN block, hence overwrite the GLOBAL block
|
||||
fitType = runs[runNo].GetFitType();
|
||||
}
|
||||
switch (fitType) {
|
||||
case MSR_FITTYPE_SINGLE_HISTO:
|
||||
data = fRunList->GetSingleHisto(runNo, PRunListCollection::kRunNo);
|
||||
if (!data) { // something wrong
|
||||
|
@ -109,8 +109,8 @@ PRunBase::PRunBase(PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t runNo,
|
||||
}
|
||||
|
||||
// set fit time ranges
|
||||
fFitStartTime = fRunInfo->GetFitRange(0);
|
||||
fFitEndTime = fRunInfo->GetFitRange(1);
|
||||
fFitStartTime = PMUSR_UNDEFINED;
|
||||
fFitEndTime = PMUSR_UNDEFINED;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
@ -94,7 +94,12 @@ Bool_t PRunListCollection::Add(Int_t runNo, EPMusrHandleTag tag)
|
||||
{
|
||||
Bool_t success = true;
|
||||
|
||||
// try to get the fit type from the RUN block
|
||||
Int_t fitType = (*fMsrInfo->GetMsrRunList())[runNo].GetFitType();
|
||||
if (fitType == -1) { // fit type NOT given in the RUN block, check the GLOBAL block
|
||||
fitType = (*fMsrInfo->GetMsrGlobal()).GetFitType();
|
||||
}
|
||||
cout << endl << "debug> PRunListCollection::Add(): fitType=" << fitType << endl;
|
||||
|
||||
switch (fitType) {
|
||||
case PRUN_SINGLE_HISTO:
|
||||
|
@ -804,55 +804,13 @@ Bool_t PRunSingleHisto::PrepareData()
|
||||
cout.precision(10);
|
||||
cout << endl << ">> PRunSingleHisto::PrepareData(): time resolution=" << fixed << runData->GetTimeResolution() << "(ns)" << endl;
|
||||
|
||||
if (fHandleTag == kFit)
|
||||
success = PrepareFitData(runData, histoNo[0]);
|
||||
else if ((fHandleTag == kView) && !fRunInfo->IsLifetimeCorrected())
|
||||
success = PrepareRawViewData(runData, histoNo[0]);
|
||||
else if ((fHandleTag == kView) && fRunInfo->IsLifetimeCorrected())
|
||||
success = PrepareViewData(runData, histoNo[0]);
|
||||
else
|
||||
success = false;
|
||||
|
||||
// cleanup
|
||||
histoNo.clear();
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// PrepareFitData (protected)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Take the pre-processed data (i.e. grouping and addrun are preformed) and form the histogram for fitting.
|
||||
* The following steps are preformed:
|
||||
* -# get fit start/stop time
|
||||
* -# check that 'first good data bin', 'last good data bin', and 't0' make any sense
|
||||
* -# check how the background shall be handled, i.e. fitted, subtracted from background estimate data range, or subtacted from a given fixed background.
|
||||
* -# packing (i.e rebinning)
|
||||
*
|
||||
* <b>return:</b>
|
||||
* - true, if everything went smooth
|
||||
* - false, otherwise
|
||||
*
|
||||
* \param runData raw run data handler
|
||||
* \param histoNo forward histogram number
|
||||
*/
|
||||
Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoNo)
|
||||
{
|
||||
if (fMsrInfo->EstimateN0()) {
|
||||
EstimateN0();
|
||||
}
|
||||
|
||||
// transform raw histo data. This is done the following way (for details see the manual):
|
||||
// for the single histo fit, just the rebinned raw data are copied
|
||||
|
||||
// first get start data, end data, and t0
|
||||
Int_t start;
|
||||
Int_t end;
|
||||
start = fRunInfo->GetDataRange(0);
|
||||
end = fRunInfo->GetDataRange(1);
|
||||
|
||||
// check if data range has been provided, and if not try to get it from the GLOBAL block section
|
||||
// check if data range has been given in the RUN block, if not try to get it from the GLOBAL block
|
||||
if (start < 0) {
|
||||
start = fMsrInfo->GetMsrGlobal()->GetDataRange(0);
|
||||
}
|
||||
@ -900,20 +858,83 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN
|
||||
// keep good bins for potential later use
|
||||
fGoodBins[0] = start;
|
||||
fGoodBins[1] = end;
|
||||
cout << endl << "debug> PRunSingleHisto::PrepareData(): start=" << start << ", end=" << end << endl;
|
||||
|
||||
|
||||
// set fit start/end time; first check RUN Block
|
||||
fFitStartTime = fRunInfo->GetFitRange(0);
|
||||
fFitEndTime = fRunInfo->GetFitRange(1);
|
||||
// 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
|
||||
fFitStartTime = (start + fRunInfo->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt
|
||||
fFitEndTime = (end - 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);
|
||||
}
|
||||
|
||||
// check if fit range is given in the run block. If not, i.e. it has to be found in the global section!
|
||||
if (fRunInfo->GetFitRange(0) == PMUSR_UNDEFINED) {
|
||||
// ANYTHING NEEDED AT THIS POINT??? as35
|
||||
if (fFitStartTime == PMUSR_UNDEFINED) { // fit start/end NOT found in the RUN block, check GLOBAL block
|
||||
fFitStartTime = globalBlock->GetFitRange(0);
|
||||
fFitEndTime = globalBlock->GetFitRange(1);
|
||||
// if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now
|
||||
if (globalBlock->IsFitRangeInBin()) {
|
||||
fFitStartTime = (start + globalBlock->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt
|
||||
fFitEndTime = (end - globalBlock->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
|
||||
globalBlock->SetFitRange(fFitStartTime, 0);
|
||||
globalBlock->SetFitRange(fFitEndTime, 1);
|
||||
}
|
||||
}
|
||||
if ((fFitStartTime == PMUSR_UNDEFINED) || (fFitEndTime == PMUSR_UNDEFINED)) {
|
||||
cerr << "PRunSingleHisto::PrepareData(): **ERROR** Couldn't get fit start/end time!" << endl;
|
||||
return false;
|
||||
}
|
||||
cout << endl << "debug> PRunSingleHisto::PrepareData(): fFitStartTime=" << fFitStartTime << ", fFitEndTime=" << fFitEndTime << endl;
|
||||
|
||||
Bool_t lifetimecorrection = false;
|
||||
PMsrPlotList *plot = fMsrInfo->GetMsrPlotList();
|
||||
lifetimecorrection = plot->at(0).fLifeTimeCorrection;
|
||||
|
||||
if (fHandleTag == kFit)
|
||||
success = PrepareFitData(runData, histoNo[0]);
|
||||
else if ((fHandleTag == kView) && !lifetimecorrection)
|
||||
success = PrepareRawViewData(runData, histoNo[0]);
|
||||
else if ((fHandleTag == kView) && lifetimecorrection)
|
||||
success = PrepareViewData(runData, histoNo[0]);
|
||||
else
|
||||
success = false;
|
||||
|
||||
// cleanup
|
||||
histoNo.clear();
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// PrepareFitData (protected)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Take the pre-processed data (i.e. grouping and addrun are preformed) and form the histogram for fitting.
|
||||
* The following steps are preformed:
|
||||
* -# get fit start/stop time
|
||||
* -# check that 'first good data bin', 'last good data bin', and 't0' make any sense
|
||||
* -# check how the background shall be handled, i.e. fitted, subtracted from background estimate data range, or subtacted from a given fixed background.
|
||||
* -# packing (i.e rebinning)
|
||||
*
|
||||
* <b>return:</b>
|
||||
* - true, if everything went smooth
|
||||
* - false, otherwise
|
||||
*
|
||||
* \param runData raw run data handler
|
||||
* \param histoNo forward histogram number
|
||||
*/
|
||||
Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoNo)
|
||||
{
|
||||
if (fMsrInfo->EstimateN0()) {
|
||||
EstimateN0();
|
||||
}
|
||||
|
||||
// transform raw histo data. This is done the following way (for details see the manual):
|
||||
// for the single histo fit, just the rebinned raw data are copied
|
||||
|
||||
// check how the background shall be handled
|
||||
if (fRunInfo->GetBkgFitParamNo() == -1) { // bkg shall **NOT** be fitted
|
||||
@ -949,9 +970,9 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN
|
||||
normalizer = fPacking * (fTimeResolution * 1.0e3); // fTimeResolution us->ns
|
||||
// data start at data_start-t0
|
||||
// time shifted so that packing is included correctly, i.e. t0 == t0 after packing
|
||||
fData.SetDataTimeStart(fTimeResolution*((Double_t)start-(Double_t)t0+(Double_t)(fPacking-1)/2.0));
|
||||
fData.SetDataTimeStart(fTimeResolution*((Double_t)fGoodBins[0]-(Double_t)t0+(Double_t)(fPacking-1)/2.0));
|
||||
fData.SetDataTimeStep(fTimeResolution*fPacking);
|
||||
for (Int_t i=start; i<end; i++) {
|
||||
for (Int_t i=fGoodBins[0]; i<fGoodBins[1]; i++) {
|
||||
if (fPacking == 1) {
|
||||
value = fForward[i];
|
||||
value /= normalizer;
|
||||
@ -961,7 +982,7 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN
|
||||
else
|
||||
fData.AppendErrorValue(TMath::Sqrt(value));
|
||||
} else { // packed data, i.e. fPacking > 1
|
||||
if (((i-start) % fPacking == 0) && (i != start)) { // fill data
|
||||
if (((i-fGoodBins[0]) % fPacking == 0) && (i != fGoodBins[0])) { // fill data
|
||||
value /= normalizer;
|
||||
fData.AppendValue(value);
|
||||
if (value == 0.0)
|
||||
@ -1017,7 +1038,7 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi
|
||||
|
||||
// raw data, since PMusrCanvas is doing ranging etc.
|
||||
// start = the first bin which is a multiple of packing backward from first good data bin
|
||||
Int_t start = fRunInfo->GetDataRange(0) - (fRunInfo->GetDataRange(0)/packing)*packing;
|
||||
Int_t start = fGoodBins[0] - (fGoodBins[0]/packing)*packing;
|
||||
// end = last bin starting from start which is a multipl of packing and still within the data
|
||||
Int_t end = start + ((fForward.size()-start)/packing)*packing;
|
||||
// check if data range has been provided, and if not try to estimate them
|
||||
@ -1025,7 +1046,7 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi
|
||||
Int_t offset = (Int_t)(10.0e-3/fTimeResolution);
|
||||
start = ((Int_t)fT0s[0]+offset) - (((Int_t)fT0s[0]+offset)/packing)*packing;
|
||||
end = start + ((fForward.size()-start)/packing)*packing;
|
||||
cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** data range was not provided, will try data range start = " << start << ".";
|
||||
cerr << endl << ">> PRunSingleHisto::PrepareRawViewData(): **WARNING** data range was not provided, will try data range start = " << start << ".";
|
||||
cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
|
||||
cerr << endl;
|
||||
}
|
||||
@ -1049,12 +1070,6 @@ 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;
|
||||
@ -1116,7 +1131,7 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi
|
||||
} else { // no background given to do the job, try estimate
|
||||
fRunInfo->SetBkgRange(static_cast<Int_t>(fT0s[0]*0.1), 0);
|
||||
fRunInfo->SetBkgRange(static_cast<Int_t>(fT0s[0]*0.6), 1);
|
||||
cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** Neither fix background nor background bins are given!";
|
||||
cerr << endl << ">> PRunSingleHisto::PrepareRawViewData(): **WARNING** Neither fix background nor background bins are given!";
|
||||
cerr << endl << ">> Will try the following: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1);
|
||||
cerr << endl << ">> NO WARRANTY THAT THIS MAKES ANY SENSE! Better check ...";
|
||||
cerr << endl;
|
||||
@ -1218,7 +1233,7 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo
|
||||
Int_t t0 = (Int_t)fT0s[0];
|
||||
|
||||
// start = the first bin which is a multiple of packing backward from first good data bin
|
||||
Int_t start = fRunInfo->GetDataRange(0) - (fRunInfo->GetDataRange(0)/packing)*packing;
|
||||
Int_t start = fGoodBins[0] - (fGoodBins[0]/packing)*packing;
|
||||
// end = last bin starting from start which is a multiple of packing and still within the data
|
||||
Int_t end = start + ((fForward.size()-start)/packing)*packing;
|
||||
|
||||
@ -1227,7 +1242,7 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo
|
||||
Int_t offset = (Int_t)(10.0e-3/fTimeResolution);
|
||||
start = ((Int_t)fT0s[0]+offset) - (((Int_t)fT0s[0]+offset)/packing)*packing;
|
||||
end = start + ((fForward.size()-start)/packing)*packing;
|
||||
cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** data range was not provided, will try data range start = " << start << ".";
|
||||
cerr << endl << ">> PRunSingleHisto::PrepareViewData(): **WARNING** data range was not provided, will try data range start = " << start << ".";
|
||||
cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
|
||||
cerr << endl;
|
||||
}
|
||||
@ -1252,12 +1267,6 @@ 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
|
||||
@ -1296,7 +1305,7 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo
|
||||
} else { // no background given to do the job, try estimate
|
||||
fRunInfo->SetBkgRange(static_cast<Int_t>(fT0s[0]*0.1), 0);
|
||||
fRunInfo->SetBkgRange(static_cast<Int_t>(fT0s[0]*0.6), 1);
|
||||
cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** Neither fix background nor background bins are given!";
|
||||
cerr << endl << ">> PRunSingleHisto::PrepareViewData(): **WARNING** Neither fix background nor background bins are given!";
|
||||
cerr << endl << ">> Will try the following: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1);
|
||||
cerr << endl << ">> NO WARRANTY THAT THIS MAKES ANY SENSE! Better check ...";
|
||||
cerr << endl;
|
||||
|
@ -45,7 +45,7 @@
|
||||
class PMsrHandler
|
||||
{
|
||||
public:
|
||||
PMsrHandler(const Char_t *fileName, const Bool_t fourierOnly=false, PStartupOptions *startupOptions=0);
|
||||
PMsrHandler(const Char_t *fileName, PStartupOptions *startupOptions=0, const Bool_t fourierOnly=false);
|
||||
virtual ~PMsrHandler();
|
||||
|
||||
virtual Int_t ReadMsrFile();
|
||||
@ -154,6 +154,8 @@ class PMsrHandler
|
||||
|
||||
virtual Bool_t ParseDetectorGrouping(TString str, PIntVector &group);
|
||||
virtual void MakeDetectorGroupingString(TString str, PIntVector &group, TString &result, Bool_t includeDetector = true);
|
||||
|
||||
virtual void CheckLegacyLifetimecorrection();
|
||||
};
|
||||
|
||||
#endif // _PMSRHANDLER_H_
|
||||
|
@ -713,6 +713,7 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
Int_t fPlotType; ///< plot type
|
||||
Bool_t fLifeTimeCorrection; ///< needed for single histo. If yes, only the asymmetry is shown, otherweise the positron spectrum
|
||||
Bool_t fUseFitRanges; ///< yes -> use the fit ranges to plot the data, no (default) -> use range information if present
|
||||
Bool_t fLogX; ///< yes -> x-axis in log-scale, no (default) -> x-axis in lin-scale
|
||||
Bool_t fLogY; ///< yes -> y-axis in log-scale, no (default) -> y-axis in lin-scale
|
||||
|
Loading…
x
Reference in New Issue
Block a user