//*CMZ : 0.90/09 03/12/96 17.45.55 by Rene Brun //*-- Author : Rene Brun 22/08/95 // ---------------------------------- minexam.C // Copyright (C) 1994 CodeCERN. All rights reserved. //______________________________________________________________________________ //*-*-*-*-*-*-*-*-*-*-*-*The Minuit standard test program-*-*-*-*-*-*-*-*-* //*-* ======================== * //*-* * //*-* This program is the translation to C++ of the minexam program * //*-* distributed with the Minuit/Fortran source file. * //*-* original author Fred James * //*-* * //*-* Fit randomly-generated leptonic K0 decays to the * //*-* time distribution expected for interfering K1 and K2, * //*-* with free parameters Re(X), Im(X), DeltaM, and GammaS. * //*-* * //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* /* #include "TROOT.h" #include "TMinuit.h" #include "TMath.h" #include "TStopwatch.h" #include #include #include #ifdef __SC__ long G__globalvarpointer; // To make the Symantec linker happy #endif */ int Error; extern void fcnk0(Int_t &npar, Double_t *gin, Double_t &f, Double_t *x, Int_t iflag); static ncount = 0; //VoidFuncPtr_t dictfuncs[] = { NULL }; //______________________________________________________________________________ TMinuitExample() { // TROOT minexam("TestMinuit","Test of Minuit", dictfuncs); static Int_t nprm[5] = { 0 , 1 , 4 , 9 , 10}; static Double_t vstrt[5] = {0. , 0. , .535 , .892 , 518.3}; static Double_t stp[5] = {0.1 , 0.1 , 0.1 , 0. , 0.}; static Double_t p0=0; static Double_t p1=1; static Double_t p3=3; static Double_t p5=5; Int_t ierflg = 0; const Int_t FIVE=5; const Int_t THREE=3; TStopwatch timer; TMinuit *gMinuit = new TMinuit(5); //initialize TMinuit with a maximum of 5 params cout<<"Starting timer"<mninit(5,6,7); gMinuit->SetFCN(fcnk0); /* gMinuit->mnparm(0, "Re(X)", vstrt[0], stp[0], 0,0,ierflg); gMinuit->mnparm(1, "Im(X)", vstrt[1], stp[1], 0,0,ierflg); gMinuit->mnparm(4, "Delta M", vstrt[2], stp[2], 0,0,ierflg); gMinuit->mnparm(9, "T Kshort", vstrt[3], stp[3], 0,0,ierflg); gMinuit->mnparm(10, "T Klong", vstrt[4], stp[4], 0,0,ierflg); */ gMinuit->mnparm(nprm[0], "Re(X)", vstrt[0], stp[0], 0,0,ierflg); gMinuit->mnparm(nprm[1], "Im(X)", vstrt[1], stp[1], 0,0,ierflg); gMinuit->mnparm(nprm[2], "Delta M", vstrt[2], stp[2], 0,0,ierflg); gMinuit->mnparm(nprm[3], "T Kshort", vstrt[3], stp[3], 0,0,ierflg); gMinuit->mnparm(nprm[4], "T Klong", vstrt[4], stp[4], 0,0,ierflg); if (ierflg) { Printf(" UNABLE TO DEFINE PARAMETER NO."); return ierflg; } // gMinuit->mnseti("Time Distribution of Leptonic K0 Decays"); //*-*- Request FCN to read in (or generate random) data (IFLAG=1) gMinuit->mnexcm("CALL FCN", &p1 ,1,ierflg); gMinuit->mnexcm("FIX", &p5 ,1,ierflg); gMinuit->mnexcm("SET PRINT", &p0 ,1,ierflg); gMinuit->mnexcm("MIGRAD", &p0 ,0,ierflg); gMinuit->mnexcm("MINOS", &p0 ,0,ierflg); //gMinuit->mnexcm("RELEASE", &p5 ,1,ierflg); //gMinuit->mnexcm("MIGRAD", &p0 ,0,ierflg); //gMinuit->mnexcm("MINOS", &p0 ,0,ierflg); //gMinuit->mnexcm("CALL FCN", &p3 , 1,ierflg); cout<<"Time at the end of job = "< 3) { ep = evp-thp; chi1 = (ep*ep)/evp; chisq = chisq + chi1; if (iflag != 4) { cout< 3) { em = evm-thm; chi2 = (em*em)/evm; chisq = chisq + chi2; if (iflag != 4) { cout<