/************************************************************************** * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ // $Id$ // $MpId: AliMpSector.cxx,v 1.14 2006/05/24 13:58:46 ivana Exp $ // Category: sector // // Class AliMpSector // ----------------- // Class describing the sector of the MUON chamber of station 1. // Included in AliRoot: 2003/05/02 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay #include "AliMpSector.h" #include "AliMpSectorPadIterator.h" #include "AliMpZone.h" #include "AliMpRow.h" #include "AliMpVRowSegment.h" #include "AliMpVMotif.h" #include "AliMpMotifMap.h" #include "AliMpIntPair.h" #include "AliMpConstants.h" #include "AliLog.h" #include /// \cond CLASSIMP ClassImp(AliMpSector) /// \endcond //_____________________________________________________________________________ AliMpSector::AliMpSector(const TString& id, Int_t nofZones, Int_t nofRows, AliMp::Direction direction, const TVector2& offset) : TNamed("Sector", ""), fID(id), fOffset(offset), fZones(), fRows(), fMotifMap(0), fDirection(direction), fMinPadDimensions(TVector2(1.e6, 1.e6)), fMaxPadIndices(AliMpIntPair::Invalid()), fNofPads(0) { /// Standard constructor AliDebugStream(1) << "this = " << this << endl; fMotifMap = new AliMpMotifMap(true); //fMotifMap = new AliMpMotifMap(); #ifdef WITH_STL for (Int_t izone = 0; izoneGetID() << " center Y " << row->Position().Y() << endl; for (Int_t j=0; jGetNofRowSegments(); j++) { AliMpVRowSegment* rowSegment = row->GetRowSegment(j); cout << " ROW Segment " << j << " borders " << rowSegment->LeftBorderX() << " " << rowSegment->RightBorderX() << " x-size " << 2*rowSegment->Dimensions().X() << " " << endl; } } } //_____________________________________________________________________________ AliMpRow* AliMpSector::FindRow(const TVector2& position) const { /// Find the row for the specified y position. \n /// If y is on border the lowest row is returned. Double_t y = position.Y(); #ifdef WITH_STL for (Int_t i=0; i= fRows[i]->LowBorderY() && y <= fRows[i]->UpperBorderY()) return fRows[i]; } #endif #ifdef WITH_ROOT for (Int_t i=0; i= ((AliMpRow*)fRows[i])->LowBorderY() && y <= ((AliMpRow*)fRows[i])->UpperBorderY()) return (AliMpRow*)fRows[i]; } #endif return 0; } //_____________________________________________________________________________ AliMpVMotif* AliMpSector::FindMotif(const TVector2& position) const { /// Find the motif in the specified position. \n /// Return 0 if no motif is found. // Find the row segment AliMpVRowSegment* rowSegment = FindRowSegment(position); if (!rowSegment) return 0; // Find motif return rowSegment->FindMotif(position); } //_____________________________________________________________________________ Int_t AliMpSector::FindMotifPositionId(const TVector2& position) const { /// Find the motif position ID in the specified position. \n /// Return 0 if no motif is found. // Find the row segment AliMpVRowSegment* rowSegment = FindRowSegment(position); if (!rowSegment) return 0; // Find motif position ID return rowSegment->FindMotifPositionId(position); } //_____________________________________________________________________________ AliMpRow* AliMpSector::FindRow(Int_t motifPositionId) const { /// Find the row with the the specified motif position. \n /// Return 0 if no row is found. AliMpVRowSegment* segment = FindRowSegment(motifPositionId); if (segment) return segment->GetRow(); return 0; } //_____________________________________________________________________________ AliMpVRowSegment* AliMpSector::FindRowSegment(Int_t motifPositionId) const { /// Find the row segment with the the specified motif position. \n /// Return 0 if no row segment is found. for (Int_t irow=0; irowGetNofRowSegments(); iseg++) { AliMpVRowSegment* segment = row->GetRowSegment(iseg); if (segment->HasMotifPosition(motifPositionId)) return segment; } } return 0; } //_____________________________________________________________________________ TVector2 AliMpSector::FindPosition(Int_t motifPositionId) const { /// Find the position of the motif specified by its position Id. \n /// Return 0 if no row segment is found. AliMpVRowSegment* segment = FindRowSegment(motifPositionId); if (!segment) { AliWarningStream() << "Given motifPositionId not found." << endl; return TVector2(); } return segment->MotifCenter(motifPositionId); } //_____________________________________________________________________________ AliMpZone* AliMpSector::FindZone(const TVector2& padDimensions) const { /// Find the zone with specified padDimensions. for (Int_t i=0; iGetPadDimensions())) return zone; } // Return 0 if not found return 0; } //_____________________________________________________________________________ TVector2 AliMpSector::Position() const { /// Return the sector offset. return fOffset; } //_____________________________________________________________________________ TVector2 AliMpSector::Dimensions() const { /// Return the maximum halflengths in x, y. Double_t x = 0.; Double_t y = 0.; for (Int_t i=0; iDimensions().X() > x) x = fRows[i]->Dimensions().X(); // add all rows y dimensions y += fRows[i]->Dimensions().Y(); #endif #ifdef WITH_ROOT // take the largest x row dimension if ( ((AliMpRow*)fRows[i])->Dimensions().X() > x) x = ((AliMpRow*)fRows[i])->Dimensions().X(); // add all rows y dimensions y += ((AliMpRow*)fRows[i])->Dimensions().Y(); #endif } return TVector2(x, y); } //_____________________________________________________________________________ Int_t AliMpSector::GetNofZones() const { /// Return the number of zones. #ifdef WITH_STL return fZones.size(); #endif #ifdef WITH_ROOT return fZones.GetEntriesFast(); #endif } //_____________________________________________________________________________ AliMpZone* AliMpSector::GetZone(Int_t zoneID) const { /// Return zone with specified ID. if (zoneID < 1 || zoneID > GetNofZones()) { AliWarningStream() << "Index outside range" << endl; return 0; } #ifdef WITH_STL return fZones[zoneID-1]; #endif #ifdef WITH_ROOT return (AliMpZone*)fZones[zoneID-1]; #endif } //_____________________________________________________________________________ Int_t AliMpSector::GetNofRows() const { /// Return the number of rows. #ifdef WITH_STL return fRows.size(); #endif #ifdef WITH_ROOT return fRows.GetEntriesFast(); #endif } //_____________________________________________________________________________ AliMpRow* AliMpSector::GetRow(Int_t rowID) const { /// Return row with specified ID. if (rowID < 0 || rowID >= GetNofRows()) { AliWarningStream() << "Index outside range" << endl; return 0; } #ifdef WITH_STL return fRows[rowID]; #endif #ifdef WITH_ROOT return (AliMpRow*)fRows[rowID]; #endif } //_____________________________________________________________________________ AliMp::PlaneType AliMpSector::GetPlaneType() const { /// Return the plane type return GetDirection()==AliMp::kY ? AliMp::kBendingPlane : AliMp::kNonBendingPlane; } //_____________________________________________________________________________ void AliMpSector::GetAllMotifPositionsIDs(TArrayI& ecn) const { /// Return the array of all motif positions IDs fMotifMap->GetAllMotifPositionsIDs(ecn); } //_____________________________________________________________________________ void AliMpSector::Print(Option_t* opt) const { /// Print the map of motifs cout << "Sector," << PlaneTypeName(GetPlaneType()) << endl; fMotifMap->Print(opt); }