6 // Class describing the sector of the MUON chamber of station 1.
8 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
10 #include <Riostream.h>
12 #include "AliMpSector.h"
13 #include "AliMpSectorPadIterator.h"
14 #include "AliMpZone.h"
16 #include "AliMpVRowSegment.h"
17 #include "AliMpVMotif.h"
18 #include "AliMpMotifMap.h"
19 #include "AliMpIntPair.h"
20 #include "AliMpConstants.h"
24 //_____________________________________________________________________________
25 AliMpSector::AliMpSector(const TString& id, Int_t nofZones, Int_t nofRows,
26 AliMpDirection direction)
29 fOffset(TVector2(0., 0.)),
32 fDirection(direction),
33 fMinPadDimensions(TVector2(1.e6, 1.e6))
36 fMotifMap = new AliMpMotifMap();
38 for (Int_t izone = 0; izone<nofZones; izone++)
39 fZones.push_back(new AliMpZone(izone+1));
41 for (Int_t irow = 0; irow<nofRows; irow++)
42 fRows.push_back(new AliMpRow(irow, fMotifMap));
46 //_____________________________________________________________________________
47 AliMpSector::AliMpSector()
50 fOffset(TVector2(0., 0.)),
55 fMinPadDimensions(TVector2(0., 0.))
60 //_____________________________________________________________________________
61 AliMpSector::~AliMpSector() {
64 for (Int_t izone = 0; izone<GetNofZones(); izone++)
67 for (Int_t irow = 0; irow<GetNofRows(); irow++)
77 //_____________________________________________________________________________
78 AliMpVPadIterator* AliMpSector::CreateIterator() const
80 return new AliMpSectorPadIterator(this);
84 //_____________________________________________________________________________
85 AliMpVRowSegment* AliMpSector::FindRowSegment(const TVector2& position) const
87 // Finds the row segment in the specified position.
88 // Returns 0 if no motif is found.
92 AliMpRow* row = FindRow(position);
96 // Find the row segment and return its motif
97 AliMpVRowSegment* rowSegment = row->FindRowSegment(position.X());
102 //_____________________________________________________________________________
103 void AliMpSector::SetRowOffsets()
105 // For each row checks consitency of the row segments
106 // and calculates the row offset.
109 Double_t offset = fOffset.Y();
111 for (UInt_t irow=0; irow<fRows.size(); irow++)
112 offset = GetRow(irow)->SetOffsetY(offset);
115 //_____________________________________________________________________________
116 void AliMpSector::SetMotifPositions()
118 // Creates motif positions objects and fills them in the motif map.
121 for (UInt_t i=0; i<fRows.size(); i++)
122 GetRow(i)->SetMotifPositions();
125 //_____________________________________________________________________________
126 void AliMpSector::SetGlobalIndices()
128 // Set the indices limits to all indexed elements
129 // (row, row segment, motif positions).
132 AliMpIntPair indices(0,0);
133 AliMpRow* rowBefore=0;
134 for (UInt_t i=0; i<fRows.size(); i++) {
135 GetRow(i)->SetGlobalIndices(fDirection, rowBefore);
136 rowBefore = GetRow(i);
140 //_____________________________________________________________________________
141 void AliMpSector::SetMinPadDimensions()
143 // Sets the minimal pad dimensions.
146 for (Int_t i=1; i<GetNofZones()+1; i++) {
147 TVector2 padDimensions = GetZone(i)->GetPadDimensions();
149 if ( fDirection == kX &&
150 padDimensions.Y() > 0. && padDimensions.Y() < fMinPadDimensions.Y() ||
152 padDimensions.X() > 0. && padDimensions.X() < fMinPadDimensions.X())
154 fMinPadDimensions = padDimensions;
162 //_____________________________________________________________________________
163 void AliMpSector::SetRowSegmentOffsets()
165 // For all rows sets offset to all row segments.
168 for (UInt_t irow=0; irow<fRows.size(); irow++)
169 GetRow(irow)->SetRowSegmentOffsets(fOffset);
172 //_____________________________________________________________________________
173 void AliMpSector::Initialize()
175 // Makes needed settings after sector is read from
182 SetMinPadDimensions();
185 //_____________________________________________________________________________
186 void AliMpSector::PrintGeometry() const
188 // Prints the positions of rows, rows segments
191 for (Int_t i=0; i<GetNofRows(); i++) {
192 AliMpRow* row = GetRow(i);
194 cout << "ROW " << row->GetID()
195 << " center Y " << row->Position().Y() << endl;
197 for (Int_t j=0; j<row->GetNofRowSegments(); j++) {
198 AliMpVRowSegment* rowSegment = row->GetRowSegment(j);
200 cout << " ROW Segment " << j
202 << rowSegment->LeftBorderX() << " "
203 << rowSegment->RightBorderX()
205 << 2*rowSegment->Dimensions().X() << " "
212 //_____________________________________________________________________________
213 AliMpRow* AliMpSector::FindRow(const TVector2& position) const
215 // Finds the row for the specified y position.
216 // If y is on border the lowest row is returned.
219 Double_t y = position.Y();
221 for (UInt_t i=0; i<fRows.size(); i++) {
222 if ( y >= fRows[i]->LowBorderY() && y <= fRows[i]->UpperBorderY())
229 //_____________________________________________________________________________
230 AliMpVMotif* AliMpSector::FindMotif(const TVector2& position) const
232 // Finds the motif in the specified position.
233 // Returns 0 if no motif is found.
236 // Find the row segment
237 AliMpVRowSegment* rowSegment = FindRowSegment(position);
239 if (!rowSegment) return 0;
242 return rowSegment->FindMotif(position);
245 //_____________________________________________________________________________
246 Int_t AliMpSector::FindMotifPositionId(const TVector2& position) const
248 // Finds the motif position ID in the specified position.
249 // Returns 0 if no motif is found.
252 // Find the row segment
253 AliMpVRowSegment* rowSegment = FindRowSegment(position);
255 if (!rowSegment) return 0;
257 // Find motif position ID
258 return rowSegment->FindMotifPositionId(position);
261 //_____________________________________________________________________________
262 AliMpRow* AliMpSector::FindRow(Int_t motifPositionId) const
264 // Finds the row with the the specified motif position.
265 // Returns 0 if no row is found.
268 AliMpVRowSegment* segment = FindRowSegment(motifPositionId);
270 if (segment) return segment->GetRow();
275 //_____________________________________________________________________________
276 AliMpVRowSegment* AliMpSector::FindRowSegment(Int_t motifPositionId) const
278 // Finds the row segment with the the specified motif position.
279 // Returns 0 if no row segment is found.
282 for (UInt_t irow=0; irow<fRows.size(); irow++) {
283 AliMpRow* row = fRows[irow];
285 for (Int_t iseg=0; iseg<row->GetNofRowSegments(); iseg++) {
286 AliMpVRowSegment* segment = row->GetRowSegment(iseg);
287 if (segment->HasMotifPosition(motifPositionId)) return segment;
294 //_____________________________________________________________________________
295 TVector2 AliMpSector::FindPosition(Int_t motifPositionId) const
297 // Finds the position of the motif specified by its position Id.
298 // Returns 0 if no row segment is found.
301 AliMpVRowSegment* segment = FindRowSegment(motifPositionId);
304 Warning("FindPosition", "Given motifPositionId not found.");
308 return segment->MotifCenter(motifPositionId);
311 //_____________________________________________________________________________
312 AliMpZone* AliMpSector::FindZone(const TVector2& padDimensions) const
314 // Finds the zone with specified padDimensions.
317 for (Int_t i=0; i<GetNofZones(); i++) {
318 AliMpZone* zone = GetZone(i+1);
319 if (AliMpConstants::IsEqual(padDimensions, zone->GetPadDimensions()))
323 // Return 0 if not found
327 //_____________________________________________________________________________
328 TVector2 AliMpSector::Position() const
330 // Returns the offset.
337 //_____________________________________________________________________________
338 TVector2 AliMpSector::Dimensions() const
340 // Returns the maximum halflength in x, y.
345 for (Int_t i=0; i<GetNofRows(); i++) {
347 // take the largest x row dimension
348 if (fRows[i]->Dimensions().X() > x)
349 x = fRows[i]->Dimensions().X();
351 // add all rows y dimensions
352 y += fRows[i]->Dimensions().Y();
355 return TVector2(x, y);
358 //_____________________________________________________________________________
359 Int_t AliMpSector::GetNofZones() const
361 // Returns the number of zones.
364 return fZones.size();
367 //_____________________________________________________________________________
368 AliMpZone* AliMpSector::GetZone(Int_t zoneID) const
370 // Returns zone with specified ID.
373 if (zoneID < 1 || zoneID > GetNofZones()) {
374 Warning("GetZone", "Index outside range");
378 return fZones[zoneID-1];
381 //_____________________________________________________________________________
382 Int_t AliMpSector::GetNofRows() const
384 // Returns the number of rows.
390 //_____________________________________________________________________________
391 AliMpRow* AliMpSector::GetRow(Int_t rowID) const
393 // Returns row with specified ID.
396 if (rowID < 0 || rowID >= GetNofRows()) {
397 Warning("GetRow", "Index outside range");