changed name of a function for a more precise self description. Added function to collect to mu minus parameters.

This commit is contained in:
2016-04-25 12:15:36 +02:00
parent be9498f37d
commit 4dc36ffbae
3 changed files with 68 additions and 19 deletions

View File

@ -114,7 +114,7 @@ void PFitterFcn::CalcExpectedChiSquare(const std::vector<Double_t> &par, Double_
// single histo // single histo
for (UInt_t i=0; i<fRunListCollection->GetNoOfSingleHisto(); i++) { for (UInt_t i=0; i<fRunListCollection->GetNoOfSingleHisto(); i++) {
value = fRunListCollection->GetSingleHistoChisqExpected(par, i); // calculate the expected chisq for single histo run block 'i' value = fRunListCollection->GetSingleRunChisqExpected(par, i); // calculate the expected chisq for single histo run block 'i'
expectedChisqPerRun.push_back(value); expectedChisqPerRun.push_back(value);
totalExpectedChisq += value; totalExpectedChisq += value;
} }

View File

@ -334,23 +334,24 @@ Double_t PRunListCollection::GetNonMusrChisq(const std::vector<Double_t>& par) c
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// GetSingleHistoChisqExpected (public) // GetSingleRunChisqExpected (public)
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/** /**
* <p>Calculates expected chi-square of the single histogram with run block index idx of a msr-file. * <p>Calculates expected chi-square of the run block index idx of a msr-file.
* Currently this is only possible for Single Histo, and Mu Minus fits.
* *
* <b>return:</b> * <b>return:</b>
* - expected chi-square of for a single histogram * - expected chi-square of for a single run block
* *
* \param par fit parameter vector * \param par fit parameter vector
* \param idx run block index * \param idx run block index
*/ */
Double_t PRunListCollection::GetSingleHistoChisqExpected(const std::vector<Double_t>& par, const UInt_t idx) const Double_t PRunListCollection::GetSingleRunChisqExpected(const std::vector<Double_t>& par, const UInt_t idx) const
{ {
Double_t expectedChisq = 0.0; Double_t expectedChisq = 0.0;
if (idx > fMsrInfo->GetMsrRunList()->size()) { if (idx > fMsrInfo->GetMsrRunList()->size()) {
cerr << ">> PRunListCollection::GetSingleHistoChisqExpected() **ERROR** idx=" << idx << " is out of range [0.." << fMsrInfo->GetMsrRunList()->size() << "[" << endl << endl; cerr << ">> PRunListCollection::GetSingleRunChisqExpected() **ERROR** idx=" << idx << " is out of range [0.." << fMsrInfo->GetMsrRunList()->size() << "[" << endl << endl;
return expectedChisq; return expectedChisq;
} }
@ -371,21 +372,9 @@ Double_t PRunListCollection::GetSingleHistoChisqExpected(const std::vector<Doubl
case PRUN_SINGLE_HISTO: case PRUN_SINGLE_HISTO:
expectedChisq = fRunSingleHistoList[subIdx]->CalcChiSquareExpected(par); expectedChisq = fRunSingleHistoList[subIdx]->CalcChiSquareExpected(par);
break; break;
case PRUN_SINGLE_HISTO_RRF:
expectedChisq = fRunSingleHistoRRFList[subIdx]->CalcChiSquareExpected(par);
break;
case PRUN_ASYMMETRY:
expectedChisq = fRunAsymmetryList[subIdx]->CalcChiSquareExpected(par);
break;
case PRUN_ASYMMETRY_RRF:
expectedChisq = fRunAsymmetryRRFList[subIdx]->CalcChiSquareExpected(par);
break;
case PRUN_MU_MINUS: case PRUN_MU_MINUS:
expectedChisq = fRunMuMinusList[subIdx]->CalcChiSquareExpected(par); expectedChisq = fRunMuMinusList[subIdx]->CalcChiSquareExpected(par);
break; break;
case PRUN_NON_MUSR:
expectedChisq = fRunNonMusrList[subIdx]->CalcChiSquareExpected(par);
break;
default: default:
break; break;
} }
@ -1084,6 +1073,10 @@ Int_t PRunListCollection::GetStartTimeBin(Int_t fitType, UInt_t idx)
if (idx < fRunAsymmetryList.size()) if (idx < fRunAsymmetryList.size())
result = fRunAsymmetryList[idx]->GetStartTimeBin(); result = fRunAsymmetryList[idx]->GetStartTimeBin();
break; break;
case MSR_FITTYPE_MU_MINUS:
if (idx < fRunMuMinusList.size())
result = fRunMuMinusList[idx]->GetStartTimeBin();
break;
default: default:
break; break;
} }
@ -1113,6 +1106,10 @@ Int_t PRunListCollection::GetEndTimeBin(Int_t fitType, UInt_t idx)
if (idx < fRunAsymmetryList.size()) if (idx < fRunAsymmetryList.size())
result = fRunAsymmetryList[idx]->GetEndTimeBin(); result = fRunAsymmetryList[idx]->GetEndTimeBin();
break; break;
case MSR_FITTYPE_MU_MINUS:
if (idx < fRunMuMinusList.size())
result = fRunMuMinusList[idx]->GetEndTimeBin();
break;
default: default:
break; break;
} }
@ -1258,6 +1255,57 @@ Int_t PRunListCollection::GetAsymmetryParams(UInt_t idx, const std::vector<Doubl
return ierr; return ierr;
} }
//--------------------------------------------------------------------------
// GetMuMinusParams (public)
//--------------------------------------------------------------------------
/**
* @brief PRunListCollection::GetMuMinusParams
* @param idx
* @param par
* @param shp
* @return
*/
Int_t PRunListCollection::GetMuMinusParams(UInt_t idx, const std::vector<Double_t>& par, PDKSParams &dksp)
{
Int_t ierr = 0;
// make sure idx is within proper bounds
if (idx >= fRunMuMinusList.size())
return 1;
// get run block
PMsrRunBlock runInfo = fMsrInfo->GetMsrRunList()->at(idx);
// init param
InitDKSParams(dksp);
// get packed time resolution
dksp.fPackedTimeResolution = fRunMuMinusList[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() * dksp.fPackedTimeResolution : time-offset from fgb-time to fit start time
dksp.fStartTime = fRunMuMinusList[idx]->GetData()->GetDataTimeStart() + fRunMuMinusList[idx]->GetStartTimeBin() * dksp.fPackedTimeResolution;
// get number of bins fitted
dksp.fNoOfFitBins = fRunMuMinusList[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) // InitDKSParams (private)
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------

View File

@ -85,7 +85,7 @@ class PRunListCollection
virtual Double_t GetMuMinusChisq(const std::vector<Double_t>& par) const; virtual Double_t GetMuMinusChisq(const std::vector<Double_t>& par) const;
virtual Double_t GetNonMusrChisq(const std::vector<Double_t>& par) const; virtual Double_t GetNonMusrChisq(const std::vector<Double_t>& par) const;
virtual Double_t GetSingleHistoChisqExpected(const std::vector<Double_t>& par, const UInt_t idx) const; virtual Double_t GetSingleRunChisqExpected(const std::vector<Double_t>& par, const UInt_t idx) const;
virtual Double_t GetSingleRunChisq(const std::vector<Double_t>& par, const UInt_t idx) const; virtual Double_t GetSingleRunChisq(const std::vector<Double_t>& par, const UInt_t idx) const;
virtual Double_t GetSingleHistoMaximumLikelihood(const std::vector<Double_t>& par) const; virtual Double_t GetSingleHistoMaximumLikelihood(const std::vector<Double_t>& par) const;
@ -126,6 +126,7 @@ class PRunListCollection
virtual Int_t GetEndTimeBin(Int_t fitType, UInt_t idx); virtual Int_t GetEndTimeBin(Int_t fitType, UInt_t idx);
virtual Int_t GetSingleHistoParams(UInt_t idx, const std::vector<Double_t>& par, PDKSParams &dksp); virtual Int_t GetSingleHistoParams(UInt_t idx, const std::vector<Double_t>& par, PDKSParams &dksp);
virtual Int_t GetAsymmetryParams(UInt_t idx, const std::vector<Double_t>& par, PDKSParams &dksp); virtual Int_t GetAsymmetryParams(UInt_t idx, const std::vector<Double_t>& par, PDKSParams &dksp);
virtual Int_t GetMuMinusParams(UInt_t idx, const std::vector<Double_t>& par, PDKSParams &dksp);
private: private:
PMsrHandler *fMsrInfo; ///< pointer to the msr-file handler PMsrHandler *fMsrInfo; ///< pointer to the msr-file handler