]>
Commit | Line | Data |
---|---|---|
dee1d5f1 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
5f91c9e8 | 16 | // $Id$ |
13985652 | 17 | // $MpId: AliMpArea.cxx,v 1.8 2006/05/24 13:58:29 ivana Exp $ |
5f91c9e8 | 18 | // Category: basic |
3d1463c8 | 19 | |
20 | //----------------------------------------------------------------------------- | |
5f91c9e8 | 21 | // Class AliMpArea |
22 | // ---------------- | |
23 | // Class that defines a rectangle area positioned in plane.. | |
3ffe1a93 | 24 | // Included in AliRoot: 2003/05/02 |
5f91c9e8 | 25 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay |
3d1463c8 | 26 | //----------------------------------------------------------------------------- |
5f91c9e8 | 27 | |
5f91c9e8 | 28 | #include "AliMpArea.h" |
52dd0c39 | 29 | #include "AliMpConstants.h" |
5f91c9e8 | 30 | |
2c605e66 | 31 | #include <Riostream.h> |
32 | ||
13985652 | 33 | /// \cond CLASSIMP |
5f91c9e8 | 34 | ClassImp(AliMpArea) |
13985652 | 35 | /// \endcond |
5f91c9e8 | 36 | |
37 | //_____________________________________________________________________________ | |
38 | AliMpArea::AliMpArea(const TVector2& position, const TVector2& dimensions) | |
39 | : TObject(), | |
40 | fPosition(position), | |
41 | fDimensions(dimensions), | |
dee1d5f1 | 42 | fValidity(true) |
43 | { | |
44 | /// Standard constructor | |
45 | ||
5f91c9e8 | 46 | // Check dimensions |
52dd0c39 | 47 | if ( fDimensions.X() < - AliMpConstants::LengthTolerance() || |
48 | fDimensions.Y() < - AliMpConstants::LengthTolerance() || | |
49 | ( fDimensions.X() < AliMpConstants::LengthTolerance() && | |
50 | fDimensions.Y() < AliMpConstants::LengthTolerance() ) ) | |
51 | { | |
5f91c9e8 | 52 | fDimensions = TVector2(); |
53 | fValidity = false; | |
54 | } | |
55 | } | |
56 | ||
57 | //_____________________________________________________________________________ | |
58 | AliMpArea::AliMpArea() | |
59 | : TObject(), | |
60 | fPosition(TVector2()), | |
61 | fDimensions(TVector2()), | |
dee1d5f1 | 62 | fValidity(false) |
63 | { | |
64 | /// Default constructor | |
5f91c9e8 | 65 | } |
66 | ||
67 | //_____________________________________________________________________________ | |
68 | AliMpArea::AliMpArea(const AliMpArea& rhs): | |
69 | TObject(rhs), | |
70 | fPosition(rhs.fPosition), | |
0471c97b | 71 | fDimensions(rhs.fDimensions), |
72 | fValidity(rhs.fValidity) | |
dee1d5f1 | 73 | { |
74 | /// Copy constructor | |
5f91c9e8 | 75 | } |
76 | ||
77 | //_____________________________________________________________________________ | |
dee1d5f1 | 78 | AliMpArea::~AliMpArea() |
79 | { | |
80 | /// Destructor | |
5f91c9e8 | 81 | } |
82 | ||
83 | // | |
84 | // operators | |
85 | // | |
86 | ||
87 | //______________________________________________________________________________ | |
88 | AliMpArea& AliMpArea::operator = (const AliMpArea& right) | |
89 | { | |
dee1d5f1 | 90 | /// Assignment operator |
5f91c9e8 | 91 | |
dee1d5f1 | 92 | // check assignment to self |
5f91c9e8 | 93 | if (this == &right) return *this; |
94 | ||
dee1d5f1 | 95 | // base class assignment |
5f91c9e8 | 96 | TObject::operator=(right); |
97 | ||
98 | fPosition = right.fPosition; | |
99 | fDimensions = right.fDimensions; | |
100 | fValidity = right.fValidity; | |
101 | ||
102 | return *this; | |
103 | } | |
104 | ||
105 | // | |
106 | // public methods | |
107 | // | |
108 | ||
109 | //_____________________________________________________________________________ | |
110 | Double_t AliMpArea::LeftBorder() const | |
111 | { | |
dee1d5f1 | 112 | /// Return the position of the left edge. |
5f91c9e8 | 113 | |
114 | return fPosition.X() - fDimensions.X(); | |
115 | } | |
116 | ||
117 | //_____________________________________________________________________________ | |
118 | Double_t AliMpArea::RightBorder() const | |
119 | { | |
dee1d5f1 | 120 | /// Return the position of right edge. |
5f91c9e8 | 121 | |
122 | return fPosition.X() + fDimensions.X(); | |
123 | } | |
124 | ||
125 | //_____________________________________________________________________________ | |
126 | Double_t AliMpArea::UpBorder() const | |
127 | { | |
dee1d5f1 | 128 | /// Return the position of the up edge. |
5f91c9e8 | 129 | |
130 | return fPosition.Y() + fDimensions.Y(); | |
131 | } | |
132 | ||
133 | //_____________________________________________________________________________ | |
134 | Double_t AliMpArea::DownBorder() const | |
135 | { | |
dee1d5f1 | 136 | /// Return the position of the down edge. |
5f91c9e8 | 137 | |
138 | return fPosition.Y() - fDimensions.Y(); | |
139 | } | |
140 | ||
141 | //_____________________________________________________________________________ | |
142 | TVector2 AliMpArea::LeftDownCorner() const | |
143 | { | |
dee1d5f1 | 144 | /// Return position of the left down corner. |
5f91c9e8 | 145 | |
146 | return TVector2(LeftBorder(), DownBorder()); | |
147 | } | |
148 | ||
149 | //_____________________________________________________________________________ | |
150 | TVector2 AliMpArea::LeftUpCorner() const | |
151 | { | |
dee1d5f1 | 152 | /// Return position of the left up corner. |
5f91c9e8 | 153 | |
154 | return TVector2(LeftBorder(), UpBorder()); | |
155 | } | |
156 | ||
157 | //_____________________________________________________________________________ | |
158 | TVector2 AliMpArea::RightDownCorner() const | |
159 | { | |
dee1d5f1 | 160 | /// Return position of the right down corner. |
5f91c9e8 | 161 | |
162 | return TVector2(RightBorder(), DownBorder()); | |
163 | } | |
164 | ||
165 | ||
166 | //_____________________________________________________________________________ | |
167 | TVector2 AliMpArea::RightUpCorner() const | |
168 | { | |
dee1d5f1 | 169 | /// Return position of the right up corner. |
5f91c9e8 | 170 | |
171 | return TVector2(RightBorder(), UpBorder()); | |
172 | } | |
173 | ||
52dd0c39 | 174 | //_____________________________________________________________________________ |
175 | void | |
176 | AliMpArea::Print(Option_t*) const | |
177 | { | |
71a2d3aa | 178 | /// Printing |
179 | ||
52dd0c39 | 180 | cout << (*this) << endl; |
181 | } | |
182 | ||
5f91c9e8 | 183 | //_____________________________________________________________________________ |
184 | ostream& operator<< (ostream &stream,const AliMpArea& area) | |
185 | { | |
dee1d5f1 | 186 | /// Output streaming |
187 | ||
5f91c9e8 | 188 | stream << "Area: position: (" |
189 | << area.Position().X() << ", " << area.Position().Y() << ") " | |
190 | << " dimensions: (" | |
191 | << area.Dimensions().X() << ", " << area.Dimensions().Y() << ") " | |
52dd0c39 | 192 | << " valid: " << (area.IsValid()==true ? "YES":"NO") |
5f91c9e8 | 193 | << endl; |
194 | return stream; | |
195 | } | |
196 |