Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
genie::BLI2DNonUnifGrid Class Reference

#include "/cvmfs/nova.opensciencegrid.org/externals/genie/v3_00_06_p01/Linux64bit+2.6-2.12-e17-debug/GENIE-Generator/src/Framework/Numerical/BLI2D.h"

Inheritance diagram for genie::BLI2DNonUnifGrid:
genie::BLI2DGrid

Public Member Functions

 BLI2DNonUnifGrid ()
 
 BLI2DNonUnifGrid (int nx, double xmin, double xmax, int ny, double ymin, double ymax)
 
 BLI2DNonUnifGrid (int nx, int ny, double *x, double *y, double *z)
 
bool AddPoint (double x, double y, double z)
 
double Evaluate (double x, double y) const
 
double XMin (void) const
 
double XMax (void) const
 
double YMin (void) const
 
double YMax (void) const
 
double ZMin (void) const
 
double ZMax (void) const
 

Protected Member Functions

int IdxZ (int ix, int iy) const
 

Protected Attributes

int fNX
 
int fNY
 
int fNZ
 
double * fX
 
double * fY
 
double * fZ
 
double fDX
 
double fDY
 
double fXmin
 
double fXmax
 
double fYmin
 
double fYmax
 
double fZmin
 
double fZmax
 

Private Member Functions

void Init (int nx=0, double xmin=0, double xmax=0, int ny=0, double ymin=0, double ymax=0)
 

Private Attributes

int fNFillX
 
int fNFillY
 

Detailed Description

Definition at line 100 of file BLI2D.h.

Constructor & Destructor Documentation

genie::BLI2DNonUnifGrid::BLI2DNonUnifGrid ( )
BLI2DNonUnifGrid::BLI2DNonUnifGrid ( int  nx,
double  xmin,
double  xmax,
int  ny,
double  ymin,
double  ymax 
)

Definition at line 195 of file BLI2D.cxx.

References genie::BLI2DGrid::Init().

197 {
198  this->Init(nx, xmin, xmax, ny, ymin, ymax);
199 }
std::map< std::string, double > xmax
Double_t ymax
Definition: plot.C:25
void Init(int nx=0, double xmin=0, double xmax=0, int ny=0, double ymin=0, double ymax=0)
Definition: BLI2D.cxx:400
Double_t ymin
Definition: plot.C:24
BLI2DNonUnifGrid::BLI2DNonUnifGrid ( int  nx,
int  ny,
double *  x,
double *  y,
double *  z 
)

Definition at line 201 of file BLI2D.cxx.

References genie::BLI2DGrid::AddPoint(), genie::BLI2DGrid::IdxZ(), genie::BLI2DGrid::Init(), xmax, make_mec_shifts_plots::xmin, ymax, and ymin.

203 {
204  double xmin = x[0];
205  double xmax = x[nx-1];
206  double ymin = y[0];
207  double ymax = y[ny-1];
208 
209  this->Init(nx, xmin, xmax, ny, ymin, ymax);
210 
211  for(int ix=0; ix<nx; ix++) {
212  for(int iy=0; iy<ny; iy++) {
213  this->AddPoint(x[ix], y[iy], z[this->IdxZ(ix,iy)]);
214  }
215  }
216 }
bool AddPoint(double x, double y, double z)
Definition: BLI2D.cxx:218
std::map< std::string, double > xmax
Double_t ymax
Definition: plot.C:25
void Init(int nx=0, double xmin=0, double xmax=0, int ny=0, double ymin=0, double ymax=0)
Definition: BLI2D.cxx:400
z
Definition: test.py:28
int IdxZ(int ix, int iy) const
Definition: BLI2D.cxx:49
Double_t ymin
Definition: plot.C:24

Member Function Documentation

bool BLI2DNonUnifGrid::AddPoint ( double  x,
double  y,
double  z 
)
virtual

Implements genie::BLI2DGrid.

Definition at line 218 of file BLI2D.cxx.

