NC::Fitter Namespace Reference

Classes

class  ConstrainRange
 This class supports the function flipping in MinFinderSimple. More...
class  Discretizer
class  Penalizer
class  PenalizerInt
class  FuncCache
class  FuncCacheInt
class  MinFinderSimple
class  MinFinderSimpleInt
class  FixVars
 Effectively reduce the number of arguments taken by fun. More...
class  FixVarsInt
 Effectively reduce the number of arguments taken by fun. More...
class  MarginalizeSimple
 Minimize callable f with respect to all its arguments except xcoord and (optionally) ycoord. More...
class  MarginalizeSimpleInt
 Minimize callable f with respect to all its arguments except xcoord and (optionally) ycoord. More...
class  MinuitForCallable
class  MarginalizeHybrid
class  CoordBase
 Base class for coordinate types. More...
struct  Coord
 A simple two-dimensional coordinate. More...
class  ICallableND
 Interface to a general function in many dimensions. More...
class  ICallableInt
 Interface to a function on integers in many dimensions. More...
class  ICallable2D
 Interface to a function on two-dimensional coordinates. More...

Typedefs

typedef CoordBase< double > CoordNDim
 An N-dimensional coordinate.
typedef CoordBase< int > CoordInt
 An N-dimensional coordinate in integer space.

Functions

CoordNDim ConvertCoord (const CoordInt &c, std::vector< NCParameter > ps)
CoordNDim ConvertContourCoord (const CoordNDim &c, vector< NCParameter > ps)
 This final one is intended to be used on the output of FindContourInt.
ostream & operator<< (ostream &os, const FuncCache &c)
ostream & operator<< (ostream &os, const FuncCacheInt &c)
double MinFinderMinuit (const ICallableND *chiSqrFunc, const std::vector< NCParameter > params, CoordNDim &ret, TMinuit **ppMinu)
std::vector< CoordFindContour (const ICallable2D *func, const Coord &minCoord, const double height, const Coord &precision, std::vector< TGraph > *marg_graphs)
 Find contour of height height in the function func.
TMatrix FindCovarianceMatrix (const ICallableND *func, const CoordNDim &minCoord, const std::vector< NCParameter > params)
bool Interpolate (double val1, double val2, double target, double &ret)
std::vector< CoordNDimFindContourInt (const ICallableInt *func_org, const CoordInt &minCoord, const double height, std::vector< TGraph > *marg_graphs)
 Find contour of height height in the function func.
TH2D * GetLowResGrid (const ICallable2D *func, const Coord min, const Coord max, const Coord prec)
TH2D * GridSearchInt (const ICallableInt *func, const CoordInt min, const CoordInt max)
TH2D * ConvertGrid (const TH2D *intgrid, const NCParameter &xp, const NCParameter &yp)
TGraph * CreateOneDimProjection (const ICallable2D *func, const NCParameter param, const double minVal, double &leftErr, double &rightErr, std::vector< TGraph > &marg_graphs)
TGraph CreateOneDimProjectionInt (const ICallableInt *func, int minstep, int maxstep, double &leftErr, double &rightErr)
vector< TGraph > MakeSlices (const ICallableND *func, const vector< NCParameter > &ps, const CoordNDim &minpos)
vector< TH2D * > Make2DSlices (const ICallableND *func, const vector< NCParameter > &ps, const CoordNDim &minpos)
void PrintGridSearch (const ICallableND *func, const std::vector< NCParameter > &params, std::ostream &out)
CoordNDim ConvertContourCoord (const CoordNDim &c, std::vector< NCParameter > ps)
std::ostream & operator<< (std::ostream &os, const FuncCache &c)
std::ostream & operator<< (std::ostream &os, const FuncCacheInt &c)
std::vector< TGraph > MakeSlices (const ICallableND *func, const std::vector< NCParameter > &ps, const CoordNDim &minpos)
std::vector< TH2D * > Make2DSlices (const ICallableND *func, const std::vector< NCParameter > &ps, const CoordNDim &minpos)
ostream & operator<< (ostream &os, const CoordNDim &c)
std::ostream & operator<< (std::ostream &os, const CoordNDim &c)

Typedef Documentation

An N-dimensional coordinate in integer space.

See also:
CoordBase

Definition at line 53 of file NCFitterTypes.h.

An N-dimensional coordinate.

See also:
CoordBase

Definition at line 51 of file NCFitterTypes.h.


Function Documentation

CoordNDim NC::Fitter::ConvertContourCoord ( const CoordNDim &  c,
std::vector< NCParameter ps 
)
CoordNDim NC::Fitter::ConvertContourCoord ( const CoordNDim &  c,
vector< NCParameter ps 
)

This final one is intended to be used on the output of FindContourInt.

Definition at line 63 of file NCFitter.cxx.

References n.

