Classes | Public Member Functions | Protected Attributes | List of all members
ana::KrigeKernel Class Reference

Helper for SurfaceKrige. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-30/CAFAna/Fit/SurfaceKrige.h"

Classes

struct  Pt
 

Public Member Functions

 KrigeKernel ()
 
double operator() (double x1, double y1, double x2, double y2) const
 
void AddPoint (double x, double y, double z)
 

Protected Attributes

double fGrad
 
double fGradX
 
double fGradY
 
std::vector< PtfPts
 

Detailed Description

Helper for SurfaceKrige.

Definition at line 10 of file SurfaceKrige.h.

Constructor & Destructor Documentation

ana::KrigeKernel::KrigeKernel ( )

Definition at line 15 of file SurfaceKrige.cxx.

16  : fGrad(1), fGradX(1), fGradY(1)
17  {
18  }

Member Function Documentation

void ana::KrigeKernel::AddPoint ( double  x,
double  y,
double  z 
)

Definition at line 35 of file SurfaceKrige.cxx.

References a, b, dx, dy, stan::math::fabs(), fGrad, fGradX, fGradY, fPts, MECModelEnuComparisons::g, util::pythag(), util::sqr(), ana::SurfaceKrige::SurfaceKrige(), registry_explorer::v, ana::KrigeKernel::Pt::x, submit_syst::x, X2, ana::KrigeKernel::Pt::y, submit_syst::y, Y2, and ana::KrigeKernel::Pt::z.

Referenced by ana::SurfaceKrige::FillSurface().

36  {
37  // Learn the best function of dx and dy to predict the variance
38 
39  Pt p = {x, y, z};
40  fPts.push_back(p);
41 
42  double R2 = 0, ZR = 0;
43  double X2 = 0, XY = 0, Y2 = 0, ZX = 0, ZY = 0;
44  for(unsigned int ai = 0; ai < fPts.size(); ++ai){
45  for(unsigned int bi = ai+1; bi < fPts.size(); ++bi){
46  const Pt a = fPts[ai];
47  const Pt b = fPts[bi];
48 
49  const double dz2 = util::sqr(a.z-b.z);
50 
51  const double dx = fabs(a.x-b.x);
52  const double dy = fabs(a.y-b.y);
53 
54  const double dr = util::pythag(a.x-b.x, a.y-b.y);
55 
56  R2 += dr*dr;
57  ZR += dz2*dr;
58 
59  X2 += dx*dx;
60  XY += dx*dy;
61  Y2 += dy*dy;
62  ZX += dz2 * dx;
63  ZY += dz2 * dy;
64  }
65  }
66 
67  if(R2) fGrad = ZR / R2;
68 
69  // Only compute 2D coefficients once we have some stats
70  if(fPts.size() < 10) return;
71 
72  TMatrixD M(2, 2); TVectorD v(2);
73  M(0, 0) = X2; M(0, 1) = XY; v(0) = ZX;
74  M(1, 0) = XY; M(1, 1) = Y2; v(1) = ZY;
75 
76  M.Invert();
77  TVectorD g = M*v;
78 
79  fGradX = fabs(g(0));
80  fGradY = fabs(g(1));
81  }
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
std::vector< Pt > fPts
Definition: SurfaceKrige.h:24
const char * p
Definition: xmltok.h:285
T sqr(T x)
More efficient square function than pow(x,2)
Definition: MathUtil.h:23
Double_t X2
Definition: plot.C:264
double dy[NP][NC]
double dx[NP][NC]
const double a
z
Definition: test.py:28
double pythag(double x, double y)
2D Euclidean distance
Definition: MathUtil.h:29
const hit & b
Definition: hits.cxx:21
Double_t Y2
Definition: plot.C:264
double ana::KrigeKernel::operator() ( double  x1,
double  y1,
double  x2,
double  y2 
) const

Definition at line 21 of file SurfaceKrige.cxx.

References stan::math::fabs(), fGrad, fGradX, fGradY, and util::pythag().

22  {
23  // TODO - the 2D model doesn't seem to actually work
24  if(true){//fPts.size() < 10){
25  // Use a very simple function when we don't have much data
26  return fGrad*util::pythag(x1-x2, y1-y2);
27  }
28  else{
29  // Treat x and y separately later
30  return fGradX*fabs(x1-x2) + fGradY*fabs(y1-y2);
31  }
32  }
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
double pythag(double x, double y)
2D Euclidean distance
Definition: MathUtil.h:29

Member Data Documentation

double ana::KrigeKernel::fGrad
protected

Definition at line 20 of file SurfaceKrige.h.

Referenced by AddPoint(), and operator()().

double ana::KrigeKernel::fGradX
protected

Definition at line 21 of file SurfaceKrige.h.

Referenced by AddPoint(), and operator()().

double ana::KrigeKernel::fGradY
protected

Definition at line 21 of file SurfaceKrige.h.

Referenced by AddPoint(), and operator()().

std::vector<Pt> ana::KrigeKernel::fPts
protected

Definition at line 24 of file SurfaceKrige.h.

Referenced by AddPoint().


The documentation for this class was generated from the following files: