CMS 3D CMS Logo

Trapezoid2RectangleMappingX.h
Go to the documentation of this file.
1 #ifndef Trapezoid2RectangleMappingX_h
2 #define Trapezoid2RectangleMappingX_h
3 
13 //#define DEBUG_GRID_TRM
14 
15 #ifdef DEBUG_GRID_TRM
16 #include <iostream>
17 #endif
18 
20 
22 public:
24 
26  Trapezoid2RectangleMappingX(double x0, double y0, double bovera, double h) : x0_(x0), y0_(y0), parallel_(false) {
27  k_ = 2 / h * (bovera - 1.) / (bovera + 1.);
28 
29 #ifdef DEBUG_GRID_TRM
30  std::cout << "Trapezoid2RectangleMappingX constructed with x0,y0 " << x0 << " " << y0 << " b/a= " << bovera
31  << " h= " << h << std::endl;
32 #endif
33  }
34 
36  Trapezoid2RectangleMappingX(double x0, double y0, double k) : x0_(x0), y0_(y0), k_(k), parallel_(true) {
37 #ifdef DEBUG_GRID_TRM
38  std::cout << "Trapezoid2RectangleMappingX constructed with x0,y0 " << x0 << " " << y0 << " k= " << k << std::endl;
39 #endif
40  }
41 
42  void rectangle(double xtrap, double ytrap, double& xrec, double& yrec) const {
43  yrec = ytrap - y0_;
44  if (!parallel_)
45  xrec = (xtrap - x0_) / (1. + yrec * k_);
46  else
47  xrec = xtrap - x0_ + k_ * yrec;
48 
49 #ifdef DEBUG_GRID
50  std::cout << xtrap << " " << ytrap << " transformed to rectangle " << xrec << " " << yrec << std::endl;
51 #endif
52  }
53 
54  void trapezoid(double xrec, double yrec, double& xtrap, double& ytrap) const {
55  if (!parallel_)
56  xtrap = x0_ + xrec * (1. + yrec * k_);
57  else
58  xtrap = x0_ + xrec - k_ * yrec;
59  ytrap = y0_ + yrec;
60 
61 #ifdef DEBUG_GRID
62  std::cout << xrec << " " << yrec << " transformed to trapezoid " << xtrap << " " << ytrap << std::endl;
63 #endif
64  }
65 
66 private:
67  double x0_;
68  double y0_;
69  double k_;
70  bool parallel_;
71 };
72 
73 #endif
Trapezoid2RectangleMappingX::rectangle
void rectangle(double xtrap, double ytrap, double &xrec, double &yrec) const
Definition: Trapezoid2RectangleMappingX.h:42
Visibility.h
funct::false
false
Definition: Factorize.h:34
Trapezoid2RectangleMappingX::Trapezoid2RectangleMappingX
Trapezoid2RectangleMappingX(double x0, double y0, double bovera, double h)
normal trapezoid case, a != b
Definition: Trapezoid2RectangleMappingX.h:26
gather_cfg.cout
cout
Definition: gather_cfg.py:144
h
dqmdumpme.k
k
Definition: dqmdumpme.py:60
Trapezoid2RectangleMappingX
Definition: Trapezoid2RectangleMappingX.h:21
funct::true
true
Definition: Factorize.h:173
Trapezoid2RectangleMappingX::trapezoid
void trapezoid(double xrec, double yrec, double &xtrap, double &ytrap) const
Definition: Trapezoid2RectangleMappingX.h:54
dso_internal
#define dso_internal
Definition: Visibility.h:13
Trapezoid2RectangleMappingX::parallel_
bool parallel_
Definition: Trapezoid2RectangleMappingX.h:70
Trapezoid2RectangleMappingX::k_
double k_
Definition: Trapezoid2RectangleMappingX.h:69
Trapezoid2RectangleMappingX::Trapezoid2RectangleMappingX
Trapezoid2RectangleMappingX()
Definition: Trapezoid2RectangleMappingX.h:23
Trapezoid2RectangleMappingX::Trapezoid2RectangleMappingX
Trapezoid2RectangleMappingX(double x0, double y0, double k)
special parallelogram case, a == b. The meaning of k changes.
Definition: Trapezoid2RectangleMappingX.h:36
Trapezoid2RectangleMappingX::x0_
double x0_
Definition: Trapezoid2RectangleMappingX.h:67
Trapezoid2RectangleMappingX::y0_
double y0_
Definition: Trapezoid2RectangleMappingX.h:68