CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
void trapezoid(double xrec, double yrec, double &xtrap, double &ytrap) const
void rectangle(double xtrap, double ytrap, double &xrec, double &yrec) const
#define dso_internal
Definition: Visibility.h:13
Trapezoid2RectangleMappingX(double x0, double y0, double k)
special parallelogram case, a == b. The meaning of k changes.
tuple cout
Definition: gather_cfg.py:144
Trapezoid2RectangleMappingX(double x0, double y0, double bovera, double h)
normal trapezoid case, a != b
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4