55 mpc = par[1] - mpshift * par[0];
58 xlow = x[0] - sc * par[3];
59 xupp = x[0] + sc * par[3];
61 step = (xupp-xlow) / np;
64 for(i=1.0; i<=np/2; i++) {
65 xx = xlow + (i-.5) * step;
69 xx = xupp - (i-.5) * step;
74 return (par[2] * step * sum * invsq2pi / par[3]);
101 sprintf(FunName,
"Fitfcn_%s",his->
GetName());
103 TF1 *ffitold = (
TF1*)
gROOT->GetListOfFunctions()->FindObject(FunName);
104 if (ffitold)
delete ffitold;
110 for (i=0; i<4; i++) {
114 his->
Fit(FunName,
"RB0");
117 for (i=0; i<4; i++) {
139 Int_t MAXCALLS = 10000;
144 p = params[1] - 0.1 * params[0];
145 step = 0.05 * params[0];
150 while ( (l != lold) && (i < MAXCALLS) ) {
173 p = maxx + params[0];
180 while ( (l != lold) && (i < MAXCALLS) ) {
201 p = maxx - 0.5 * params[0];
207 while ( (l != lold) && (i < MAXCALLS) ) {
232 Int_t data[100] = {0,0,0,0,0,0,2,6,11,18,18,55,90,141,255,323,454,563,681,
233 737,821,796,832,720,637,558,519,460,357,291,279,241,212,
234 153,164,139,106,95,91,76,80,80,59,58,51,30,49,23,35,28,23,
235 22,27,27,24,20,16,17,14,20,12,12,13,10,17,7,6,12,6,12,4,
236 9,9,10,3,4,5,2,4,1,5,5,1,7,1,6,3,3,3,4,5,4,4,2,2,7,2,4};
237 TH1F *hSNR =
new TH1F(
"snr",
"Signal-to-noise",400,0,400);
239 for (
Int_t i=0; i<100; i++) hSNR->
Fill(i,data[i]);
246 Double_t sv[4], pllo[4], plhi[4], fp[4], fpe[4];
250 pllo[0]=0.5; pllo[1]=5.0; pllo[2]=1.0; pllo[3]=0.4;
251 plhi[0]=5.0; plhi[1]=50.0; plhi[2]=1000000.0; plhi[3]=5.0;
252 sv[0]=1.8; sv[1]=20.0; sv[2]=50000.0; sv[3]=3.0;
256 TF1 *fitsnr =
langaufit(hSNR,fr,sv,pllo,plhi,fp,fpe,&chisqr,&ndf);
261 printf(
"Fitting done\nPlotting results...\n");
271 fitsnr->
Draw(
"lsame");
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Double_t Landau(Double_t x, Double_t mpv=0, Double_t sigma=1, Bool_t norm=kFALSE)
The LANDAU function.
virtual void SetParameters(const Double_t *params)
virtual void SetParNames(const char *name0="p0", const char *name1="p1", const char *name2="p2", const char *name3="p3", const char *name4="p4", const char *name5="p5", const char *name6="p6", const char *name7="p7", const char *name8="p8", const char *name9="p9", const char *name10="p10")
Set up to 10 parameter names.
R__EXTERN TStyle * gStyle
TF1 * langaufit(TH1F *his, Double_t *fitrange, Double_t *startvalues, Double_t *parlimitslo, Double_t *parlimitshi, Double_t *fitparams, Double_t *fiterrors, Double_t *ChiSqr, Int_t *NDF)
1-D histogram with a float per channel (see TH1 documentation)}
virtual Double_t GetParError(Int_t ipar) const
Return value of parameter number ipar.
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
Int_t langaupro(Double_t *params, Double_t &maxx, Double_t &FWHM)
virtual Int_t GetNDF() const
Return the number of degrees of freedom in the fit the fNDF parameter has been previously computed du...
Double_t GetChisquare() const
virtual void SetRange(Int_t first=0, Int_t last=0)
Set the viewing range for the axis from bin first to last.
virtual void SetParLimits(Int_t ipar, Double_t parmin, Double_t parmax)
Set limits for parameter ipar.
virtual Double_t GetMean(Int_t axis=1) const
For axis = 1,2 or 3 returns the mean value of the histogram along X,Y or Z axis.
virtual void Draw(Option_t *option="")
Draw this histogram with options.
void SetOptFit(Int_t fit=1)
The type of information about fit parameters printed in the histogram statistics box can be selected ...
virtual const char * GetName() const
Returns name of object.
Double_t Gaus(Double_t x, Double_t mean=0, Double_t sigma=1, Bool_t norm=kFALSE)
Calculate a gaussian function with mean and sigma.
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
virtual Double_t * GetParameters() const
void SetLabelSize(Float_t size=0.04, Option_t *axis="X")
Set size of axis labels.
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
Double_t langaufun(Double_t *x, Double_t *par)
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
Fit histogram with function fname.