]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpSector.cxx
Removing gcc 4.3 warnings
[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#ifdef WITH_STL
5f91c9e8 68 for (Int_t izone = 0; izone<nofZones; izone++)
69 fZones.push_back(new AliMpZone(izone+1));
70
71 for (Int_t irow = 0; irow<nofRows; irow++)
72 fRows.push_back(new AliMpRow(irow, fMotifMap));
f79c58a5 73#endif
74
75#ifdef WITH_ROOT
76 for (Int_t izone = 0; izone<nofZones; izone++)
77 fZones.Add(new AliMpZone(izone+1));
78
79 for (Int_t irow = 0; irow<nofRows; irow++)
80 fRows.Add(new AliMpRow(irow, fMotifMap));
81#endif
5f91c9e8 82}
83
84//_____________________________________________________________________________
85AliMpSector::AliMpSector()
5006ec94 86 : TNamed(),
5f91c9e8 87 fID(""),
88 fOffset(TVector2(0., 0.)),
89 fZones(),
90 fRows(),
91 fMotifMap(0),
cddd101e 92 fDirection(AliMp::kX),
f9a3ff6a 93 fMinPadDimensions(TVector2(0., 0.)),
b0d9eae3 94 fMaxPadDimensions(),
f9a3ff6a 95 fMaxPadIndices(AliMpIntPair::Invalid()),
96 fNofPads(0)
5f91c9e8 97{
dee1d5f1 98/// Default constructor
642b74ab 99
100 AliDebugStream(1) << "this = " << this << endl;
5f91c9e8 101}
102
103//_____________________________________________________________________________
dee1d5f1 104AliMpSector::~AliMpSector()
105{
106/// Destructor
107
642b74ab 108 AliDebugStream(1) << "this = " << this << endl;
109
5f91c9e8 110 // deletes
111 for (Int_t izone = 0; izone<GetNofZones(); izone++)
112 delete fZones[izone];
113
114 for (Int_t irow = 0; irow<GetNofRows(); irow++)
115 delete fRows[irow];
116
117 delete fMotifMap;
118}
119
120//
121// private methods
122//
123
124//_____________________________________________________________________________
125AliMpVPadIterator* AliMpSector::CreateIterator() const
126{
dee1d5f1 127/// Create sector pad iterator
128
5f91c9e8 129 return new AliMpSectorPadIterator(this);
130}
131
132
133//_____________________________________________________________________________
134AliMpVRowSegment* AliMpSector::FindRowSegment(const TVector2& position) const
135{
dee1d5f1 136/// Find the row segment in the specified position. \n
137/// Return if no motif is found.
5f91c9e8 138
139 // Find row
140 AliMpRow* row = FindRow(position);
141
142 if (!row) return 0;
143
144 // Find the row segment and return its motif
145 AliMpVRowSegment* rowSegment = row->FindRowSegment(position.X());
146
147 return rowSegment;
148}
149
150//_____________________________________________________________________________
151void AliMpSector::SetRowOffsets()
152{
dee1d5f1 153/// For each row check consitency of the row segments
154/// and calculate the row offset.
5f91c9e8 155
156 Double_t offset = fOffset.Y();
157
f79c58a5 158 for (Int_t irow=0; irow<GetNofRows(); irow++)
5f91c9e8 159 offset = GetRow(irow)->SetOffsetY(offset);
160}
161
162//_____________________________________________________________________________
163void AliMpSector::SetMotifPositions()
164{
dee1d5f1 165/// Create motif positions objects and fills them in the motif map.
5f91c9e8 166
f79c58a5 167 for (Int_t i=0; i<GetNofRows(); i++)
5f91c9e8 168 GetRow(i)->SetMotifPositions();
169}
170
171//_____________________________________________________________________________
172void AliMpSector::SetGlobalIndices()
173{
dee1d5f1 174/// Set the indices limits to all indexed elements
175/// (row, row segment, motif positions).
5f91c9e8 176
177 AliMpIntPair indices(0,0);
178 AliMpRow* rowBefore=0;
f79c58a5 179 for (Int_t i=0; i<GetNofRows(); i++) {
5f91c9e8 180 GetRow(i)->SetGlobalIndices(fDirection, rowBefore);
181 rowBefore = GetRow(i);
182 }
183}
184
185//_____________________________________________________________________________
b0d9eae3 186void AliMpSector::SetMinMaxPadDimensions()
5f91c9e8 187{
dee1d5f1 188/// Set the minimal pad dimensions.
5f91c9e8 189
190 for (Int_t i=1; i<GetNofZones()+1; i++) {
191 TVector2 padDimensions = GetZone(i)->GetPadDimensions();
192
94bf739c 193 if ( (fDirection == AliMp::kX &&
194 padDimensions.Y() > 0. && padDimensions.Y() < fMinPadDimensions.Y()) ||
195 (fDirection == AliMp::kY &&
196 padDimensions.X() > 0. && padDimensions.X() < fMinPadDimensions.X()))
5f91c9e8 197
198 fMinPadDimensions = padDimensions;
b0d9eae3 199
94bf739c 200 if ( (fDirection == AliMp::kX &&
201 padDimensions.Y() > 0. && padDimensions.Y() > fMaxPadDimensions.Y()) ||
202 (fDirection == AliMp::kY &&
203 padDimensions.X() > 0. && padDimensions.X() > fMinPadDimensions.X()))
b0d9eae3 204
205 fMaxPadDimensions = padDimensions;
5f91c9e8 206 }
207}
208
f9a3ff6a 209//_____________________________________________________________________________
210void AliMpSector::SetMaxPadIndices()
211{
212/// Set maximum pad indices in x, y
213
214 if ( fMaxPadIndices != AliMpIntPair::Invalid() ) return;
215
216 Int_t maxIndexInX = 0;
217 Int_t maxIndexInY = 0;
218 for (Int_t i=0; i<GetNofRows(); i++) {
219
220 Int_t ixh = GetRow(i)->GetHighIndicesLimit().GetFirst();
221 if ( ixh > maxIndexInX ) maxIndexInX = ixh;
222
223 Int_t iyh = GetRow(i)->GetHighIndicesLimit().GetSecond();
224 if ( iyh > maxIndexInY ) maxIndexInY = iyh;
225 }
226
227 fMaxPadIndices = AliMpIntPair(maxIndexInX, maxIndexInY);
228}
229
230
231//_____________________________________________________________________________
232void AliMpSector::SetNofPads()
233{
234/// Set the total number of pads
235
236 fNofPads = fMotifMap->CalculateNofPads();
237}
238
5f91c9e8 239//
240// public methods
241//
242
243//_____________________________________________________________________________
244void AliMpSector::SetRowSegmentOffsets()
245{
dee1d5f1 246/// For all rows set the offset to all row segments.
5f91c9e8 247
f79c58a5 248 for (Int_t irow=0; irow<GetNofRows(); irow++)
5f91c9e8 249 GetRow(irow)->SetRowSegmentOffsets(fOffset);
250}
251
252//_____________________________________________________________________________
253void AliMpSector::Initialize()
254{
dee1d5f1 255/// Make needed settings after sector is read from
256/// data files.
5f91c9e8 257
258 SetRowOffsets();
259 SetMotifPositions();
260 SetGlobalIndices();
b0d9eae3 261 SetMinMaxPadDimensions();
f9a3ff6a 262 SetMaxPadIndices();
263 SetNofPads();
5f91c9e8 264}
265
266//_____________________________________________________________________________
267void AliMpSector::PrintGeometry() const
268{
dee1d5f1 269/// Print the positions of rows, rows segments
5f91c9e8 270
271 for (Int_t i=0; i<GetNofRows(); i++) {
272 AliMpRow* row = GetRow(i);
273
274 cout << "ROW " << row->GetID()
275 << " center Y " << row->Position().Y() << endl;
276
277 for (Int_t j=0; j<row->GetNofRowSegments(); j++) {
278 AliMpVRowSegment* rowSegment = row->GetRowSegment(j);
279
280 cout << " ROW Segment " << j
281 << " borders "
282 << rowSegment->LeftBorderX() << " "
283 << rowSegment->RightBorderX()
284 << " x-size "
285 << 2*rowSegment->Dimensions().X() << " "
286 << endl;
287 }
288 }
289}
290
291
292//_____________________________________________________________________________
293AliMpRow* AliMpSector::FindRow(const TVector2& position) const
294{
dee1d5f1 295/// Find the row for the specified y position. \n
296/// If y is on border the lowest row is returned.
5f91c9e8 297
298 Double_t y = position.Y();
299
f79c58a5 300#ifdef WITH_STL
301 for (Int_t i=0; i<GetNofRows(); i++) {
5f91c9e8 302 if ( y >= fRows[i]->LowBorderY() && y <= fRows[i]->UpperBorderY())
303 return fRows[i];
304 }
f79c58a5 305#endif
306
307#ifdef WITH_ROOT
308 for (Int_t i=0; i<GetNofRows(); i++) {
309 if ( y >= ((AliMpRow*)fRows[i])->LowBorderY() &&
310 y <= ((AliMpRow*)fRows[i])->UpperBorderY())
311 return (AliMpRow*)fRows[i];
312 }
313#endif
5f91c9e8 314
315 return 0;
316}
317
318//_____________________________________________________________________________
319AliMpVMotif* AliMpSector::FindMotif(const TVector2& position) const
320{
dee1d5f1 321/// Find the motif in the specified position. \n
322/// Return 0 if no motif is found.
5f91c9e8 323
324 // Find the row segment
325 AliMpVRowSegment* rowSegment = FindRowSegment(position);
326
327 if (!rowSegment) return 0;
328
329 // Find motif
330 return rowSegment->FindMotif(position);
331}
5f91c9e8 332//_____________________________________________________________________________
333Int_t AliMpSector::FindMotifPositionId(const TVector2& position) const
334{
dee1d5f1 335/// Find the motif position ID in the specified position. \n
336/// Return 0 if no motif is found.
337
5f91c9e8 338 // Find the row segment
339 AliMpVRowSegment* rowSegment = FindRowSegment(position);
340
341 if (!rowSegment) return 0;
342
343 // Find motif position ID
344 return rowSegment->FindMotifPositionId(position);
345}
346
347//_____________________________________________________________________________
348AliMpRow* AliMpSector::FindRow(Int_t motifPositionId) const
349{
dee1d5f1 350/// Find the row with the the specified motif position. \n
351/// Return 0 if no row is found.
5f91c9e8 352
353 AliMpVRowSegment* segment = FindRowSegment(motifPositionId);
354
355 if (segment) return segment->GetRow();
356
357 return 0;
358}
359
360//_____________________________________________________________________________
361AliMpVRowSegment* AliMpSector::FindRowSegment(Int_t motifPositionId) const
362{
dee1d5f1 363/// Find the row segment with the the specified motif position. \n
364/// Return 0 if no row segment is found.
5f91c9e8 365
f79c58a5 366 for (Int_t irow=0; irow<GetNofRows(); irow++) {
367
368#ifdef WITH_STL
5f91c9e8 369 AliMpRow* row = fRows[irow];
f79c58a5 370#endif
371#ifdef WITH_ROOT
372 AliMpRow* row = (AliMpRow*)fRows[irow];
373#endif
5f91c9e8 374
375 for (Int_t iseg=0; iseg<row->GetNofRowSegments(); iseg++) {
376 AliMpVRowSegment* segment = row->GetRowSegment(iseg);
377 if (segment->HasMotifPosition(motifPositionId)) return segment;
378 }
379 }
380
381 return 0;
382}
383
384//_____________________________________________________________________________
385TVector2 AliMpSector::FindPosition(Int_t motifPositionId) const
386{
dee1d5f1 387/// Find the position of the motif specified by its position Id. \n
388/// Return 0 if no row segment is found.
5f91c9e8 389
390 AliMpVRowSegment* segment = FindRowSegment(motifPositionId);
391
392 if (!segment) {
2c605e66 393 AliWarningStream() << "Given motifPositionId not found." << endl;
5f91c9e8 394 return TVector2();
395 }
396
397 return segment->MotifCenter(motifPositionId);
398}
399
400//_____________________________________________________________________________
401AliMpZone* AliMpSector::FindZone(const TVector2& padDimensions) const
402{
dee1d5f1 403/// Find the zone with specified padDimensions.
5f91c9e8 404
405 for (Int_t i=0; i<GetNofZones(); i++) {
406 AliMpZone* zone = GetZone(i+1);
407 if (AliMpConstants::IsEqual(padDimensions, zone->GetPadDimensions()))
408 return zone;
409 }
410
411 // Return 0 if not found
412 return 0;
413}
414
415//_____________________________________________________________________________
416TVector2 AliMpSector::Position() const
417{
dee1d5f1 418/// Return the sector offset.
5f91c9e8 419
420 return fOffset;
421}
422
423
424//_____________________________________________________________________________
425TVector2 AliMpSector::Dimensions() const
426{
dee1d5f1 427/// Return the maximum halflengths in x, y.
5f91c9e8 428
429 Double_t x = 0.;
430 Double_t y = 0.;
431 for (Int_t i=0; i<GetNofRows(); i++) {
432
f79c58a5 433#ifdef WITH_STL
5f91c9e8 434 // take the largest x row dimension
435 if (fRows[i]->Dimensions().X() > x)
436 x = fRows[i]->Dimensions().X();
437
438 // add all rows y dimensions
439 y += fRows[i]->Dimensions().Y();
f79c58a5 440#endif
441
442#ifdef WITH_ROOT
443 // take the largest x row dimension
444 if ( ((AliMpRow*)fRows[i])->Dimensions().X() > x)
445 x = ((AliMpRow*)fRows[i])->Dimensions().X();
446
447 // add all rows y dimensions
448 y += ((AliMpRow*)fRows[i])->Dimensions().Y();
449#endif
5f91c9e8 450 }
451
452 return TVector2(x, y);
453}
454
455//_____________________________________________________________________________
456Int_t AliMpSector::GetNofZones() const
457{
dee1d5f1 458/// Return the number of zones.
5f91c9e8 459
f79c58a5 460#ifdef WITH_STL
5f91c9e8 461 return fZones.size();
f79c58a5 462#endif
463
464#ifdef WITH_ROOT
465 return fZones.GetEntriesFast();
466#endif
5f91c9e8 467}
468
469//_____________________________________________________________________________
470AliMpZone* AliMpSector::GetZone(Int_t zoneID) const
471{
dee1d5f1 472/// Return zone with specified ID.
5f91c9e8 473
474 if (zoneID < 1 || zoneID > GetNofZones()) {
2c605e66 475 AliWarningStream() << "Index outside range" << endl;
5f91c9e8 476 return 0;
477 }
478
f79c58a5 479#ifdef WITH_STL
5f91c9e8 480 return fZones[zoneID-1];
f79c58a5 481#endif
482
483#ifdef WITH_ROOT
484 return (AliMpZone*)fZones[zoneID-1];
485#endif
5f91c9e8 486}
487
488//_____________________________________________________________________________
489Int_t AliMpSector::GetNofRows() const
490{
dee1d5f1 491/// Return the number of rows.
5f91c9e8 492
f79c58a5 493#ifdef WITH_STL
5f91c9e8 494 return fRows.size();
f79c58a5 495#endif
496
497#ifdef WITH_ROOT
498 return fRows.GetEntriesFast();
499#endif
5f91c9e8 500}
501
502//_____________________________________________________________________________
503AliMpRow* AliMpSector::GetRow(Int_t rowID) const
504{
dee1d5f1 505/// Return row with specified ID.
5f91c9e8 506
507 if (rowID < 0 || rowID >= GetNofRows()) {
2c605e66 508 AliWarningStream() << "Index outside range" << endl;
5f91c9e8 509 return 0;
510 }
511
f79c58a5 512#ifdef WITH_STL
5f91c9e8 513 return fRows[rowID];
f79c58a5 514#endif
515
516#ifdef WITH_ROOT
517 return (AliMpRow*)fRows[rowID];
518#endif
5f91c9e8 519}
c9da0af9 520
f9a3ff6a 521//_____________________________________________________________________________
cddd101e 522AliMp::PlaneType
f9a3ff6a 523AliMpSector::GetPlaneType() const
524{
525/// Return the plane type
526
cddd101e 527 return GetDirection()==AliMp::kY ? AliMp::kBendingPlane : AliMp::kNonBendingPlane;
f9a3ff6a 528}
529
530//_____________________________________________________________________________
531void
532AliMpSector::GetAllMotifPositionsIDs(TArrayI& ecn) const
533{
534/// Return the array of all motif positions IDs
535
536 fMotifMap->GetAllMotifPositionsIDs(ecn);
537}
538
c9da0af9 539//_____________________________________________________________________________
540void
541AliMpSector::Print(Option_t* opt) const
542{
f9a3ff6a 543/// Print the map of motifs
544
545 cout << "Sector," << PlaneTypeName(GetPlaneType()) << endl;
c9da0af9 546 fMotifMap->Print(opt);
547}