Changeset 4358 for trunk/MagicSoft/Mars/mfit
- Timestamp:
- 06/28/04 16:34:45 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mfit
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mfit/MTFitLoop.cc
r3582 r4358 47 47 #include "MTFitLoop.h" 48 48 49 #include <TArrayD.h> 49 50 #include <TMinuit.h> 50 51 #include <TStopwatch.h> 51 52 52 53 #include "MParList.h" 54 #include "MTaskList.h" 55 #include "MEvtLoop.h" 56 57 #include "MParameters.h" 58 53 59 #include "MRead.h" 54 #include "MEvtLoop.h"55 60 56 61 #include "MLog.h" 57 62 #include "MLogManip.h" 63 64 ClassImp(MTFitLoop); 65 66 using namespace std; 58 67 59 68 //------------------------------------------------------------------------ … … 74 83 MParList *plist = fEvtLoop->GetParList(); 75 84 76 MParameterD *eval = (MParameterD*) plist->FindCreateObj("MParameterD", fFitParameter);77 MParContainer *pars = plist->FindObject(fParametersName);85 MParameterD *eval = (MParameterD*) plist->FindCreateObj("MParameterD", fFitParameter); 86 MParContainer *pars = (MParContainer*)plist->FindObject(fParametersName); 78 87 79 88 MRead *read = (MRead*)plist->FindObject("MTaskList")->FindObject("MRead"); … … 104 113 if (fDebug>=0) 105 114 { 106 *fLog << inf << "Set : ";107 for (Int_t i=0; i< 7; i++)115 *fLog << inf << "Set(" << gMinuit->fMaxpar << "): "; 116 for (Int_t i=0; i<gMinuit->fMaxpar; i++) 108 117 *fLog << par[i] << " "; 109 118 *fLog << endl; … … 129 138 } 130 139 131 MTFitLoop::MTFitLoop( )140 MTFitLoop::MTFitLoop(Int_t num) : fNum(num), fMaxIterations(1000) 132 141 { 133 142 fDebug = -1; … … 135 144 } 136 145 137 void MTFitLoop::Optimize(MEvtLoop &loop )146 void MTFitLoop::Optimize(MEvtLoop &loop, TArrayD &pars) 138 147 { 139 148 *fLog << inf << "Event loop was setup" << endl; 140 MParList *parlist = loop ->GetParList();149 MParList *parlist = loop.GetParList(); 141 150 if (!parlist) 142 151 return; 143 152 144 MParContainer *pars = plist->FindObject(fParametersName);145 if (!pars)146 return;147 148 fEvtLoop = evtloop;149 150 MParContainer ¶meters = *pars;153 // MParContainer *pars = (MParContainer*)parlist->FindObject(fParametersName); 154 // if (!pars) 155 // return; 156 157 fEvtLoop = &loop; 158 159 // MParContainer ¶meters = *pars; 151 160 152 161 TMinuit *minsave = gMinuit; 153 162 154 gMinuit = new TMinuit(par ameters.GetSize());163 gMinuit = new TMinuit(pars.GetSize()); 155 164 gMinuit->SetPrintLevel(-1); 165 gMinuit->SetMaxIterations(fMaxIterations); 156 166 157 167 gMinuit->SetFCN(fcn); … … 164 174 // less than 0.001*[tolerance]*UP (see [SET ERRordef])."); 165 175 // 166 if (gMinuit->SetErrorDef(1 000))176 if (gMinuit->SetErrorDef(1)) 167 177 { 168 178 *fLog << err << dbginf << "SetErrorDef failed." << endl; … … 173 183 // Set starting values and step sizes for parameters 174 184 // 175 for (Int_t i=0; i<par ameters.GetSize(); i++)185 for (Int_t i=0; i<pars.GetSize(); i++) 176 186 { 177 187 TString name = "par["; 178 188 name += i; 179 189 name += "]"; 180 Double_t vinit = par ameters[i];181 Double_t step = fabs(par ameters[i]/3);190 Double_t vinit = pars[i]; 191 Double_t step = fabs(pars[i]/3); 182 192 183 193 Double_t limlo = 0; // limlo=limup=0: no limits … … 192 202 } 193 203 194 for (int i=0; i<par ameters.GetSize(); i++)195 if ( i<fFixParams.GetSize() && fFixParams[i]!=0)204 for (int i=0; i<pars.GetSize() && i<fFixedParams.GetSize(); i++) 205 if (fFixedParams[i]!=0) 196 206 gMinuit->FixParameter(i); 197 else198 gMinuit->Release(i);199 207 200 208 // Now ready for minimization step: … … 217 225 // Update values of fA, fB: 218 226 // 219 for (Int_t i=0; i<par ameters.GetSize(); i++)227 for (Int_t i=0; i<pars.GetSize(); i++) 220 228 { 221 229 Double_t x1, x2; 222 230 gMinuit->GetParameter(i,x1,x2); 223 par ameters[i] = x1;224 cout << i << ": " << par ameters[i] << endl;225 } 226 227 list.SetVariables(parameters);231 pars[i] = x1; 232 cout << i << ": " << pars[i] << endl; 233 } 234 235 //list.SetVariables(pars); 228 236 229 237 gMinuit = minsave; -
trunk/MagicSoft/Mars/mfit/MTFitLoop.h
r3582 r4358 28 28 TArrayC fFixedParams; 29 29 30 Int_t fNum; 31 Int_t fMaxIterations; 32 30 33 public: 31 MTFitLoop( );34 MTFitLoop(const Int_t num=0); 32 35 33 void Optimize(MEvtLoop &loop );36 void Optimize(MEvtLoop &loop, TArrayD &pars); 34 37 35 38 void SetNameParameters(const char *parm) { fParametersName = parm; } … … 37 40 38 41 void SetFixedParameters(const TArrayC &c) { fFixedParams = c; } 42 void SetMaxIterations(Int_t maxiter=500) {fMaxIterations = maxiter;} // for debugging 39 43 40 44 void SetDebug(Int_t n) { fDebug = n; }
Note:
See TracChangeset
for help on using the changeset viewer.