Commit bbb6d584 authored by Jérémie Dudouet's avatar Jérémie Dudouet
Browse files

Hist1DPlayer:

Background modified, a pl1 is used in addition to the step
parent 0b02b060
......@@ -508,24 +508,26 @@ void CXHist1DPlayer::DoFit()
Float_t RightTailValMin = fNE_RT[1]->GetNumber();;
Float_t RightTailValMax = fNE_RT[2]->GetNumber();;
Float_t StepVal = 0.5;
Float_t StepValMin = 0.;
Float_t StepVal = 0.01;
Float_t StepValMin = -1.;
Float_t StepValMax = 1.;
Int_t NPars = 2+6*fFitEnergies.size();
Int_t NPars = 3+6*fFitEnergies.size();
fFitFunction = new TF1("MyFit", this, &CXHist1DPlayer::DoubleTailedStepedGaussian, fFitBackgd[0], fFitBackgd[1], NPars, "CXHist1DPlayer", "DoubleTailedStepedGaussian");
fFitFunction->SetParName(0, "NumberOfPeaks");
fFitFunction->SetParName(1, "UsingBkg");
fFitFunction->SetParName(1, "BkgConst");
fFitFunction->SetParName(2, "BkgSlope");
for(uint i=0 ; i<fFitEnergies.size() ; i++)
{
fFitFunction->SetParName(2+i*6+0, Form("Height_%d",i));
fFitFunction->SetParName(2+i*6+1, Form("Position_%d",i));
fFitFunction->SetParName(2+i*6+2, Form("FWHM_%d",i));
fFitFunction->SetParName(2+i*6+3, Form("LeftTail_%d",i));
fFitFunction->SetParName(2+i*6+4, Form("RightTail_%d",i));
fFitFunction->SetParName(2+i*6+5, Form("AmplitudeStep_%d",i));
fFitFunction->SetParName(3+i*6+0, Form("Height_%d",i));
fFitFunction->SetParName(3+i*6+1, Form("Position_%d",i));
fFitFunction->SetParName(3+i*6+2, Form("FWHM_%d",i));
fFitFunction->SetParName(3+i*6+3, Form("LeftTail_%d",i));
fFitFunction->SetParName(3+i*6+4, Form("RightTail_%d",i));
fFitFunction->SetParName(3+i*6+5, Form("AmplitudeStep_%d",i));
}
fFitFunction->SetNpx(1000);
......@@ -542,38 +544,41 @@ void CXHist1DPlayer::DoFit()
fFitFunction->SetParameter(1, fCurrentHist->GetBinContent(fCurrentHist->FindBin(fFitBackgd[0])));
fFitFunction->SetParLimits(1, fCurrentHist->GetMinimum(),fCurrentHist->GetMaximum());
fFitFunction->SetParameter(2, 0);
fFitFunction->SetParLimits(2, -10, 10);
for(uint i=0 ; i<fFitEnergies.size() ; i++)
{
//Height
fFitFunction->SetParameter(2+i*6+0, fCurrentHist->GetBinContent(fCurrentHist->FindBin(fFitEnergies[i])) - (fCurrentHist->GetBinContent(fCurrentHist->FindBin(fFitBackgd[0]))+fCurrentHist->GetBinContent(fCurrentHist->FindBin(fFitBackgd[1])))*0.5 );
fFitFunction->SetParLimits(2+i*6+0, fCurrentHist->GetBinContent((fCurrentHist->FindBin(fFitEnergies[i]))-(fCurrentHist->GetBinContent(fCurrentHist->FindBin(fFitBackgd[0]))+fCurrentHist->GetBinContent(fCurrentHist->FindBin(fFitBackgd[1])))*0.5)*0.5, fCurrentHist->GetMaximum());
fFitFunction->SetParameter(3+i*6+0, fCurrentHist->GetBinContent(fCurrentHist->FindBin(fFitEnergies[i])) - (fCurrentHist->GetBinContent(fCurrentHist->FindBin(fFitBackgd[0]))+fCurrentHist->GetBinContent(fCurrentHist->FindBin(fFitBackgd[1])))*0.5 );
fFitFunction->SetParLimits(3+i*6+0, fCurrentHist->GetBinContent((fCurrentHist->FindBin(fFitEnergies[i]))-(fCurrentHist->GetBinContent(fCurrentHist->FindBin(fFitBackgd[0]))+fCurrentHist->GetBinContent(fCurrentHist->FindBin(fFitBackgd[1])))*0.5)*0.5, fCurrentHist->GetBinContent(fCurrentHist->GetMaximumBin()));
//Position
fFitFunction->SetParameter(2+i*6+1, fFitEnergies[i]);
fFitFunction->SetParLimits(2+i*6+1, fFitEnergies[i]-DefFWHM, fFitEnergies[i]+DefFWHM);
fFitFunction->SetParameter(3+i*6+1, fFitEnergies[i]);
fFitFunction->SetParLimits(3+i*6+1, fFitEnergies[i]-DefFWHM, fFitEnergies[i]+DefFWHM);
if(fFixMean->GetState() == kButtonDown)
fFitFunction->FixParameter(2+i*6+1,fFitEnergies[i]);
fFitFunction->FixParameter(3+i*6+1,fFitEnergies[i]);
//FWHM
fFitFunction->SetParameter(2+i*6+2, DefFWHM);
fFitFunction->SetParLimits(2+i*6+2, DefFWHM_min, DefFWHM_max);
fFitFunction->SetParameter(3+i*6+2, DefFWHM);
fFitFunction->SetParLimits(3+i*6+2, DefFWHM_min, DefFWHM_max);
if(fFixFWHM->GetState() == kButtonDown)
fFitFunction->FixParameter(2+i*6+2,DefFWHM);
fFitFunction->FixParameter(3+i*6+2,DefFWHM);
//LeftTail
fFitFunction->SetParameter(2+i*6+3, LeftTailVal);
fFitFunction->SetParLimits(2+i*6+3, LeftTailValMin, LeftTailValMax);
fFitFunction->SetParameter(3+i*6+3, LeftTailVal);
fFitFunction->SetParLimits(3+i*6+3, LeftTailValMin, LeftTailValMax);
if(fUseLT->GetState() == kButtonUp)
fFitFunction->FixParameter(2+i*6+3,-5);
fFitFunction->FixParameter(3+i*6+3,-5);
else if(fFixLT->GetState() == kButtonDown)
fFitFunction->FixParameter(2+i*6+3,LeftTailVal);
fFitFunction->FixParameter(3+i*6+3,LeftTailVal);
//RightTail
fFitFunction->SetParameter(2+i*6+4, RightTailVal);
fFitFunction->SetParLimits(2+i*6+4, RightTailValMin, RightTailValMax);
fFitFunction->SetParameter(3+i*6+4, RightTailVal);
fFitFunction->SetParLimits(3+i*6+4, RightTailValMin, RightTailValMax);
if(fUseRT->GetState() == kButtonUp)
fFitFunction->FixParameter(2+i*6+4,5);
fFitFunction->FixParameter(3+i*6+4,5);
else if(fFixRT->GetState() == kButtonDown)
fFitFunction->FixParameter(2+i*6+4,RightTailVal);
fFitFunction->FixParameter(3+i*6+4,RightTailVal);
//AmplitudeStep
fFitFunction->SetParameter(2+i*6+5, StepVal);
fFitFunction->SetParLimits(2+i*6+5, StepValMin, StepValMax);
fFitFunction->SetParameter(3+i*6+5, StepVal);
fFitFunction->SetParLimits(3+i*6+5, StepValMin, StepValMax);
}
fCurrentHist->GetXaxis()->SetRangeUser(x,y);
......@@ -594,7 +599,7 @@ void CXHist1DPlayer::DoFit()
Float_t Ampli = fCurrentHist->GetBinContent(fCurrentHist->FindBin(fFitEnergies[i]))-
fBackFunction->Eval(fFitEnergies[i]);
fFitFunction->FixParameter(2+i*6+0,Ampli);
fFitFunction->FixParameter(3+i*6+0,Ampli);
}
r = fCurrentHist->Fit(fFitFunction,"R0S");
......@@ -661,19 +666,19 @@ void CXHist1DPlayer::DoFit()
Float_t Area = (peak->Integral(fFitBackgd[0],fFitBackgd[1],1e-6)-fBackFunction->Integral(fFitBackgd[0],fFitBackgd[1],1e-6))/fCurrentHist->GetBinWidth(1);
Float_t AreaErr = 2*sqrt(Area);
Float_t Mean = peak->GetParameter(2+i*6+1);
Float_t MeanErr = peak->GetParError(2+i*6+1);
Float_t FWHM = peak->GetParameter(2+i*6+2);
Float_t FWHMErr = peak->GetParError(2+i*6+2);
Float_t LeftT = TMath::Abs(peak->GetParameter(2+i*6+3));
Float_t LeftTErr = peak->GetParError(2+i*6+3);
Float_t Right = peak->GetParameter(2+i*6+4);
Float_t RightErr = peak->GetParError(2+i*6+4);
Float_t Mean = peak->GetParameter(3+i*6+1);
Float_t MeanErr = peak->GetParError(3+i*6+1);
Float_t FWHM = peak->GetParameter(3+i*6+2);
Float_t FWHMErr = peak->GetParError(3+i*6+2);
Float_t LeftT = TMath::Abs(peak->GetParameter(3+i*6+3));
Float_t LeftTErr = peak->GetParError(3+i*6+3);
Float_t Right = peak->GetParameter(3+i*6+4);
Float_t RightErr = peak->GetParError(3+i*6+4);
peak->SetParameter(1,0);//without backgroud
Float_t Max = peak->GetParameter(2+i*6+0);
Float_t MaxErr = peak->GetParError(2+i*6+0);
Float_t Max = peak->GetParameter(3+i*6+0);
Float_t MaxErr = peak->GetParError(3+i*6+0);
Float_t FWHM_L = peak->GetX(Max/2,fFitBackgd[0],Mean,1e-6);
Float_t FWHM_L_err = peak->GetX((Max-MaxErr)/2,fFitBackgd[0],Mean,1e-6);
......@@ -816,18 +821,19 @@ double CXHist1DPlayer::DoubleTailedStepedGaussian(double*xx,double*pp)
Int_t Npar = 6;
Float_t Flat_BackGround = pp[1];
Float_t Back_const = pp[1];
Float_t Back_slope = pp[2];
f_tot += Flat_BackGround;
f_tot += Back_const + x*Back_slope;
for(int i=0 ; i<NSubPeaks ; i++)
{
Float_t Ampli = pp[2+i*Npar+0];
Float_t Mean = pp[2+i*Npar+1];
Float_t Sigma = pp[2+i*Npar+2]*1./sqrt(8.*log(2.));
Float_t Lambda = pp[2+i*Npar+3];
Float_t Rho = pp[2+i*Npar+4];
Float_t S = pp[2+i*Npar+5];
Float_t Ampli = pp[3+i*Npar+0];
Float_t Mean = pp[3+i*Npar+1];
Float_t Sigma = pp[3+i*Npar+2]*1./sqrt(8.*log(2.));
Float_t Lambda = pp[3+i*Npar+3];
Float_t Rho = pp[3+i*Npar+4];
Float_t S = pp[3+i*Npar+5];
Float_t U = (x-Mean)/Sigma;
Float_t f_g = Ampli*TMath::Exp(-U*U*0.5);
......@@ -853,18 +859,19 @@ double CXHist1DPlayer::StepedBackground(double*xx,double*pp)
int NSubPeaks = (int)pp[0]; //Number of subpeaks in the peak range
Float_t Flat_BackGround = pp[1];
Float_t Back_const = pp[1];
Float_t Back_slope = pp[2];
Int_t Npar = 6;
f_tot += Flat_BackGround;
f_tot += Back_const + x*Back_slope;
for(int i=0 ; i<NSubPeaks ; i++)
{
Float_t Ampli = pp[2+i*Npar+0];
Float_t Mean = pp[2+i*Npar+1];
Float_t Sigma = pp[2+i*Npar+2]*1./sqrt(8.*log(2.));
Float_t S = pp[2+i*Npar+5];
Float_t Ampli = pp[3+i*Npar+0];
Float_t Mean = pp[3+i*Npar+1];
Float_t Sigma = pp[3+i*Npar+2]*1./sqrt(8.*log(2.));
Float_t S = pp[3+i*Npar+5];
f_tot += Ampli*S*1./((1+TMath::Exp((x-Mean)/Sigma))*(1+TMath::Exp((x-Mean)/Sigma)));
}
......@@ -887,16 +894,16 @@ double CXHist1DPlayer::PeakFunction(double*xx,double*pp)
if(pp[1]==0)
WithBackground = false;
Float_t Flat_BackGround = fBackFunction->Eval(x);
Float_t BackGround = fBackFunction->Eval(x);
if(WithBackground)
f_tot += Flat_BackGround;
f_tot += BackGround;
Float_t Ampli = pp[2+NSubPeaks*Npar+0];
Float_t Mean = pp[2+NSubPeaks*Npar+1];
Float_t Sigma = pp[2+NSubPeaks*Npar+2]*1./sqrt(8.*log(2.));
Float_t Lambda = pp[2+NSubPeaks*Npar+3];
Float_t Rho = pp[2+NSubPeaks*Npar+4];
Float_t Ampli = pp[3+NSubPeaks*Npar+0];
Float_t Mean = pp[3+NSubPeaks*Npar+1];
Float_t Sigma = pp[3+NSubPeaks*Npar+2]*1./sqrt(8.*log(2.));
Float_t Lambda = pp[3+NSubPeaks*Npar+3];
Float_t Rho = pp[3+NSubPeaks*Npar+4];
Float_t S = 0;
Float_t U = (x-Mean)/Sigma;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment