]>
Commit | Line | Data |
---|---|---|
8356cc1d | 1 | //////////////////////////////////////////////////////////////////////////////// |
2 | // | |
3 | // Author: Artur Szostak | |
4 | // Email: artur@alice.phy.uct.ac.za | artursz@iafrica.com | |
5 | // | |
6 | //////////////////////////////////////////////////////////////////////////////// | |
7 | ||
8 | #include "AliRoot/Region.hpp" | |
9 | #include "AliRoot/Point.hpp" | |
98af1577 | 10 | #include <TMath.h> |
11 | #include "Utils.hpp" | |
8356cc1d | 12 | |
13 | ClassImp(AliMUONHLT::Region); | |
14 | ||
15 | namespace AliMUONHLT | |
16 | { | |
17 | ||
18 | ||
19 | Region::Region() : TObject() | |
20 | { | |
21 | fLeft = fRight = fBottom = fTop = 0.0; | |
22 | }; | |
23 | ||
24 | ||
25 | Region::Region(const Float_t left, const Float_t right, const Float_t bottom, const Float_t top) | |
26 | : TObject() | |
27 | { | |
28 | if (left > right) | |
29 | { | |
30 | fLeft = fRight = fBottom = fTop = 0.0; | |
31 | Error("Region", "parameter left (%f) is larger than right (%f).", left, right); | |
32 | } | |
33 | else if (bottom > top) | |
34 | { | |
35 | fLeft = fRight = fBottom = fTop = 0.0; | |
36 | Error("Region", "parameter bottom (%f) is larger than top (%f).", bottom, top); | |
37 | } | |
38 | else | |
39 | { | |
40 | fLeft = left; | |
41 | fRight = right; | |
42 | fBottom = bottom; | |
43 | fTop = top; | |
44 | }; | |
45 | }; | |
46 | ||
47 | ||
48 | void Region::Left(const Float_t value) | |
49 | { | |
50 | if (value > fRight) | |
51 | Error("Left", "Trying to assign fLeft (%f) larger than fRight (%f).", value, fRight); | |
52 | else | |
53 | fLeft = value; | |
54 | }; | |
55 | ||
56 | ||
57 | void Region::Right(const Float_t value) | |
58 | { | |
59 | if (value < fLeft) | |
60 | Error("Right", "Trying to assign fRight (%f) smaller than fLeft (%f).", value, fLeft); | |
61 | else | |
62 | fRight = value; | |
63 | }; | |
64 | ||
65 | ||
66 | void Region::Bottom(const Float_t value) | |
67 | { | |
68 | if (value > fTop) | |
69 | Error("Bottom", "Trying to assign fBottom (%f) larger than fTop (%f).", value, fTop); | |
70 | else | |
71 | fBottom = value; | |
72 | }; | |
73 | ||
74 | ||
75 | void Region::Top(const Float_t value) | |
76 | { | |
77 | if (value < fBottom) | |
78 | Error("Top", "Trying to assign fTop (%f) smaller than fBottom (%f).", value, fBottom); | |
79 | else | |
80 | fTop = value; | |
81 | }; | |
82 | ||
83 | ||
84 | Bool_t Region::Contains(const Point& p) const | |
85 | { | |
86 | return fLeft <= p.fX and p.fX <= fRight and fBottom <= p.fY and p.fY <= fTop; | |
87 | }; | |
88 | ||
89 | ||
98af1577 | 90 | ostream& operator << (ostream& os, const Region& r) |
8356cc1d | 91 | { |
92 | os << "[(" << r.fLeft << ", " << r.fRight << "), (" << r.fLeft << ", " << r.fRight << ")]"; | |
93 | return os; | |
94 | }; | |
95 | ||
96 | ||
97 | }; // AliMUONHLT |