CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Trapezoid2RectangleMappingX.h
Go to the documentation of this file.
1 #ifndef Trapezoid2RectangleMappingX_h
2 #define Trapezoid2RectangleMappingX_h
3 
16 //#define DEBUG_GRID_TRM
17 
18 #ifdef DEBUG_GRID_TRM
19 #include <iostream>
20 #endif
21 
23 
25 public:
26 
28 
30  Trapezoid2RectangleMappingX( double x0, double y0, double bovera, double h) :
31  x0_(x0), y0_(y0), parallel_(false)
32  {
33  k_ = 2/h * (bovera-1.) / (bovera+1.);
34 
35 #ifdef DEBUG_GRID_TRM
36  std::cout << "Trapezoid2RectangleMappingX constructed with x0,y0 " << x0 << " " << y0
37  << " b/a= " << bovera << " h= " << h << std::endl;
38 #endif
39  }
40 
42  Trapezoid2RectangleMappingX( double x0, double y0, double k) :
43  x0_(x0), y0_(y0), k_(k), parallel_(true)
44  {
45 #ifdef DEBUG_GRID_TRM
46  std::cout << "Trapezoid2RectangleMappingX constructed with x0,y0 " << x0 << " " << y0
47  << " k= " << k << std::endl;
48 #endif
49  }
50 
51  void rectangle( double xtrap, double ytrap,
52  double& xrec, double& yrec) const {
53 
54  yrec = ytrap - y0_;
55  if (!parallel_) xrec = (xtrap - x0_) / (1.+ yrec*k_);
56  else xrec = xtrap - x0_ + k_*yrec;
57 
58 #ifdef DEBUG_GRID
59  std::cout << xtrap << " " << ytrap << " transformed to rectangle " << xrec << " " << yrec << std::endl;
60 #endif
61  }
62 
63  void trapezoid( double xrec, double yrec,
64  double& xtrap, double& ytrap) const {
65  if (!parallel_) xtrap = x0_ + xrec * (1.+ yrec*k_);
66  else xtrap = x0_ + xrec - k_*yrec;
67  ytrap = y0_ + yrec;
68 
69 #ifdef DEBUG_GRID
70  std::cout << xrec << " " << yrec << " transformed to trapezoid " << xtrap << " " << ytrap << std::endl;
71 #endif
72  }
73 
74 private:
75  double x0_;
76  double y0_;
77  double k_;
78  bool parallel_;
79 };
80 
81 #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.
int k[5][pyjets_maxn]
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
tuple cout
Definition: gather_cfg.py:121
Trapezoid2RectangleMappingX(double x0, double y0, double bovera, double h)
normal trapezoid case, a != b