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


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

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


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

示例1: fit

void fit(boot &A,boot &B,boot &C,bvec &X,bvec &Y)
{
  //copy X
  X_fit=new double[nens];
  for(int iens=0;iens<nens;iens++) X_fit[iens]=X[iens].med();
  Y_fit=new double[nens];
  err_Y_fit=new double[nens];
  
  TMinuit minu;
  minu.SetPrintLevel(-1);
  
  minu.DefineParameter(0,"A",0.0,0.0001,0,0);
  minu.DefineParameter(1,"B",0.0,0.0001,0,0);
  minu.DefineParameter(2,"C",0.0,0.0001,0,0);
  
  minu.SetFCN(chi2_wr);
  
  double C2;
  for(int iboot=0;iboot<nboot+1;iboot++)
    {
      if(iboot>0)
        minu.SetPrintLevel(-1);
      
      minu.DefineParameter(3,"a380",lat[0][iboot],0.0001,0,0);
      minu.DefineParameter(4,"a390",lat[1][iboot],0.0001,0,0);
      minu.DefineParameter(5,"a405",lat[2][iboot],0.0001,0,0);
      minu.DefineParameter(6,"a420",lat[3][iboot],0.0001,0,0);
      minu.FixParameter(3);
      minu.FixParameter(4);
      minu.FixParameter(5);
      minu.FixParameter(6);
      
      for(int iens=0;iens<nens;iens++)
        {
          Y_fit[iens]=Y.data[iens].data[iboot];
          err_Y_fit[iens]=Y.data[iens].err();
        }
      
      //minimize
      minu.Migrad();
      
      //get back parameters
      double dum;
      minu.GetParameter(0,A.data[iboot],dum);
      minu.GetParameter(1,B.data[iboot],dum);
      minu.GetParameter(2,C.data[iboot],dum);
      
      double lat_med[4]={lat[0].med(),lat[1].med(),lat[2].med(),lat[3].med()};
      if(iboot==0) C2=chi2(A.data[iboot],B[iboot],C[iboot],lat_med);
    }
  
  //calculate the chi2
  cout<<"A = ("<<A<<"), B=("<<B<<"), C=("<<C<<")"<<endl;
  cout<<"Chi2 = "<<C2<<" / "<<nens-3<<" = "<<C2/(nens-3)<<endl;
  
  delete[] X_fit;
  delete[] Y_fit;
  delete[] err_Y_fit;
}
开发者ID:sunpho84,项目名称:sunpho,代码行数:59,代码来源:fD_with_gh.cpp

示例2:

std::vector<double> run_fit(double parOOR, double parOEFG, double parOFTMR,
                            double parOTO, double parSRS) {
    TMinuit minuit;
    double arglist[10];
    int iflag;
    arglist[0] = -1;
    minuit.mnexcm("SET PRINT",arglist,1,iflag);
    minuit.mnexcm("SET NOW",arglist,0,iflag);
    minuit.SetFCN(fcn);
    arglist[0] = 2;
    minuit.mnexcm("SET STR",arglist,1,iflag);
    minuit.mnparm(0,"parOOR",parOOR,0.1,0,0,iflag);//or
    minuit.mnparm(1,"parEFG",parOEFG,0.1,0,0,iflag);//efgp
    minuit.mnparm(2,"parFTMR",parOFTMR,0.1,0,0,iflag);//ftr
    minuit.mnparm(3,"parTO",parOTO,0.1,0,0,iflag);//top
    minuit.mnparm(4,"parSRS",parSRS,0.1,0,0,iflag);//srs

    if (parSRS == 0)
        minuit.FixParameter(4);

    arglist[0] = 10000;
    arglist[1] = 0.0001;
    minuit.mnexcm("MIGRAD",arglist,2,iflag);
    minuit.mnexcm("HESSE",arglist,0,iflag);

    double fmin, fedm,errdef;
    int npari, nparx, istat;
    minuit.mnstat(fmin,fedm,errdef,npari,nparx,istat);

    double val,err;
    std::vector<double> ret_ary;
    for(int p = 0; p < 5; p++) {
        minuit.GetParameter(p, val, err);
        ret_ary.push_back(val);
    }
    ret_ary.push_back(fmin);

    return ret_ary;
}
开发者ID:soulish,项目名称:NCAA_C,代码行数:39,代码来源:generateWeights.cpp

