当前位置: 首页>>代码示例>>C++>>正文


C++ TF1::GetParameters方法代码示例

本文整理汇总了C++中TF1::GetParameters方法的典型用法代码示例。如果您正苦于以下问题:C++ TF1::GetParameters方法的具体用法?C++ TF1::GetParameters怎么用?C++ TF1::GetParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TF1的用法示例。


在下文中一共展示了TF1::GetParameters方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: gaus1peakfit

/*============================================================================*/
void gaus1peakfit(Char_t *s, Float_t x1, Float_t x2, Float_t x3, Float_t x4)
{
  Double_t par[5],epar[5],x[4],y[4];
  TH1 *hist;
  hist = (TH1 *) gROOT->FindObject(s);
  setcanvas(1);
  TCanvas *c1=(TCanvas*) gROOT->FindObject("c1");
  if(c1==NULL)setcanvas(1);
  c1->Clear();
  hist->SetAxisRange(x1-30,x4+30);
  hist->Draw();

  //--**-- Linear background estimation --**--//
  x[0] = x1;
  x[1] = x2;
  x[2] = x3;
  x[3] = x4;
  Int_t bin1 = hist->FindBin(x1);
  y[0] = hist->GetBinContent(bin1);
  Int_t bin2 = hist->FindBin(x2);
  y[1] = hist->GetBinContent(bin2);
  Int_t bin3 = hist->FindBin(x3);
  y[2] = hist->GetBinContent(bin3);
  Int_t bin4 = hist->FindBin(x4);
  y[3] = hist->GetBinContent(bin4);
  TGraph *g = new TGraph(4,x,y);
  TF1 *fpol1 = new TF1("POL1","pol1",x1,x4);
  g->Fit(fpol1,"RQN");
  par[3]=fpol1->GetParameter(0);
  par[4]=fpol1->GetParameter(1);

  //--**-- Gaussian Peak estimation without background --**--//
  TF1 *fgaus = new TF1("GAUS","gaus",x2,x3);
  hist->Fit(fgaus,"RQN");
  fgaus->GetParameters(&par[0]);

  //--**-- Final Peak Fit with Background --**--//
  TF1 *func = new TF1("FGAUS","gaus(0)+pol1(3)",x1,x4);
  func->SetParameters(par);
  hist->Fit(func,"R+QN");
  func->GetParameters(par);
  epar[0]=func->GetParError(0);
  epar[1]=func->GetParError(1);
  epar[2]=func->GetParError(2);
  Double_t fwhm = par[2]*TMath::Sqrt(8*TMath::Log(2));
  Double_t efwhm = epar[2]*TMath::Sqrt(8*TMath::Log(2));
  Double_t N0 = par[0]*(TMath::Sqrt(TMath::TwoPi())*par[2]);
  Double_t r0 = epar[0]/par[0];
  Double_t r2 = epar[2]/par[2];
  Double_t eN0= N0*TMath::Sqrt(r0*r0+r2*r2);
  printf("Peak = %f +- %f; FFHM = %f +- %f; Area = %f +- %f\n",
          par[1],epar[1],fwhm,efwhm,N0,eN0);
  //printf("%11.4f %11.4f %11.0f %11.0f\n",
  //        par[1],epar[1],N0,eN0);
  func->SetLineWidth(0.5);
  func->SetLineStyle(1);
  func->SetLineColor(4);
  func->SetFillColor(4);
  func->Draw("same");
}
开发者ID:adamhayes,项目名称:ChicoSort,代码行数:61,代码来源:gatemat.cpp

示例2: problem_1

