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 $
22 // Class that defines a rectangle area positioned in plane..
23 // Included in AliRoot: 2003/05/02
24 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
26 #include "AliMpArea.h"
27 #include "AliMpConstants.h"
29 #include <Riostream.h>
35 //_____________________________________________________________________________
36 AliMpArea::AliMpArea(const TVector2& position, const TVector2& dimensions)
39 fDimensions(dimensions),
42 /// Standard constructor
45 if ( fDimensions.X() < - AliMpConstants::LengthTolerance() ||
46 fDimensions.Y() < - AliMpConstants::LengthTolerance() ||
47 ( fDimensions.X() < AliMpConstants::LengthTolerance() &&
48 fDimensions.Y() < AliMpConstants::LengthTolerance() ) )
50 fDimensions = TVector2();
55 //_____________________________________________________________________________
56 AliMpArea::AliMpArea()
58 fPosition(TVector2()),
59 fDimensions(TVector2()),
62 /// Default constructor
65 //_____________________________________________________________________________
66 AliMpArea::AliMpArea(const AliMpArea& rhs):
68 fPosition(rhs.fPosition),
69 fDimensions(rhs.fDimensions),
70 fValidity(rhs.fValidity)
75 //_____________________________________________________________________________
76 AliMpArea::~AliMpArea()
85 //______________________________________________________________________________
86 AliMpArea& AliMpArea::operator = (const AliMpArea& right)
88 /// Assignment operator
90 // check assignment to self
91 if (this == &right) return *this;
93 // base class assignment
94 TObject::operator=(right);
96 fPosition = right.fPosition;
97 fDimensions = right.fDimensions;
98 fValidity = right.fValidity;
107 //_____________________________________________________________________________
108 Double_t AliMpArea::LeftBorder() const
110 /// Return the position of the left edge.
112 return fPosition.X() - fDimensions.X();
115 //_____________________________________________________________________________
116 Double_t AliMpArea::RightBorder() const
118 /// Return the position of right edge.
120 return fPosition.X() + fDimensions.X();
123 //_____________________________________________________________________________
124 Double_t AliMpArea::UpBorder() const
126 /// Return the position of the up edge.
128 return fPosition.Y() + fDimensions.Y();
131 //_____________________________________________________________________________
132 Double_t AliMpArea::DownBorder() const
134 /// Return the position of the down edge.
136 return fPosition.Y() - fDimensions.Y();
139 //_____________________________________________________________________________
140 TVector2 AliMpArea::LeftDownCorner() const
142 /// Return position of the left down corner.
144 return TVector2(LeftBorder(), DownBorder());
147 //_____________________________________________________________________________
148 TVector2 AliMpArea::LeftUpCorner() const
150 /// Return position of the left up corner.
152 return TVector2(LeftBorder(), UpBorder());
155 //_____________________________________________________________________________
156 TVector2 AliMpArea::RightDownCorner() const
158 /// Return position of the right down corner.
160 return TVector2(RightBorder(), DownBorder());
164 //_____________________________________________________________________________
165 TVector2 AliMpArea::RightUpCorner() const
167 /// Return position of the right up corner.
169 return TVector2(RightBorder(), UpBorder());
172 //_____________________________________________________________________________
174 AliMpArea::Print(Option_t*) const
178 cout << (*this) << endl;
181 //_____________________________________________________________________________
182 ostream& operator<< (ostream &stream,const AliMpArea& area)
186 stream << "Area: position: ("
187 << area.Position().X() << ", " << area.Position().Y() << ") "
189 << area.Dimensions().X() << ", " << area.Dimensions().Y() << ") "
190 << " valid: " << (area.IsValid()==true ? "YES":"NO")