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


C++ TMinuit::mnexcm方法代码示例

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


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

示例1: Ifit2

//______________________________________________________________________________
void Ifit2()
{
  file = new TFile("run41800dETIFWC1.root");
  Bool_t IsFWC1 = kTRUE;

  TMinuit *minuit = new TMinuit(3);
  minuit->SetFCN(fcn);
  Double_t arglist[10];
  Int_t ierflg;      
     
  //ToF peak position from MC
  Double_t ToFFWC1Theta[6] =
    {
      2.088228e+01,2.092216e+01,2.112093e+01,2.149825e+01,2.212018e+01,2.297665e+01
    };
  
  Double_t ToFFWC2Theta[6] =
   {
     1.976750e+01,1.988218e+01,2.025691e+01,2.078644e+01,2.158632e+01,2.263857e+01
   };
  
  Double_t ToFFWCTheta[6];
  for(Int_t i = 0; i<6; i++){
    if(IsFWC1)  ToFFWCTheta[i] = ToFFWC1Theta[i];
   else ToFFWCTheta[i] = ToFFWC2Theta[i];
  }

  //  Int_t nbin = 3;

  TH2D* hdEToF[6][24];
  TF1*  fFit[6][24];
 
  for(Int_t el = 1; el<25; el++){
    Double_t vstart[3]; 
    for(Int_t bin = 1; bin<7; bin++){
       
      hdEToF[bin-1][el-1] = (TH2D*)file->Get(Form("hToFFWCdEFWC_bin%02d_ifwc%02d",bin,el));
      hdE = hdEToF[bin-1][el-1];

      //err x and y
      //So here I fit x coordinate of THE point
      //Then I calculate where I would like to cut the whole thing off
      TF1* g1 = new TF1("g1","gaus",15.,28.);  
      Double_t maxt = ToFFWCTheta[bin-1];
      hdE->ProjectionX("hproj1")->Fit("g1", "IQ", "", maxt-2.5, maxt+2.5);
      merrx = g1->GetParameter(2);
      cutx = maxt+3*merrx;
      

      //Same for y.
      TF1* g2 = new TF1("g2","gaus",0.,4000.);
      Int_t BinDown = hdE->GetXaxis()->FindBin(maxt-2.5);
      Int_t BinUp = hdE->GetXaxis()->FindBin(maxt+2.5);
      Double_t maxy = hdE->ProjectionY()->GetMaximumBin();
      Double_t maxdE = hdE->GetYaxis()->GetBinCenter(maxy);
      hdE->ProjectionY("hproj2",BinDown,BinUp)->Fit("g2", "I", "", maxdE-500., maxdE+500);
      merry = g2->GetParameter(2);
      cuty = maxdE+5*merry;
      
      cout<<"err: "<<merrx<<" "<<merry<<endl;
      cout<<"cut: "<<cutx<<" "<<cuty<<endl;
      //Ranges of fitting 
      nbinsx = hdE->GetXaxis()->FindBin(38.);     
      nbinx0 = hdE->GetXaxis()->FindBin(maxt+4*merrx);

      //I set range of fitting in y
      Int_t up = hdE->GetYaxis()->GetNbins();
      nbinsy = up;            
      Int_t nentr = hdE->GetEntries();
      for(Int_t i=0; i<nbinsy; i++){
			if(i<maxy) continue;
			if(hdE->ProjectionX("hproj",i+1,i+1)->GetEntries()<0.0005*nentr){
	  			nbinsy = i+1; 
	}
      }
      
      cout<<"x range: "<<maxt+4*merrx<<" - "<<38.<<endl;
      cout<<"Y range: "<<hdE->GetYaxis()->GetBinCenter(nbinsy)<<endl;
     
      //3Hen peak position
      ym = maxdE;
      xm =  hdE->GetXaxis()->GetBinCenter(hdE->ProjectionX()->GetMaximumBin());
      cout<<" xm, ym: "<<xm<<" "<<ym<<endl;

      //Fit to profile - start parameters
      TF1* g0 = new TF1("g0","pol2",15.,38.);
      TProfile* pp;
      pp = hdE->ProfileX();
      pp->Fit("g0","IQ","0",maxt-5*merrx,/*hdE->GetXaxis()->GetBinCenter(nbinsx)*/38.);   
      
      //initialize TMinuit with a maximum of 3 params
      ierflg = 0;
      arglist[0] = 1;
      minuit->mnexcm("SET ERR", arglist ,1,ierflg);
      
      // Set starting values and step sizes for parameters
      if(bin<5){
		vstart[0] = g0->GetParameter(2);
		vstart[1] = g0->GetParameter(1);
//.........这里部分代码省略.........
开发者ID:mstechly,项目名称:root-marysia,代码行数:101,代码来源:Ifit2.C


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