本文整理汇总了C++中TF1::SetParNames方法的典型用法代码示例。如果您正苦于以下问题:C++ TF1::SetParNames方法的具体用法?C++ TF1::SetParNames怎么用?C++ TF1::SetParNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TF1
的用法示例。
在下文中一共展示了TF1::SetParNames方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
#endif
{
ifstream filenames("namelist.txt");
ofstream velfile("datavel.txt");
velfile << "nomefile\tvelocita\tpunto iniziale\n";
TF1 *line = new TF1 ("linea", "[0]+[1]*x", 0., 20.);
line->SetParNames("x_0","v");
while(!filenames.eof()){
string fname;
filenames >> fname;//fname non deve contenere spazi e ".txt"
if(fname.find(".dat")==string::npos)
fname+=".dat";
if(fname!=".dat"){
cout <<"*\n"<< fname << ":" << endl;
int sets=0;
sets |= preparedraw::doMax;
preparedraw myData(fname,sets);
myData.maximum()->Fit(line,"N");
velfile << fname << "\t" <<line->GetParameter(1)<< "\t"<< line->GetParameter(0)<<endl;
}
}
velfile.close();
}
示例2: myfit
void myfit()
{
TString dir = gSystem->UnixPathName(__FILE__);
dir.ReplaceAll("myfit.C","../hsimple.C");
dir.ReplaceAll("/./","/");
if (!gInterpreter->IsLoaded(dir.Data())) gInterpreter->LoadMacro(dir.Data());
TFile *hsimple = (TFile*)gROOT->ProcessLineFast("hsimple(1)");
if (!hsimple) return;
TCanvas *c1 = new TCanvas("c1","the fit canvas",500,400);
TH1F *hpx = (TH1F*)hsimple->Get("hpx");
// Creates a Root function based on function fitf above
TF1 *func = new TF1("fitf",fitf,-2,2,3);
// Sets initial values and parameter names
func->SetParameters(100,0,1);
func->SetParNames("Constant","Mean_value","Sigma");
// Fit histogram in range defined by function
hpx->Fit(func,"r");
// Gets integral of function between fit limits
printf("Integral of function = %g\n",func->Integral(-2,2));
}
示例3: stubsVSangle
void stubsVSangle(){
TCanvas *c1 = new TCanvas("c1","c1",800,600);
c1->SetTickx();
c1->SetTicky();
double angle, MV, sigma;
int n = 11;
TGraphErrors *g1 = new TGraphErrors();
ifstream fp;
fp.open("stubsVsAngle.txt");
while(!fp.eof()){
for (int i = 0 ; i < n ; ++i){
if(fp >> angle >> MV >> sigma ){
g1->SetPoint(i,angle*0.0174532925,MV*0.09);
}
}
}
TF1 *func = new TF1("fit","[0] + [1]*tan([2]+x)");
func->SetParNames ("shift","spacing","ang0");
// set starting parameters but not fixing any
func->SetParameter(0, 0.5);
func->SetParameter(1, 2.75);
func->SetParameter(2, 0.02);
g1->Fit("fit");
fp.close();
g1->SetMarkerStyle(20);
g1->SetMarkerColor(1);
g1->Draw("ap");
g1->SetMinimum(0);
//g1->SetMaximum(12);
g1->GetXaxis()->SetTitle("angle [rad]");
g1->GetYaxis()->SetTitle("Delta strip (mv)[mm]");
g1->SetTitle("rotated DUT");
TLegend* leg = new TLegend(0.3,0.8,0.6,0.9);
leg->SetFillColor(0);
//leg->SetLineColor(0);
leg->AddEntry(g1,"mv","pl");
leg->AddEntry(func,"Fit","L");
leg->Draw();
}
示例4: fitPixelBeam
TF1* fitPixelBeam(TH1D* hist, double pixelWidth, double beamSigma, bool display)
{
TF1* conv = new TF1("conv",
"[2] + [4] * 0.5 * ( TMath::Erf(([0]/2 + [3] - x)/(sqrt(2)*[1])) + TMath::Erf(([0]/2 + [3] + x)/(sqrt(2)*[1])) )");
conv->SetParNames("Width", "Sigma", "Background", "Offset", "Scale");
const unsigned int numBins = hist->GetNbinsX();
const double limitLow = hist->GetXaxis()->GetBinLowEdge(1);
const double limitHigh = hist->GetXaxis()->GetBinUpEdge(numBins);
// Estimate the background using the +/- 10% edges of the histogram
double background = 0;
const unsigned int numBackgroundBins = numBins * 0.1 + 1;
for (unsigned int n = 0; n < numBackgroundBins; n++)
{
background += hist->GetBinContent(n + 1);
background += hist->GetBinContent(numBins - n);
}
background /= (double)(2 * numBackgroundBins);
// Estimate the scale
double scale = 0;
for (unsigned int bin = 1; bin <= numBins; bin++)
if (hist->GetBinContent(bin) > scale) scale = hist->GetBinContent(bin);
double offset = 0;
conv->SetRange(limitLow, limitHigh);
conv->SetParameters(pixelWidth, beamSigma, background, offset, scale);
conv->SetParLimits(0, 0.1 * pixelWidth, 100 * pixelWidth);
conv->SetParLimits(1, 0, 100 * beamSigma);
conv->SetParLimits(2, 0, scale);
conv->SetParLimits(3, -pixelWidth, pixelWidth);
conv->SetParLimits(4, 0.1 * scale, 10 * scale);
hist->Fit("conv", "QR0B");
if (display)
{
TCanvas* can = new TCanvas();
conv->SetLineColor(46);
conv->SetLineWidth(1);
hist->Draw();
conv->Draw("SAME");
can->Update();
can->WaitPrimitive();
}
return conv;
}
示例5: sprintf
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)
{
// Once again, here are the Landau * Gaussian parameters:
// par[0]=Width (scale) parameter of Landau density
// par[1]=Most Probable (MP, location) parameter of Landau density
// par[2]=Total area (integral -inf to inf, normalization constant)
// par[3]=Width (sigma) of convoluted Gaussian function
//
// Variables for langaufit call:
// his histogram to fit
// fitrange[2] lo and hi boundaries of fit range
// startvalues[4] reasonable start values for the fit
// parlimitslo[4] lower parameter limits
// parlimitshi[4] upper parameter limits
// fitparams[4] returns the final fit parameters
// fiterrors[4] returns the final fit errors
// ChiSqr returns the chi square
// NDF returns ndf
Int_t i;
Char_t FunName[100];
sprintf(FunName,"Fitfcn_%s",his->GetName());
TF1 *ffitold = (TF1*)gROOT->GetListOfFunctions()->FindObject(FunName);
if (ffitold) delete ffitold;
TF1 *ffit = new TF1(FunName,langaufun,fitrange[0],fitrange[1],4);
ffit->SetParameters(startvalues);
ffit->SetParNames("Width","MP","Area","GSigma");
for (i=0; i<4; i++) {
ffit->SetParLimits(i, parlimitslo[i], parlimitshi[i]);
}
his->Fit(FunName,"RB0"); // fit within specified range, use ParLimits, do not plot
ffit->GetParameters(fitparams); // obtain fit parameters
for (i=0; i<4; i++) {
fiterrors[i] = ffit->GetParError(i); // obtain fit parameter errors
}
ChiSqr[0] = ffit->GetChisquare(); // obtain chi^2
NDF[0] = ffit->GetNDF(); // obtain ndf
return (ffit); // return fit function
}
示例6: linLorentzianFit
TF1* linLorentzianFit(TH1* histoY){
TString name = histoY->GetName() + TString("Fit");
// Fit slices projected along Y from bins in X
TF1 *fit = new TF1(name,lorentzianPlusLinear,70,110,5);
fit->SetParameters(histoY->GetMaximum(),histoY->GetRMS(),histoY->GetMean(),10,-0.1);
fit->SetParNames("norm","width","mean","offset","slope");
fit->SetParLimits(1,-10,10);
//fit->SetParLimits(2,85,95);
//fit->SetParLimits(2,90,93);
fit->SetParLimits(2,2,4);
fit->SetParLimits(3,0,100);
fit->SetParLimits(4,-1,0);
fit->SetLineWidth(2);
//histoY -> Fit(name,"0","",85,97);
histoY -> Fit(name,"0","",2,4);
return fit;
}
示例7: lorentzianFit
TF1* lorentzianFit(TH1* histoY, const TString & resonanceType){
TString name = histoY->GetName() + TString("Fit");
// Fit slices projected along Y from bins in X
TF1 *fit = 0;
if( resonanceType == "JPsi" || resonanceType == "Psi2S" ) {
fit = new TF1(name, lorentzian, 3.09, 3.15, 3);
}
if( resonanceType.Contains("Upsilon") ) {
fit = new TF1(name, lorentzian, 9, 10, 3);
}
if( resonanceType == "Z" ) {
fit = new TF1(name, lorentzian, 80, 105, 3);
}
fit->SetParameters(histoY->GetMaximum(),histoY->GetRMS(),histoY->GetMean());
fit->SetParNames("norm","width","mean");
fit->SetLineWidth(2);
histoY->Fit( name,"R0" );
return fit;
}
示例8: drawHits
pqPoint HitCollection::drawHits(bool fit, bool draw, bool rz) {
unsigned int hits_n = hitCollection.size();
TGraph hits_h(hits_n);
hits_h.SetTitle("Hits");
for (unsigned int hit_i = 0; hit_i < hits_n; hit_i++) {
hits_h.SetPoint(hit_i, hitCollection[hit_i].x, hitCollection[hit_i].y);
}
TCanvas c("c", "c", 600, 600);
hits_h.GetXaxis()->SetLimits(-1.1*zmax, 1.1*zmax);
hits_h.GetYaxis()->SetRangeUser(0., 1.1*rmax);
hits_h.GetXaxis()->SetTitle("x[cm]");
hits_h.GetYaxis()->SetTitle("y[cm]");
hits_h.Draw("A*");
pqPoint pqpoint;
if (fit) {
gStyle->SetOptFit(10001);
string pol1("[1]*x + [0]");
if (rz) pol1 = "1./[1]*x - [0]/[1]";
TF1 * fitfun = new TF1("fitfun", pol1.c_str());
fitfun->SetParNames("q","p");
fitfun->SetParameters(1., 1.);
hits_h.Fit(fitfun, draw ? "" : "q");
c.Update();
pqpoint.p = fitfun->GetParameter("p");
// pqpoint.p = atan(fun->GetParameter("p"));
pqpoint.q = fitfun->GetParameter("q");
pqpoint.w = 1.;
}
else pqpoint.w = -1.;
TPaveStats *st = (TPaveStats*)hits_h.FindObject("stats");
st->SetY1NDC(0.72);
st->SetY2NDC(0.87);
st->SetX1NDC(0.13);
st->SetX2NDC(0.28);
if (draw) c.Print(Form("figs/hits_%s.pdf", name.c_str()));
return pqpoint;
}
示例9: gaussianFit
TF1* gaussianFit(TH1* histoY, const TString & resonanceType){
TString name = histoY->GetName() + TString("Fit");
// Fit slices projected along Y from bins in X
// -------------------------------------------
TF1 *fit = 0;
// Set parameters according to the selected resonance
if( resonanceType == "JPsi" ) {
fit = new TF1(name,gaussian,2,4,3);
fit->SetParLimits(2, 3.09, 3.15);
}
if( resonanceType.Contains("Upsilon") ) {
fit = new TF1(name,gaussian,8.5,10.5,3);
// fit = new TF1(name,gaussian,9,11,3);
fit->SetParLimits(2, 9.2, 9.6);
fit->SetParLimits(1, 0.09, 0.1);
}
if( resonanceType == "Z" ) {
fit = new TF1(name,gaussian,80,100,3);
fit->SetParLimits(2, 80, 100);
fit->SetParLimits(1, 0.01, 1);
}
if( resonanceType == "reso" ) {
fit = new TF1(name,gaussian,-0.05,0.05,3);
fit->SetParLimits(2, -0.5, 0.5);
fit->SetParLimits(1, 0, 0.5);
}
fit->SetParameters(histoY->GetMaximum(),histoY->GetRMS(),histoY->GetMean());
// fit->SetParLimits(1, 0.01, 1);
// fit->SetParLimits(1, 40, 60);
fit->SetParNames("norm","width","mean");
fit->SetLineWidth(2);
if( histoY->GetNbinsX() > 1000 ) histoY->Rebin(10);
histoY->Fit(name,"R0");
return fit;
}
示例10: FitHist
void FitHist(Double_t * d, char * path)
{
TH1D* hist = GetHist(path);
if (hist == NULL )
{
d[0]=-1;
d[1]=-1;
d[2]=-1;
return;
}
TF1 *func = new TF1 ("fit",DoubleErrf,hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax(),3);
func->SetParameters(0.,0.1,hist->GetEntries());
func->SetParNames ("Mean_value","Sigma","N");
hist->Fit("fit","Q");
//Double_t d[2];
d[0]=func->GetParameter(0);
d[1]=func->GetParameter(1);
d[2]=func->GetParameter(2);
//return d;
//cout<<endl<<"for "<<path<<endl<<"mean = "<<func->GetParameter(0)<<endl<<"sigma = "<<func->GetParameter(1)<<endl;
}
示例11: myfit
void myfit()
{
TFile* hsimple = TFile::Open("hsimple.root");
if (!hsimple) return;
TCanvas *c1 = new TCanvas("c1","the fit canvas",500,400);
TH1F *hpx = (TH1F*)hsimple->Get("hpx");
// Creates a Root function based on function fitf above
TF1 *func = new TF1("fitf",fitf,-2,2,3);
// Sets initial values and parameter names
func->SetParameters(100,0,1);
func->SetParNames("Constant","Mean_value","Sigma");
// Fit histogram in range defined by function
hpx->Fit(func,"r");
// Gets integral of function between fit limits
printf("Integral of function = %g\n",func->Integral(-2,2));
}
示例12: func
//*************************************************************
std::pair<std::pair<Double_t,Double_t>, std::pair<Double_t,Double_t> > fitResidualsCB(TH1 *hist)
//*************************************************************
{
//hist->Rebin(2);
float mean = hist->GetMean();
float sigma = hist->GetRMS();
//int nbinsX = hist->GetNbinsX();
float nentries = hist->GetEntries();
float meanerr = sigma/TMath::Sqrt(nentries);
float sigmaerr = TMath::Sqrt(sigma*sigma*TMath::Sqrt(2/nentries));
float lowBound = hist->GetXaxis()->GetBinLowEdge(1);
float highBound = hist->GetXaxis()->GetBinLowEdge(hist->GetNbinsX()+1);
if(TMath::IsNaN(mean) || TMath::IsNaN(sigma)){
mean=0;
sigma= - lowBound + highBound;
}
TF1 func("tmp", "gaus", mean - 1.*sigma, mean + 1.*sigma);
if (0 == hist->Fit(&func,"QNR")) { // N: do not blow up file by storing fit!
mean = func.GetParameter(1);
sigma = func.GetParameter(2);
}
// first round
TF1 *doubleCB = new TF1("myDoubleCB",DoubleSidedCB,lowBound,highBound,7);
doubleCB->SetParameters(mean,sigma,1.5,1.5,2.5,2.5,100);
doubleCB->SetParLimits(0,mean-meanerr,mean+meanerr);
doubleCB->SetParLimits(1,0.,sigma+2*sigmaerr);
doubleCB->SetParLimits(2,0.,30.);
doubleCB->SetParLimits(3,0.,30.);
doubleCB->SetParLimits(4,0.,50.);
doubleCB->SetParLimits(5,0.,50.);
doubleCB->SetParLimits(6,0.,100*nentries);
doubleCB->SetParNames("#mu","#sigma","#alpha_{L}","#alpha_{R}","n_{L}","n_{R}","N");
doubleCB->SetLineColor(kRed);
doubleCB->SetNpx(1000);
// doubleCB->SetRange(0.8*lowBound,0.8*highBound);
hist->Fit(doubleCB,"QM");
// second round
float p0 = doubleCB->GetParameter(0);
float p1 = doubleCB->GetParameter(1);
float p2 = doubleCB->GetParameter(2);
float p3 = doubleCB->GetParameter(3);
float p4 = doubleCB->GetParameter(4);
float p5 = doubleCB->GetParameter(5);
float p6 = doubleCB->GetParameter(6);
float p0err = doubleCB->GetParError(0);
float p1err = doubleCB->GetParError(1);
float p2err = doubleCB->GetParError(2);
float p3err = doubleCB->GetParError(3);
float p4err = doubleCB->GetParError(4);
float p5err = doubleCB->GetParError(5);
float p6err = doubleCB->GetParError(6);
if( (doubleCB->GetChisquare()/doubleCB->GetNDF()) >5){
std::cout<<"------------------------"<<std::endl;
std::cout<<"chi2 1st:"<<doubleCB->GetChisquare()<<std::endl;
//std::cout<<"p0: "<<p0<<"+/-"<<p0err<<std::endl;
//std::cout<<"p1: "<<p1<<"+/-"<<p1err<<std::endl;
//std::cout<<"p2: "<<p2<<"+/-"<<p2err<<std::endl;
//std::cout<<"p3: "<<p3<<"+/-"<<p3err<<std::endl;
//std::cout<<"p4: "<<p4<<"+/-"<<p4err<<std::endl;
//std::cout<<"p5: "<<p5<<"+/-"<<p5err<<std::endl;
//std::cout<<"p6: "<<p6<<"+/-"<<p6err<<std::endl;
doubleCB->SetParameters(p0,p1,3,3,6,6,p6);
doubleCB->SetParLimits(0,p0-2*p0err,p0+2*p0err);
doubleCB->SetParLimits(1,p1-2*p1err,p0+2*p1err);
doubleCB->SetParLimits(2,p2-2*p2err,p0+2*p2err);
doubleCB->SetParLimits(3,p3-2*p3err,p0+2*p3err);
doubleCB->SetParLimits(4,p4-2*p4err,p0+2*p4err);
doubleCB->SetParLimits(5,p5-2*p5err,p0+2*p5err);
doubleCB->SetParLimits(6,p6-2*p6err,p0+2*p6err);
hist->Fit(doubleCB,"MQ");
//gMinuit->Command("SCAn 1");
//TGraph *gr = (TGraph*)gMinuit->GetPlot();
//gr->SetMarkerStyle(21);
//gr->Draw("alp");
std::cout<<"chi2 2nd:"<<doubleCB->GetChisquare()<<std::endl;
}
float res_mean = doubleCB->GetParameter(0);
float res_width = doubleCB->GetParameter(1);
//.........这里部分代码省略.........
示例13: UpsilonMassFit_All
//.........这里部分代码省略.........
diMuonsInvMass_RecA1[ih]->Add(diMuonsInvMass_RecA[ifile][ih]);
diMuonsInvMass_GenA1[ih]->Add(diMuonsInvMass_GenA[ifile][ih]);
diMuonsPt_GenA1[ih]->Add(diMuonsPt_GenA[ifile][ih]);
diMuonsPt_RecA1[ih]->Add(diMuonsPt_RecA[ifile][ih]);
}
}
//===========================Fitting===================================================================//
// Fit ranges
double mass_low, mass_high;
double MassUpsilon, WeidthUpsilon;
// Low mass range upsilon width 54 KeV
MassUpsilon = 9.46; WeidthUpsilon = 0.060;
mass_low = 8.8; mass_high = 10.0; // Fit ranges
// Fit Function crystall ball
// TF1 *GAUSPOL = new TF1("GAUSPOL",CrystalBall,8.0,12.0,5);
//GAUSPOL->SetParNames("#alpha","n","Mean","#sigma","N");
//GAUSPOL->SetLineWidth(2.0);
//GAUSPOL->SetLineColor(2);
//GAUSPOL->SetParameter(0, 1.756);
//GAUSPOL->SetParameter(1, 2.636);
//GAUSPOL->SetParameter(2, MassUpsilon);
//GAUSPOL->SetParameter(3, WeidthUpsilon);
//GAUSPOL->SetParLimits(2, 0.1*MassUpsilon,2.0*MassUpsilon);
//GAUSPOL->SetParLimits(3, 0.1*WeidthUpsilon,2.0*WeidthUpsilon);
// Fit Function crystall ball
TF1 *GAUSPOL = new TF1("GAUSPOL",CrystalBall,8.0,12.0,6);
GAUSPOL->SetParNames("Yield (#Upsilon)","BinWidth","Mean","Sigma","#alpha","n");
GAUSPOL->SetParameter(2, MassUpsilon);
GAUSPOL->SetParameter(3, WeidthUpsilon);
GAUSPOL->SetParLimits(3, 0.1*WeidthUpsilon,2.0*WeidthUpsilon);
GAUSPOL->SetParameter(4, 1.0);
GAUSPOL->SetParameter(5, 20.0);
GAUSPOL->SetLineWidth(2.0);
GAUSPOL->SetLineColor(2);
//=====================Loop for eff===========================================================
double GenNo[100]={0};
double Eff[100]={0};
double GenError[100]={0};
double RecError[100]={0};
double errEff_cat_S1[100]={0};
double errEff_cat_S2[100]={0};
double errEff_cat_S1_1[100]={0},errEff_cat_S1_2[100]={0};
double errEff_cat_S2_1[100]={0},errEff_cat_S2_2[100]={0};
char PlotName[500],PlotName1[500], PlotName2[500];
char GPlotName[500],GPlotName1[500], GPlotName2[500];
for (Int_t ih = 0; ih < Nptbin; ih++) {
cout<<" no of gen dimuons from diMuons Pt histo "<<diMuonsPt_GenA1[ih]->Integral(1,100)<<endl;
cout<<" no of gen dimuons from diMuons Mass histo "<<diMuonsInvMass_GenA1[ih]->Integral(1,100)<<endl;
//from pT histogram
//gen_pt[ih] =diMuonsPt_GenA1[ih]->IntegralAndError(1,100,genError);
gen_pt[ih] = diMuonsInvMass_GenA1[ih]->IntegralAndError(1,100,genError);
示例14: main
//.........这里部分代码省略.........
hcosfiint->SetBinContent(i,cosfiint[i-1]);
hncohe->SetBinContent(i,ncohe[i-1]);
hninco->SetBinContent(i,ninco[i-1]);
hsinfiint->SetBinContent(i,sinfiint[i-1]);
}
//read yield
TString inrootname("pi0alt" + uimanager.input_filename("fit") + ".root");
TFile *yield = new TFile(inrootname);
if (!yield->IsOpen()) exit(open_err(inrootname));
TH1F *yieldhist = (TH1F*)yield->Get("hyield");
//TH1F *yieldhist = (TH1F*)yield->Get("hyield_mc_nocut");
yieldhist->SetDirectory(0);
if (!uimanager.target() && !uimanager.isouter()) yieldhist->SetTitle("#pi^{0} yield (Si, crystal w/o tran.)");
else if (!uimanager.target()) yieldhist->SetTitle("#pi^{0} yield (Si, crystal w/ tran.)");
else if (!uimanager.isouter()) yieldhist->SetTitle("#pi^{0} yield (C12, crystal w/o tran.)");
else yieldhist->SetTitle("#pi^{0} yield (C12, crystal w/ tran.)");
double nyield = 0, nyield_err = 0;
for(int i = 1; i<=125; i++) {
nyield += yieldhist->GetBinContent(i);
nyield_err += yieldhist->GetBinError(i)*yieldhist->GetBinError(i);
}
nyield_err = sqrt(nyield_err);
//***************** end reading files **************************************
gStyle->SetOptFit(1);
gStyle->SetOptStat(0);
gStyle->SetPaperSize(12,24);
//Double_t parameter[4] = {7.9, 1.0, 1.0, 0.8};
Double_t parameter[4] = {7.7, 1.0, 0.8, 0.5};
TF1 *ftot = new TF1("ftot", dndt, 0., dndt_fit_range, 4);
ftot->SetParNames("#Gamma","C1","#phi","C2");
ftot->SetParameter(0,parameter[0]);
ftot->SetParameter(1,parameter[1]);
ftot->SetParameter(2,parameter[2]);
ftot->SetParameter(3,parameter[3]);
/*
ftot->FixParameter(0,parameter[0]);
ftot->FixParameter(1,parameter[1]);
ftot->FixParameter(2,parameter[2]);
ftot->FixParameter(3,parameter[3]);
*/
ftot->SetParLimits(0, 3, 10);
ftot->SetParLimits(1, 0.3, 1.5);
ftot->SetParLimits(2, 0, 3.1415936/2);
ftot->SetParLimits(3, 0., 10.0);
yieldhist->Fit("ftot", "RMBE0");
Double_t chi2 = ftot->GetChisquare()/ftot->GetNDF();
parameter[0]=ftot->GetParameter(0);
parameter[1]=ftot->GetParameter(1);
parameter[2]=ftot->GetParameter(2);
parameter[3]=ftot->GetParameter(3);
Double_t e1 = ftot->GetParError(0);
Double_t e2 = ftot->GetParError(1);
Double_t e3 = ftot->GetParError(2);
Double_t e4 = ftot->GetParError(3);
//cout<<chi2<<" "<<parameter[0]<<" "<<parameter[1]<<" "<<parameter[2]<<" "<<parameter[3]<<endl;
TString fname = "fitresult" + uimanager.input_filename("fit") + ".dat";
ofstream output(fname);
示例15: main
//.........这里部分代码省略.........
cout << " Lo prendo dal DoubleMu" << endl;
}else if( jj<8 ){
sigma = 4; // 4
sigma2 = 5; //5
h = (TH1D*)dataFile_HT450->Get( HistoName.c_str() );
cout << " Lo prendo dal HT450" << endl;
}else{
sigma = 4;
sigma2 = 4; //3
h = (TH1D*)dataFile_HT450->Get( HistoName.c_str() );
cout << " Lo prendo dal HT450" << endl;
}
if( jj > 8) continue; // >8 prima
if( ii==3 && jj > 6) continue; // ultimo fit in endcap non funziona
if(!h) continue;
int Nentries = h->GetEntries();
if(Nentries<100) continue; //200
h->Rebin(2);
double hN = h->GetMaximum();
double hMean = h->GetMean();
double hRMS = h->GetRMS();
/*
TF1 *expon = new TF1("expon", "[0] + [1]*exp(-[2]*x)", 0.1, 0.4);
h -> Fit(expon, "R");
*/
/*
TF1 *crystal = new TF1("crystal", CrystalBall, hMean-2*hRMS , hMean+1*hRMS, 5);
crystal->SetParameters(hN, hMean, hRMS, 1.0, 2.0);
crystal->SetParNames("N", "Mean", "sigma","#alpha","n");
crystal->SetParLimits(0, hN-0.05*hN, hN+0.05*hN);
h -> Fit(crystal, "R");
*/
/*
TF1 *doublecrystal = new TF1("doublecrystal", doubleCrystalBall, hMean-3*hRMS , hMean+4*hRMS, 7);
doublecrystal->SetParNames("N", "Mean", "sigma","#alphaR","nR","#alphaL", "nL");
doublecrystal->SetParameters(hN, 0.01, 0.03, 1.2, 30., 15, 40.);
doublecrystal->SetParLimits(1, 0.005, 0.015);
doublecrystal->SetParLimits(2, 0.015, 0.035);
doublecrystal->SetParLimits(3, 0 , 1.4);
doublecrystal->SetParLimits(4, 1, 10);
doublecrystal->SetParLimits(5, 0, 10);
doublecrystal->SetParLimits(6, 0, 15);
h -> Fit(doublecrystal, "R");
*/
/*
// secondo giro
TF1 *doublecrystal2 = new TF1("doublecrystal2", doubleCrystalBall, doublecrystal->GetParameter(1)-2* doublecrystal->GetParameter(2),doublecrystal->GetParameter(1)+1*doublecrystal->GetParameter(2), 7);
doublecrystal2->SetLineColor(kBlue);
doublecrystal2->SetParNames("N", "Mean", "sigma","#alphaR","nR","#alphaL", "nL");
doublecrystal2->SetParameters(doublecrystal->GetParameter(0), doublecrystal->GetParameter(1), doublecrystal->GetParameter(2), doublecrystal->GetParameter(3), doublecrystal->GetParameter(4), doublecrystal->GetParameter(5), doublecrystal->GetParameter(6));
h -> Fit(doublecrystal2, "+R");
// terzo giro
TF1 *doublecrystal3 = new TF1("doublecrystal3", doubleCrystalBall, doublecrystal2->GetParameter(1)-2* doublecrystal2->GetParameter(2),doublecrystal2->GetParameter(1)+1*doublecrystal2->GetParameter(2), 7);
doublecrystal3->SetLineColor(kGreen);
doublecrystal3->SetParNames("N", "Mean", "sigma","#alphaR","nR","#alphaL", "nL");
doublecrystal3->SetParameters(doublecrystal2->GetParameter(0), doublecrystal2->GetParameter(1), doublecrystal2->GetParameter(2), doublecrystal2->GetParameter(3), doublecrystal2->GetParameter(4), doublecrystal2->GetParameter(5), doublecrystal2->GetParameter(6));
h -> Fit(doublecrystal3, "+R");
*/