void problem_1() {
    //Declare variable for energy
    Float_t energy;

    //declare a histogram for the energy
    TH1D *energy_hist = new TH1D("Energy","Energy",50,100,160);
    //declare the canvas to display hist
    TCanvas *c1 = new TCanvas("c1","c1",10,10,900,900);
    TF1 *fitFcn = new TF1("fitFcn",fitFunction,90,180,6);

    //get the input file
    TFile *inputFile = new TFile("data.root");
    //get the correct tree from the input file
    //depending on the tree name change "data"
    TTree *data_tree = (TTree*)inputFile->Get("data");

    //Get the branch named E1 and put it into the varialbe energy
    data_tree->SetBranchAddress("E", &energy);

    //Get the number of events for the for loop
    int count = data_tree->GetEntries();

    for (int i = 0; i < count; i++) {
        //get the current event i
        data_tree->GetEntry(i);
        //Fill the histogram
        energy_hist->Fill(energy);
    }
    //label the axis and draw the histogram after it's filled
    energy_hist->GetXaxis()->SetTitle("E (GeV)");
    energy_hist->Draw();
    // first try without starting values for the parameters
    // this defaults to 1 for each param.
    energy_hist->Fit("fitFcn");
    // this results in an ok fit for the polynomial function however
    // the non-linear part (Lorentzian) does not respond well
    // second try: set start values for some parameters
    fitFcn->SetParameter(4,1.66); // width
    fitFcn->SetParameter(5,126.5); // peak
    energy_hist->Fit("fitFcn");

    // improve the picture:
    TF1 *backFcn = new TF1("backFcn",background,100,160,3);
    backFcn->SetLineColor(1);
    backFcn->SetLineStyle(3);
    TF1 *signalFcn = new TF1("signalFcn",gaussian,100,160,3);
    signalFcn->SetLineColor(4);
    Double_t par[6];

    // writes the fit results into the par array
    fitFcn->GetParameters(par);
    backFcn->SetParameters(par);
    backFcn->Draw("same");
    signalFcn->SetParameters(&par[4]);
    signalFcn->Draw("same");

    gStyle->SetOptFit(1111);

}
开发者ID:tylern4,项目名称:Homework,代码行数:59,代码来源:problem_1.C

示例3: getDoubleFit

	  TF1 * getDoubleFit(TH1 * hist, bool autorange, double inner, double outer, int which=1){
		  /**
		   * @brief performes a double gaussian Fit
		   */

		  Double_t parameters[6] = {0,0,0,0,0,0};
		  Double_t parameters_new[6] = {0,0,0,0,0,0};


		  double center = hist->GetMean();

		  if (autorange){
			  double inner = fabs(center - hist->GetXaxis()->GetXmax()) /10;
			  double outer = fabs(center - hist->GetXaxis()->GetXmax()) /10*8;
		  }

		  TF1 * fit1 = new TF1("fit1", "gaus", center-inner, center+inner );

		  hist->Fit(fit1, "Q0R");
		  fit1->GetParameters(&parameters[0]);

		  TF1 * fit2 = new TF1("fit2", "gaus", center-outer, center+outer );

		  hist->Fit(fit2, "Q0R");
		  fit2->GetParameters(&parameters[3]);

		  TF1 * fitproper = new TF1("fitproper", "gaus(0)+gaus(3)", center-outer, center+outer);
		  fitproper->SetParameters(parameters);
		  fitproper->SetParName(0, "Const.(inner)");
		  fitproper->SetParName(1, "Mean (inner)");
		  fitproper->SetParName(2, "Sigma (inner)");
		  fitproper->SetParName(3, "Const.(outer)");
		  fitproper->SetParName(4, "Mean (outer)");
		  fitproper->SetParName(5, "Sigma (outer)");

		  hist->Fit(fitproper, "Q0R");
		  fitproper->GetParameters(&parameters_new[0]);


		  fitproper->SetLineColor(hist->GetLineColor());
		  fitproper->SetLineWidth(hist->GetLineWidth());
		  fitproper->SetLineStyle(2);

		  if (which==1){
		  	  TF1 * Gausinner = new TF1("Gausinner", "gaus(0)", center-inner, center+inner);
			  Gausinner->SetParameters(parameters_new);
		  	  return Gausinner;
		  }
		  else{
			  TF1 * Gausouter = new TF1("Gausouter", "gaus(3)", center-outer, center+outer);
			  Gausouter->SetParameters(parameters_new);
			  return Gausouter;
		  }

	  }
开发者ID:xyBlackWitch,项目名称:PhD,代码行数:55,代码来源:common_jenny.cpp

