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"
28 #include <Riostream.h>
34 //_____________________________________________________________________________
35 AliMpArea::AliMpArea(const TVector2& position, const TVector2& dimensions)
38 fDimensions(dimensions),
41 /// Standard constructor
44 if ( fDimensions.X() < 0. || fDimensions.Y() < 0. ||
45 ( fDimensions.X() == 0 && fDimensions.Y() == 0.0 ) ) {
46 fDimensions = TVector2();
51 //_____________________________________________________________________________
52 AliMpArea::AliMpArea()
54 fPosition(TVector2()),
55 fDimensions(TVector2()),
58 /// Default constructor
61 //_____________________________________________________________________________
62 AliMpArea::AliMpArea(const AliMpArea& rhs):
64 fPosition(rhs.fPosition),
65 fDimensions(rhs.fDimensions)
70 //_____________________________________________________________________________
71 AliMpArea::~AliMpArea()
80 //______________________________________________________________________________
81 AliMpArea& AliMpArea::operator = (const AliMpArea& right)
83 /// Assignment operator
85 // check assignment to self
86 if (this == &right) return *this;
88 // base class assignment
89 TObject::operator=(right);
91 fPosition = right.fPosition;
92 fDimensions = right.fDimensions;
93 fValidity = right.fValidity;
102 //_____________________________________________________________________________
103 Double_t AliMpArea::LeftBorder() const
105 /// Return the position of the left edge.
107 return fPosition.X() - fDimensions.X();
110 //_____________________________________________________________________________
111 Double_t AliMpArea::RightBorder() const
113 /// Return the position of right edge.
115 return fPosition.X() + fDimensions.X();
118 //_____________________________________________________________________________
119 Double_t AliMpArea::UpBorder() const
121 /// Return the position of the up edge.
123 return fPosition.Y() + fDimensions.Y();
126 //_____________________________________________________________________________
127 Double_t AliMpArea::DownBorder() const
129 /// Return the position of the down edge.
131 return fPosition.Y() - fDimensions.Y();
134 //_____________________________________________________________________________
135 TVector2 AliMpArea::LeftDownCorner() const
137 /// Return position of the left down corner.
139 return TVector2(LeftBorder(), DownBorder());
142 //_____________________________________________________________________________
143 TVector2 AliMpArea::LeftUpCorner() const
145 /// Return position of the left up corner.
147 return TVector2(LeftBorder(), UpBorder());
150 //_____________________________________________________________________________
151 TVector2 AliMpArea::RightDownCorner() const
153 /// Return position of the right down corner.
155 return TVector2(RightBorder(), DownBorder());
159 //_____________________________________________________________________________
160 TVector2 AliMpArea::RightUpCorner() const
162 /// Return position of the right up corner.
164 return TVector2(RightBorder(), UpBorder());
167 //_____________________________________________________________________________
168 ostream& operator<< (ostream &stream,const AliMpArea& area)
172 stream << "Area: position: ("
173 << area.Position().X() << ", " << area.Position().Y() << ") "
175 << area.Dimensions().X() << ", " << area.Dimensions().Y() << ") "