CMS 3D CMS Logo

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