]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpPlane.cxx
Mapping test macros (D. Guez, I. Hrivnacova)
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpPlane.cxx
1 // $Id$
2 // Category: plane
3 //
4 // Class AliMpPlane
5 // ----------------
6 // Class represents the plane composed of 4 sector positions:
7 //   I.  FS                             II. |  I.
8 //  II.  BS inverted in x             _____ | ____
9 // III.  FS inverted in x, y                |
10 //  IV.  BS inverted in y              III. |  IV.
11 //   
12 // FS - front sector
13 // BS - back sector    
14 //
15 // Included in AliRoot: 2003/05/02
16 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
17
18 #include <Riostream.h>
19 #include <TError.h>
20
21 #include "AliMpPlane.h"
22 #include "AliMpReader.h"
23 #include "AliMpSector.h"
24 #include "AliMpSectorPosition.h"
25 #include "AliMpIntPair.h"
26
27 ClassImp(AliMpPlane)
28
29 //
30 // static methods
31 //
32
33 //______________________________________________________________________________
34 AliMpPlane* 
35 AliMpPlane::Create(AliMpStationType station, AliMpPlaneType type, 
36                    const TVector2& q1Position, const TVector2& q2Position,
37                    const TVector2& q3Position, const TVector2& q4Position)
38 {
39 // Factory method for creating planes.
40 // ---
41
42   // Build sectors
43   AliMpReader bReader(station, kBendingPlane);
44   // bReader.SetVerboseLevel(1);
45   AliMpSector* bSector = bReader.BuildSector();
46   cout << "bending sector is built" << endl;
47
48   AliMpReader nbReader(station, kNonBendingPlane);
49   // nbReader.SetVerboseLevel(1);
50   AliMpSector* nbSector = nbReader.BuildSector();
51   cout << "non-bending sector is built" << endl;
52
53   if (type == kBendingPlane)
54     return new AliMpPlane(bSector, nbSector,
55                       q1Position, q2Position, q3Position, q4Position );
56   else  
57     return new AliMpPlane(nbSector, bSector,
58                       q1Position, q2Position, q3Position, q4Position );
59 }
60
61 //______________________________________________________________________________
62 AliMpPlane* AliMpPlane::Create(AliMpStationType station, AliMpPlaneType type) 
63 {
64 // Factory method for creating planes with 
65 // not shifted qudrants.
66 // ---
67
68   return Create(station, type, TVector2(), TVector2(), TVector2(), TVector2());
69 }
70
71 //
72 // constructors, destructors
73 //
74
75 //______________________________________________________________________________
76 AliMpPlane::AliMpPlane(AliMpSector* frontSector, AliMpSector* backSector,
77                        const TVector2& q1Position, const TVector2& q2Position,
78                        const TVector2& q3Position, const TVector2& q4Position)
79   : TObject(),
80     fkFrontSector(frontSector),
81     fkBackSector(backSector),
82     fSectorPositions()
83 {
84 //
85   
86 #ifdef WITH_STL
87   // Create sector positions
88   fSectorPositions.push_back(
89     new AliMpSectorPosition(fkFrontSector, q1Position, AliMpIntPair( 1, 1)));
90   fSectorPositions.push_back(
91     new AliMpSectorPosition(fkBackSector,  q2Position, AliMpIntPair(-1, 1)));
92   fSectorPositions.push_back(
93     new AliMpSectorPosition(fkFrontSector, q3Position, AliMpIntPair(-1,-1)));
94   fSectorPositions.push_back(
95     new AliMpSectorPosition(fkBackSector,  q4Position, AliMpIntPair( 1,-1)));
96 #endif
97
98 #ifdef WITH_ROOT
99   // Create sector positions
100   fSectorPositions.Add(
101     new AliMpSectorPosition(fkFrontSector, q1Position, AliMpIntPair( 1, 1)));
102   fSectorPositions.Add(
103     new AliMpSectorPosition(fkBackSector,  q2Position, AliMpIntPair(-1, 1)));
104   fSectorPositions.Add(
105     new AliMpSectorPosition(fkFrontSector, q3Position, AliMpIntPair(-1,-1)));
106   fSectorPositions.Add(
107     new AliMpSectorPosition(fkBackSector,  q4Position, AliMpIntPair( 1,-1)));
108 #endif
109 }
110
111 //_____________________________________________________________________________
112 AliMpPlane::AliMpPlane(const AliMpPlane& right) 
113   : TObject(right) {
114 // 
115   Fatal("AliMpPlane", "Copy constructor not provided.");
116 }
117
118 //______________________________________________________________________________
119 AliMpPlane::AliMpPlane() 
120   : TObject(),
121     fkFrontSector(0),
122     fkBackSector(0),
123     fSectorPositions()
124 {
125 //
126 }
127
128 //______________________________________________________________________________
129 AliMpPlane::~AliMpPlane() {
130 // 
131
132   delete fkFrontSector; 
133   delete fkBackSector; 
134
135   for (Int_t i=0; i<GetNofSectorPositions(); i++) 
136     delete GetSectorPosition(i);    
137 }
138
139 //
140 // operators
141 //
142
143 //_____________________________________________________________________________
144 AliMpPlane& AliMpPlane::operator=(const AliMpPlane& right)
145 {
146   // check assignement to self
147   if (this == &right) return *this;
148
149   Fatal("operator =", "Assignement operator not provided.");
150     
151   return *this;  
152 }    
153
154 //
155 // public methods
156 //
157
158 //______________________________________________________________________________
159 const AliMpSectorPosition* 
160 AliMpPlane::SectorPosition(const AliMpIntPair& scale) const
161 {
162 // Returns the sector position specified by scale.
163 // ---
164
165   for (Int_t i=0; i<GetNofSectorPositions(); i++) 
166     if (GetSectorPosition(i)->GetScale() == scale) return GetSectorPosition(i);
167
168   Fatal("SectorPosition", "Wrong scale");
169   return 0; 
170 }
171
172 //______________________________________________________________________________
173 Int_t AliMpPlane::GetNofSectorPositions() const
174 {
175 // Returns number of sector positions.
176 // ---
177
178 #ifdef WITH_STL
179   return fSectorPositions.size();
180 #endif
181
182 #ifdef WITH_ROOT
183   return fSectorPositions.GetEntriesFast();
184 #endif
185 }  
186
187
188 //______________________________________________________________________________
189 AliMpSectorPosition* AliMpPlane::GetSectorPosition(Int_t i) const
190 {
191 // Returns i-th sector position.
192 // ---
193  
194 #ifdef WITH_STL
195   return  fSectorPositions[i];
196 #endif
197
198 #ifdef WITH_ROOT
199   return  (AliMpSectorPosition*)fSectorPositions[i];
200 #endif
201 }     
202
203