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