1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // $MpId: AliMpSector.cxx,v 1.10 2005/09/26 16:12:23 ivana Exp $
22 // Class describing the sector of the MUON chamber of station 1.
23 // Included in AliRoot: 2003/05/02
24 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
27 #include <Riostream.h>
29 #include "AliMpSector.h"
30 #include "AliMpSectorPadIterator.h"
31 #include "AliMpZone.h"
33 #include "AliMpVRowSegment.h"
34 #include "AliMpVMotif.h"
35 #include "AliMpMotifMap.h"
36 #include "AliMpIntPair.h"
37 #include "AliMpConstants.h"
41 //_____________________________________________________________________________
42 AliMpSector::AliMpSector(const TString& id, Int_t nofZones, Int_t nofRows,
43 AliMpDirection direction, const TVector2& offset)
44 : TNamed("Sector", ""),
49 fDirection(direction),
50 fMinPadDimensions(TVector2(1.e6, 1.e6))
52 /// Standard constructor
54 fMotifMap = new AliMpMotifMap(true);
55 //fMotifMap = new AliMpMotifMap();
58 for (Int_t izone = 0; izone<nofZones; izone++)
59 fZones.push_back(new AliMpZone(izone+1));
61 for (Int_t irow = 0; irow<nofRows; irow++)
62 fRows.push_back(new AliMpRow(irow, fMotifMap));
66 for (Int_t izone = 0; izone<nofZones; izone++)
67 fZones.Add(new AliMpZone(izone+1));
69 for (Int_t irow = 0; irow<nofRows; irow++)
70 fRows.Add(new AliMpRow(irow, fMotifMap));
74 //_____________________________________________________________________________
75 AliMpSector::AliMpSector(const AliMpSector& right)
78 /// Protected copy constructor (not provided)
80 Fatal("AliMpSector", "Copy constructor not provided.");
83 //_____________________________________________________________________________
84 AliMpSector::AliMpSector()
87 fOffset(TVector2(0., 0.)),
92 fMinPadDimensions(TVector2(0., 0.))
94 /// Default constructor
97 //_____________________________________________________________________________
98 AliMpSector::~AliMpSector()
103 for (Int_t izone = 0; izone<GetNofZones(); izone++)
104 delete fZones[izone];
106 for (Int_t irow = 0; irow<GetNofRows(); irow++)
116 //_____________________________________________________________________________
117 AliMpSector& AliMpSector::operator=(const AliMpSector& right)
119 /// Protected assignment operator (not provided)
121 // check assignment to self
122 if (this == &right) return *this;
124 Fatal("operator =", "Assignment operator not provided.");
133 //_____________________________________________________________________________
134 AliMpVPadIterator* AliMpSector::CreateIterator() const
136 /// Create sector pad iterator
138 return new AliMpSectorPadIterator(this);
142 //_____________________________________________________________________________
143 AliMpVRowSegment* AliMpSector::FindRowSegment(const TVector2& position) const
145 /// Find the row segment in the specified position. \n
146 /// Return if no motif is found.
149 AliMpRow* row = FindRow(position);
153 // Find the row segment and return its motif
154 AliMpVRowSegment* rowSegment = row->FindRowSegment(position.X());
159 //_____________________________________________________________________________
160 void AliMpSector::SetRowOffsets()
162 /// For each row check consitency of the row segments
163 /// and calculate the row offset.
165 Double_t offset = fOffset.Y();
167 for (Int_t irow=0; irow<GetNofRows(); irow++)
168 offset = GetRow(irow)->SetOffsetY(offset);
171 //_____________________________________________________________________________
172 void AliMpSector::SetMotifPositions()
174 /// Create motif positions objects and fills them in the motif map.
176 for (Int_t i=0; i<GetNofRows(); i++)
177 GetRow(i)->SetMotifPositions();
180 //_____________________________________________________________________________
181 void AliMpSector::SetGlobalIndices()
183 /// Set the indices limits to all indexed elements
184 /// (row, row segment, motif positions).
186 AliMpIntPair indices(0,0);
187 AliMpRow* rowBefore=0;
188 for (Int_t i=0; i<GetNofRows(); i++) {
189 GetRow(i)->SetGlobalIndices(fDirection, rowBefore);
190 rowBefore = GetRow(i);
194 //_____________________________________________________________________________
195 void AliMpSector::SetMinPadDimensions()
197 /// Set the minimal pad dimensions.
199 for (Int_t i=1; i<GetNofZones()+1; i++) {
200 TVector2 padDimensions = GetZone(i)->GetPadDimensions();
202 if ( fDirection == kX &&
203 padDimensions.Y() > 0. && padDimensions.Y() < fMinPadDimensions.Y() ||
205 padDimensions.X() > 0. && padDimensions.X() < fMinPadDimensions.X())
207 fMinPadDimensions = padDimensions;
215 //_____________________________________________________________________________
216 void AliMpSector::SetRowSegmentOffsets()
218 /// For all rows set the offset to all row segments.
220 for (Int_t irow=0; irow<GetNofRows(); irow++)
221 GetRow(irow)->SetRowSegmentOffsets(fOffset);
224 //_____________________________________________________________________________
225 void AliMpSector::Initialize()
227 /// Make needed settings after sector is read from
233 SetMinPadDimensions();
236 //_____________________________________________________________________________
237 void AliMpSector::PrintGeometry() const
239 /// Print the positions of rows, rows segments
241 for (Int_t i=0; i<GetNofRows(); i++) {
242 AliMpRow* row = GetRow(i);
244 cout << "ROW " << row->GetID()
245 << " center Y " << row->Position().Y() << endl;
247 for (Int_t j=0; j<row->GetNofRowSegments(); j++) {
248 AliMpVRowSegment* rowSegment = row->GetRowSegment(j);
250 cout << " ROW Segment " << j
252 << rowSegment->LeftBorderX() << " "
253 << rowSegment->RightBorderX()
255 << 2*rowSegment->Dimensions().X() << " "
262 //_____________________________________________________________________________
263 AliMpRow* AliMpSector::FindRow(const TVector2& position) const
265 /// Find the row for the specified y position. \n
266 /// If y is on border the lowest row is returned.
268 Double_t y = position.Y();
271 for (Int_t i=0; i<GetNofRows(); i++) {
272 if ( y >= fRows[i]->LowBorderY() && y <= fRows[i]->UpperBorderY())
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];
288 //_____________________________________________________________________________
289 AliMpVMotif* AliMpSector::FindMotif(const TVector2& position) const
291 /// Find the motif in the specified position. \n
292 /// Return 0 if no motif is found.
294 // Find the row segment
295 AliMpVRowSegment* rowSegment = FindRowSegment(position);
297 if (!rowSegment) return 0;
300 return rowSegment->FindMotif(position);
302 //_____________________________________________________________________________
303 Int_t AliMpSector::FindMotifPositionId(const TVector2& position) const
305 /// Find the motif position ID in the specified position. \n
306 /// Return 0 if no motif is found.
308 // Find the row segment
309 AliMpVRowSegment* rowSegment = FindRowSegment(position);
311 if (!rowSegment) return 0;
313 // Find motif position ID
314 return rowSegment->FindMotifPositionId(position);
317 //_____________________________________________________________________________
318 AliMpRow* AliMpSector::FindRow(Int_t motifPositionId) const
320 /// Find the row with the the specified motif position. \n
321 /// Return 0 if no row is found.
323 AliMpVRowSegment* segment = FindRowSegment(motifPositionId);
325 if (segment) return segment->GetRow();
330 //_____________________________________________________________________________
331 AliMpVRowSegment* AliMpSector::FindRowSegment(Int_t motifPositionId) const
333 /// Find the row segment with the the specified motif position. \n
334 /// Return 0 if no row segment is found.
336 for (Int_t irow=0; irow<GetNofRows(); irow++) {
339 AliMpRow* row = fRows[irow];
342 AliMpRow* row = (AliMpRow*)fRows[irow];
345 for (Int_t iseg=0; iseg<row->GetNofRowSegments(); iseg++) {
346 AliMpVRowSegment* segment = row->GetRowSegment(iseg);
347 if (segment->HasMotifPosition(motifPositionId)) return segment;
354 //_____________________________________________________________________________
355 TVector2 AliMpSector::FindPosition(Int_t motifPositionId) const
357 /// Find the position of the motif specified by its position Id. \n
358 /// Return 0 if no row segment is found.
360 AliMpVRowSegment* segment = FindRowSegment(motifPositionId);
363 Warning("FindPosition", "Given motifPositionId not found.");
367 return segment->MotifCenter(motifPositionId);
370 //_____________________________________________________________________________
371 AliMpZone* AliMpSector::FindZone(const TVector2& padDimensions) const
373 /// Find the zone with specified padDimensions.
375 for (Int_t i=0; i<GetNofZones(); i++) {
376 AliMpZone* zone = GetZone(i+1);
377 if (AliMpConstants::IsEqual(padDimensions, zone->GetPadDimensions()))
381 // Return 0 if not found
385 //_____________________________________________________________________________
386 TVector2 AliMpSector::Position() const
388 /// Return the sector offset.
394 //_____________________________________________________________________________
395 TVector2 AliMpSector::Dimensions() const
397 /// Return the maximum halflengths in x, y.
401 for (Int_t i=0; i<GetNofRows(); i++) {
404 // take the largest x row dimension
405 if (fRows[i]->Dimensions().X() > x)
406 x = fRows[i]->Dimensions().X();
408 // add all rows y dimensions
409 y += fRows[i]->Dimensions().Y();
413 // take the largest x row dimension
414 if ( ((AliMpRow*)fRows[i])->Dimensions().X() > x)
415 x = ((AliMpRow*)fRows[i])->Dimensions().X();
417 // add all rows y dimensions
418 y += ((AliMpRow*)fRows[i])->Dimensions().Y();
422 return TVector2(x, y);
425 //_____________________________________________________________________________
426 Int_t AliMpSector::GetNofZones() const
428 /// Return the number of zones.
431 return fZones.size();
435 return fZones.GetEntriesFast();
439 //_____________________________________________________________________________
440 AliMpZone* AliMpSector::GetZone(Int_t zoneID) const
442 /// Return zone with specified ID.
444 if (zoneID < 1 || zoneID > GetNofZones()) {
445 Warning("GetZone", "Index outside range");
450 return fZones[zoneID-1];
454 return (AliMpZone*)fZones[zoneID-1];
458 //_____________________________________________________________________________
459 Int_t AliMpSector::GetNofRows() const
461 /// Return the number of rows.
468 return fRows.GetEntriesFast();
472 //_____________________________________________________________________________
473 AliMpRow* AliMpSector::GetRow(Int_t rowID) const
475 /// Return row with specified ID.
477 if (rowID < 0 || rowID >= GetNofRows()) {
478 Warning("GetRow", "Index outside range");
487 return (AliMpRow*)fRows[rowID];