示例3: fit

void fit(boot &A,boot &B,boot &C,boot &D)
{
  //copy ml
  ml_fit=new double[nens];
  for(int iens=0;iens<nens;iens++) ml_fit[iens]=ml[iens].med();
  
  //alloc dM2Pi and dM2K
  dM2Pi_fit=new double[nens];
  err_dM2Pi_fit=new double[nens];
  dM2K_fit=new double[nens];
  err_dM2K_fit=new double[nens];
  
  TMinuit minu;
  minu.SetPrintLevel(-1);
  
  int npars=4;
  minu.DefineParameter(0,"A",0.0,0.0001,0,0);
  minu.DefineParameter(1,"B",0.0,0.0001,0,0);
  minu.DefineParameter(2,"C",0.0,0.0001,0,0);
  minu.DefineParameter(3,"D",0.0,0.0001,0,0);
  minu.SetFCN(chi2_wr);
  
  double C2;
  for(int iboot=0;iboot<nboot+1;iboot++)
    {
      if(iboot>0) minu.SetPrintLevel(-1);
      
      minu.DefineParameter(4,"a380",lat[0][iboot],0.0001,0,0);
      minu.DefineParameter(5,"a390",lat[1][iboot],0.0001,0,0);
      minu.DefineParameter(6,"a405",lat[2][iboot],0.0001,0,0);
      minu.DefineParameter(7,"a420",lat[3][iboot],0.0001,0,0);
      minu.FixParameter(4);
      minu.FixParameter(5);
      minu.FixParameter(6);
      minu.FixParameter(7);
      
      for(int iens=0;iens<nens;iens++)
        {
          dM2Pi_fit[iens]=dM2Pi.data[iens].data[iboot];
          err_dM2Pi_fit[iens]=dM2Pi.data[iens].err();
          dM2K_fit[iens]=dM2K.data[iens].data[iboot];
          err_dM2K_fit[iens]=dM2K.data[iens].err();
        }
      
      //minimize
      minu.Migrad();
      
      //get back parameters
      double dum;
      minu.GetParameter(0,A.data[iboot],dum);
      minu.GetParameter(1,B.data[iboot],dum);
      minu.GetParameter(2,C.data[iboot],dum);
      minu.GetParameter(3,D.data[iboot],dum);
      
      double lat_med[4]={lat[0].med(),lat[1].med(),lat[2].med(),lat[3].med()};
      if(iboot==nboot) C2=chi2(A.data[iboot],B[iboot],C[iboot],D[iboot],lat_med,true);
    }
  
  //calculate the chi2
  cout<<"A=("<<A<<"), B=("<<B<<"), C=("<<C<<"), D=("<<D<<")"<<endl;
  cout<<"Chi2 = "<<C2<<" / "<<2*nens-npars<<" = "<<C2/(2*nens-npars)<<endl;
  
  delete[] ml_fit;
  delete[] dM2Pi_fit;
  delete[] err_dM2Pi_fit;
  delete[] dM2K_fit;
  delete[] err_dM2K_fit;
}
开发者ID:sunpho84,项目名称:sunpho,代码行数:68,代码来源:extr_deltaM2.cpp

示例4: parab_fit

