]>
Commit | Line | Data |
---|---|---|
dee1d5f1 | 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 | ||
5f91c9e8 | 16 | // $Id$ |
dee1d5f1 | 17 | // $MpId: AliMpPad.cxx,v 1.6 2005/08/26 15:43:36 ivana Exp $ |
5f91c9e8 | 18 | // Category: basic |
19 | // | |
20 | // Class AliMpPad | |
21 | // --------------- | |
22 | // Class which encapsuate all informations about a pad | |
dbe945cc | 23 | // Included in AliRoot: 2003/05/02 |
5f91c9e8 | 24 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay |
25 | ||
26 | #include <Riostream.h> | |
27 | ||
28 | #include "AliMpPad.h" | |
29 | ||
30 | ClassImp(AliMpPad) | |
31 | ||
32 | ////////////////////////////////////////////////////////// | |
33 | // | |
34 | // This class encapsulate all the information about a pad | |
35 | // | |
36 | ////////////////////////////////////////////////////////// | |
37 | ||
38 | // | |
39 | // foreign operators | |
40 | // | |
41 | ||
42 | //_____________________________________________________________________________ | |
43 | Bool_t operator==(const TVector2& v1,const TVector2& v2) | |
44 | { | |
45 | return v1.X()==v2.X() && v1.Y()==v2.Y(); | |
46 | } | |
47 | ||
48 | ||
49 | //_____________________________________________________________________________ | |
50 | ostream& operator<<(ostream& out,const TVector2& v) | |
51 | { | |
52 | out << '(' << v.X() << ',' << v.Y() << ')'; | |
53 | return out; | |
54 | } | |
55 | ||
56 | //_____________________________________________________________________________ | |
57 | AliMpPad::AliMpPad(const AliMpIntPair& location,const AliMpIntPair& indices, | |
58 | const TVector2& position,const TVector2& dimensions, | |
59 | Bool_t validity) | |
60 | : TObject(), | |
61 | fLocation(location), | |
62 | fIndices(indices), | |
63 | fPosition(position), | |
64 | fDimensions(dimensions), | |
65 | fValidity(validity) | |
66 | { | |
dee1d5f1 | 67 | /// Standard constructor \n |
68 | /// Be carefull : this constructor doesn't check the validity of | |
69 | /// the correspondance between location and indices. | |
70 | /// By default, validity is set true. | |
71 | /// It is aimed to be used by MSegmentation methods, and never from outside.... | |
5f91c9e8 | 72 | } |
73 | ||
74 | ||
75 | //_____________________________________________________________________________ | |
76 | AliMpPad::AliMpPad() | |
77 | : TObject(), | |
78 | fLocation(AliMpIntPair::Invalid()), | |
79 | fIndices(AliMpIntPair::Invalid()), | |
80 | fPosition(-1.,-1.), | |
81 | fDimensions(0.,0.), | |
82 | fValidity(false) | |
83 | { | |
dee1d5f1 | 84 | /// Default constructor - creates pad in invalid state |
5f91c9e8 | 85 | } |
86 | ||
87 | ||
88 | //_____________________________________________________________________________ | |
89 | AliMpPad::AliMpPad(const AliMpPad& src) | |
90 | : TObject(src) | |
91 | { | |
dee1d5f1 | 92 | /// Copy constructor |
93 | ||
5f91c9e8 | 94 | *this = src; |
95 | } | |
96 | ||
97 | //_____________________________________________________________________________ | |
dee1d5f1 | 98 | AliMpPad::~AliMpPad() |
99 | { | |
100 | /// Destructor | |
5f91c9e8 | 101 | } |
102 | ||
103 | //_____________________________________________________________________________ | |
104 | AliMpPad& AliMpPad::operator = (const AliMpPad& src) | |
105 | { | |
dee1d5f1 | 106 | /// Assignment operator |
107 | ||
108 | // check assignment to self | |
5f91c9e8 | 109 | if (this == &src) return *this; |
110 | ||
dee1d5f1 | 111 | // base class assignment |
5f91c9e8 | 112 | TObject::operator=(src); |
113 | ||
dee1d5f1 | 114 | // assignment operator |
5f91c9e8 | 115 | fLocation = src.fLocation; |
116 | fIndices = src.fIndices; | |
117 | fPosition.Set(src.fPosition); | |
118 | fDimensions.Set(src.fDimensions); | |
119 | fValidity = src.fValidity; | |
120 | ||
121 | return *this; | |
122 | } | |
123 | ||
124 | //_____________________________________________________________________________ | |
125 | Bool_t AliMpPad::operator == (const AliMpPad& pos2) const | |
126 | { | |
dee1d5f1 | 127 | /// Equality operator |
128 | ||
5f91c9e8 | 129 | // are this and pos2 equals? |
130 | ||
131 | // one valid, one invalid | |
132 | if (fValidity != pos2.fValidity) return false; | |
133 | ||
134 | // both invalid | |
135 | if (!fValidity) return true; | |
136 | ||
137 | // both valid | |
138 | return (fLocation==pos2.fLocation) && (fIndices ==pos2.fIndices ) | |
139 | && (fPosition==pos2.fPosition) && (fDimensions==pos2.fDimensions); | |
140 | } | |
141 | //_____________________________________________________________________________ | |
142 | Bool_t AliMpPad::operator!= (const AliMpPad& pos2) const | |
143 | { | |
dee1d5f1 | 144 | /// Non-equality operator |
145 | ||
5f91c9e8 | 146 | // are this and pos2 equals? |
147 | return !(*this==pos2); | |
148 | } | |
149 | ||
150 | //_____________________________________________________________________________ | |
151 | ostream& operator<< (ostream &out, const AliMpPad& op) | |
152 | { | |
dee1d5f1 | 153 | /// Output streaming |
154 | ||
5f91c9e8 | 155 | if (op.IsValid()) { |
156 | out << "Pad: Location " << op.GetLocation() | |
157 | << " Indices " << op.GetIndices() | |
158 | << " Position " << op.Position() | |
159 | << " Dimensions " << op.Dimensions(); | |
160 | return out; | |
161 | } | |
162 | else { | |
163 | out << "Pad::Invalid"; | |
164 | return out; | |
165 | } | |
166 | } | |
167 | ||
168 | //_____________________________________________________________________________ | |
169 | Bool_t operator < (const AliMpPad& left, const AliMpPad& right) | |
170 | { | |
dee1d5f1 | 171 | /// Less operator |
172 | ||
173 | return left.GetIndices()<right.GetIndices(); | |
5f91c9e8 | 174 | } |
175 | ||
176 | //_____________________________________________________________________________ | |
2998a151 | 177 | void AliMpPad::Print(const char* /*option*/) const |
5f91c9e8 | 178 | { |
dee1d5f1 | 179 | /// Prints all pad data. |
5f91c9e8 | 180 | |
181 | if (fValidity) { | |
182 | cout << "Indices: " << fIndices << "; " | |
183 | << " Location: " << fLocation << "; " | |
184 | << " Position: " << fPosition.X() << " " << fPosition.Y() << "; " | |
185 | << " Dimensions: " << fDimensions.X() << " " << fDimensions.Y() | |
186 | << endl; | |
187 | } | |
188 | else { | |
189 | cout << "Pad::Invalid " << endl; | |
190 | } | |
191 | } | |
192 |