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