]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpPad.cxx
Code for MUON Station1 (I.Hrivnacova)
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpPad.cxx
CommitLineData
5f91c9e8 1// $Id$
2// Category: basic
3//
4// Class AliMpPad
5// ---------------
6// Class which encapsuate all informations about a pad
7//
8// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
9
10#include <Riostream.h>
11
12#include "AliMpPad.h"
13
14ClassImp(AliMpPad)
15
16//////////////////////////////////////////////////////////
17//
18// This class encapsulate all the information about a pad
19//
20//////////////////////////////////////////////////////////
21
22//
23// foreign operators
24//
25
26//_____________________________________________________________________________
27Bool_t operator==(const TVector2& v1,const TVector2& v2)
28{
29return v1.X()==v2.X() && v1.Y()==v2.Y();
30}
31
32
33//_____________________________________________________________________________
34ostream& operator<<(ostream& out,const TVector2& v)
35{
36 out << '(' << v.X() << ',' << v.Y() << ')';
37 return out;
38}
39
40//_____________________________________________________________________________
41AliMpPad::AliMpPad(const AliMpIntPair& location,const AliMpIntPair& indices,
42 const TVector2& position,const TVector2& dimensions,
43 Bool_t validity)
44 : TObject(),
45 fLocation(location),
46 fIndices(indices),
47 fPosition(position),
48 fDimensions(dimensions),
49 fValidity(validity)
50{
51// Be carefull : this constructor doesn't check the validity of
52// the correspondance between location and indices.
53// By default, validity is set true.
54// It is aimed to be used by MSegmentation methods, and never from outside....
55}
56
57
58//_____________________________________________________________________________
59AliMpPad::AliMpPad()
60 : TObject(),
61 fLocation(AliMpIntPair::Invalid()),
62 fIndices(AliMpIntPair::Invalid()),
63 fPosition(-1.,-1.),
64 fDimensions(0.,0.),
65 fValidity(false)
66{
67// Default constructor - creates pad in invalid state
68}
69
70
71//_____________________________________________________________________________
72AliMpPad::AliMpPad(const AliMpPad& src)
73 : TObject(src)
74{
75 *this = src;
76}
77
78//_____________________________________________________________________________
79AliMpPad::~AliMpPad() {
80//
81}
82
83//_____________________________________________________________________________
84AliMpPad& AliMpPad::operator = (const AliMpPad& src)
85{
86 // check assignement to self
87 if (this == &src) return *this;
88
89 // base class assignement
90 TObject::operator=(src);
91
92 // assignement operator
93 fLocation = src.fLocation;
94 fIndices = src.fIndices;
95 fPosition.Set(src.fPosition);
96 fDimensions.Set(src.fDimensions);
97 fValidity = src.fValidity;
98
99 return *this;
100}
101
102//_____________________________________________________________________________
103Bool_t AliMpPad::operator == (const AliMpPad& pos2) const
104{
105 // are this and pos2 equals?
106
107 // one valid, one invalid
108 if (fValidity != pos2.fValidity) return false;
109
110 // both invalid
111 if (!fValidity) return true;
112
113 // both valid
114 return (fLocation==pos2.fLocation) && (fIndices ==pos2.fIndices )
115 && (fPosition==pos2.fPosition) && (fDimensions==pos2.fDimensions);
116}
117//_____________________________________________________________________________
118Bool_t AliMpPad::operator!= (const AliMpPad& pos2) const
119{
120 // are this and pos2 equals?
121 return !(*this==pos2);
122}
123
124//_____________________________________________________________________________
125ostream& operator<< (ostream &out, const AliMpPad& op)
126{
127 if (op.IsValid()) {
128 out << "Pad: Location " << op.GetLocation()
129 << " Indices " << op.GetIndices()
130 << " Position " << op.Position()
131 << " Dimensions " << op.Dimensions();
132 return out;
133 }
134 else {
135 out << "Pad::Invalid";
136 return out;
137 }
138}
139
140//_____________________________________________________________________________
141Bool_t operator < (const AliMpPad& left, const AliMpPad& right)
142{
143return left.GetIndices()<right.GetIndices();
144}
145
146//_____________________________________________________________________________
147void AliMpPad::Print() const
148{
149// Prints all pad data.
150// ---
151
152 if (fValidity) {
153 cout << "Indices: " << fIndices << "; "
154 << " Location: " << fLocation << "; "
155 << " Position: " << fPosition.X() << " " << fPosition.Y() << "; "
156 << " Dimensions: " << fDimensions.X() << " " << fDimensions.Y()
157 << endl;
158 }
159 else {
160 cout << "Pad::Invalid " << endl;
161 }
162}
163