示例4: tripleGaussFit

	  TF1 * tripleGaussFit(TH1 * hist, bool autorange, double inner=0.01, double outer=0.1){
		  /**
		   * @brief performes a double gaussian Fit
		   */
		  Double_t parameters[9] = {0,0,0,0,0,0,0,0,0};


		  double center = hist->GetMean();


		  if (autorange){
			  double inner = fabs(center - hist->GetXaxis()->GetXmax()) /10;
			  double outer = fabs(center - hist->GetXaxis()->GetXmax()) /10*8;
		  }
		  double middle = (outer - inner)/2;

		  TF1 * fit1 = new TF1("fit1", "gaus", center-inner, center+inner );

		  hist->Fit(fit1, "0R");
		  fit1->GetParameters(&parameters[0]);

		  TF1 * fitmid = new TF1("fitmid", "gaus", center-middle, center+middle );
		  fitmid->SetParameter(1, parameters[1]);
		  hist->Fit(fitmid, "0R");
		  fitmid->GetParameters(&parameters[3]);

		  TF1 * fit2 = new TF1("fit2", "gaus", center-outer, center+outer );
		  fit2->SetParameter(1, parameters[1]);
		  hist->Fit(fit2, "0R");
		  fit2->GetParameters(&parameters[6]);

		  TF1 * fitproper = new TF1("fitproper", "gaus(0)+gaus(3)+gaus(6)", center-outer, center+outer);
		  fitproper->SetParameters(parameters);
		  fitproper->SetParName(0, "Const.(inner)");
		  fitproper->SetParName(1, "Mean (inner)");
		  fitproper->SetParName(2, "Sigma (inner)");
		  fitproper->SetParName(3, "Const.(middle)");
		  fitproper->SetParName(4, "Mean (middle)");
		  fitproper->SetParName(5, "Sigma (middle)");
		  fitproper->SetParName(6, "Const.(outer)");
		  fitproper->SetParName(7, "Mean (outer)");
		  fitproper->SetParName(8, "Sigma (outer)");

		  hist->Fit(fitproper, "0R");

//		  fitproper->SetLineColor(hist->GetLineColor());
//		  fitproper->SetLineWidth(hist->GetLineWidth());
////		  fitproper->SetLineStyle(2);

		  return fitproper;

	  }
开发者ID:xyBlackWitch,项目名称:PhD,代码行数:52,代码来源:common_jenny.cpp

示例5: FitAcceptance

int BBCEfficiency::FitAcceptance(float left_low = -60., float left_high = 0., float right_low = 0., float right_high = 60.) {
  // these fit ranges should encompass any vertex cut range.
  TF1* left = new TF1("left","gaus",left_low,left_high);
  left->SetLineColor(kGreen);
  TF1* right = new TF1("right","gaus",right_low,right_high);
  right->SetLineColor(kBlue);
  Double_t par[6];
  Derivative(trigger_acceptance_, acceptance_first_derivative_);


  // Needs parameter settings, etc, but we've already successfully fit.
  // left_erf_  = new TF1("left_erf_","[0]+[1]*TMath::Erf((x-[2])/[3])",-60,0);
  // right_erf_ = new TF1("right_erf_","[0]+[1]*TMath::Erf((x-[2])/[3])",0,60);

  for(int i = 0; i < acceptance_first_derivative_->GetNbinsX(); i++) {
    abs_acceptance_first_derivative_->SetBinContent(i+1,fabs(acceptance_first_derivative_->GetBinContent(i+1)));
    abs_acceptance_first_derivative_->SetBinError(i+1,acceptance_first_derivative_->GetBinError(i+1));
  }

  abs_acceptance_first_derivative_->Fit(left,"R");
  abs_acceptance_first_derivative_->Fit(right,"R+");
  left->GetParameters(&par[0]);
  right->GetParameters(&par[3]);

  // store for access later in the class to member variables.
  left_gaus_ = left;
  right_gaus_ = right;
  
  z_vtx_cut_min_ = left_gaus_->GetParameter(1); 
  z_vtx_cut_max_ = right_gaus_->GetParameter(1); 

  std::cout << "Trigger vertex cut: " << z_vtx_cut_min_ << ", " << z_vtx_cut_max_ << std::endl;

  plot_registry_.push_back(left);
  plot_registry_.push_back(right);
  return 0;
}
开发者ID:Jollyhrothgar,项目名称:vernierScans,代码行数:37,代码来源:BBCEfficiency.C

示例6: RRootHistRead_v1

