test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
gridTesters.cc
Go to the documentation of this file.
1 #include "Grid1D.h"
2 #include "Grid3D.h"
3 #include <cassert>
4 
5 namespace {
6  bool testGrid1D( Grid1D const & grid) {
7 
8  bool ok=true;
9 
11  int i = grid.index(7.2,f);
12  ok &= grid.inRange(i);
13 
14  ok &= (8==i);
15  ok &= (0.6==f);
16 
17  return ok;
18  }
19 }
20 
21 
22 #include<iostream>
23 #include<cstdlib>
24 #include<cstdio>
25 
26 namespace {
27  void print(Grid1D grid, Grid1D::Scalar a) {
29  int i = grid.index(a,f);
30  ::printf("%i %f %a\n",i,f,f);
31  grid.normalize(i,f);
32  ::printf("%i %f %a\n",i,f,f);
33  }
34 }
35 
36 int grid1d_t() {
37 
38  bool ok=true;
39  Grid1D grid(-10.,10.,11);
40 
41  print(grid, 7.2);
42  print(grid, 10.);
43  print(grid, -10.2);
44  print(grid, 10.2);
45 
46  ok &= testGrid1D(grid);
47 
48  assert(ok? 0 : 1);
49  return ok ? 0 : 1;
50 
51 }
52 
53 
54 
55 namespace {
56 
57  Grid3D const * factory() {
58 
59  Grid1D ga(0.,10.,5);
60  Grid1D gb(-10.,10.,11);
61  Grid1D gc(-10.,10.,11);
62 
63  std::vector< Grid3D::BVector> data;
64  data.reserve(ga.nodes()*gb.nodes()*gc.nodes());
65  for (int i=0; i<ga.nodes(); ++i)
66  for (int j=0; j<gb.nodes(); ++j)
67  for (int k=0; k<gc.nodes(); ++k) {
68  data.push_back(Grid3D::BVector(10*ga.node(i),10*gb.node(j),10*gc.node(k)));
69  }
70 
71  return new Grid3D(ga,gb,gc,data);
72 
73  }
74 
75 }
76 
77 
78 
79 
81 #include <iostream>
82 
83 int grid3d_t() {
84 
85  Grid3D const * grid = factory();
86 
88 
89  std::cout << inter.interpolate(7.5,7.2,-3.4) << std::endl;
90  std::cout << inter.interpolate(-0.5,10.2,-3.4) << std::endl;
91 
92 
93  delete grid;
94  return 0;
95 }
int grid3d_t()
Definition: gridTesters.cc:83
float Scalar
Definition: Grid1D.h:10
int i
Definition: DBlmapReader.cc:9
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:10
assert(m_qm.get())
bool inRange(int i) const
Definition: Grid1D.h:29
ReturnType interpolate(Scalar a, Scalar b, Scalar c)
int j
Definition: DBlmapReader.cc:9
double f[11][100]
Definition: Grid3D.h:28
Definition: Grid1D.h:7
int inter
double a
Definition: hdecay.h:121
void normalize(int &ind, Scalar &f) const
Definition: Grid1D.h:41
tuple cout
Definition: gather_cfg.py:145
int grid1d_t()
Definition: gridTesters.cc:36
int index(Scalar a, Scalar &f) const
Definition: Grid1D.h:34