merge dks to master
This commit is contained in:
@@ -1142,6 +1142,13 @@ void PMusrCanvas::HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected)
|
||||
cout << "**INFO** averaging of a single data set doesn't make any sense, will ignore 'a' ..." << endl;
|
||||
return;
|
||||
}
|
||||
} else if (x == 'c') {
|
||||
Int_t state = fDataTheoryPad->GetCrosshair();
|
||||
if (state == 0)
|
||||
fDataTheoryPad->SetCrosshair(2);
|
||||
else
|
||||
fDataTheoryPad->SetCrosshair(0);
|
||||
fMainCanvas->Update();
|
||||
} else {
|
||||
fMainCanvas->Update();
|
||||
}
|
||||
|
||||
@@ -187,15 +187,7 @@ Double_t PRunAsymmetryRRF::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
|
||||
@@ -204,12 +196,12 @@ Double_t PRunAsymmetryRRF::CalcChiSquare(const std::vector<Double_t>& par)
|
||||
asymFcnValue = 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,asymFcnValue,a,b,f) 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();
|
||||
switch (fAlphaBetaTag) {
|
||||
case 1: // alpha == 1, beta == 1
|
||||
@@ -387,15 +379,15 @@ void PRunAsymmetryRRF::SetFitRangeBin(const TString fitRange)
|
||||
void PRunAsymmetryRRF::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;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,8 @@ using namespace std;
|
||||
PRunSingleHistoRRF::PRunSingleHistoRRF() : PRunBase()
|
||||
{
|
||||
fNoOfFitBins = 0;
|
||||
fBackground = 0;
|
||||
fBackground = 0.0;
|
||||
fBkgErr = 1.0;
|
||||
fRRFPacking = -1;
|
||||
|
||||
// the 2 following variables are need in case fit range is given in bins, and since
|
||||
@@ -159,15 +160,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 +169,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 +208,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 +217,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 +397,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;
|
||||
}
|
||||
@@ -608,6 +593,9 @@ Bool_t PRunSingleHistoRRF::PrepareFitData(PRawRunData* runData, const UInt_t his
|
||||
if (!EstimateBkg(histoNo))
|
||||
return false;
|
||||
}
|
||||
// subtract background from fForward
|
||||
for (UInt_t i=0; i<fForward.size(); i++)
|
||||
fForward[i] -= fBackground;
|
||||
} else { // fixed background given
|
||||
for (UInt_t i=0; i<fForward.size(); i++) {
|
||||
fForward[i] -= fRunInfo->GetBkgFix(0);
|
||||
@@ -628,7 +616,7 @@ Bool_t PRunSingleHistoRRF::PrepareFitData(PRawRunData* runData, const UInt_t his
|
||||
exp_t_tau = exp(time_tau);
|
||||
fForward[i] *= exp_t_tau;
|
||||
fM.push_back(fForward[i]); // i.e. M(t) = [N(t)-Nbkg] exp(+t/tau); needed to estimate N0 later on
|
||||
fMerr.push_back(exp_t_tau*sqrt(rawNt[i]-fBackground));
|
||||
fMerr.push_back(exp_t_tau*sqrt(rawNt[i]+fBkgErr*fBkgErr));
|
||||
}
|
||||
|
||||
// calculate weights
|
||||
@@ -636,7 +624,7 @@ Bool_t PRunSingleHistoRRF::PrepareFitData(PRawRunData* runData, const UInt_t his
|
||||
if (fMerr[i] > 0.0)
|
||||
fW.push_back(1.0/(fMerr[i]*fMerr[i]));
|
||||
else
|
||||
fW.push_back(0.0);
|
||||
fW.push_back(1.0);
|
||||
}
|
||||
// now fForward = exp(+t/tau) [N(t)-Nbkg] = M(t)
|
||||
|
||||
@@ -1075,6 +1063,9 @@ Double_t PRunSingleHistoRRF::GetMainFrequency(PDoubleVector &data)
|
||||
if (power->GetBinContent(i)>power->GetBinContent(i+1))
|
||||
continue;
|
||||
}
|
||||
// ignore everything below 10 MHz
|
||||
if (power->GetBinCenter(i) < 10.0)
|
||||
continue;
|
||||
// check for maximum
|
||||
if (power->GetBinContent(i) > maxFreqVal) {
|
||||
maxFreqVal = power->GetBinContent(i);
|
||||
@@ -1105,15 +1096,17 @@ Double_t PRunSingleHistoRRF::EstimateN0(Double_t &errN0, Double_t freqMax)
|
||||
{
|
||||
// endBin is estimated such that the number of full cycles (according to the maximum frequency of the data)
|
||||
// is approximately the time fN0EstimateEndTime.
|
||||
Int_t endBin = (Int_t)round(fN0EstimateEndTime / fTimeResolution * ceil(freqMax)/freqMax);
|
||||
Int_t endBin = (Int_t)round(ceil(fN0EstimateEndTime*freqMax/TMath::TwoPi()) * (TMath::TwoPi()/freqMax) / fTimeResolution);
|
||||
|
||||
Double_t n0 = 0.0;
|
||||
Double_t wN = 0.0;
|
||||
for (Int_t i=0; i<endBin; i++) {
|
||||
n0 += fW[i]*fM[i];
|
||||
// n0 += fW[i]*fM[i];
|
||||
n0 += fM[i];
|
||||
wN += fW[i];
|
||||
}
|
||||
n0 /= wN;
|
||||
// n0 /= wN;
|
||||
n0 /= endBin;
|
||||
|
||||
errN0 = 0.0;
|
||||
for (Int_t i=0; i<endBin; i++) {
|
||||
@@ -1201,7 +1194,12 @@ Bool_t PRunSingleHistoRRF::EstimateBkg(UInt_t histoNo)
|
||||
|
||||
fBackground = bkg; // keep background (per bin)
|
||||
|
||||
cout << endl << "info> fBackground=" << fBackground << endl;
|
||||
bkg = 0.0;
|
||||
for (UInt_t i=start; i<end; i++)
|
||||
bkg += pow(fForward[i]-fBackground, 2.0);
|
||||
fBkgErr = sqrt(bkg/(static_cast<Double_t>(end - start)));
|
||||
|
||||
cout << endl << "info> fBackground=" << fBackground << "(" << fBkgErr << ")" << endl;
|
||||
|
||||
fRunInfo->SetBkgEstimated(fBackground, 0);
|
||||
|
||||
|
||||
@@ -97,7 +97,6 @@ PStartupHandler::PStartupHandler()
|
||||
Char_t *home=0;
|
||||
Char_t musrpath[128];
|
||||
Char_t startup_path_name[128];
|
||||
Bool_t found = false;
|
||||
|
||||
strncpy(musrpath, "", sizeof(musrpath));
|
||||
|
||||
@@ -106,32 +105,39 @@ PStartupHandler::PStartupHandler()
|
||||
if (StartupFileExists(startup_path_name)) {
|
||||
fStartupFileFound = true;
|
||||
fStartupFilePath = TString(startup_path_name);
|
||||
} else { // startup file is not found in the current directory
|
||||
}
|
||||
if (!fStartupFileFound) { // startup file not found in the current directory
|
||||
// check if the startup file is found under $HOME/.musrfit
|
||||
home = getenv("HOME");
|
||||
if (home != 0) {
|
||||
sprintf(musrpath, "%s/.musrfit", home);
|
||||
found = true;
|
||||
}
|
||||
pmusrpath = getenv("MUSRFITPATH");
|
||||
if (!found) {
|
||||
// check if the MUSRFITPATH system variable is set
|
||||
if (pmusrpath != 0) {
|
||||
if (strcmp(pmusrpath, "")) { // MUSRFITPATH variable set but empty
|
||||
found = true;
|
||||
}
|
||||
sprintf(startup_path_name, "%s/.musrfit/musrfit_startup.xml", home);
|
||||
if (StartupFileExists(startup_path_name)) {
|
||||
fStartupFilePath = TString(startup_path_name);
|
||||
fStartupFileFound = true;
|
||||
}
|
||||
}
|
||||
if (!found) { // MUSRFITPATH not set or empty, will try default one
|
||||
home = getenv("ROOTSYS");
|
||||
}
|
||||
if (!fStartupFileFound) { // startup file not found in $HOME/.musrfit
|
||||
// check if the MUSRFITPATH system variable is set
|
||||
pmusrpath = getenv("MUSRFITPATH");
|
||||
if (pmusrpath != 0) {
|
||||
sprintf(startup_path_name, "%s/musrfit_startup.xml", pmusrpath);
|
||||
if (StartupFileExists(startup_path_name)) {
|
||||
fStartupFilePath = TString(startup_path_name);
|
||||
fStartupFileFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!fStartupFileFound) { // MUSRFITPATH not set or empty, will try $ROOTSYS/bin
|
||||
home = getenv("ROOTSYS");
|
||||
if (home != 0) {
|
||||
sprintf(musrpath, "%s/bin", home);
|
||||
cerr << endl << "**WARNING** MUSRFITPATH environment variable not set will try " << musrpath << endl;
|
||||
}
|
||||
|
||||
sprintf(startup_path_name, "%s/musrfit_startup.xml", musrpath);
|
||||
fStartupFilePath = TString(startup_path_name);
|
||||
if (StartupFileExists(startup_path_name)) {
|
||||
fStartupFileFound = true;
|
||||
sprintf(startup_path_name, "%s/musrfit_startup.xml", musrpath);
|
||||
if (StartupFileExists(startup_path_name)) {
|
||||
fStartupFilePath = TString(startup_path_name);
|
||||
fStartupFileFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user