void RRootHistRead_v1(){
	
	TFile *inputFile = new TFile("pPb_MBSpectra_Combine_-1_1.root");
	cout << "Is the file Open " << inputFile->IsOpen() << endl;

	//Copy the histogram
	TString hName = "Spectra_NtrkOffline0_inf";
	TH1D *h = (TH1D*)inputFile->Get(hName);

	cout << "Number of bins in the histogram: " << h->GetSize() << "\n";
	h->Draw();

	double nhBins = h->GetSize();
	for (int i=0; i < nhBins; i++) cout << h->GetBinWidth(i) << ", ";
	cout << endl;

	// Fit function
	double nParam = 2, maxValue = 5, minValue = 0;

	TF1 *fitFn = new TF1("fitFn", fitFunction, minValue, maxValue, nParam);

	// Set parameters for Fit
	fitFn->SetParameter(0, 0.008);

	// Get parameters from Fit
	double paramFromFit[2];
	fitFn->GetParameters(paramFromFit);

	// Generate data from fit
	double nBins = 27, pT[27], spectraFromFit[27]; // From the Xi 
	for (int i=0; i < nBins; i++){

		spectraFromFit[i] = paramFromFit[0]*exp(-i) + paramFromFit[1];
		cout << spectraFromFit[i] << ", ";
		pT[i] = i;
			
	}

	// Using Integral for the Fit
	h->Fit(fitFn, "I");

	TGraph *g = new TGraph(nBins, pT, spectraFromFit);
	g->SetMarkerStyle(7);
	g->SetMarkerSize(1.5);
	g->SetMarkerColor(kGreen);
	g->Draw("ALP");
	h->Draw("same");
	
}
开发者ID:ravijanjam,项目名称:CPlusplusPrograms,代码行数:49,代码来源:RRootHistRead_v1.C

示例7: GetFitParameterDoubleFit

	void GetFitParameterDoubleFit(TH1* &histo, bool autorange = true, double innerRange=0.1 , double outerRange=1, bool excludeCenter=false){

		Double_t parameter[6] = {0,0,0,0,0,0};
		TF1 * fit;

		if(excludeCenter){
			fit = andi::doubleGaussFitExcludeCenter(histo, false, innerRange, outerRange);
		}
		else{
			fit = doubleGaussFit(histo, autorange, innerRange, outerRange);
		}

		fit->GetParameters(&parameter[0]);

	}
开发者ID:xyBlackWitch,项目名称:PhD,代码行数:15,代码来源:common_jenny.cpp

示例8: fitExclude

void fitExclude() {
   //Create a source function
   TF1 *f1 = new TF1("f1","[0] +[1]*x +gaus(2)",0,5);
   f1->SetParameters(6,-1,5,3,0.2);
   // create and fill histogram according to the source function
   TH1F *h = new TH1F("h","background + signal",100,0,5);
   h->FillRandom("f1",2000);
   TF1 *fl = new TF1("fl",fline,0,5,2);
   fl->SetParameters(2,-1);
   //fit only the linear background excluding the signal area
   reject = kTRUE;
   h->Fit(fl,"0");
   reject = kFALSE;
   //store 2 separate functions for visualization
   TF1 *fleft = new TF1("fleft",fline,0,2.5,2);
   fleft->SetParameters(fl->GetParameters());
   h->GetListOfFunctions()->Add(fleft);
   gROOT->GetListOfFunctions()->Remove(fleft);
   TF1 *fright = new TF1("fright",fline,3.5,5,2);
   fright->SetParameters(fl->GetParameters());
   h->GetListOfFunctions()->Add(fright);
   gROOT->GetListOfFunctions()->Remove(fright);
   h->Draw();
}
开发者ID:MycrofD,项目名称:root,代码行数:24,代码来源:fitExclude.C

示例9: 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

}
开发者ID:Y--,项目名称:root,代码行数:47,代码来源:langaus.C

示例10: gaussFit

		TF1 * gaussFit(TH1 * hist, double inner) {
			Double_t parameters[6] = {0,0,0,0,0,0};


			double center =0;// hist->GetMean();

			TF1 * fit = new TF1("fit", "gaus", center-inner, center+inner );

			hist->Fit(fit, "Q0R");
			fit->GetParameters(&parameters[0]);
			fit->SetParameters(parameters);
			fit->SetParName(0, "Const.");
			fit->SetParName(1, "Mean");
			fit->SetParName(2, "Sigma");

			return fit;
		}
开发者ID:xyBlackWitch,项目名称:PhD,代码行数:17,代码来源:common_jenny.cpp

示例11: LadderTimes

void LadderTimes()
{
  TH1F* Time;
  Double_t par[4];
  Double_t Max;
  Char_t Buff[256];

  for(Int_t ch=0; ch<352; ch++)
  {
    sprintf(Buff, "Ladder_Time%d", ch);
    Time = (TH1F*)gROOT->FindObject(Buff);
    Max = Time->GetMaximumBin()*Time->GetBinWidth(Time->GetMaximumBin()) - 1000.0;
   
    TF1* gauss = new TF1("gauss", "gaus", Max-8, Max+8);
    Time->Fit(gauss, "RQ+");
    gauss->GetParameters(&par[0]);
    
    printf("%5.2f\n", par[1]/0.117710);
  }
}
开发者ID:A2-Collaboration,项目名称:acqu,代码行数:20,代码来源:LadderTimes.cpp

