X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=blobdiff_plain;f=MUON%2Fmapping%2FAliMpSector.cxx;h=1e2b91353e277bab7f897414be4660e22efab7c5;hp=38eb2997adbc3c396730173d0afed491b52fab1d;hb=cddcc1f3b00cdcdac20666f644fb42998a250ff6;hpb=630711edefd71029942090b543cf767a964d0dbf diff --git a/MUON/mapping/AliMpSector.cxx b/MUON/mapping/AliMpSector.cxx index 38eb2997adb..1e2b91353e2 100755 --- a/MUON/mapping/AliMpSector.cxx +++ b/MUON/mapping/AliMpSector.cxx @@ -32,7 +32,7 @@ #include "AliMpVRowSegment.h" #include "AliMpVMotif.h" #include "AliMpMotifMap.h" -#include "AliMpIntPair.h" +#include "AliMpEncodePair.h" #include "AliMpConstants.h" #include "AliLog.h" @@ -45,17 +45,23 @@ ClassImp(AliMpSector) //_____________________________________________________________________________ AliMpSector::AliMpSector(const TString& id, Int_t nofZones, Int_t nofRows, - AliMp::Direction direction, const TVector2& offset) + AliMp::Direction direction, + Double_t offsetx, Double_t offsety) : TNamed("Sector", ""), fID(id), - fOffset(offset), + fOffsetX(offsetx), + fOffsetY(offsety), + fDimensionX(0.), + fDimensionY(0.), fZones(), fRows(), fMotifMap(0), fDirection(direction), - fMinPadDimensions(TVector2(1.e6, 1.e6)), - fMaxPadDimensions(), - fMaxPadIndices(AliMpIntPair::Invalid()), + fMinPadDimensionX(1.e6), + fMinPadDimensionY(1.e6), + fMaxPadDimensionX(0.), + fMaxPadDimensionY(0.), + fLMaxPadIndices(0), fNofPads(0) { /// Standard constructor @@ -64,35 +70,31 @@ AliMpSector::AliMpSector(const TString& id, Int_t nofZones, Int_t nofRows, fMotifMap = new AliMpMotifMap; -#ifdef WITH_STL - for (Int_t izone = 0; izone= ((AliMpRow*)fRows[i])->LowBorderY() && + y <= ((AliMpRow*)fRows[i])->UpperBorderY()) + return (AliMpRow*)fRows[i]; + } + + return 0; } +//_____________________________________________________________________________ +Int_t AliMpSector::FindMotifPositionId(Double_t x, Double_t y) 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(x,y); + + if ( ! rowSegment ) return 0; + + // Find motif position ID + return rowSegment->FindMotifPositionId(x, y); +} //_____________________________________________________________________________ -AliMpVRowSegment* AliMpSector::FindRowSegment(const TVector2& position) const +AliMpVRowSegment* AliMpSector::FindRowSegment(Double_t x, Double_t y) const { /// Find the row segment in the specified position. \n /// Return if no motif is found. // Find row - AliMpRow* row = FindRow(position); + AliMpRow* row = FindRow(y); if (!row) return 0; // Find the row segment and return its motif - AliMpVRowSegment* rowSegment = row->FindRowSegment(position.X()); + AliMpVRowSegment* rowSegment = row->FindRowSegment(x); return rowSegment; } @@ -153,7 +176,7 @@ void AliMpSector::SetRowOffsets() /// For each row check consitency of the row segments /// and calculate the row offset. - Double_t offset = fOffset.Y(); + Double_t offset = fOffsetY; for (Int_t irow=0; irowSetOffsetY(offset); @@ -174,7 +197,6 @@ void AliMpSector::SetGlobalIndices() /// Set the indices limits to all indexed elements /// (row, row segment, motif positions). - AliMpIntPair indices(0,0); AliMpRow* rowBefore=0; for (Int_t i=0; iSetGlobalIndices(fDirection, rowBefore); @@ -188,21 +210,22 @@ void AliMpSector::SetMinMaxPadDimensions() /// Set the minimal pad dimensions. for (Int_t i=1; iGetPadDimensions(); + Double_t dx = GetZone(i)->GetPadDimensionX(); + Double_t dy = GetZone(i)->GetPadDimensionY(); - if ( fDirection == AliMp::kX && - padDimensions.Y() > 0. && padDimensions.Y() < fMinPadDimensions.Y() || - fDirection == AliMp::kY && - padDimensions.X() > 0. && padDimensions.X() < fMinPadDimensions.X()) + if ( ( fDirection == AliMp::kX && dy > 0. && dy < fMinPadDimensionY ) || + ( fDirection == AliMp::kY && dx > 0. && dx < fMinPadDimensionX ) ) { - fMinPadDimensions = padDimensions; + fMinPadDimensionX = dx; + fMinPadDimensionY = dy; + } - if ( fDirection == AliMp::kX && - padDimensions.Y() > 0. && padDimensions.Y() > fMaxPadDimensions.Y() || - fDirection == AliMp::kY && - padDimensions.X() > 0. && padDimensions.X() > fMinPadDimensions.X()) + if ( ( fDirection == AliMp::kX && dy > 0. && dy > fMaxPadDimensionY ) || + ( fDirection == AliMp::kY && dx > 0. && dx > fMinPadDimensionX ) ) { - fMaxPadDimensions = padDimensions; + fMaxPadDimensionX = dx; + fMaxPadDimensionY = dy; + } } } @@ -211,20 +234,20 @@ void AliMpSector::SetMaxPadIndices() { /// Set maximum pad indices in x, y - if ( fMaxPadIndices != AliMpIntPair::Invalid() ) return; + if ( fLMaxPadIndices != 0 ) return; Int_t maxIndexInX = 0; Int_t maxIndexInY = 0; for (Int_t i=0; iGetHighIndicesLimit().GetFirst(); + Int_t ixh = GetRow(i)->GetHighLimitIx(); if ( ixh > maxIndexInX ) maxIndexInX = ixh; - Int_t iyh = GetRow(i)->GetHighIndicesLimit().GetSecond(); + Int_t iyh = GetRow(i)->GetHighLimitIy(); if ( iyh > maxIndexInY ) maxIndexInY = iyh; } - fMaxPadIndices = AliMpIntPair(maxIndexInX, maxIndexInY); + fLMaxPadIndices = AliMp::Pair(maxIndexInX, maxIndexInY); } @@ -236,17 +259,45 @@ void AliMpSector::SetNofPads() fNofPads = fMotifMap->CalculateNofPads(); } +//_____________________________________________________________________________ +void AliMpSector::SetDimensions() +{ +/// Set the maximum halflengths in x, y. + + fDimensionX = 0.; + fDimensionY = 0.; + + for (Int_t i=0; iGetDimensionX() > fDimensionX ) + fDimensionX = ((AliMpRow*)fRows[i])->GetDimensionX(); + + // add all rows y dimensions + fDimensionY += ((AliMpRow*)fRows[i])->GetDimensionY(); + } +} + // // public methods // +//_____________________________________________________________________________ +AliMpVPadIterator* AliMpSector::CreateIterator() const +{ +/// Create sector pad iterator + + return new AliMpSectorPadIterator(this); +} + + //_____________________________________________________________________________ void AliMpSector::SetRowSegmentOffsets() { /// For all rows set the offset to all row segments. for (Int_t irow=0; irowSetRowSegmentOffsets(fOffset); + GetRow(irow)->SetRowSegmentOffsets(fOffsetX); } //_____________________________________________________________________________ @@ -261,6 +312,7 @@ void AliMpSector::Initialize() SetMinMaxPadDimensions(); SetMaxPadIndices(); SetNofPads(); + SetDimensions(); } //_____________________________________________________________________________ @@ -272,7 +324,7 @@ void AliMpSector::PrintGeometry() const AliMpRow* row = GetRow(i); cout << "ROW " << row->GetID() - << " center Y " << row->Position().Y() << endl; + << " center Y " << row->GetPositionY() << endl; for (Int_t j=0; jGetNofRowSegments(); j++) { AliMpVRowSegment* rowSegment = row->GetRowSegment(j); @@ -282,68 +334,13 @@ void AliMpSector::PrintGeometry() const << rowSegment->LeftBorderX() << " " << rowSegment->RightBorderX() << " x-size " - << 2*rowSegment->Dimensions().X() << " " + << 2*rowSegment->GetDimensionX() << " " << 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 { @@ -365,13 +362,8 @@ AliMpVRowSegment* AliMpSector::FindRowSegment(Int_t motifPositionId) const for (Int_t irow=0; irowGetNofRowSegments(); iseg++) { AliMpVRowSegment* segment = row->GetRowSegment(iseg); if (segment->HasMotifPosition(motifPositionId)) return segment; @@ -382,74 +374,36 @@ AliMpVRowSegment* AliMpSector::FindRowSegment(Int_t motifPositionId) const } //_____________________________________________________________________________ -TVector2 AliMpSector::FindPosition(Int_t motifPositionId) const +Double_t AliMpSector::GetPositionX() const { -/// Find the position of the motif specified by its position Id. \n -/// Return 0 if no row segment is found. +/// Return the sector offset. - AliMpVRowSegment* segment = FindRowSegment(motifPositionId); + return fOffsetX; +} - if (!segment) { - AliWarningStream() << "Given motifPositionId not found." << endl; - return TVector2(); - } - return segment->MotifCenter(motifPositionId); -} - //_____________________________________________________________________________ -AliMpZone* AliMpSector::FindZone(const TVector2& padDimensions) const +Double_t AliMpSector::GetPositionY() const { -/// Find the zone with specified padDimensions. +/// Return the sector offset. - for (Int_t i=0; iGetPadDimensions())) - return zone; - } - - // Return 0 if not found - return 0; -} + return fOffsetY; +} //_____________________________________________________________________________ -TVector2 AliMpSector::Position() const +Double_t AliMpSector::GetDimensionX() const { -/// Return the sector offset. +/// Return the maximum halflengths in x. - return fOffset; + return fDimensionX; } - //_____________________________________________________________________________ -TVector2 AliMpSector::Dimensions() const +Double_t AliMpSector::GetDimensionY() 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 +/// Return the maximum halflengths in y. -#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); + return fDimensionY; } //_____________________________________________________________________________ @@ -457,13 +411,7 @@ Int_t AliMpSector::GetNofZones() const { /// Return the number of zones. -#ifdef WITH_STL - return fZones.size(); -#endif - -#ifdef WITH_ROOT return fZones.GetEntriesFast(); -#endif } //_____________________________________________________________________________ @@ -476,13 +424,7 @@ AliMpZone* AliMpSector::GetZone(Int_t zoneID) const return 0; } -#ifdef WITH_STL - return fZones[zoneID-1]; -#endif - -#ifdef WITH_ROOT return (AliMpZone*)fZones[zoneID-1]; -#endif } //_____________________________________________________________________________ @@ -490,13 +432,7 @@ Int_t AliMpSector::GetNofRows() const { /// Return the number of rows. -#ifdef WITH_STL - return fRows.size(); -#endif - -#ifdef WITH_ROOT return fRows.GetEntriesFast(); -#endif } //_____________________________________________________________________________ @@ -509,13 +445,7 @@ AliMpRow* AliMpSector::GetRow(Int_t rowID) const return 0; } -#ifdef WITH_STL - return fRows[rowID]; -#endif - -#ifdef WITH_ROOT return (AliMpRow*)fRows[rowID]; -#endif } //_____________________________________________________________________________ @@ -527,6 +457,15 @@ AliMpSector::GetPlaneType() const return GetDirection()==AliMp::kY ? AliMp::kBendingPlane : AliMp::kNonBendingPlane; } +//_____________________________________________________________________________ +Int_t +AliMpSector::GetNofMotifPositions() const +{ + /// Return the number of manus + + return fMotifMap->GetNofMotifPositions(); +} + //_____________________________________________________________________________ void AliMpSector::GetAllMotifPositionsIDs(TArrayI& ecn) const