References genie::BLI2DGrid::fNX, genie::BLI2DGrid::fNY, genie::BLI2DGrid::fX, genie::BLI2DGrid::fXmax, genie::BLI2DGrid::fXmin, genie::BLI2DGrid::fY, genie::BLI2DGrid::fYmax, genie::BLI2DGrid::fYmin, genie::BLI2DGrid::fZ, genie::BLI2DGrid::fZmax, genie::BLI2DGrid::fZmin, MECModelEnuComparisons::i, genie::BLI2DGrid::IdxZ(), calib::j, LOG, pDEBUG, pWARN, submit_syst::x, submit_syst::y, and test::z.

219 {
220 
221  // check the x,y values' existence before moving anything
222  // if they do, use them
223  // if they don't, add them in the appropriate place
224  //
225  int xidx = -1;
226  int yidx = -1;
227  bool changex = true;
228  bool changey = true;
229  // first, check and see if the x,y values exist
230  // NOTE: == should not be used with double values:
231  // instead, a tolerance of ~5 significant digits is checked
232  for(int i=0;i<fNFillX;i++)
233  {
234  if (!(TMath::Abs(x-fX[i])<=.5*.0000001*(TMath::Abs(x)+TMath::Abs(fX[i]))) && x<fX[i])
235  {
236  // missed one, make sure there aren't too many x and move everything up
237  if (fNFillX==fNX)
238  {
239  LOG("BLI2DNonUnifGrid", pWARN) << "Warning: too many x values, cannot add x = "<<x;
240  return false;
241  }
242  else
243  {
244  xidx=i;
245  changex=true;
246  break;
247  }
248  }
249  else
250  {
251  if (TMath::Abs(x-fX[i])<=.5*.0000001*(TMath::Abs(x)+TMath::Abs(fX[i]))) {
252  xidx=i;
253  LOG("BLI2DNonUnifGrid", pDEBUG) << "x value found at index "<<i;
254  changex=false; break;}
255  changex=true;
256  }
257  }
258  if (changex && xidx<0) xidx=fNFillX;
259  if (changex) LOG("BLI2DNonUnifGrid", pDEBUG) << "Adding x value at index "<<xidx;
260 
261  for(int i=0;i<fNFillY;i++)
262  {
263  if (!(TMath::Abs(y-fY[i])<=.5*.0000001*(TMath::Abs(y)+TMath::Abs(fY[i]))) && y<fY[i])
264  {
265  if (fNFillY==fNY)
266  {
267  LOG("BLI2DNonUnifGrid", pWARN) << "Warning: too many y values, cannot add y = "<<y;
268  return false;
269  }
270  else
271  {
272  yidx=i;
273  changey=true;
274  break;
275  }
276  }
277  else
278  {
279  if (TMath::Abs(y-fY[i])<=.5*.0000001*(TMath::Abs(y)+TMath::Abs(fY[i]))) {
280  yidx=i;
281  LOG("BLI2DNonUnifGrid", pDEBUG) << "y value found at index "<<i;
282  changey=false; break;}
283  changey=true;
284  }
285  }
286  if (changey && yidx<0) yidx=fNFillY;
287  if (changey) LOG("BLI2DNonUnifGrid", pDEBUG) << "Adding y value at index "<<yidx;
288 
289  // make new entries if needed
290  if (changex && xidx>=0)
291  {
292  for (int j=0;j<fNFillX-xidx;j++)
293  {
294  fX[fNFillX-j]=fX[fNFillX-j-1];
295  for (int k=0;k<fNFillY;k++)
296  {
297  fZ[ this->IdxZ(fNFillX-j,k) ]
298  = fZ[ this->IdxZ(fNFillX-j-1,k) ];
299  }
300  }
301  fX[xidx]=x;
302  fNFillX++;
303  fXmin = TMath::Min(x,fXmin);
304  fXmax = TMath::Max(x,fXmax);
305  }
306  if (changey && yidx>=0)
307  {
308  for (int j=0;j<fNFillY-yidx;j++)
309  {
310  fY[fNFillY-j]=fY[fNFillY-j-1];
311  for (int k=0;k<fNFillX;k++)
312  {
313  fZ[ this->IdxZ(k,fNFillY-j) ]
314  = fZ[ this->IdxZ(k,fNFillY-j-1) ];
315  }
316  }
317  fY[yidx]=y;
318  fNFillY++;
319  fYmin = TMath::Min(y,fYmin);
320  fYmax = TMath::Max(y,fYmax);
321  }
322 
323  int iz = this->IdxZ(xidx,yidx);
324 
325  fZ[iz] = z;
326 
327  fZmin = TMath::Min(z, fZmin);
328  fZmax = TMath::Max(z, fZmax);
329 
330  LOG("BLI2DNonUnifGrid", pDEBUG)
331  << "Added x = " << x << " (ix = " << xidx << ")"
332  << " y = " << y << " (iy = " << yidx << ") -> "
333  << " z = " << z << " (iz = " << iz << ")";
334 
335  return true;
336 }
double fXmin
Definition: BLI2D.h:63
double fYmax
Definition: BLI2D.h:66
double * fY
Definition: BLI2D.h:59
double fZmax
Definition: BLI2D.h:68
double * fX
Definition: BLI2D.h:58
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
const double j
Definition: BetheBloch.cxx:29
z
Definition: test.py:28
#define pWARN
Definition: Messenger.h:61
int IdxZ(int ix, int iy) const
Definition: BLI2D.cxx:49
double fYmin
Definition: BLI2D.h:65
double fXmax
Definition: BLI2D.h:64
double fZmin
Definition: BLI2D.h:67
double * fZ
Definition: BLI2D.h:60
#define pDEBUG
Definition: Messenger.h:64
double BLI2DNonUnifGrid::Evaluate ( double  x,
double  y 
) const
virtual

