]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpSector.cxx
Error message removed when data is posted by other than the owner.
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpSector.cxx
CommitLineData
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$
13985652 17// $MpId: AliMpSector.cxx,v 1.14 2006/05/24 13:58:46 ivana Exp $
5f91c9e8 18// Category: sector
3d1463c8 19
20//-----------------------------------------------------------------------------
5f91c9e8 21// Class AliMpSector
22// -----------------
23// Class describing the sector of the MUON chamber of station 1.
dbe945cc 24// Included in AliRoot: 2003/05/02
5f91c9e8 25// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
3d1463c8 26//-----------------------------------------------------------------------------
5f91c9e8 27
5f91c9e8 28#include "AliMpSector.h"
29#include "AliMpSectorPadIterator.h"
30#include "AliMpZone.h"
31#include "AliMpRow.h"
32#include "AliMpVRowSegment.h"
33#include "AliMpVMotif.h"
34#include "AliMpMotifMap.h"
35#include "AliMpIntPair.h"
36#include "AliMpConstants.h"
37
cddd101e 38#include "AliLog.h"
39
2c605e66 40#include <Riostream.h>
41
13985652 42/// \cond CLASSIMP
5f91c9e8 43ClassImp(AliMpSector)
13985652 44/// \endcond
5f91c9e8 45
46//_____________________________________________________________________________
d1d8330f 47AliMpSector::AliMpSector(const TString& id, Int_t nofZones, Int_t nofRows,
cddd101e 48 AliMp::Direction direction, const TVector2& offset)
5006ec94 49 : TNamed("Sector", ""),
5f91c9e8 50 fID(id),
14b7b896 51 fOffset(offset),
5f91c9e8 52 fZones(),
53 fRows(),
13e7956b 54 fMotifMap(0),
5f91c9e8 55 fDirection(direction),
f9a3ff6a 56 fMinPadDimensions(TVector2(1.e6, 1.e6)),
b0d9eae3 57 fMaxPadDimensions(),
f9a3ff6a 58 fMaxPadIndices(AliMpIntPair::Invalid()),
59 fNofPads(0)
5f91c9e8 60{
dee1d5f1 61/// Standard constructor
62
642b74ab 63 AliDebugStream(1) << "this = " << this << endl;
64
630711ed 65 fMotifMap = new AliMpMotifMap;
5f91c9e8 66
f79c58a5 67 for (Int_t izone = 0; izone<nofZones; izone++)
68 fZones.Add(new AliMpZone(izone+1));
69
70 for (Int_t irow = 0; irow<nofRows; irow++)
71 fRows.Add(new AliMpRow(irow, fMotifMap));
5f91c9e8 72}
73
74//_____________________________________________________________________________
75AliMpSector::AliMpSector()
5006ec94 76 : TNamed(),
5f91c9e8 77 fID(""),
78 fOffset(TVector2(0., 0.)),
79 fZones(),
80 fRows(),
81 fMotifMap(0),
cddd101e 82 fDirection(AliMp::kX),
f9a3ff6a 83 fMinPadDimensions(TVector2(0., 0.)),
b0d9eae3 84 fMaxPadDimensions(),
f9a3ff6a 85 fMaxPadIndices(AliMpIntPair::Invalid()),
86 fNofPads(0)
5f91c9e8 87{
dee1d5f1 88/// Default constructor
642b74ab 89
90 AliDebugStream(1) << "this = " << this << endl;
5f91c9e8 91}
92
93//_____________________________________________________________________________
dee1d5f1 94AliMpSector::~AliMpSector()
95{
96/// Destructor
97
642b74ab 98 AliDebugStream(1) << "this = " << this << endl;
99
5f91c9e8 100 // deletes
101 for (Int_t izone = 0; izone<GetNofZones(); izone++)
102 delete fZones[izone];
103
104 for (Int_t irow = 0; irow<GetNofRows(); irow++)
105 delete fRows[irow];
106
107 delete fMotifMap;
108}
109
110//
111// private methods
112//
113
114//_____________________________________________________________________________
115AliMpVPadIterator* AliMpSector::CreateIterator() const
116{
dee1d5f1 117/// Create sector pad iterator
118
5f91c9e8 119 return new AliMpSectorPadIterator(this);
120}
121
122
123//_____________________________________________________________________________
124AliMpVRowSegment* AliMpSector::FindRowSegment(const TVector2& position) const
125{
dee1d5f1 126/// Find the row segment in the specified position. \n
127/// Return if no motif is found.
5f91c9e8 128
129 // Find row
130 AliMpRow* row = FindRow(position);
131
132 if (!row) return 0;
133
134 // Find the row segment and return its motif
135 AliMpVRowSegment* rowSegment = row->FindRowSegment(position.X());
136
137 return rowSegment;
138}
139
140//_____________________________________________________________________________
141void AliMpSector::SetRowOffsets()
142{
dee1d5f1 143/// For each row check consitency of the row segments
144/// and calculate the row offset.
5f91c9e8 145
146 Double_t offset = fOffset.Y();
147
f79c58a5 148 for (Int_t irow=0; irow<GetNofRows(); irow++)
5f91c9e8 149 offset = GetRow(irow)->SetOffsetY(offset);
150}
151
152//_____________________________________________________________________________
153void AliMpSector::SetMotifPositions()
154{
dee1d5f1 155/// Create motif positions objects and fills them in the motif map.
5f91c9e8 156
f79c58a5 157 for (Int_t i=0; i<GetNofRows(); i++)
5f91c9e8 158 GetRow(i)->SetMotifPositions();
159}
160
161//_____________________________________________________________________________
162void AliMpSector::SetGlobalIndices()
163{
dee1d5f1 164/// Set the indices limits to all indexed elements
165/// (row, row segment, motif positions).
5f91c9e8 166
167 AliMpIntPair indices(0,0);
168 AliMpRow* rowBefore=0;
f79c58a5 169 for (Int_t i=0; i<GetNofRows(); i++) {
5f91c9e8 170 GetRow(i)->SetGlobalIndices(fDirection, rowBefore);
171 rowBefore = GetRow(i);
172 }
173}
174
175//_____________________________________________________________________________
b0d9eae3 176void AliMpSector::SetMinMaxPadDimensions()
5f91c9e8 177{
dee1d5f1 178/// Set the minimal pad dimensions.
5f91c9e8 179
180 for (Int_t i=1; i<GetNofZones()+1; i++) {
181 TVector2 padDimensions = GetZone(i)->GetPadDimensions();
182
94bf739c 183 if ( (fDirection == AliMp::kX &&
184 padDimensions.Y() > 0. && padDimensions.Y() < fMinPadDimensions.Y()) ||
185 (fDirection == AliMp::kY &&
186 padDimensions.X() > 0. && padDimensions.X() < fMinPadDimensions.X()))
5f91c9e8 187
188 fMinPadDimensions = padDimensions;
b0d9eae3 189
94bf739c 190 if ( (fDirection == AliMp::kX &&
191 padDimensions.Y() > 0. && padDimensions.Y() > fMaxPadDimensions.Y()) ||
192 (fDirection == AliMp::kY &&
193 padDimensions.X() > 0. && padDimensions.X() > fMinPadDimensions.X()))
b0d9eae3 194
195 fMaxPadDimensions = padDimensions;
5f91c9e8 196 }
197}
198
f9a3ff6a 199//_____________________________________________________________________________
200void AliMpSector::SetMaxPadIndices()
201{
202/// Set maximum pad indices in x, y
203
204 if ( fMaxPadIndices != AliMpIntPair::Invalid() ) return;
205
206 Int_t maxIndexInX = 0;
207 Int_t maxIndexInY = 0;
208 for (Int_t i=0; i<GetNofRows(); i++) {
209
210 Int_t ixh = GetRow(i)->GetHighIndicesLimit().GetFirst();
211 if ( ixh > maxIndexInX ) maxIndexInX = ixh;
212
213 Int_t iyh = GetRow(i)->GetHighIndicesLimit().GetSecond();
214 if ( iyh > maxIndexInY ) maxIndexInY = iyh;
215 }
216
217 fMaxPadIndices = AliMpIntPair(maxIndexInX, maxIndexInY);
218}
219
220
221//_____________________________________________________________________________
222void AliMpSector::SetNofPads()
223{
224/// Set the total number of pads
225
226 fNofPads = fMotifMap->CalculateNofPads();
227}
228
5f91c9e8 229//
230// public methods
231//
232
233//_____________________________________________________________________________
234void AliMpSector::SetRowSegmentOffsets()
235{
dee1d5f1 236/// For all rows set the offset to all row segments.
5f91c9e8 237
f79c58a5 238 for (Int_t irow=0; irow<GetNofRows(); irow++)
5f91c9e8 239 GetRow(irow)->SetRowSegmentOffsets(fOffset);
240}
241
242//_____________________________________________________________________________
243void AliMpSector::Initialize()
244{
dee1d5f1 245/// Make needed settings after sector is read from
246/// data files.
5f91c9e8 247
248 SetRowOffsets();
249 SetMotifPositions();
250 SetGlobalIndices();
b0d9eae3 251 SetMinMaxPadDimensions();
f9a3ff6a 252 SetMaxPadIndices();
253 SetNofPads();
5f91c9e8 254}
255
256//_____________________________________________________________________________
257void AliMpSector::PrintGeometry() const
258{
dee1d5f1 259/// Print the positions of rows, rows segments
5f91c9e8 260
261 for (Int_t i=0; i<GetNofRows(); i++) {
262 AliMpRow* row = GetRow(i);
263
264 cout << "ROW " << row->GetID()
265 << " center Y " << row->Position().Y() << endl;
266
267 for (Int_t j=0; j<row->GetNofRowSegments(); j++) {
268 AliMpVRowSegment* rowSegment = row->GetRowSegment(j);
269
270 cout << " ROW Segment " << j
271 << " borders "
272 << rowSegment->LeftBorderX() << " "
273 << rowSegment->RightBorderX()
274 << " x-size "
275 << 2*rowSegment->Dimensions().X() << " "
276 << endl;
277 }
278 }
279}
280
281
282//_____________________________________________________________________________
283AliMpRow* AliMpSector::FindRow(const TVector2& position) const
284{
dee1d5f1 285/// Find the row for the specified y position. \n
286/// If y is on border the lowest row is returned.
5f91c9e8 287
288 Double_t y = position.Y();
289
f79c58a5 290 for (Int_t i=0; i<GetNofRows(); i++) {
291 if ( y >= ((AliMpRow*)fRows[i])->LowBorderY() &&
292 y <= ((AliMpRow*)fRows[i])->UpperBorderY())
293 return (AliMpRow*)fRows[i];
294 }
5f91c9e8 295
296 return 0;
297}
298
299//_____________________________________________________________________________
300AliMpVMotif* AliMpSector::FindMotif(const TVector2& position) const
301{
dee1d5f1 302/// Find the motif in the specified position. \n
303/// Return 0 if no motif is found.
5f91c9e8 304
305 // Find the row segment
306 AliMpVRowSegment* rowSegment = FindRowSegment(position);
307
308 if (!rowSegment) return 0;
309
310 // Find motif
311 return rowSegment->FindMotif(position);
312}
5f91c9e8 313//_____________________________________________________________________________
314Int_t AliMpSector::FindMotifPositionId(const TVector2& position) const
315{
dee1d5f1 316/// Find the motif position ID in the specified position. \n
317/// Return 0 if no motif is found.
318
5f91c9e8 319 // Find the row segment
320 AliMpVRowSegment* rowSegment = FindRowSegment(position);
321
322 if (!rowSegment) return 0;
323
324 // Find motif position ID
325 return rowSegment->FindMotifPositionId(position);
326}
327
328//_____________________________________________________________________________
329AliMpRow* AliMpSector::FindRow(Int_t motifPositionId) const
330{
dee1d5f1 331/// Find the row with the the specified motif position. \n
332/// Return 0 if no row is found.
5f91c9e8 333
334 AliMpVRowSegment* segment = FindRowSegment(motifPositionId);
335
336 if (segment) return segment->GetRow();
337
338 return 0;
339}
340
341//_____________________________________________________________________________
342AliMpVRowSegment* AliMpSector::FindRowSegment(Int_t motifPositionId) const
343{
dee1d5f1 344/// Find the row segment with the the specified motif position. \n
345/// Return 0 if no row segment is found.
5f91c9e8 346
f79c58a5 347 for (Int_t irow=0; irow<GetNofRows(); irow++) {
348
f79c58a5 349 AliMpRow* row = (AliMpRow*)fRows[irow];
2294822d 350
5f91c9e8 351 for (Int_t iseg=0; iseg<row->GetNofRowSegments(); iseg++) {
352 AliMpVRowSegment* segment = row->GetRowSegment(iseg);
353 if (segment->HasMotifPosition(motifPositionId)) return segment;
354 }
355 }
356
357 return 0;
358}
359
360//_____________________________________________________________________________
361TVector2 AliMpSector::FindPosition(Int_t motifPositionId) const
362{
dee1d5f1 363/// Find the position of the motif specified by its position Id. \n
364/// Return 0 if no row segment is found.
5f91c9e8 365
366 AliMpVRowSegment* segment = FindRowSegment(motifPositionId);
367
368 if (!segment) {
2c605e66 369 AliWarningStream() << "Given motifPositionId not found." << endl;
5f91c9e8 370 return TVector2();
371 }
372
373 return segment->MotifCenter(motifPositionId);
374}
375
376//_____________________________________________________________________________
377AliMpZone* AliMpSector::FindZone(const TVector2& padDimensions) const
378{
dee1d5f1 379/// Find the zone with specified padDimensions.
5f91c9e8 380
381 for (Int_t i=0; i<GetNofZones(); i++) {
382 AliMpZone* zone = GetZone(i+1);
383 if (AliMpConstants::IsEqual(padDimensions, zone->GetPadDimensions()))
384 return zone;
385 }
386
387 // Return 0 if not found
388 return 0;
389}
390
391//_____________________________________________________________________________
392TVector2 AliMpSector::Position() const
393{
dee1d5f1 394/// Return the sector offset.
5f91c9e8 395
396 return fOffset;
397}
398
399
400//_____________________________________________________________________________
401TVector2 AliMpSector::Dimensions() const
402{
dee1d5f1 403/// Return the maximum halflengths in x, y.
5f91c9e8 404
405 Double_t x = 0.;
406 Double_t y = 0.;
407 for (Int_t i=0; i<GetNofRows(); i++) {
408
f79c58a5 409 // take the largest x row dimension
410 if ( ((AliMpRow*)fRows[i])->Dimensions().X() > x)
411 x = ((AliMpRow*)fRows[i])->Dimensions().X();
412
413 // add all rows y dimensions
414 y += ((AliMpRow*)fRows[i])->Dimensions().Y();
5f91c9e8 415 }
416
417 return TVector2(x, y);
418}
419
420//_____________________________________________________________________________
421Int_t AliMpSector::GetNofZones() const
422{
dee1d5f1 423/// Return the number of zones.
5f91c9e8 424
f79c58a5 425 return fZones.GetEntriesFast();
5f91c9e8 426}
427
428//_____________________________________________________________________________
429AliMpZone* AliMpSector::GetZone(Int_t zoneID) const
430{
dee1d5f1 431/// Return zone with specified ID.
5f91c9e8 432
433 if (zoneID < 1 || zoneID > GetNofZones()) {
2c605e66 434 AliWarningStream() << "Index outside range" << endl;
5f91c9e8 435 return 0;
436 }
437
f79c58a5 438 return (AliMpZone*)fZones[zoneID-1];
5f91c9e8 439}
440
441//_____________________________________________________________________________
442Int_t AliMpSector::GetNofRows() const
443{
dee1d5f1 444/// Return the number of rows.
5f91c9e8 445
f79c58a5 446 return fRows.GetEntriesFast();
5f91c9e8 447}
448
449//_____________________________________________________________________________
450AliMpRow* AliMpSector::GetRow(Int_t rowID) const
451{
dee1d5f1 452/// Return row with specified ID.
5f91c9e8 453
454 if (rowID < 0 || rowID >= GetNofRows()) {
2c605e66 455 AliWarningStream() << "Index outside range" << endl;
5f91c9e8 456 return 0;
457 }
458
f79c58a5 459 return (AliMpRow*)fRows[rowID];
5f91c9e8 460}
c9da0af9 461
f9a3ff6a 462//_____________________________________________________________________________
cddd101e 463AliMp::PlaneType
f9a3ff6a 464AliMpSector::GetPlaneType() const
465{
466/// Return the plane type
467
cddd101e 468 return GetDirection()==AliMp::kY ? AliMp::kBendingPlane : AliMp::kNonBendingPlane;
f9a3ff6a 469}
470
3635f34f 471//_____________________________________________________________________________
472Int_t
473AliMpSector::GetNofMotifPositions() const
474{
475 /// Return the number of manus
476
477 return fMotifMap->GetNofMotifPositions();
478}
479
f9a3ff6a 480//_____________________________________________________________________________
481void
482AliMpSector::GetAllMotifPositionsIDs(TArrayI& ecn) const
483{
484/// Return the array of all motif positions IDs
485
486 fMotifMap->GetAllMotifPositionsIDs(ecn);
487}
488
c9da0af9 489//_____________________________________________________________________________
490void
491AliMpSector::Print(Option_t* opt) const
492{
f9a3ff6a 493/// Print the map of motifs
494
495 cout << "Sector," << PlaneTypeName(GetPlaneType()) << endl;
c9da0af9 496 fMotifMap->Print(opt);
497}