From 4dc36ffbae466f234e41978959a765472efa94bb Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Mon, 25 Apr 2016 12:15:36 +0200 Subject: [PATCH] changed name of a function for a more precise self description. Added function to collect to mu minus parameters. --- src/classes/PFitterFcn.cpp | 2 +- src/classes/PRunListCollection.cpp | 82 +++++++++++++++++++++++------- src/include/PRunListCollection.h | 3 +- 3 files changed, 68 insertions(+), 19 deletions(-) diff --git a/src/classes/PFitterFcn.cpp b/src/classes/PFitterFcn.cpp index be870a59..1fa274a2 100644 --- a/src/classes/PFitterFcn.cpp +++ b/src/classes/PFitterFcn.cpp @@ -114,7 +114,7 @@ void PFitterFcn::CalcExpectedChiSquare(const std::vector &par, Double_ // single histo for (UInt_t i=0; iGetNoOfSingleHisto(); 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); totalExpectedChisq += value; } diff --git a/src/classes/PRunListCollection.cpp b/src/classes/PRunListCollection.cpp index f21fa70f..ca743843 100644 --- a/src/classes/PRunListCollection.cpp +++ b/src/classes/PRunListCollection.cpp @@ -334,23 +334,24 @@ Double_t PRunListCollection::GetNonMusrChisq(const std::vector& par) c } //-------------------------------------------------------------------------- -// GetSingleHistoChisqExpected (public) +// GetSingleRunChisqExpected (public) //-------------------------------------------------------------------------- /** - *

Calculates expected chi-square of the single histogram with run block index idx of a msr-file. + *

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. * * return: - * - expected chi-square of for a single histogram + * - expected chi-square of for a single run block * * \param par fit parameter vector * \param idx run block index */ -Double_t PRunListCollection::GetSingleHistoChisqExpected(const std::vector& par, const UInt_t idx) const +Double_t PRunListCollection::GetSingleRunChisqExpected(const std::vector& par, const UInt_t idx) const { Double_t expectedChisq = 0.0; 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; } @@ -371,21 +372,9 @@ Double_t PRunListCollection::GetSingleHistoChisqExpected(const std::vectorCalcChiSquareExpected(par); 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: expectedChisq = fRunMuMinusList[subIdx]->CalcChiSquareExpected(par); break; - case PRUN_NON_MUSR: - expectedChisq = fRunNonMusrList[subIdx]->CalcChiSquareExpected(par); - break; default: break; } @@ -1084,6 +1073,10 @@ Int_t PRunListCollection::GetStartTimeBin(Int_t fitType, UInt_t idx) if (idx < fRunAsymmetryList.size()) result = fRunAsymmetryList[idx]->GetStartTimeBin(); break; + case MSR_FITTYPE_MU_MINUS: + if (idx < fRunMuMinusList.size()) + result = fRunMuMinusList[idx]->GetStartTimeBin(); + break; default: break; } @@ -1113,6 +1106,10 @@ Int_t PRunListCollection::GetEndTimeBin(Int_t fitType, UInt_t idx) if (idx < fRunAsymmetryList.size()) result = fRunAsymmetryList[idx]->GetEndTimeBin(); break; + case MSR_FITTYPE_MU_MINUS: + if (idx < fRunMuMinusList.size()) + result = fRunMuMinusList[idx]->GetEndTimeBin(); + break; default: break; } @@ -1258,6 +1255,57 @@ Int_t PRunListCollection::GetAsymmetryParams(UInt_t idx, const std::vector& 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; iGetNoOfFuncs(); 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& par) const; virtual Double_t GetNonMusrChisq(const std::vector& par) const; - virtual Double_t GetSingleHistoChisqExpected(const std::vector& par, const UInt_t idx) const; + virtual Double_t GetSingleRunChisqExpected(const std::vector& par, const UInt_t idx) const; virtual Double_t GetSingleRunChisq(const std::vector& par, const UInt_t idx) const; virtual Double_t GetSingleHistoMaximumLikelihood(const std::vector& par) const; @@ -126,6 +126,7 @@ class PRunListCollection virtual Int_t GetEndTimeBin(Int_t fitType, UInt_t idx); virtual Int_t GetSingleHistoParams(UInt_t idx, const std::vector& par, PDKSParams &dksp); virtual Int_t GetAsymmetryParams(UInt_t idx, const std::vector& par, PDKSParams &dksp); + virtual Int_t GetMuMinusParams(UInt_t idx, const std::vector& par, PDKSParams &dksp); private: PMsrHandler *fMsrInfo; ///< pointer to the msr-file handler