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),
66 fValidity(rhs.fValidity)
71 //_____________________________________________________________________________
72 AliMpArea::~AliMpArea()
81 //______________________________________________________________________________
82 AliMpArea& AliMpArea::operator = (const AliMpArea& right)
84 /// Assignment operator
86 // check assignment to self
87 if (this == &right) return *this;
89 // base class assignment
90 TObject::operator=(right);
92 fPosition = right.fPosition;
93 fDimensions = right.fDimensions;
94 fValidity = right.fValidity;
103 //_____________________________________________________________________________
104 Double_t AliMpArea::LeftBorder() const
106 /// Return the position of the left edge.
108 return fPosition.X() - fDimensions.X();
111 //_____________________________________________________________________________
112 Double_t AliMpArea::RightBorder() const
114 /// Return the position of right edge.
116 return fPosition.X() + fDimensions.X();
119 //_____________________________________________________________________________
120 Double_t AliMpArea::UpBorder() const
122 /// Return the position of the up edge.
124 return fPosition.Y() + fDimensions.Y();
127 //_____________________________________________________________________________
128 Double_t AliMpArea::DownBorder() const
130 /// Return the position of the down edge.
132 return fPosition.Y() - fDimensions.Y();
135 //_____________________________________________________________________________
136 TVector2 AliMpArea::LeftDownCorner() const
138 /// Return position of the left down corner.
140 return TVector2(LeftBorder(), DownBorder());
143 //_____________________________________________________________________________
144 TVector2 AliMpArea::LeftUpCorner() const
146 /// Return position of the left up corner.
148 return TVector2(LeftBorder(), UpBorder());
151 //_____________________________________________________________________________
152 TVector2 AliMpArea::RightDownCorner() const
154 /// Return position of the right down corner.
156 return TVector2(RightBorder(), DownBorder());
160 //_____________________________________________________________________________
161 TVector2 AliMpArea::RightUpCorner() const
163 /// Return position of the right up corner.
165 return TVector2(RightBorder(), UpBorder());
168 //_____________________________________________________________________________
169 ostream& operator<< (ostream &stream,const AliMpArea& area)
173 stream << "Area: position: ("
174 << area.Position().X() << ", " << area.Position().Y() << ") "
176 << area.Dimensions().X() << ", " << area.Dimensions().Y() << ") "