Inheritance diagram for NC::GetChiSqrFromDerived:

Public Member Functions | |
| GetChiSqrFromDerived () | |
| GetChiSqrFromDerived (NCExtrapolation *P, std::vector< NCParameter > pars, bool penalty, bool analyticNorm) | |
| virtual | ~GetChiSqrFromDerived () |
| double | EvalAtEx (const CoordNDim &r, CoordNDim *ret) const |
| Find the value of the function and return additional information. | |
| void | UsePenalty (bool p) |
| void | DrawAndWriteGraph () const |
Private Attributes | |
| NCExtrapolation * | p |
| std::vector< NCParameter > | params |
| bool | usePenalty |
| bool | fAnalyticNormalization |
Static Private Attributes | |
| std::map< CoordNDim, double > | cache |
| std::vector< CoordNDim > | evaledAt |
| std::vector< double > | chisqRets |
Additionally keep a cache to speed up repeated queries. Evaluates points outside the physical region using a penalty term.
Definition at line 33 of file NCFitMaster.cxx.
|
|
Definition at line 36 of file NCFitMaster.cxx. 00036 {}
|
|
||||||||||||||||||||
|
Definition at line 37 of file NCFitMaster.cxx. 00041 :p(P), params(pars), usePenalty(penalty), 00042 fAnalyticNormalization(analyticNorm){}
|
|
|
Definition at line 43 of file NCFitMaster.cxx. 00043 {} // shut gcc up
|
|
|
Definition at line 136 of file NCFitMaster.cxx. References evaledAt. 00137 {
00138 TCanvas c("minimizer_eval_positions");
00139 TH2D axes("", "Evaluation Positions;time;", 100, 0, evaledAt.size(), 100, -1, 5);
00140 axes.Draw();
00141 for(unsigned int m = 0; m < evaledAt[0].size(); ++m){
00142 TGraph* g = new TGraph;
00143 g->Set(evaledAt.size());
00144 g->SetMarkerColor(m+1);
00145 for(unsigned int n = 0; n < evaledAt.size(); ++n){
00146 g->SetPoint(n, n, evaledAt[n][m]);
00147 g->Draw("p same");
00148 }
00149 }
00150
00151 c.Write();
00152 }
|
|
||||||||||||
|
Find the value of the function and return additional information.
Implements NC::Fitter::ICallableND. Definition at line 65 of file NCFitMaster.cxx. References cache, chisqRets, NC::Fitter::CoordNDim, evaledAt, fAnalyticNormalization, NCExtrapolation::FindChiSqrForPars(), NCExtrapolation::GetCoordConv(), NC::CoordinateConverter::OscParsFromCoordNDim(), p, params, and NC::CoordinateConverter::SystParsFromCoordNDim(). 00067 {
00068 if(retCoord) *retCoord = r;
00069
00070 evaledAt.push_back(r);
00071
00072 const map<CoordNDim, double>::const_iterator it = cache.find(r);
00073 if(it != cache.end()){
00074 // cout << "chisq from cache " << r << endl;
00075 chisqRets.push_back(it->second);
00076 return it->second;
00077 }
00078 // Maximum cache size is arbitrary, tune for performance.
00079 const unsigned int maxCacheSize = int(1e7); // on the order of 10meg
00080 if(cache.size() > maxCacheSize) cache.clear();
00081 //cout << "UNCACHED CHISQ REQUESTED " << r << endl;
00082
00083 CoordNDim evalAt = r;
00084
00085 if(usePenalty){
00086 // If the point is outside the physical region - move it to the boundary
00087 for(unsigned int n = 0; n < params.size(); ++n){
00088 if(params[n].UseLimits()){
00089 if(r[n] < params[n].Min()) evalAt[n] = params[n].Min();
00090 if(r[n] > params[n].Max()) evalAt[n] = params[n].Max();
00091 }
00092 }
00093 }
00094
00095 const CoordinateConverter* cc = p->GetCoordConv();
00096 NC::OscProb::OscPars* oscPars = cc->OscParsFromCoordNDim(evalAt);
00097
00098 double norm = 1;
00099 double ret = p->FindChiSqrForPars(oscPars,
00100 cc->SystParsFromCoordNDim(evalAt),
00101 fAnalyticNormalization ? &norm : 0);
00102
00103 // TODO WE NEED TO STORE NORM INTO RETCOORD, BUT DON'T KNOW WHICH ONE!
00104
00105 delete oscPars;
00106
00107 if(usePenalty){
00108 // If we had to move the point then apply a quadratic penalty term.
00109 // The factor of 1000 was arrived at through trial and error.
00110 const double amplitude = 1e3;
00111 for(unsigned int n = 0; n < params.size(); ++n){
00112 if(params[n].UseLimits()){
00113 const double wsqr = (params[n].Min()-params[n].Max())*(params[n].Min()-params[n].Max());
00114 assert(wsqr);
00115 if(r[n] < params[n].Min())
00116 ret += amplitude*(params[n].Min()-r[n])*(params[n].Min()-r[n])/wsqr;
00117 if(r[n] > params[n].Max())
00118 ret += amplitude*(r[n]-params[n].Max())*(r[n]-params[n].Max())/wsqr;
00119 }
00120 }
00121 }
00122
00123 // for(unsigned int n = 0; n < evalAt.size(); ++n)
00124 // cout << names[n] << " = " << evalAt[n] << " ";
00125 // cout << "-> " << ret << endl;
00126
00127 // TODO - this cache is broken when using more than one extrapolation
00128 // disable it for now
00129 // cache[r] = ret;
00130 chisqRets.push_back(ret);
00131
00132 return ret;
00133 }
|
|
|
Definition at line 45 of file NCFitMaster.cxx. 00045 {usePenalty = p;}
|
|
|
Definition at line 60 of file NCFitMaster.cxx. Referenced by EvalAtEx(). |
|
|
Definition at line 62 of file NCFitMaster.cxx. Referenced by EvalAtEx(). |
|
|
Definition at line 61 of file NCFitMaster.cxx. Referenced by DrawAndWriteGraph(), and EvalAtEx(). |
|
|
Definition at line 53 of file NCFitMaster.cxx. Referenced by EvalAtEx(). |
|
|
Definition at line 48 of file NCFitMaster.cxx. Referenced by EvalAtEx(). |
|
|
Definition at line 51 of file NCFitMaster.cxx. Referenced by EvalAtEx(). |
|
|
Definition at line 52 of file NCFitMaster.cxx. |
1.3.9.1