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