Implements genie::BLI2DGrid.

Definition at line 338 of file BLI2D.cxx.

References genie::BLI2DGrid::fX, genie::BLI2DGrid::fXmax, genie::BLI2DGrid::fXmin, genie::BLI2DGrid::fY, genie::BLI2DGrid::fYmax, genie::BLI2DGrid::fYmin, genie::BLI2DGrid::fZ, MECModelEnuComparisons::i, genie::BLI2DGrid::IdxZ(), x1, submit_syst::x2, y1, submit_syst::y2, and test::z.

339 {
340  double evalx=TMath::Min(x,fXmax);
341  evalx=TMath::Max(evalx,fXmin);
342  double evaly=TMath::Min(y,fYmax);
343  evaly=TMath::Max(evaly,fYmin);
344 
345  int ix_lo = -2;
346  int iy_lo = -2;
347  for (int i=0;i<fNFillX;i++)
348  {
349  if (evalx<=fX[fNFillX-1-i]) ix_lo=fNFillX-2-i;
350  else break;
351  }
352  for (int i=0;i<fNFillY;i++)
353  {
354  if (evaly<=fY[fNFillY-1-i]) iy_lo=fNFillY-2-i;
355  else break;
356  }
357  int ix_hi = ix_lo + 1;
358  int iy_hi = iy_lo + 1;
359 
360  // in case x = xmin
361  if (ix_lo==-1) {ix_lo++; ix_hi++;}
362  if (iy_lo==-1) {iy_lo++; iy_hi++;}
363  // in case x = xmax
364  if (ix_lo==-2) {ix_lo=fNFillX-2; ix_hi=fNFillX-1;}
365  if (iy_lo==-2) {iy_lo=fNFillY-2; iy_hi=fNFillY-1;}
366  // if an error occurs
367  if (ix_lo<0 || iy_lo<0 ) return 0.;
368  if (ix_hi>fNFillX || iy_hi>fNFillY) return 0.;
369 
370  double x1 = fX[ix_lo];
371  double x2 = fX[ix_hi];
372  double y1 = fY[iy_lo];
373  double y2 = fY[iy_hi];
374 
375  double z11 = fZ[ this->IdxZ(ix_lo,iy_lo) ];
376  double z21 = fZ[ this->IdxZ(ix_hi,iy_lo) ];
377  double z12 = fZ[ this->IdxZ(ix_lo,iy_hi) ];
378  double z22 = fZ[ this->IdxZ(ix_hi,iy_hi) ];
379 
380  double z1 = z11 * (x2-evalx)/(x2-x1) + z21 * (evalx-x1)/(x2-x1);
381  double z2 = z12 * (x2-evalx)/(x2-x1) + z22 * (evalx-x1)/(x2-x1);
382  double z = z1 * (y2-evaly)/(y2-y1) + z2 * (evaly-y1)/(y2-y1);
383 
384  /*
385  LOG("BLI2DNonUnifGrid", pINFO) << "x = " << evalx << " -> nearby nodes: " << x1 << ", " << x2;
386  LOG("BLI2DNonUnifGrid", pINFO) << "y = " << evaly << " -> nearby nodes: " << y1 << ", " << y2;
387  LOG("BLI2DNonUnifGrid", pINFO) << "xmin = " << fXmin << ", xmax = " << fXmax;
388  LOG("BLI2DNonUnifGrid", pINFO) << "ymin = " << fYmin << ", ymax = " << fYmax;
389  LOG("BLI2DNonUnifGrid", pINFO) << "z11 := z(" << this->IdxZ(ix_lo,iy_lo) << ") = " << z11;
390  LOG("BLI2DNonUnifGrid", pINFO) << "z21 := z(" << this->IdxZ(ix_hi,iy_lo) << ") = " << z21;
391  LOG("BLI2DNonUnifGrid", pINFO) << "z12 := z(" << this->IdxZ(ix_lo,iy_hi) << ") = " << z12;
392  LOG("BLI2DNonUnifGrid", pINFO) << "z22 := z(" << this->IdxZ(ix_hi,iy_hi) << ") = " << z22;
393  LOG("BLI2DNonUnifGrid", pINFO) << "z1 = " << z1 << ", z2 = " << z2;
394  LOG("BLI2DNonUnifGrid", pINFO) << "interpolated z(x,y) = " << z;
395  */
396 
397  return z;
398 }
double fXmin
Definition: BLI2D.h:63
double fYmax
Definition: BLI2D.h:66
double * fY
Definition: BLI2D.h:59
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
double * fX
Definition: BLI2D.h:58
z
Definition: test.py:28
int IdxZ(int ix, int iy) const
Definition: BLI2D.cxx:49
double fYmin
Definition: BLI2D.h:65
double fXmax
Definition: BLI2D.h:64
double * fZ
Definition: BLI2D.h:60
int BLI2DGrid::IdxZ ( int  ix,
int  iy 
) const
protectedinherited
void BLI2DNonUnifGrid::Init ( int  nx = 0,
double  xmin = 0,
double  xmax = 0,
int  ny = 0,
double  ymin = 0,
double  ymax = 0 
)
privatevirtual