void parab_fit(double ch2,jack &a,jack &b,jack &c,double *X,jvec Y,const char *path,bool fl_parab=1)
{
  ofstream out(path);
  out<<"@type xydy\n";
  
  double MX=0;
  //copy X
  nc_fit=Y.nel;
  X_fit=new double[nc_fit];
  for(int iel=0;iel<nc_fit;iel++)
    if(use[iel])
    {
      X_fit[iel]=X[iel];
      out<<X[iel]<<" "<<Y[iel]<<endl;
      if(X[iel]>MX) MX=X[iel];
    }
  Y_fit=new double[nc_fit];
  err_Y_fit=new double[nc_fit];
  
  TMinuit minu;
  minu.SetPrintLevel(0);
  
  int npars=3;
  minu.DefineParameter(0,"A",0.0,0.0001,0,0);
  minu.DefineParameter(1,"B",0.0,0.0001,0,0);
  minu.DefineParameter(2,"C",0.0,0.0001,0,0);
  if(!fl_parab)
    {
      minu.FixParameter(0);
      npars--;
    }
  minu.SetFCN(chi2_wr);
  
  for(int ijack=0;ijack<=njack;ijack++)
    {
      minu.DefineParameter(2,"C",fixed_A[ijack],0.0001,0,0);
      minu.FixParameter(2);
      if(ijack>0)
        minu.SetPrintLevel(-1);
      
      for(int iel=0;iel<nc_fit;iel++)
        {
          Y_fit[iel]=Y.data[iel].data[ijack];
          err_Y_fit[iel]=Y[iel].err();
        }
      
      //minimize
      minu.Migrad();
      
      //get back parameters
      double dum;
      minu.GetParameter(0,a.data[ijack],dum);
      minu.GetParameter(1,b.data[ijack],dum);
      minu.GetParameter(2,c.data[ijack],dum);
    }
  
  out<<"&\[email protected] xy\n";
  for(double t=0;t<MX;t+=MX/100)
    out<<t<<" "<<parab(a[njack],b[njack],c[njack],t)<<endl;
  
  out.close();
}
开发者ID:sunpho84,项目名称:sunpho,代码行数:62,代码来源:disp_rel.cpp

示例5: runAngleOpt

void runAngleOpt() {

  gSystem->AddIncludePath("-I${ANITA_UTIL_INSTALL_DIR}/include");

  double startVal=0;               
  double stepSize=0.1;       
  double minVal=-2;           
  double maxVal=2;            
  Double_t p0 = 0;

  //Load libraries. Need to have ANITA_UTIL_INSTALL_DIR/lib and ROOTSYS/lib in the LD_LIBRARY_PATH               
  gSystem->Load("libfftw3.so");
  gSystem->Load("libMathMore.so");
  gSystem->Load("libPhysics.so");  
  gSystem->Load("libGeom.so");  
  gSystem->Load("libMinuit.so");  
  gSystem->Load("libRootFftwWrapper.so");         
  gSystem->Load("libAnitaEvent.so");      
  gSystem->Load("libAnitaCorrelator.so");

  AnitaGeomTool *fGeomTool = AnitaGeomTool::Instance();
  gSystem->CompileMacro("anglePlotterOpt.C","k");
  
  Double_t relDeltaOut=0;

  TMinuit *myMin = new TMinuit(1);
  myMin->SetObjectFit(anglePlotterOpt);
  myMin->SetFCN(iHateRoot);
  //setArray();

  for(int u = 0; u < 1; u++){

    int middle = 16;

      for(int y = 16; y <32; y++){

	int leftOpt, rightOpt;
	fGeomTool->getThetaPartners(middle,leftOpt,rightOpt); 


	myMin->DefineParameter(0, "antNum", middle, stepSize, minVal, maxVal);
	myMin->FixParameter(0);  
    
	myMin->DefineParameter(1, "deltaT", startVal, stepSize, minVal, maxVal);

  
	Double_t deltaT,deltaTErr;
  
	//*********MINUIT METHOD*******************
	myMin->SetPrintLevel(-1);
	myMin->Migrad();   
	myMin->GetParameter(1,deltaT,deltaTErr);

  

	setValue(rightOpt,deltaT);

	//	printArray();

	//	cout << middle << "  " << rightOpt << "  " << deltaT << endl;
  
	cout << "deltaTArrayMod[" << rightOpt << "] = " << deltaT << ";" << endl;

	middle = rightOpt;

      }

  }

  
  //   myMin->DeleteArrays();

  //   myMin->DeleteArrays();

  
}
开发者ID:anitaNeutrino,项目名称:anitaEventCorrelator,代码行数:76,代码来源:runAngleOpt.C

示例6: testZeeMCSmearWithScale


