]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpArea.cxx
- Added class for Global Crate object
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpArea.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 // $Id$
17 // $MpId: AliMpArea.cxx,v 1.8 2006/05/24 13:58:29 ivana Exp $
18 // Category: basic
19
20 //-----------------------------------------------------------------------------
21 // Class AliMpArea
22 // ----------------
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 //-----------------------------------------------------------------------------
27
28 #include "AliMpArea.h"
29 #include "AliMpConstants.h"
30
31 #include <Riostream.h>
32
33 /// \cond CLASSIMP
34 ClassImp(AliMpArea)
35 /// \endcond
36
37 //_____________________________________________________________________________
38 AliMpArea::AliMpArea(const TVector2& position, const TVector2& dimensions)
39   : TObject(),
40     fPosition(position),
41     fDimensions(dimensions),
42     fValidity(true) 
43 {
44 /// Standard constructor
45
46   // Check dimensions
47   if (  fDimensions.X() < - AliMpConstants::LengthTolerance() || 
48         fDimensions.Y() < - AliMpConstants::LengthTolerance() || 
49       ( fDimensions.X() < AliMpConstants::LengthTolerance() && 
50         fDimensions.Y() < AliMpConstants::LengthTolerance() ) )
51   {
52     fDimensions = TVector2();
53     fValidity = false;
54   }  
55 }
56
57 //_____________________________________________________________________________
58 AliMpArea::AliMpArea()
59   : TObject(),
60     fPosition(TVector2()),
61     fDimensions(TVector2()), 
62     fValidity(false) 
63 {
64 /// Default constructor
65 }
66
67 //_____________________________________________________________________________
68 AliMpArea::AliMpArea(const AliMpArea& rhs):
69   TObject(rhs),
70   fPosition(rhs.fPosition),
71   fDimensions(rhs.fDimensions), 
72   fValidity(rhs.fValidity) 
73 {
74 /// Copy constructor
75 }
76
77 //_____________________________________________________________________________
78 AliMpArea::~AliMpArea() 
79 {
80 /// Destructor
81 }
82
83 //
84 // operators
85 //
86
87 //______________________________________________________________________________
88 AliMpArea& AliMpArea::operator = (const AliMpArea& right)
89 {
90 /// Assignment operator
91
92   // check assignment to self
93   if (this == &right) return *this;
94
95   // base class assignment
96   TObject::operator=(right);
97
98   fPosition = right.fPosition;
99   fDimensions = right.fDimensions;
100   fValidity = right.fValidity;
101
102   return *this;
103
104
105 //
106 // public methods
107 //
108
109 //_____________________________________________________________________________
110 Double_t AliMpArea::LeftBorder() const
111 {
112 /// Return the position of the left edge.
113
114   return fPosition.X() - fDimensions.X();
115 }
116
117 //_____________________________________________________________________________
118 Double_t AliMpArea::RightBorder() const
119 {
120 /// Return the position of right edge.
121
122   return fPosition.X() + fDimensions.X();
123 }
124
125 //_____________________________________________________________________________
126 Double_t AliMpArea::UpBorder() const
127 {
128 /// Return the position of the up edge.
129
130   return fPosition.Y() + fDimensions.Y();
131 }
132
133 //_____________________________________________________________________________
134 Double_t AliMpArea::DownBorder() const
135 {
136 /// Return the position of the down edge.
137
138   return fPosition.Y() - fDimensions.Y();
139 }
140
141 //_____________________________________________________________________________
142 TVector2 AliMpArea::LeftDownCorner() const
143 {
144 /// Return position of the left down corner.
145
146   return TVector2(LeftBorder(), DownBorder());
147 }  
148
149 //_____________________________________________________________________________
150 TVector2 AliMpArea::LeftUpCorner() const
151 {
152 /// Return position of the left up corner.
153
154   return TVector2(LeftBorder(), UpBorder());
155 }  
156
157 //_____________________________________________________________________________
158 TVector2 AliMpArea::RightDownCorner() const
159 {
160 /// Return position of the right down corner.
161
162   return TVector2(RightBorder(), DownBorder());
163 }  
164
165
166 //_____________________________________________________________________________
167 TVector2 AliMpArea::RightUpCorner() const
168 {
169 /// Return position of the right up corner.
170
171   return TVector2(RightBorder(), UpBorder());
172 }  
173
174 //_____________________________________________________________________________
175 void
176 AliMpArea::Print(Option_t*) const
177 {
178 /// Printing
179
180   cout << (*this) << endl;
181 }
182
183 //_____________________________________________________________________________
184 ostream& operator<< (ostream &stream,const AliMpArea& area)
185 {
186 /// Output streaming
187
188   stream << "Area: position: (" 
189          << area.Position().X() << ", " << area.Position().Y() << ") " 
190          << " dimensions: (" 
191          << area.Dimensions().X() << ", " << area.Dimensions().Y() << ") " 
192   << " valid: " << (area.IsValid()==true ? "YES":"NO")
193          << endl;
194   return stream;
195 }
196