00064   {
00065     assert(c.size() == ps.size());
00066 
00067     CoordNDim ret(c.size());
00068     for(unsigned int n = 0; n < c.size(); ++n)
00069       ret[n] = ps[n].ValFromStep(c[n]);
00070 
00071     return ret;
00072   }

CoordNDim NC::Fitter::ConvertCoord ( const CoordInt &  c,
std::vector< NCParameter ps 
)
TH2D * NC::Fitter::ConvertGrid ( const TH2D *  intgrid,
const NCParameter xp,
const NCParameter yp 
)
TGraph * NC::Fitter::CreateOneDimProjection ( const ICallable2D *  func,
const NCParameter  param,
const double  minVal,
double &  leftErr,
double &  rightErr,
std::vector< TGraph > &  marg_graphs 
)
TGraph NC::Fitter::CreateOneDimProjectionInt ( const ICallableInt *  func,
int  minstep,
int  maxstep,
double &  leftErr,
double &  rightErr 
)
std::vector< Coord > NC::Fitter::FindContour ( const ICallable2D *  func,
const Coord &  minCoord,
const double  height,
const Coord &  precision,
std::vector< TGraph > *  marg_graphs 
)

Find contour of height height in the function func.

Search will be to precision precision. You must pass the previously located minimum of the function in minCoord. The contour must be continuous, finite and closed.

std::vector<CoordNDim> NC::Fitter::FindContourInt ( const ICallableInt *  func_org,
const CoordInt &  minCoord,
const double  height,
std::vector< TGraph > *  marg_graphs 
)

Find contour of height height in the function func.

Search will be to precision precision. You must pass the previously located minimum of the function in minCoord. The contour must be continuous, finite and closed.

TMatrix NC::Fitter::FindCovarianceMatrix ( const ICallableND *  func,
const CoordNDim &  minCoord,
const std::vector< NCParameter params 
)

Referenced by NC::FitMaster::Run().

TH2D * NC::Fitter::GetLowResGrid ( const ICallable2D *  func,
const Coord  min,
const Coord  max,
const Coord  prec 
)
TH2D* NC::Fitter::GridSearchInt ( const ICallableInt *  func,
const CoordInt  min,
const CoordInt  max 
)
bool NC::Fitter::Interpolate ( double  val1,
double  val2,
double  target,
double &  ret 
)

Definition at line 885 of file NCFitter.cxx.

00886   {
00887     if( (val1-target)*(val2-target) > 0) return false;
00888     const double diff = (val2-val1) ? val2-val1 : 1;
00889     ret = (target-val1)/diff;
00890     return true;
00891   }

std::vector<TH2D*> NC::Fitter::Make2DSlices ( const ICallableND *  func,
const std::vector< NCParameter > &  ps,
const CoordNDim &  minpos 
)
vector<TH2D*> NC::Fitter::Make2DSlices ( const ICallableND *  func,
const vector< NCParameter > &  ps,
const CoordNDim &  minpos 
)

Definition at line 1317 of file NCFitter.cxx.

References NC::Fitter::ICallableND::EvalAtEx(), Plot::Format(), NCParameter::LatexName(), NCParameter::Max(), NCParameter::Min(), NCParameter::Precision(), NC::Utility::ReportProgress(), and NCParameter::ShortName().

Referenced by NC::FitMaster::Run().

01320   {
01321     vector<TH2D*> ret;
01322     for(unsigned int p = 0; p < ps.size(); ++p){
01323       for(unsigned int q = 0; q < p; ++q){
01324         // +.5 makes us round to nearest int instead of toward zero.
01325         assert(ps[p].Precision());
01326         assert(ps[q].Precision());
01327 
01328         NCParameter px=ps[p];
01329         NCParameter py=ps[q];
01330 
01331         const int Nx = int((px.Max()-px.Min())/px.Precision()+.5);
01332         const int Ny = int((py.Max()-py.Min())/py.Precision()+.5);
01333 
01334         TH2D* h = new TH2D("foo", "bar", Nx, px.Min(), px.Max(),
01335                            Ny, py.Min(), py.Max());
01336         h->SetName(TString::Format("2dslice_%s_%s", px.ShortName().c_str(),
01337                                    py.ShortName().c_str() ));
01338 
01339         h->GetXaxis()->SetTitle(px.LatexName().c_str());
01340         h->GetYaxis()->SetTitle(py.LatexName().c_str());
01341 
01342         TStopwatch sw; // starts automatically
01343 
01344         for(int nx = 1; nx <= Nx; ++nx){
01345           ReportProgress(double(nx)/Nx, sw);
01346           const double xhere = px.Min()+nx*px.Precision();
01347           for(int ny = 1; ny <= Ny; ++ny){
01348             const double yhere = py.Min()+ny*py.Precision();
01349             CoordNDim evalAt = minpos;
01350             evalAt[p] = xhere; evalAt[q] = yhere;
01351             CoordNDim junk;
01352             h->SetBinContent(nx, ny, func->EvalAtEx(evalAt, &junk));
01353           } // end for ny
01354         } // end for nx
01355 
01356         ret.push_back(h);
01357       }
01358     }
01359 
01360     return ret;
01361   }