//.........这里部分代码省略.........
    smearcat[2] = 0.015;
    smearcat[3] = 0.02;
    
    if(fitdet==2){
      smearcat[0] = 0.02;
      smearcat[1] = 0.02;
      smearcat[2] = 0.02;
      smearcat[3] = 0.02;
    }
    
  }
  

  for(int j=0; j<4; j++){
    TString parname = TString (Form("smearcat%d",j));
    if(smearMethod=="corrSmear"){
      minuit->mnparm(j, parname, smearcat[j], STEPMN, 0.5,smearcatMax[j],ierflg);
    }else  if(smearMethod=="uncorrSmear"){
      minuit->mnparm(j, parname, smearcat[j], STEPMN, 0,smearcatMax[j],ierflg);
    }

    fitpar[j] = smearcat[j]; //initialized values
  }
  
  for(int j=4; j<npar; j++){
    TString parname = TString (Form("scalecat%d",j-4));
    minuit->mnparm(j, parname, deltaEcat[j-4], STEPMN, -0.03,0.03,ierflg);
    fitpar[j] = deltaEcat[j-4]; //initialized values
  }
  

  if(fixscale==1){
    for(int j=4; j<npar; j++){
      minuit->FixParameter(j);
    }
  }
  


  if(testpaircat==1){
    minuit->FixParameter(0);
    minuit->FixParameter(2);
    minuit->FixParameter(3);

    minuit->FixParameter(4);
    minuit->FixParameter(6);
    minuit->FixParameter(7);

  }else if( testpaircat==0){
    minuit->FixParameter(1);
    minuit->FixParameter(2);
    minuit->FixParameter(3);

    minuit->FixParameter(5);
    minuit->FixParameter(6);
    minuit->FixParameter(7);

  } else if( testpaircat==2){
    minuit->FixParameter(0);
    minuit->FixParameter(1);
    minuit->FixParameter(3);

    minuit->FixParameter(4);
    minuit->FixParameter(5);
    minuit->FixParameter(7);
开发者ID:sixie,项目名称:CITHZZ,代码行数:66,代码来源:testZeeMCSmearWithScale.C

示例7: runQuickOptAllAntFixedZ

void runQuickOptAllAntFixedZ() {
  
  gSystem->AddIncludePath("-I${ANITA_UTIL_INSTALL_DIR}/include");
  
  double startVal=0;               
  double stepSize=0.05;       
  double minVal=-0.5;           
  double maxVal=0.5;            
  Double_t p0 = 0;

  //Load libraries. Need to have ANITA_UTIL_INSTALL_DIR/lib and ROOTSYS/lib in the LD_LIBRARY_PATH               
  gSystem->Load("libfftw3.so");
  gSystem->Load("libMathMore.so");
  gSystem->Load("libPhysics.so");  
  gSystem->Load("libGeom.so");  
  gSystem->Load("libMinuit.so");  
  gSystem->Load("libRootFftwWrapper.so");         
  gSystem->Load("libAnitaEvent.so");      
  gSystem->Load("libAnitaCorrelator.so");

  AnitaGeomTool *fGeomTool = AnitaGeomTool::Instance();
  gSystem->CompileMacro("quickOptAllAntFixedZ.C","k");

  fillArrays(eventNumberIndex, thetaWaveIndex, phiWaveIndex, antIndex1, antIndex2, maxCorrTimeIndex, adjacent);
  
  Double_t relDeltaOut=0;

  TMinuit *myMin = new TMinuit(192);
  myMin->SetObjectFit(quickOptAllAntFixedZ);
  myMin->SetFCN(iHateRoot);
//   myMin->SetMaxIterations(2);
  //myMin->SetErrorDef(1000);

//   int ierflg;
//   double eps[1] = {2.};
//   myMin->mnexcm("SET EPS", eps, 1, ierflg);
  //setArray();

  double startValR[MAX_ANTENNAS] ={0};
  double startValZ[MAX_ANTENNAS] ={0};
  double startValPhi[MAX_ANTENNAS] ={0};
  double startValCableDelays[MAX_ANTENNAS] ={0};
  
  
  for(int y = 0; y <MAX_ANTENNAS; y++){
    
    char name[30];
    sprintf(name,"r%d",y);
    myMin->DefineParameter(y, name, startValR[y], stepSize, -0.1, 0.1);
    sprintf(name,"z%d",y);
    myMin->DefineParameter(y+MAX_ANTENNAS, name, startValZ[y], stepSize, -0.1, 0.1);
    myMin->FixParameter(y+MAX_ANTENNAS);
    sprintf(name,"phi%d",y);
    myMin->DefineParameter(y+MAX_ANTENNAS*2, name, startValPhi[y], stepSize, -0.1, 0.1);
    sprintf(name,"cable%d",y);
    myMin->DefineParameter(y+MAX_ANTENNAS*3, name, startValCableDelays[y], stepSize, -0.5, 0.5);
  }
  
  
  
  Double_t deltaR[MAX_ANTENNAS],deltaRErr[MAX_ANTENNAS];
  Double_t deltaZ[MAX_ANTENNAS],deltaZErr[MAX_ANTENNAS];
  Double_t deltaPhi[MAX_ANTENNAS],deltaPhiErr[MAX_ANTENNAS];
  Double_t deltaCableDelays[MAX_ANTENNAS],deltaCableDelaysErr[MAX_ANTENNAS];
  
  //*********MINUIT METHOD*******************
//   myMin->SetPrintLevel(-1);
  myMin->Migrad();
  //  int error_flag;
  //  myMin->mnexcm("MINOS",0,0,error_flag);  

  ofstream newfile("newLindaNumbersCableDelays_ALLANTENNAS_RMS_GRAD_FixedZ.txt");
  for(int u = 0; u <MAX_ANTENNAS; u++){
    myMin->GetParameter(u,deltaR[u],deltaRErr[u]);
    cout << "deltaR[" << u << "] = " << deltaR[u] << " +/- " << deltaRErr[u] << endl;
	
    
    myMin->GetParameter(u+MAX_ANTENNAS,deltaZ[u],deltaZErr[u]);
    cout << " deltaZ[" << u << "] = " << deltaZ[u] << " +/- " << deltaZErr[u] << endl;
    
    myMin->GetParameter(u+MAX_ANTENNAS*2,deltaPhi[u],deltaPhiErr[u]);
    cout << " deltaPhi[" << u << "] = " << deltaPhi[u] << " +/- " << deltaPhiErr[u] << endl;

    myMin->GetParameter(u+MAX_ANTENNAS*3,deltaCableDelays[u],deltaCableDelaysErr[u]);
    cout << " deltaCableDelays[" << u << "] = " << deltaCableDelays[u]  << " +/- " << deltaCableDelaysErr[u] << endl;
    
    newfile << u << "  " << deltaR[u]<< "  " << deltaZ[u]<< "  " << deltaPhi[u]<< "  " << deltaCableDelays[u] << endl;


  }
  
  
  cout << "Easy table" << endl;
  for(int u = 0; u <MAX_ANTENNAS; u++)  cout << u << " & " << deltaR[u]<< " & " << deltaZ[u]<< " & " << deltaPhi[u]<< " & " << deltaCableDelays[u] << endl;

  
}
开发者ID:strutt,项目名称:antennaPositionCalib,代码行数:97,代码来源:runQuickOptAllAntFixedZ.C

示例8: main


//.........这里部分代码省略.........
   gMinuit->SetPrintLevel(-1);
   Double_t arglist[10];
   Int_t ierflg = 0;
   int NoPar = 6;
   
   bool AntFit = false;
   
   if(AntFit){
   // Antenna Fit Settings
   //++++++++++++++++++++++
   cout << "Antenna Fit" << endl;
   cout << "+++++++++++" << endl;
   
   gMinuit->SetFCN(FcnParFS);
   
// no effect
  arglist[0] = 1;
  gMinuit->mnexcm("SET ERR", arglist ,1,ierflg);

  arglist[0] = 1;
  gMinuit->mnexcm("SET STRATEGY", arglist, 1, ierflg);
  

   gMinuit->mnparm(0, "scale",  1., 0.01, 0, 0, ierflg);
   gMinuit->mnparm(1, "r0",    400., 1, 0, 0, ierflg);
   gMinuit->mnparm(2, "Epower",  1., 0.01, 0.8, 1.2, ierflg);
//   gMinuit->mnparm(2, "Epower",  1., 0.1, 0, 0, ierflg);
   gMinuit->mnparm(3, "Zphase",  0., 0.1, -TMath::Pi()*2, TMath::Pi()*2, ierflg);
   gMinuit->mnparm(4, "Bphase",  0., 0.1, -TMath::Pi()*2, TMath::Pi()*2, ierflg);
   gMinuit->mnparm(5, "offset",  2., 0.1, 0, 0, ierflg);
//   gMinuit->FixParameter(0);
//   gMinuit->FixParameter(2);

   gMinuit->FixParameter(3);
   gMinuit->FixParameter(4);
   gMinuit->FixParameter(5);
   }
   else{
   // Channel Fit Settings
   //+++++++++++++++++++++
   cout << "Channel Fit" << endl;
   cout << "+++++++++++" << endl;

   gMinuit->SetFCN(FcnParFSChannel);
   
// no effect
  arglist[0] = 1;
  gMinuit->mnexcm("SET ERR", arglist ,1,ierflg);

  arglist[0] = 1;
  gMinuit->mnexcm("SET STRATEGY", arglist, 1, ierflg);
  
   gMinuit->mnparm(0, "scale",  1., 0.01, 0.1, 100, ierflg);
   gMinuit->mnparm(1, "r0",    400., 1, 100, 1000, ierflg);
   gMinuit->mnparm(2, "Epower",  1., 0.01, 0.8, 1.2, ierflg);
//   gMinuit->mnparm(2, "Epower",  1., 0.01, 0, 0, ierflg);
   gMinuit->mnparm(3, "Zphase",  0., 0.1, -TMath::Pi()*2, TMath::Pi()*2, ierflg);
   gMinuit->mnparm(4, "Bphase",  0., 0.1, -TMath::Pi()*2, TMath::Pi()*2, ierflg);
   gMinuit->mnparm(5, "offset",  2., 0.1, 0, 0, ierflg);
//   gMinuit->FixParameter(0);
//   gMinuit->FixParameter(2);

   gMinuit->FixParameter(3);
   gMinuit->FixParameter(4);
   gMinuit->FixParameter(5);
   }
开发者ID:lbaehren,项目名称:lofarsoft,代码行数:67,代码来源:FitParFieldStrength.cpp

示例9: testEnergySmearZee


//.........这里部分代码省略.........
  double deltaEcat[4] = {0,0,0,0};
  
  smearcatMax[0] = 0.05;
  smearcatMax[1] = 0.05;
  smearcatMax[2] = 0.05;
  smearcatMax[3] = 0.05;
  
  smearcat[0] = 0.005;
  smearcat[1] = 0.01;
  smearcat[2] = 0.015;
  smearcat[3] = 0.02;
  
  if(barrelorEndcap==2){
    smearcat[0] = 0.02;
    smearcat[1] = 0.02;
    smearcat[2] = 0.02;
    smearcat[3] = 0.02;
  }
  
  for(int j=0; j<4; j++){
    TString parname = TString (Form("smearcat%d",j));
    minuit->mnparm(j, parname, smearcat[j], STEPMN, 0,smearcatMax[j],ierflg);
    fitpar[j] = smearcat[j]; //initialized values
  }
  
  for(int j=4; j<npar; j++){
    TString parname = TString (Form("scalecat%d",j-4));
    minuit->mnparm(j, parname, deltaEcat[j-4], STEPMN, -0.03,0.03,ierflg);
    fitpar[j] = deltaEcat[j-4]; //initialized values
  }

  if(fixscale==1){
    for(int j=4; j<npar; j++){
      minuit->FixParameter(j);
    }
  }

  int testpaircat = testcat; 
  
  if(testpaircat==1){
    minuit->FixParameter(0);
    minuit->FixParameter(2);
    minuit->FixParameter(3);

    minuit->FixParameter(4);
    minuit->FixParameter(6);
    minuit->FixParameter(7);

  }else if( testpaircat==0){
    minuit->FixParameter(1);
    minuit->FixParameter(2);
    minuit->FixParameter(3);

    minuit->FixParameter(5);
    minuit->FixParameter(6);
    minuit->FixParameter(7);

  } else if( testpaircat==2){
    minuit->FixParameter(0);
    minuit->FixParameter(1);
    minuit->FixParameter(3);

    minuit->FixParameter(4);
    minuit->FixParameter(5);
    minuit->FixParameter(7);
开发者ID:sixie,项目名称:CITHZZ,代码行数:66,代码来源:testEnergySmearZee.C

示例10: runQuickOptAllAntStepsLDBHPOL

void runQuickOptAllAntStepsLDBHPOL() {
  
  gSystem->AddIncludePath("-I${ANITA_UTIL_INSTALL_DIR}/include");
  
  double startVal=0;               
  double stepSize=0.01;       
  double minVal=-0.5;           
  double maxVal=0.5;            
  Double_t p0 = 0;

  //Load libraries. Need to have ANITA_UTIL_INSTALL_DIR/lib and ROOTSYS/lib in the LD_LIBRARY_PATH               
  gSystem->Load("libfftw3.so");
  gSystem->Load("libMathMore.so");
  gSystem->Load("libPhysics.so");  
  gSystem->Load("libGeom.so");  
  gSystem->Load("libMinuit.so");  
  gSystem->Load("libRootFftwWrapper.so");         
  gSystem->Load("libAnitaEvent.so");      
  gSystem->Load("libAnitaCorrelator.so");

  AnitaGeomTool *fGeomTool = AnitaGeomTool::Instance();
  fGeomTool->useKurtAnita3Numbers(1);
  gSystem->CompileMacro("quickOptAllAntStepsLDBHPOL.C","k");

  fillArrays(eventNumberIndex, thetaWaveIndex, phiWaveIndex, antIndex1, antIndex2, maxCorrTimeIndex, adjacent);
  
  Double_t relDeltaOut=0;

  TMinuit *myMin = new TMinuit(192);
  myMin->SetObjectFit(quickOptAllAntStepsLDBHPOL);
  myMin->SetFCN(iHateRoot);
 //   myMin->SetMaxIterations(2);
  //myMin->SetErrorDef(1000);

//   int ierflg;
//   double eps[1] = {2.};
//   myMin->mnexcm("SET EPS", eps, 1, ierflg);
  //setArray();

  double minValCableDelays[MAX_ANTENNAS] ={0};
  double maxValCableDelays[MAX_ANTENNAS] ={0};

  Double_t deltaR[MAX_ANTENNAS] = {0};
  Double_t deltaRErr[MAX_ANTENNAS] = {0};
  Double_t deltaZ[MAX_ANTENNAS] = {0};
  Double_t deltaZErr[MAX_ANTENNAS] = {0};
  Double_t deltaPhi[MAX_ANTENNAS] = {0};
  Double_t deltaPhiErr[MAX_ANTENNAS] = {0};
  Double_t deltaCableDelays[MAX_ANTENNAS] = {0};
  Double_t deltaCableDelaysErr[MAX_ANTENNAS] = {0};

  //  Double_t globalDeltaz = 0.242575;
  Double_t globalDeltaz = 0.03;
  
  //Min global   deltaZ[] = -0.242575 +/- 0.00198264

  for(int y = 0; y <MAX_ANTENNAS; y++){
 
    deltaR[y] = 0;//-0.05;
    deltaCableDelays[y] = 0. - (y==47)*0.35;
    minValCableDelays[y] = deltaCableDelays[y] - 0.15;
    maxValCableDelays[y] = deltaCableDelays[y] + 0.15;
    deltaZ[y] = 0;//(y<16)*(-globalDeltaz) + (y>15)*globalDeltaz;

    char name[30];
    sprintf(name,"r%d",y);
    myMin->DefineParameter(y, name, deltaR[y], stepSize, -0.3, 0.3);
    sprintf(name,"z%d",y);
    myMin->DefineParameter(y+MAX_ANTENNAS, name, deltaZ[y], stepSize, -0.3, 0.3);
    sprintf(name,"phi%d",y);
    myMin->DefineParameter(y+MAX_ANTENNAS*2, name, deltaPhi[y], stepSize, -0.3, 0.3);
    sprintf(name,"cable%d",y);
    myMin->DefineParameter(y+MAX_ANTENNAS*3, name, deltaCableDelays[y], stepSize, minValCableDelays[y], maxValCableDelays[y]);
  }



  for(int y = 0; y <MAX_ANTENNAS; y++){
    myMin->FixParameter(y); // fixed R 
    myMin->FixParameter(y+MAX_ANTENNAS); // fixed Z
    myMin->FixParameter(y+MAX_ANTENNAS*2); // fixed phi
    //    myMin->FixParameter(y+MAX_ANTENNAS*3); // fixed t

  }

  myMin->FixParameter(MAX_ANTENNAS*3); // fixed t0

  //*********MINUIT METHOD*******************
//   myMin->SetPrintLevel(-1);
  myMin->Migrad();
  //  int error_flag;
  //  myMin->mnexcm("MINOS",0,0,error_flag);  



  for(int u = 0; u <MAX_ANTENNAS; u++){
    myMin->GetParameter(u+MAX_ANTENNAS*3,deltaCableDelays[u],deltaCableDelaysErr[u]);
    cout << " deltaCableDelays[" << u << "] = " << deltaCableDelays[u]  << " +/- " << deltaCableDelaysErr[u] << endl;

    //    myMin->GetParameter(u+MAX_ANTENNAS,deltaZ[u],deltaZErr[u]);
//.........这里部分代码省略.........
开发者ID:strutt,项目名称:antennaPositionCalib,代码行数:101,代码来源:runQuickOptAllAntStepsLDBHPOL.C

示例11: fit

void fit(boot &A,boot &B,boot &C,boot &D,bvec &X,bvec &Y)
{
  //copy X
  X_fit=new double[nens];
  for(int iens=0;iens<nens;iens++) X_fit[iens]=X[iens].med();
  Y_fit=new double[nens];
  err_Y_fit=new double[nens];
  
  TMinuit minu;
  minu.SetPrintLevel(-1);
  
  int npars=4;
  minu.DefineParameter(0,"A",0.0,0.0001,0,0);
  minu.DefineParameter(1,"B",0.0,0.0001,0,0);
  minu.DefineParameter(2,"C",0.0,0.0001,0,0);
  minu.DefineParameter(3,"D",0.0,0.0001,0,0);
  if(!include_a4)
    {
      minu.FixParameter(3);
      npars--;
    }
  if(!include_ml_term)
    {
      minu.FixParameter(1);
      npars--;
    }
  minu.SetFCN(chi2_wr);
  
  double C2;
  for(int iboot=0;iboot<nboot+1;iboot++)
    {
      if(iboot>0)
        minu.SetPrintLevel(-1);
      
      minu.DefineParameter(4,"a380",lat[0][iboot],0.0001,0,0);
      minu.DefineParameter(5,"a390",lat[1][iboot],0.0001,0,0);
      minu.DefineParameter(6,"a405",lat[2][iboot],0.0001,0,0);
      minu.DefineParameter(7,"a420",lat[3][iboot],0.0001,0,0);
      minu.FixParameter(4);
      minu.FixParameter(5);
      minu.FixParameter(6);
      minu.FixParameter(7);
      
      for(int iens=0;iens<nens;iens++)
        {
          Y_fit[iens]=Y.data[iens].data[iboot];
          err_Y_fit[iens]=Y.data[iens].err();
        }
      
      //minimize
      minu.Migrad();
      
      //get back parameters
      double dum;
      minu.GetParameter(0,A.data[iboot],dum);
      minu.GetParameter(1,B.data[iboot],dum);
      minu.GetParameter(2,C.data[iboot],dum);
      minu.GetParameter(3,D.data[iboot],dum);
      
      double lat_med[4]={lat[0].med(),lat[1].med(),lat[2].med(),lat[3].med()};
      if(iboot==nboot)
        {
          contr_flag=1;
          C2=chi2(A.data[iboot],B[iboot],C[iboot],D[iboot],lat_med);
          contr_flag=0;
        }
    }
  
  int ninc_ens=0;
  for(int iens=0;iens<nens;iens++)
    if(ibeta[iens]!=0 || include_380) ninc_ens++;
  
  //calculate the chi2
  cout<<"A=("<<A<<"), B=("<<B<<"), C=("<<C<<"), D=("<<D<<")"<<endl;
  cout<<"Chi2 = "<<C2<<" / "<<ninc_ens-npars<<" = "<<C2/(ninc_ens-npars)<<endl;
  
  delete[] X_fit;
  delete[] Y_fit;
  delete[] err_Y_fit;
}
开发者ID:sunpho84,项目名称:sunpho,代码行数:80,代码来源:extr_adim.cpp


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