made start-/endTimeBin class variables.
This commit is contained in:
@ -159,15 +159,7 @@ Double_t PRunSingleHistoRRF::CalcChiSquare(const std::vector<Double_t>& par)
|
||||
|
||||
// calculate chi square
|
||||
Double_t time(1.0);
|
||||
Int_t i, N(static_cast<Int_t>(fData.GetValue()->size()));
|
||||
|
||||
// In order not to have an IF in the next loop, determine the start and end bins for the fit range now
|
||||
Int_t startTimeBin = static_cast<Int_t>(ceil((fFitStartTime - fData.GetDataTimeStart())/fData.GetDataTimeStep()));
|
||||
if (startTimeBin < 0)
|
||||
startTimeBin = 0;
|
||||
Int_t endTimeBin = static_cast<Int_t>(floor((fFitEndTime - fData.GetDataTimeStart())/fData.GetDataTimeStep())) + 1;
|
||||
if (endTimeBin > N)
|
||||
endTimeBin = N;
|
||||
Int_t i;
|
||||
|
||||
// Calculate the theory function once to ensure one function evaluation for the current set of parameters.
|
||||
// This is needed for the LF and user functions where some non-thread-save calculations only need to be calculated once
|
||||
@ -176,12 +168,12 @@ Double_t PRunSingleHistoRRF::CalcChiSquare(const std::vector<Double_t>& par)
|
||||
time = fTheory->Func(time, par, fFuncValues);
|
||||
|
||||
#ifdef HAVE_GOMP
|
||||
Int_t chunk = (endTimeBin - startTimeBin)/omp_get_num_procs();
|
||||
Int_t chunk = (fEndTimeBin - fStartTimeBin)/omp_get_num_procs();
|
||||
if (chunk < 10)
|
||||
chunk = 10;
|
||||
#pragma omp parallel for default(shared) private(i,time,diff) schedule(dynamic,chunk) reduction(+:chisq)
|
||||
#endif
|
||||
for (i=startTimeBin; i<endTimeBin; ++i) {
|
||||
for (i=fStartTimeBin; i<fEndTimeBin; ++i) {
|
||||
time = fData.GetDataTimeStart() + (Double_t)i*fData.GetDataTimeStep();
|
||||
diff = fData.GetValue()->at(i) - fTheory->Func(time, par, fFuncValues);
|
||||
chisq += diff*diff / (fData.GetError()->at(i)*fData.GetError()->at(i));
|
||||
@ -215,15 +207,7 @@ Double_t PRunSingleHistoRRF::CalcChiSquareExpected(const std::vector<Double_t>&
|
||||
|
||||
// calculate chi square
|
||||
Double_t time(1.0);
|
||||
Int_t i, N(static_cast<Int_t>(fData.GetValue()->size()));
|
||||
|
||||
// In order not to have an IF in the next loop, determine the start and end bins for the fit range now
|
||||
Int_t startTimeBin = static_cast<Int_t>(ceil((fFitStartTime - fData.GetDataTimeStart())/fData.GetDataTimeStep()));
|
||||
if (startTimeBin < 0)
|
||||
startTimeBin = 0;
|
||||
Int_t endTimeBin = static_cast<Int_t>(floor((fFitEndTime - fData.GetDataTimeStart())/fData.GetDataTimeStep())) + 1;
|
||||
if (endTimeBin > N)
|
||||
endTimeBin = N;
|
||||
Int_t i;
|
||||
|
||||
// Calculate the theory function once to ensure one function evaluation for the current set of parameters.
|
||||
// This is needed for the LF and user functions where some non-thread-save calculations only need to be calculated once
|
||||
@ -232,12 +216,12 @@ Double_t PRunSingleHistoRRF::CalcChiSquareExpected(const std::vector<Double_t>&
|
||||
time = fTheory->Func(time, par, fFuncValues);
|
||||
|
||||
#ifdef HAVE_GOMP
|
||||
Int_t chunk = (endTimeBin - startTimeBin)/omp_get_num_procs();
|
||||
Int_t chunk = (fEndTimeBin - fStartTimeBin)/omp_get_num_procs();
|
||||
if (chunk < 10)
|
||||
chunk = 10;
|
||||
#pragma omp parallel for default(shared) private(i,time,diff) schedule(dynamic,chunk) reduction(+:chisq)
|
||||
#endif
|
||||
for (i=startTimeBin; i < endTimeBin; ++i) {
|
||||
for (i=fStartTimeBin; i < fEndTimeBin; ++i) {
|
||||
time = fData.GetDataTimeStart() + (Double_t)i*fData.GetDataTimeStep();
|
||||
theo = fTheory->Func(time, par, fFuncValues);
|
||||
diff = fData.GetValue()->at(i) - theo;
|
||||
@ -412,15 +396,15 @@ void PRunSingleHistoRRF::SetFitRangeBin(const TString fitRange)
|
||||
void PRunSingleHistoRRF::CalcNoOfFitBins()
|
||||
{
|
||||
// In order not having to loop over all bins and to stay consistent with the chisq method, calculate the start and end bins explicitly
|
||||
Int_t startTimeBin = static_cast<Int_t>(ceil((fFitStartTime - fData.GetDataTimeStart())/fData.GetDataTimeStep()));
|
||||
if (startTimeBin < 0)
|
||||
startTimeBin = 0;
|
||||
Int_t endTimeBin = static_cast<Int_t>(floor((fFitEndTime - fData.GetDataTimeStart())/fData.GetDataTimeStep())) + 1;
|
||||
if (endTimeBin > static_cast<Int_t>(fData.GetValue()->size()))
|
||||
endTimeBin = fData.GetValue()->size();
|
||||
fStartTimeBin = static_cast<Int_t>(ceil((fFitStartTime - fData.GetDataTimeStart())/fData.GetDataTimeStep()));
|
||||
if (fStartTimeBin < 0)
|
||||
fStartTimeBin = 0;
|
||||
fEndTimeBin = static_cast<Int_t>(floor((fFitEndTime - fData.GetDataTimeStart())/fData.GetDataTimeStep())) + 1;
|
||||
if (fEndTimeBin > static_cast<Int_t>(fData.GetValue()->size()))
|
||||
fEndTimeBin = fData.GetValue()->size();
|
||||
|
||||
if (endTimeBin > startTimeBin)
|
||||
fNoOfFitBins = endTimeBin - startTimeBin;
|
||||
if (fEndTimeBin > fStartTimeBin)
|
||||
fNoOfFitBins = fEndTimeBin - fStartTimeBin;
|
||||
else
|
||||
fNoOfFitBins = 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user