std::vector<TGraph> NC::Fitter::MakeSlices ( const ICallableND *  func,
const std::vector< NCParameter > &  ps,
const CoordNDim &  minpos 
)
vector<TGraph> NC::Fitter::MakeSlices ( const ICallableND *  func,
const vector< NCParameter > &  ps,
const CoordNDim &  minpos 
)

Definition at line 1272 of file NCFitter.cxx.

References NC::Fitter::ICallableND::EvalAtEx(), Plot::Format(), Munits::g, Msg::kInfo, MSG, and NC::Utility::ReportProgress().

Referenced by NC::FitMaster::Run().

01275   {
01276     vector<TGraph> ret;
01277     for(unsigned int p = 0; p < ps.size(); ++p){
01278       MSG("NCFitter", Msg::kInfo) << "Taking slice in "
01279                                   << ps[p].ShortName()
01280                                   << "..." << endl;
01281 
01282       // +.5 makes us round to nearest int instead of toward zero.
01283       assert(ps[p].Precision());
01284       const int steps = int(.5+(ps[p].Max()-ps[p].Min())/ps[p].Precision());
01285       assert(steps);
01286 
01287       vector<double> x, y;
01288 
01289       TStopwatch sw; // starts automatically
01290 
01291       for(int nx = 0; nx <= steps; ++nx){
01292         const double xhere = ps[p].Min()+nx*ps[p].Precision();
01293 
01294         ReportProgress(double(nx)/steps, sw);
01295 
01296         CoordNDim evalAt = minpos;
01297         evalAt[p] = xhere;
01298         CoordNDim junk;
01299         double upVal = func->EvalAtEx(evalAt, &junk);
01300         x.push_back(xhere);
01301         y.push_back(upVal);
01302       } // end for nx
01303 
01304       MSG("NCFitter", Msg::kInfo) << endl;
01305 
01306       TGraph g = TGraph(steps+1, &x[0], &y[0]);
01307       g.SetName(TString::Format("slice_%s", ps[p].ShortName().c_str()));
01308       g.SetTitle(TString::Format("Slice;%s;#chi^{2}",
01309                                  ps[p].LatexName().c_str()));
01310       ret.push_back(g);
01311     }
01312 
01313     return ret;
01314   }

double NC::Fitter::MinFinderMinuit ( const ICallableND *  chiSqrFunc,
const std::vector< NCParameter params,
CoordNDim &  ret,
TMinuit **  ppMinu 
)

Referenced by NC::FitMaster::Run().

std::ostream& NC::Fitter::operator<< ( std::ostream &  os,
const CoordNDim &  c 
)
ostream& NC::Fitter::operator<< ( ostream &  os,
const CoordNDim &  c 
)

Definition at line 39 of file NCFitterTypes.cxx.

References NC::Fitter::CoordBase< T >::Print().

00040   {
00041     return c.Print(os);
00042   }

std::ostream& NC::Fitter::operator<< ( std::ostream &  os,
const FuncCacheInt &  c 
)
std::ostream& NC::Fitter::operator<< ( std::ostream &  os,
const FuncCache &  c 
)
ostream& NC::Fitter::operator<< ( ostream &  os,
const FuncCacheInt &  c 
)

Definition at line 197 of file NCFitter.cxx.

References NC::Fitter::FuncCacheInt::fFunc, NC::Fitter::FuncCacheInt::fNhit, and NC::Fitter::FuncCacheInt::fNmiss.

00198   {
00199     os << "FuncCacheInt for callable at " << c.fFunc
00200        << " with " << c.fNhit+c.fNmiss << " calls "
00201        << "of which " << c.fNhit << " hit and "
00202        << c.fNmiss << " missed." << endl;
00203     return os;
00204   }

ostream& NC::Fitter::operator<< ( ostream &  os,
const FuncCache &  c 
)

Definition at line 162 of file NCFitter.cxx.

References NC::Fitter::FuncCache::fFunc, NC::Fitter::FuncCache::fNhit, and NC::Fitter::FuncCache::fNmiss.

00163   {
00164     os << "FuncCache for callable at " << c.fFunc
00165        << " with " << c.fNhit+c.fNmiss << " calls "
00166        << "of which " << c.fNhit << " hit and "
00167        << c.fNmiss << " missed." << endl;
00168     return os;
00169   }

void NC::Fitter::PrintGridSearch ( const ICallableND *  func,
const std::vector< NCParameter > &  params,
std::ostream &  out 
)

Referenced by NC::FitMaster::Run().


Generated on 18 Jan 2018 for loon by  doxygen 1.6.1