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.9 2005/09/02 10:01:09 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)
49 fDirection(direction),
50 fMinPadDimensions(TVector2(1.e6, 1.e6))
52 /// Standard constructor
54 fMotifMap = new AliMpMotifMap();
57 for (Int_t izone = 0; izone<nofZones; izone++)
58 fZones.push_back(new AliMpZone(izone+1));
60 for (Int_t irow = 0; irow<nofRows; irow++)
61 fRows.push_back(new AliMpRow(irow, fMotifMap));
65 for (Int_t izone = 0; izone<nofZones; izone++)
66 fZones.Add(new AliMpZone(izone+1));
68 for (Int_t irow = 0; irow<nofRows; irow++)
69 fRows.Add(new AliMpRow(irow, fMotifMap));
73 //_____________________________________________________________________________
74 AliMpSector::AliMpSector(const AliMpSector& right)
77 /// Protected copy constructor (not provided)
79 Fatal("AliMpSector", "Copy constructor not provided.");
82 //_____________________________________________________________________________
83 AliMpSector::AliMpSector()
86 fOffset(TVector2(0., 0.)),
91 fMinPadDimensions(TVector2(0., 0.))
93 /// Default constructor
96 //_____________________________________________________________________________
97 AliMpSector::~AliMpSector()
102 for (Int_t izone = 0; izone<GetNofZones(); izone++)
103 delete fZones[izone];
105 for (Int_t irow = 0; irow<GetNofRows(); irow++)
115 //_____________________________________________________________________________
116 AliMpSector& AliMpSector::operator=(const AliMpSector& right)
118 /// Protected assignment operator (not provided)
120 // check assignment to self
121 if (this == &right) return *this;
123 Fatal("operator =", "Assignment operator not provided.");
132 //_____________________________________________________________________________
133 AliMpVPadIterator* AliMpSector::CreateIterator() const
135 /// Create sector pad iterator
137 return new AliMpSectorPadIterator(this);
141 //_____________________________________________________________________________
142 AliMpVRowSegment* AliMpSector::FindRowSegment(const TVector2& position) const
144 /// Find the row segment in the specified position. \n
145 /// Return if no motif is found.
148 AliMpRow* row = FindRow(position);
152 // Find the row segment and return its motif
153 AliMpVRowSegment* rowSegment = row->FindRowSegment(position.X());
158 //_____________________________________________________________________________
159 void AliMpSector::SetRowOffsets()
161 /// For each row check consitency of the row segments
162 /// and calculate the row offset.
164 Double_t offset = fOffset.Y();
166 for (Int_t irow=0; irow<GetNofRows(); irow++)
167 offset = GetRow(irow)->SetOffsetY(offset);
170 //_____________________________________________________________________________
171 void AliMpSector::SetMotifPositions()
173 /// Create motif positions objects and fills them in the motif map.
175 for (Int_t i=0; i<GetNofRows(); i++)
176 GetRow(i)->SetMotifPositions();
179 //_____________________________________________________________________________
180 void AliMpSector::SetGlobalIndices()
182 /// Set the indices limits to all indexed elements
183 /// (row, row segment, motif positions).
185 AliMpIntPair indices(0,0);
186 AliMpRow* rowBefore=0;
187 for (Int_t i=0; i<GetNofRows(); i++) {
188 GetRow(i)->SetGlobalIndices(fDirection, rowBefore);
189 rowBefore = GetRow(i);
193 //_____________________________________________________________________________
194 void AliMpSector::SetMinPadDimensions()
196 /// Set the minimal pad dimensions.
198 for (Int_t i=1; i<GetNofZones()+1; i++) {
199 TVector2 padDimensions = GetZone(i)->GetPadDimensions();
201 if ( fDirection == kX &&
202 padDimensions.Y() > 0. && padDimensions.Y() < fMinPadDimensions.Y() ||
204 padDimensions.X() > 0. && padDimensions.X() < fMinPadDimensions.X())
206 fMinPadDimensions = padDimensions;
214 //_____________________________________________________________________________
215 void AliMpSector::SetRowSegmentOffsets()
217 /// For all rows set the offset to all row segments.
219 for (Int_t irow=0; irow<GetNofRows(); irow++)
220 GetRow(irow)->SetRowSegmentOffsets(fOffset);
223 //_____________________________________________________________________________
224 void AliMpSector::Initialize()
226 /// Make needed settings after sector is read from
232 SetMinPadDimensions();
235 //_____________________________________________________________________________
236 void AliMpSector::PrintGeometry() const
238 /// Print the positions of rows, rows segments
240 for (Int_t i=0; i<GetNofRows(); i++) {
241 AliMpRow* row = GetRow(i);
243 cout << "ROW " << row->GetID()
244 << " center Y " << row->Position().Y() << endl;
246 for (Int_t j=0; j<row->GetNofRowSegments(); j++) {
247 AliMpVRowSegment* rowSegment = row->GetRowSegment(j);
249 cout << " ROW Segment " << j
251 << rowSegment->LeftBorderX() << " "
252 << rowSegment->RightBorderX()
254 << 2*rowSegment->Dimensions().X() << " "
261 //_____________________________________________________________________________
262 AliMpRow* AliMpSector::FindRow(const TVector2& position) const
264 /// Find the row for the specified y position. \n
265 /// If y is on border the lowest row is returned.
267 Double_t y = position.Y();
270 for (Int_t i=0; i<GetNofRows(); i++) {
271 if ( y >= fRows[i]->LowBorderY() && y <= fRows[i]->UpperBorderY())
277 for (Int_t i=0; i<GetNofRows(); i++) {
278 if ( y >= ((AliMpRow*)fRows[i])->LowBorderY() &&
279 y <= ((AliMpRow*)fRows[i])->UpperBorderY())
280 return (AliMpRow*)fRows[i];
287 //_____________________________________________________________________________
288 AliMpVMotif* AliMpSector::FindMotif(const TVector2& position) const
290 /// Find the motif in the specified position. \n
291 /// Return 0 if no motif is found.
293 // Find the row segment
294 AliMpVRowSegment* rowSegment = FindRowSegment(position);
296 if (!rowSegment) return 0;
299 return rowSegment->FindMotif(position);
301 //_____________________________________________________________________________
302 Int_t AliMpSector::FindMotifPositionId(const TVector2& position) const
304 /// Find the motif position ID in the specified position. \n
305 /// Return 0 if no motif is found.
307 // Find the row segment
308 AliMpVRowSegment* rowSegment = FindRowSegment(position);
310 if (!rowSegment) return 0;
312 // Find motif position ID
313 return rowSegment->FindMotifPositionId(position);
316 //_____________________________________________________________________________
317 AliMpRow* AliMpSector::FindRow(Int_t motifPositionId) const
319 /// Find the row with the the specified motif position. \n
320 /// Return 0 if no row is found.
322 AliMpVRowSegment* segment = FindRowSegment(motifPositionId);
324 if (segment) return segment->GetRow();
329 //_____________________________________________________________________________
330 AliMpVRowSegment* AliMpSector::FindRowSegment(Int_t motifPositionId) const
332 /// Find the row segment with the the specified motif position. \n
333 /// Return 0 if no row segment is found.
335 for (Int_t irow=0; irow<GetNofRows(); irow++) {
338 AliMpRow* row = fRows[irow];
341 AliMpRow* row = (AliMpRow*)fRows[irow];
344 for (Int_t iseg=0; iseg<row->GetNofRowSegments(); iseg++) {
345 AliMpVRowSegment* segment = row->GetRowSegment(iseg);
346 if (segment->HasMotifPosition(motifPositionId)) return segment;
353 //_____________________________________________________________________________
354 TVector2 AliMpSector::FindPosition(Int_t motifPositionId) const
356 /// Find the position of the motif specified by its position Id. \n
357 /// Return 0 if no row segment is found.
359 AliMpVRowSegment* segment = FindRowSegment(motifPositionId);
362 Warning("FindPosition", "Given motifPositionId not found.");
366 return segment->MotifCenter(motifPositionId);
369 //_____________________________________________________________________________
370 AliMpZone* AliMpSector::FindZone(const TVector2& padDimensions) const
372 /// Find the zone with specified padDimensions.
374 for (Int_t i=0; i<GetNofZones(); i++) {
375 AliMpZone* zone = GetZone(i+1);
376 if (AliMpConstants::IsEqual(padDimensions, zone->GetPadDimensions()))
380 // Return 0 if not found
384 //_____________________________________________________________________________
385 TVector2 AliMpSector::Position() const
387 /// Return the sector offset.
393 //_____________________________________________________________________________
394 TVector2 AliMpSector::Dimensions() const
396 /// Return the maximum halflengths in x, y.
400 for (Int_t i=0; i<GetNofRows(); i++) {
403 // take the largest x row dimension
404 if (fRows[i]->Dimensions().X() > x)
405 x = fRows[i]->Dimensions().X();
407 // add all rows y dimensions
408 y += fRows[i]->Dimensions().Y();
412 // take the largest x row dimension
413 if ( ((AliMpRow*)fRows[i])->Dimensions().X() > x)
414 x = ((AliMpRow*)fRows[i])->Dimensions().X();
416 // add all rows y dimensions
417 y += ((AliMpRow*)fRows[i])->Dimensions().Y();
421 return TVector2(x, y);
424 //_____________________________________________________________________________
425 Int_t AliMpSector::GetNofZones() const
427 /// Return the number of zones.
430 return fZones.size();
434 return fZones.GetEntriesFast();
438 //_____________________________________________________________________________
439 AliMpZone* AliMpSector::GetZone(Int_t zoneID) const
441 /// Return zone with specified ID.
443 if (zoneID < 1 || zoneID > GetNofZones()) {
444 Warning("GetZone", "Index outside range");
449 return fZones[zoneID-1];
453 return (AliMpZone*)fZones[zoneID-1];
457 //_____________________________________________________________________________
458 Int_t AliMpSector::GetNofRows() const
460 /// Return the number of rows.
467 return fRows.GetEntriesFast();
471 //_____________________________________________________________________________
472 AliMpRow* AliMpSector::GetRow(Int_t rowID) const
474 /// Return row with specified ID.
476 if (rowID < 0 || rowID >= GetNofRows()) {
477 Warning("GetRow", "Index outside range");
486 return (AliMpRow*)fRows[rowID];