added DKS asymmetry fit support
This commit is contained in:
@ -1067,16 +1067,28 @@ const Char_t* PRunListCollection::GetYAxisTitle(const TString &runName, const UI
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief PRunListCollection::GetStartTimeBin
|
||||
* @param fitType
|
||||
* @param idx
|
||||
* @return
|
||||
*/
|
||||
Int_t PRunListCollection::GetStartTimeBin(UInt_t idx)
|
||||
Int_t PRunListCollection::GetStartTimeBin(Int_t fitType, UInt_t idx)
|
||||
{
|
||||
// make sure idx is within proper bounds
|
||||
if (idx >= fRunSingleHistoList.size())
|
||||
return -1;
|
||||
Int_t result = -1;
|
||||
|
||||
return fRunSingleHistoList[idx]->GetStartTimeBin();
|
||||
switch (fitType) {
|
||||
case MSR_FITTYPE_SINGLE_HISTO:
|
||||
if (idx < fRunSingleHistoList.size())
|
||||
result = fRunSingleHistoList[idx]->GetStartTimeBin();
|
||||
break;
|
||||
case MSR_FITTYPE_ASYM:
|
||||
if (idx < fRunAsymmetryList.size())
|
||||
result = fRunAsymmetryList[idx]->GetStartTimeBin();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@ -1084,16 +1096,28 @@ Int_t PRunListCollection::GetStartTimeBin(UInt_t idx)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief PRunListCollection::GetEndTimeBin
|
||||
* @param fitType
|
||||
* @param idx
|
||||
* @return
|
||||
*/
|
||||
Int_t PRunListCollection::GetEndTimeBin(UInt_t idx)
|
||||
Int_t PRunListCollection::GetEndTimeBin(Int_t fitType, UInt_t idx)
|
||||
{
|
||||
// make sure idx is within proper bounds
|
||||
if (idx >= fRunSingleHistoList.size())
|
||||
return -1;
|
||||
Int_t result = -1;
|
||||
|
||||
return fRunSingleHistoList[idx]->GetEndTimeBin();
|
||||
switch (fitType) {
|
||||
case MSR_FITTYPE_SINGLE_HISTO:
|
||||
if (idx < fRunSingleHistoList.size())
|
||||
result = fRunSingleHistoList[idx]->GetEndTimeBin();
|
||||
break;
|
||||
case MSR_FITTYPE_ASYM:
|
||||
if (idx < fRunAsymmetryList.size())
|
||||
result = fRunAsymmetryList[idx]->GetEndTimeBin();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@ -1106,7 +1130,7 @@ Int_t PRunListCollection::GetEndTimeBin(UInt_t idx)
|
||||
* @param shp
|
||||
* @return
|
||||
*/
|
||||
Int_t PRunListCollection::GetSingleHistoParams(UInt_t idx, const std::vector<Double_t>& par, PSingleHistoParams &shp)
|
||||
Int_t PRunListCollection::GetSingleHistoParams(UInt_t idx, const std::vector<Double_t>& par, PDKSParams &dksp)
|
||||
{
|
||||
Int_t ierr = 0;
|
||||
// make sure idx is within proper bounds
|
||||
@ -1114,80 +1138,141 @@ Int_t PRunListCollection::GetSingleHistoParams(UInt_t idx, const std::vector<Dou
|
||||
return 1;
|
||||
|
||||
// init param
|
||||
InitSingleHistoParams(shp);
|
||||
InitDKSParams(dksp);
|
||||
|
||||
// get flag if scaling of N0 and Nbkg is wished
|
||||
shp.fScaleN0AndBkg = fRunSingleHistoList[idx]->GetScaleN0AndBkg();
|
||||
dksp.fScaleN0AndBkg = fRunSingleHistoList[idx]->GetScaleN0AndBkg();
|
||||
|
||||
// check if norm is a parameter or a function
|
||||
PMsrRunBlock runInfo = fMsrInfo->GetMsrRunList()->at(idx);
|
||||
if (runInfo.GetNormParamNo() < MSR_PARAM_FUN_OFFSET) { // norm is a parameter
|
||||
shp.fN0 = par[runInfo.GetNormParamNo()-1];
|
||||
dksp.fN0 = par[runInfo.GetNormParamNo()-1];
|
||||
} else { // norm is a function
|
||||
// get function number
|
||||
UInt_t funNo = runInfo.GetNormParamNo()-MSR_PARAM_FUN_OFFSET;
|
||||
// evaluate function
|
||||
shp.fN0 = fMsrInfo->EvalFunc(funNo, *runInfo.GetMap(), par);
|
||||
dksp.fN0 = fMsrInfo->EvalFunc(funNo, *runInfo.GetMap(), par);
|
||||
}
|
||||
|
||||
// get tau
|
||||
if (runInfo.GetLifetimeParamNo() != -1)
|
||||
shp.fTau = par[runInfo.GetLifetimeParamNo()-1];
|
||||
dksp.fTau = par[runInfo.GetLifetimeParamNo()-1];
|
||||
else
|
||||
shp.fTau = PMUON_LIFETIME;
|
||||
dksp.fTau = PMUON_LIFETIME;
|
||||
|
||||
// get background
|
||||
if (runInfo.GetBkgFitParamNo() == -1) { // bkg not fitted
|
||||
if (runInfo.GetBkgFix(0) == PMUSR_UNDEFINED) { // no fixed background given (background interval)
|
||||
shp.fNbkg = GetBackground(idx);
|
||||
dksp.fNbkg = GetBackground(idx);
|
||||
} else { // fixed bkg given
|
||||
shp.fNbkg = runInfo.GetBkgFix(0);
|
||||
dksp.fNbkg = runInfo.GetBkgFix(0);
|
||||
}
|
||||
} else { // bkg fitted
|
||||
shp.fNbkg = par[runInfo.GetBkgFitParamNo()-1];
|
||||
dksp.fNbkg = par[runInfo.GetBkgFitParamNo()-1];
|
||||
}
|
||||
|
||||
// get packed time resolution
|
||||
shp.fPackedTimeResolution = fRunSingleHistoList[idx]->GetData()->GetDataTimeStep();
|
||||
dksp.fPackedTimeResolution = fRunSingleHistoList[idx]->GetData()->GetDataTimeStep();
|
||||
|
||||
// get start time
|
||||
// fRunSingleHistoList[idx]->GetData()->GetDataTimeStart() : time of fgb, which is 0-bin of the fit-data-set
|
||||
// fRunSingleHistoList[idx]->GetStartTimeBin() * shp.fPackedTimeResolution : time-offset from fgb-time to fit start time
|
||||
shp.fStartTime = fRunSingleHistoList[idx]->GetData()->GetDataTimeStart() + fRunSingleHistoList[idx]->GetStartTimeBin() * shp.fPackedTimeResolution;
|
||||
// fRunSingleHistoList[idx]->GetStartTimeBin() * dksp.fPackedTimeResolution : time-offset from fgb-time to fit start time
|
||||
dksp.fStartTime = fRunSingleHistoList[idx]->GetData()->GetDataTimeStart() + fRunSingleHistoList[idx]->GetStartTimeBin() * dksp.fPackedTimeResolution;
|
||||
|
||||
// get number of bins fitted
|
||||
shp.fNoOfFitBins = fRunSingleHistoList[idx]->GetNoOfFitBins();
|
||||
dksp.fNoOfFitBins = fRunSingleHistoList[idx]->GetNoOfFitBins();
|
||||
|
||||
// calculate functions
|
||||
Int_t funcNo = 0;
|
||||
for (Int_t i=0; i<fMsrInfo->GetNoOfFuncs(); i++) {
|
||||
funcNo = fMsrInfo->GetFuncNo(i);
|
||||
shp.fFun.push_back(fMsrInfo->EvalFunc(funcNo, *runInfo.GetMap(), par));
|
||||
dksp.fFun.push_back(fMsrInfo->EvalFunc(funcNo, *runInfo.GetMap(), par));
|
||||
}
|
||||
|
||||
// get map vector
|
||||
shp.fMap = *runInfo.GetMap();
|
||||
shp.fMap.erase(shp.fMap.begin()+GetNoOfMaps(), shp.fMap.end());
|
||||
dksp.fMap = *runInfo.GetMap();
|
||||
dksp.fMap.erase(dksp.fMap.begin()+GetNoOfMaps(), dksp.fMap.end());
|
||||
// need to reduce map indexes by 1 since in C/C++ arrays start at 0
|
||||
for (UInt_t i=0; i<shp.fMap.size(); i++)
|
||||
shp.fMap[i] -= 1;
|
||||
for (UInt_t i=0; i<dksp.fMap.size(); i++)
|
||||
dksp.fMap[i] -= 1;
|
||||
|
||||
return ierr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// InitSingleHistoParams (private)
|
||||
// GetAsymmetryParams (public)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* \brief PRunListCollection::InitSingleHistoParams
|
||||
* @brief PRunListCollection::GetAsymmetryParams
|
||||
* @param idx
|
||||
* @param par
|
||||
* @param shp
|
||||
* @return
|
||||
*/
|
||||
Int_t PRunListCollection::GetAsymmetryParams(UInt_t idx, const std::vector<Double_t>& par, PDKSParams &dksp)
|
||||
{
|
||||
Int_t ierr=0, ival=0;
|
||||
// make sure idx is within proper bounds
|
||||
if (idx >= fRunAsymmetryList.size())
|
||||
return 1;
|
||||
|
||||
// init param
|
||||
InitDKSParams(dksp);
|
||||
|
||||
// get alpha
|
||||
PMsrRunBlock runInfo = fMsrInfo->GetMsrRunList()->at(idx);
|
||||
ival = runInfo.GetAlphaParamNo();
|
||||
if (ival > 0)
|
||||
dksp.fAlpha = par[ival-1];
|
||||
|
||||
// get beta
|
||||
ival = runInfo.GetBetaParamNo();
|
||||
if (ival > 0)
|
||||
dksp.fBeta = par[ival-1];
|
||||
|
||||
// get packed time resolution
|
||||
dksp.fPackedTimeResolution = fRunAsymmetryList[idx]->GetData()->GetDataTimeStep();
|
||||
|
||||
// get start time
|
||||
// fRunAsymmetryList[idx]->GetData()->GetDataTimeStart() : time of fgb, which is 0-bin of the fit-data-set
|
||||
// fRunAsymmetryList[idx]->GetStartTimeBin() * dksp.fPackedTimeResolution : time-offset from fgb-time to fit start time
|
||||
dksp.fStartTime = fRunAsymmetryList[idx]->GetData()->GetDataTimeStart() + fRunAsymmetryList[idx]->GetStartTimeBin() * dksp.fPackedTimeResolution;
|
||||
|
||||
// get number of bins fitted
|
||||
dksp.fNoOfFitBins = fRunAsymmetryList[idx]->GetNoOfFitBins();
|
||||
|
||||
// calculate functions
|
||||
Int_t funcNo = 0;
|
||||
for (Int_t i=0; i<fMsrInfo->GetNoOfFuncs(); i++) {
|
||||
funcNo = fMsrInfo->GetFuncNo(i);
|
||||
dksp.fFun.push_back(fMsrInfo->EvalFunc(funcNo, *runInfo.GetMap(), par));
|
||||
}
|
||||
|
||||
// get map vector
|
||||
dksp.fMap = *runInfo.GetMap();
|
||||
dksp.fMap.erase(dksp.fMap.begin()+GetNoOfMaps(), dksp.fMap.end());
|
||||
// need to reduce map indexes by 1 since in C/C++ arrays start at 0
|
||||
for (UInt_t i=0; i<dksp.fMap.size(); i++)
|
||||
dksp.fMap[i] -= 1;
|
||||
|
||||
return ierr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// InitDKSParams (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* \brief PRunListCollection::InitDKSParams
|
||||
* \param param
|
||||
*/
|
||||
void PRunListCollection::InitSingleHistoParams(PSingleHistoParams ¶m)
|
||||
void PRunListCollection::InitDKSParams(PDKSParams ¶m)
|
||||
{
|
||||
param.fScaleN0AndBkg = false;
|
||||
param.fN0 = -1.0;
|
||||
param.fNbkg = -1.0;
|
||||
param.fTau = -1.0;
|
||||
param.fAlpha = 1.0;
|
||||
param.fBeta = 1.0;
|
||||
param.fPackedTimeResolution = -1.0;
|
||||
param.fStartTime = -1.0;
|
||||
param.fNoOfFitBins = -1;
|
||||
|
Reference in New Issue
Block a user