Implements genie::BLI2DGrid.

Definition at line 400 of file BLI2D.cxx.

References genie::BLI2DGrid::fNX, genie::BLI2DGrid::fNY, genie::BLI2DGrid::fNZ, genie::BLI2DGrid::fX, genie::BLI2DGrid::fXmax, genie::BLI2DGrid::fXmin, genie::BLI2DGrid::fY, genie::BLI2DGrid::fYmax, genie::BLI2DGrid::fYmin, genie::BLI2DGrid::fZ, genie::BLI2DGrid::fZmax, genie::BLI2DGrid::fZmin, MECModelEnuComparisons::i, cet::sqlite::max(), min(), xmax, make_mec_shifts_plots::xmin, ymax, and ymin.

402 {
403  fNX = 0;
404  fNY = 0;
405  fNZ = 0;
406  fNFillX= 0;
407  fNFillY= 0;
408  fXmin = 0.;
409  fXmax = 0.;
410  fYmin = 0.;
411  fYmax = 0.;
414  fX = 0;
415  fY = 0;
416  fZ = 0;
417 
418  if(nx>1 && ny>1) {
419  fNX = nx;
420  fNY = ny;
421  fNZ = nx * ny;
422 
423  fXmin = xmin;
424  fXmax = xmax;
425  fYmin = ymin;
426  fYmax = ymax;
429 
430  fX = new double[fNX];
431  fY = new double[fNY];
432  fZ = new double[fNZ];
433 
434  for(int i=0; i<fNX; i++) { fX[i] = 0.; }
435  for(int i=0; i<fNY; i++) { fY[i] = 0.; }
436  for(int i=0; i<fNZ; i++) { fZ[i] = 0.; }
437  }
438 }
double fXmin
Definition: BLI2D.h:63
double fYmax
Definition: BLI2D.h:66
double * fY
Definition: BLI2D.h:59
double fZmax
Definition: BLI2D.h:68
std::map< std::string, double > xmax
double * fX
Definition: BLI2D.h:58
Double_t ymax
Definition: plot.C:25
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
double fYmin
Definition: BLI2D.h:65
Double_t ymin
Definition: plot.C:24
double fXmax
Definition: BLI2D.h:64
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
double fZmin
Definition: BLI2D.h:67
double * fZ
Definition: BLI2D.h:60
double genie::BLI2DGrid::XMax ( void  ) const
inlineinherited

