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.6 2005/08/26 15:43:36 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 <Riostream.h>
28 #include "AliMpArea.h"
33 //_____________________________________________________________________________
34 AliMpArea::AliMpArea(const TVector2& position, const TVector2& dimensions)
37 fDimensions(dimensions),
40 /// Standard constructor
43 if ( fDimensions.X() < 0. || fDimensions.Y() < 0. ||
44 ( fDimensions.X() == 0 && fDimensions.Y() == 0.0 ) ) {
45 fDimensions = TVector2();
50 //_____________________________________________________________________________
51 AliMpArea::AliMpArea()
53 fPosition(TVector2()),
54 fDimensions(TVector2()),
57 /// Default constructor
60 //_____________________________________________________________________________
61 AliMpArea::AliMpArea(const AliMpArea& rhs):
63 fPosition(rhs.fPosition),
64 fDimensions(rhs.fDimensions)
69 //_____________________________________________________________________________
70 AliMpArea::~AliMpArea()
79 //______________________________________________________________________________
80 AliMpArea& AliMpArea::operator = (const AliMpArea& right)
82 /// Assignment operator
84 // check assignment to self
85 if (this == &right) return *this;
87 // base class assignment
88 TObject::operator=(right);
90 fPosition = right.fPosition;
91 fDimensions = right.fDimensions;
92 fValidity = right.fValidity;
101 //_____________________________________________________________________________
102 Double_t AliMpArea::LeftBorder() const
104 /// Return the position of the left edge.
106 return fPosition.X() - fDimensions.X();
109 //_____________________________________________________________________________
110 Double_t AliMpArea::RightBorder() const
112 /// Return the position of right edge.
114 return fPosition.X() + fDimensions.X();
117 //_____________________________________________________________________________
118 Double_t AliMpArea::UpBorder() const
120 /// Return the position of the up edge.
122 return fPosition.Y() + fDimensions.Y();
125 //_____________________________________________________________________________
126 Double_t AliMpArea::DownBorder() const
128 /// Return the position of the down edge.
130 return fPosition.Y() - fDimensions.Y();
133 //_____________________________________________________________________________
134 TVector2 AliMpArea::LeftDownCorner() const
136 /// Return position of the left down corner.
138 return TVector2(LeftBorder(), DownBorder());
141 //_____________________________________________________________________________
142 TVector2 AliMpArea::LeftUpCorner() const
144 /// Return position of the left up corner.
146 return TVector2(LeftBorder(), UpBorder());
149 //_____________________________________________________________________________
150 TVector2 AliMpArea::RightDownCorner() const
152 /// Return position of the right down corner.
154 return TVector2(RightBorder(), DownBorder());
158 //_____________________________________________________________________________
159 TVector2 AliMpArea::RightUpCorner() const
161 /// Return position of the right up corner.
163 return TVector2(RightBorder(), UpBorder());
166 //_____________________________________________________________________________
167 ostream& operator<< (ostream &stream,const AliMpArea& area)
171 stream << "Area: position: ("
172 << area.Position().X() << ", " << area.Position().Y() << ") "
174 << area.Dimensions().X() << ", " << area.Dimensions().Y() << ") "