示例12: energyCorrectionDiff

scalePair energyCorrectionDiff(TCut centCut1, float lowPt, float highPt, float lowEta, float highEta,TCut addCut) { 
   
   TString fname1 = "forest/barrelHiForestPhoton_MCphoton50_51k.root";
   if ( lowPt > 90 ) 
      fname1 = "forest/barrelHiForestPhoton_MCphoton80_28k.root";
   TFile *f1  =new TFile(fname1.Data());
   TTree *photon1 = (TTree*)f1->Get("yongsunPhotonTree");
   photon1->AddFriend("yEvt=yongsunHiEvt"    ,fname1.Data());
   photon1->AddFriend("ySkim=yongsunSkimTree"   ,fname1.Data());
   photon1->AddFriend("yHlt=yongsunHltTree"     ,fname1.Data());
   
   TCut collisionCut = "ySkim.pcollisionEventSelection==1";
   
   TCut hoeCut = "hadronicOverEm<0.2";
   TCut isoCut = "cc4 + cr4 + ct4j20 < 5 && sigmaIetaIeta<0.011";
   TCut ptCut  = Form("genMatchedPt>%.f && genMatchedPt <%.f",lowPt, highPt);
   TCut etaCut = Form("abs(eta)>%f && abs(eta)<%f",lowEta,highEta);
      
   TCut finalCut1 = genMatchCut1 && collisionCut && centCut1 && hoeCut && isoCut && ptCut && etaCut && addCut ; 
   TString variable1 = "pt/genMatchedPt";
   
   TH1D* hScale = new TH1D("hScale","",100,.5,1.5);
   TH1D* hdpt = new TH1D("hdpt","",100,-20,20);
   photon1->Draw(Form("%s>>%s",variable1.Data(),hScale->GetName()), finalCut1);
   photon1->Draw(Form("pt-genMatchedPt>>%s",hdpt->GetName()),       finalCut1);
   cout << "cut = " << finalCut1.GetTitle() <<endl;
   hScale->Draw();
   hdpt->Draw();
   TF1* ff =  cleverGaus(hScale);
   
   scalePair ret;
   double *ps = ff->GetParameters();
   ret.val = ps[1];
   ret.err = ff->GetParError(1);
   // resErr = ff->GetParError(2);
   ret.res  = ps[2];
   ret.resErr = ff->GetParError(2);  
   ret.absVal = hdpt->GetMean();
   cout <<"scale = " << ret.val << " +-" << ret.err << endl;
   return ret;
}
开发者ID:CmsHI,项目名称:CVS_SavedFMa,代码行数:41,代码来源:energyCorrection.C

示例13: GetVoigtFit

	  TF1 * GetVoigtFit(TH1 * hist, double lower, double upper){
		  /**
		   * @brief performes a Fit with a Breit-Wigner-Distribution.
		  */
		  double parameter[3];

		  double max = hist->GetMaximum();

		  int bin1 = hist->FindFirstBinAbove(max-1);

		  double center =  hist->GetBinCenter(bin1);


		  TString func = TString::Format("TMath::Voigt(x-%.4f, [0], [1])", center);

		  TF1 * fit = new TF1("fit", func, lower, upper);

		  hist->Fit(fit, "0R");

		  fit->GetParameters(&parameter[0]);


		  TF1 * voigt = new TF1("voigt", func+"*[2]", lower, upper);

		  voigt->SetParameter(0, parameter[0]);
		  voigt->SetParameter(1, parameter[1]);

		  voigt->SetParName(0, "#sigma");
		  voigt->SetParName(1, "#Gamma");
		  voigt->SetParName(2, "A");
//		  voigt->SetParName(3, "B");
//		  voigt->SetParName(4, "C");

		  hist->Fit(voigt, "0R");

		  return voigt;



	  }
开发者ID:xyBlackWitch,项目名称:PhD,代码行数:40,代码来源:common_jenny.cpp

示例14: fitmmp