Definition at line 43 of file BLI2D.h.

References genie::BLI2DGrid::fXmax.

43 { return fXmax; }
double fXmax
Definition: BLI2D.h:64
double genie::BLI2DGrid::XMin ( void  ) const
inlineinherited

Definition at line 42 of file BLI2D.h.

References genie::BLI2DGrid::fXmin.

42 { return fXmin; }
double fXmin
Definition: BLI2D.h:63
double genie::BLI2DGrid::YMax ( void  ) const
inlineinherited

Definition at line 45 of file BLI2D.h.

References genie::BLI2DGrid::fYmax.

45 { return fYmax; }
double fYmax
Definition: BLI2D.h:66
double genie::BLI2DGrid::YMin ( void  ) const
inlineinherited

Definition at line 44 of file BLI2D.h.

References genie::BLI2DGrid::fYmin.

44 { return fYmin; }
double fYmin
Definition: BLI2D.h:65
double genie::BLI2DGrid::ZMax ( void  ) const
inlineinherited
double genie::BLI2DGrid::ZMin ( void  ) const
inlineinherited

Definition at line 46 of file BLI2D.h.

References genie::BLI2DGrid::fZmin.

46 { return fZmin; }
double fZmin
Definition: BLI2D.h:67

Member Data Documentation

double genie::BLI2DGrid::fDX
protectedinherited
double genie::BLI2DGrid::fDY
protectedinherited
int genie::BLI2DNonUnifGrid::fNFillX
private

Definition at line 117 of file BLI2D.h.

int genie::BLI2DNonUnifGrid::fNFillY
private

Definition at line 118 of file BLI2D.h.

int genie::BLI2DGrid::fNX
protectedinherited

Definition at line 55 of file BLI2D.h.

Referenced by AddPoint(), genie::BLI2DUnifGrid::Init(), and Init().

int genie::BLI2DGrid::fNY
protectedinherited

Definition at line 56 of file BLI2D.h.

Referenced by AddPoint(), genie::BLI2DGrid::IdxZ(), genie::BLI2DUnifGrid::Init(), and Init().

int genie::BLI2DGrid::fNZ
protectedinherited

Definition at line 57 of file BLI2D.h.

Referenced by genie::BLI2DUnifGrid::Init(), and Init().

double* genie::BLI2DGrid::fX
protectedinherited
double genie::BLI2DGrid::fXmax
protectedinherited
double genie::BLI2DGrid::fXmin
protectedinherited
double* genie::BLI2DGrid::fY
protectedinherited
double genie::BLI2DGrid::fYmax
protectedinherited
double genie::BLI2DGrid::fYmin
protectedinherited
double* genie::BLI2DGrid::fZ
protectedinherited
double genie::BLI2DGrid::fZmax
protectedinherited
double genie::BLI2DGrid::fZmin
protectedinherited

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