CMS 3D CMS Logo

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  bool ok = true;
8 
10  int i = grid.index(7.2, f);
11  ok &= grid.inRange(i);
12 
13  ok &= (8 == i);
14  ok &= (0.6 == f);
15 
16  return ok;
17  }
18 } // namespace
19 
20 #include <iostream>
21 #include <cstdlib>
22 #include <cstdio>
23 
24 namespace {
27  int i = grid.index(a, f);
28  ::printf("%i %f %a\n", i, f, f);
29  grid.normalize(i, f);
30  ::printf("%i %f %a\n", i, f, f);
31  }
32 } // namespace
33 
34 int grid1d_t() {
35  bool ok = true;
36  Grid1D grid(-10., 10., 11);
37 
38  print(grid, 7.2);
39  print(grid, 10.);
40  print(grid, -10.2);
41  print(grid, 10.2);
42 
43  ok &= testGrid1D(grid);
44 
45  assert(ok ? 0 : 1);
46  return ok ? 0 : 1;
47 }
48 
49 namespace {
50 
51  Grid3D const* factory() {
52  Grid1D ga(0., 10., 5);
53  Grid1D gb(-10., 10., 11);
54  Grid1D gc(-10., 10., 11);
55 
56  std::vector<Grid3D::BVector> data;
57  data.reserve(ga.nodes() * gb.nodes() * gc.nodes());
58  for (int i = 0; i < ga.nodes(); ++i)
59  for (int j = 0; j < gb.nodes(); ++j)
60  for (int k = 0; k < gc.nodes(); ++k) {
61  data.push_back(Grid3D::BVector(10 * ga.node(i), 10 * gb.node(j), 10 * gc.node(k)));
62  }
63 
64  return new Grid3D(ga, gb, gc, data);
65  }
66 
67 } // namespace
68 
70 #include <iostream>
71 
72 int grid3d_t() {
73  Grid3D const* grid = factory();
74 
76 
77  std::cout << inter.interpolate(7.5, 7.2, -3.4) << std::endl;
78  std::cout << inter.interpolate(-0.5, 10.2, -3.4) << std::endl;
79 
80  delete grid;
81  return 0;
82 }
LinearGridInterpolator3D
Definition: LinearGridInterpolator3D.h:22
mps_fire.i
i
Definition: mps_fire.py:428
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
gather_cfg.cout
cout
Definition: gather_cfg.py:144
getRunAppsInfo.grid
grid
Definition: getRunAppsInfo.py:92
cms::cuda::assert
assert(be >=bs)
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
Grid3D
Definition: Grid3D.h:28
Grid1D
Definition: Grid1D.h:7
dqmdumpme.k
k
Definition: dqmdumpme.py:60
a
double a
Definition: hdecay.h:119
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
Grid1D::Scalar
float Scalar
Definition: Grid1D.h:9
grid1d_t
int grid1d_t()
Definition: gridTesters.cc:34
grid3d_t
int grid3d_t()
Definition: gridTesters.cc:72
Grid3D.h
BStorageArray
Definition: Grid3D.h:19
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
LinearGridInterpolator3D.h
inter
int inter
Definition: CascadeWrapper.h:27
Grid1D.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66