void fitmmp(TH1 *hmmp, bool verbose = false) {
  TString options;
  if (verbose) options = "";
  else options = "Q";
  TF1 *fbg = f_pol4("fbg",0.4,2,true);
  hmmp->Fit(fbg,options.Data(),"",0.42,2);
  //printf("%s\n",gMinuit->fCstatu.Data());
  if (true) { //gMinuit->fCstatu.Contains("CONVER")) {
    TF1 *fbg2 = f_pol4("fbg",0.4,2,false);
    fbg2->SetParameters(fbg->GetParameters());
    //fbg2->Draw("same");
    fbg2->SetParameter(5,0);
    fbg2->SetParameter(6,0);
    TH1 *htmp = (TH1*)hmmp->Clone("hmmp_bgsub");
    htmp->Add(fbg2,-1);
    //htmp->Draw();
    TF1 *fgaus = new TF1("fgaus","gaus",0.4,2);
    htmp->Fit(fgaus,options.Data(),"",0.74,0.85);
    TF1 *f = f_pol4gaus("f",0.4,2,fbg2,fgaus);
    f->SetNpx(500);
    hmmp->Fit(f,options.Data(),"",0.42,2);
    fgaus->SetRange(0.4,2);
    for (int i = 0; i < 3; i++) fgaus->SetParameter(i,f->GetParameter(i+5));
    for (int i = 0; i < 5; i++) fbg2->SetParameter(i,f->GetParameter(i));
    fbg2->SetLineStyle(2);
    fbg2->SetLineColor(kRed+1);
    fgaus->SetLineStyle(2);
    fgaus->SetLineColor(kGreen+1);
    hmmp->GetListOfFunctions()->Add(fbg2->Clone());
    hmmp->GetListOfFunctions()->Add(fgaus->Clone());
    delete fbg2;
    delete htmp;
    delete fgaus;
    delete f;
  } else hmmp->GetListOfFunctions()->Delete();
  delete fbg;
}
开发者ID:evan-phelps,项目名称:phys-ana-omega,代码行数:37,代码来源:fit.C

示例15: pi0_mfitpeak


//.........这里部分代码省略.........
       for (Int_t nn=1; nn <= nbins; nn++)
	 {
	   if(hgauss->GetBinContent(nn) < 0.) hgauss->SetBinContent(nn,0.001*nevtperbin0[nmaxbin]);
	   hgauss->SetBinError(nn,sqrt(hgauss->GetBinContent(nn)));
	 }

   // Declare function with wich to fit
       TF1 *g1 = new TF1("g1","gaus",lowgauss,highgauss);
   hgauss->Fit(g1,"R0");
   hgauss->DrawCopy("sep");
   g1->Draw("same");
   //  break;

   char *polff = new char[20];

   sprintf(polff,"pol%d",npol);
   
   TF1 *p4bkg; 
   if(etapi0flag != 1)
     p4bkg   = new TF1("pm2",polff, xaxis->GetBinCenter(nminbord),xaxis->GetBinCenter(nmaxbord));
   else
     p4bkg   = new TF1("pm2",polff, 0.35,0.75);
   
   

   hbkg->Fit(p4bkg,"R0");
   hbkg->DrawCopy("sep");
   p4bkg->SetLineStyle(kDashed);
   p4bkg->Draw("same");
   // break;
   
   
   Double_t par[20],parf[20],errparf[20];
   g1->GetParameters(&par[0]);
   p4bkg->GetParameters(&par[3]);

   char *totff = new char[20];
   
   sprintf(totff,"gaus(0)+pol%d(3)",npol);
   
   
   TF1 *total = new TF1("total",totff,fitl,fith);
   TF1 *p4bkgfin   = new TF1("pm2",polff,fitl,fith);
   total->SetParameters(par);

   if(etapi0flag==0){
     total->SetParLimits(1,0.10,0.15);
     total->SetParLimits(2,0.135*0.06,0.135*0.3);
     
   }else{
     total->SetParLimits(1,0.35,0.65);
   }
   
   
   //  total->FixParameter(1,1.21340e-01); 
   // total->FixParameter(2,2.69780e-02);
   
   
   

   

   mh1->Fit(total,"R0");
   
   cout<<" yield.. "<< total->GetParameter(0) <<"+/- " << total->GetParError(0)<<endl;
   
开发者ID:cmsPizeroCalibration,项目名称:Pi0Analyzer,代码行数:66,代码来源:pi0_mfitpeak_npol_v1.C


注:本文中的TF1::GetParameters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。