1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // $MpId: AliMpArea.cxx,v 1.8 2006/05/24 13:58:29 ivana Exp $
20 //-----------------------------------------------------------------------------
23 // Class that defines a rectangle area positioned in plane..
24 // Included in AliRoot: 2003/05/02
25 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
26 //-----------------------------------------------------------------------------
28 #include "AliMpArea.h"
29 #include "AliMpConstants.h"
31 #include <Riostream.h>
37 //_____________________________________________________________________________
38 AliMpArea::AliMpArea(const TVector2& position, const TVector2& dimensions)
41 fDimensions(dimensions),
44 /// Standard constructor
47 if ( fDimensions.X() < - AliMpConstants::LengthTolerance() ||
48 fDimensions.Y() < - AliMpConstants::LengthTolerance() ||
49 ( fDimensions.X() < AliMpConstants::LengthTolerance() &&
50 fDimensions.Y() < AliMpConstants::LengthTolerance() ) )
52 fDimensions = TVector2();
57 //_____________________________________________________________________________
58 AliMpArea::AliMpArea()
60 fPosition(TVector2()),
61 fDimensions(TVector2()),
64 /// Default constructor
67 //_____________________________________________________________________________
68 AliMpArea::AliMpArea(const AliMpArea& rhs):
70 fPosition(rhs.fPosition),
71 fDimensions(rhs.fDimensions),
72 fValidity(rhs.fValidity)
77 //_____________________________________________________________________________
78 AliMpArea::~AliMpArea()
87 //______________________________________________________________________________
88 AliMpArea& AliMpArea::operator = (const AliMpArea& right)
90 /// Assignment operator
92 // check assignment to self
93 if (this == &right) return *this;
95 // base class assignment
96 TObject::operator=(right);
98 fPosition = right.fPosition;
99 fDimensions = right.fDimensions;
100 fValidity = right.fValidity;
109 //_____________________________________________________________________________
110 Double_t AliMpArea::LeftBorder() const
112 /// Return the position of the left edge.
114 return fPosition.X() - fDimensions.X();
117 //_____________________________________________________________________________
118 Double_t AliMpArea::RightBorder() const
120 /// Return the position of right edge.
122 return fPosition.X() + fDimensions.X();
125 //_____________________________________________________________________________
126 Double_t AliMpArea::UpBorder() const
128 /// Return the position of the up edge.
130 return fPosition.Y() + fDimensions.Y();
133 //_____________________________________________________________________________
134 Double_t AliMpArea::DownBorder() const
136 /// Return the position of the down edge.
138 return fPosition.Y() - fDimensions.Y();
141 //_____________________________________________________________________________
142 TVector2 AliMpArea::LeftDownCorner() const
144 /// Return position of the left down corner.
146 return TVector2(LeftBorder(), DownBorder());
149 //_____________________________________________________________________________
150 TVector2 AliMpArea::LeftUpCorner() const
152 /// Return position of the left up corner.
154 return TVector2(LeftBorder(), UpBorder());
157 //_____________________________________________________________________________
158 TVector2 AliMpArea::RightDownCorner() const
160 /// Return position of the right down corner.
162 return TVector2(RightBorder(), DownBorder());
166 //_____________________________________________________________________________
167 TVector2 AliMpArea::RightUpCorner() const
169 /// Return position of the right up corner.
171 return TVector2(RightBorder(), UpBorder());
174 //_____________________________________________________________________________
176 AliMpArea::Print(Option_t*) const
180 cout << (*this) << endl;
183 //_____________________________________________________________________________
184 ostream& operator<< (ostream &stream,const AliMpArea& area)
188 stream << "Area: position: ("
189 << area.Position().X() << ", " << area.Position().Y() << ") "
191 << area.Dimensions().X() << ", " << area.Dimensions().Y() << ") "
192 << " valid: " << (area.IsValid()==true ? "YES":"NO")