X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;ds=sidebyside;f=MUON%2Fmapping%2FAliMpSectorSegmentation.cxx;h=c04381350cbb9d4b137a6bd535393e45dcd21517;hb=d9844bd8fc33dd16171d357f809f2fe99a72f45e;hp=0554e83a8c2d5cacef8c27590f37953d58f332b5;hpb=f79c58a52a23054c7b92eca3093bf5895ce24180;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/mapping/AliMpSectorSegmentation.cxx b/MUON/mapping/AliMpSectorSegmentation.cxx index 0554e83a8c2..c04381350cb 100755 --- a/MUON/mapping/AliMpSectorSegmentation.cxx +++ b/MUON/mapping/AliMpSectorSegmentation.cxx @@ -1,6 +1,23 @@ +/************************************************************************** + * 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: AliMpSectorSegmentation.cxx,v 1.15 2006/05/24 13:58:46 ivana Exp $ // Category: sector -// + +//----------------------------------------------------------------------------- // Class AliMpSectorSegmentation // ----------------------------- // Class describing the segmentation of the sector. @@ -9,9 +26,7 @@ // finding pad neighbour. // // Authors: David Guez, Ivana Hrivnacova; IPN Orsay - -#include -#include +//----------------------------------------------------------------------------- #include "AliMpSectorSegmentation.h" #include "AliMpSector.h" @@ -26,22 +41,40 @@ #include "AliMpNeighboursPadIterator.h" #include "AliMpSectorAreaHPadIterator.h" #include "AliMpSectorAreaVPadIterator.h" +#include "AliMpSectorPadIterator.h" #include "AliMpIntPair.h" #include "AliMpArea.h" #include "AliMpConstants.h" +#include "AliLog.h" + +#include +#include + +/// \cond CLASSIMP ClassImp(AliMpSectorSegmentation) +/// \endcond #ifdef WITH_ROOT -const Double_t AliMpSectorSegmentation::fgkSeparator = 10000.; +const Double_t AliMpSectorSegmentation::fgkS1 = 100000.; +const Double_t AliMpSectorSegmentation::fgkS2 = 1000.; #endif //______________________________________________________________________________ -AliMpSectorSegmentation::AliMpSectorSegmentation(const AliMpSector* sector) +AliMpSectorSegmentation::AliMpSectorSegmentation( + const AliMpSector* sector, Bool_t own) : AliMpVSegmentation(), - fkSector(sector) + fkSector(sector), + fIsOwner(own), + fPadBuffer(0), + fPadDimensionsMap(), + fMaxIndexInX(0), + fMaxIndexInY(0) { -// +/// Standard constructor + + AliDebugStream(1) << "this = " << this << endl; + fPadBuffer = new AliMpPad(AliMpPad::Invalid()); FillPadDimensionsMap(); @@ -51,51 +84,66 @@ AliMpSectorSegmentation::AliMpSectorSegmentation(const AliMpSector* sector) AliMpSectorSegmentation::AliMpSectorSegmentation() : AliMpVSegmentation(), fkSector(0), + fIsOwner(false), fPadBuffer(0), - fPadDimensionsMap() + fPadDimensionsMap(), + fMaxIndexInX(0), + fMaxIndexInY(0) { -// +/// Default constructor + + AliDebugStream(1) << "this = " << this << endl; } //______________________________________________________________________________ -AliMpSectorSegmentation::~AliMpSectorSegmentation() { -// +AliMpSectorSegmentation::~AliMpSectorSegmentation() +{ +/// Destructor + + AliDebugStream(1) << "this = " << this << endl; + + if ( fIsOwner ) delete fkSector; + delete fPadBuffer; + } // // private methods // +//_____________________________________________________________________________ +void +AliMpSectorSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const +{ + /// Fill the array ecn with all manuIds + + GetSector()->GetAllMotifPositionsIDs(ecn); +} + #ifdef WITH_ROOT //______________________________________________________________________________ Long_t AliMpSectorSegmentation::GetIndex(const TVector2& vector2) const { -// Converts the twovector to long. -// --- +/// Convert the two vector to long. - if (vector2.X() >= fgkSeparator || vector2.Y() >= fgkSeparator) - Fatal("GetIndex", "Index out of limit."); - - return Long_t(vector2.X()*fgkSeparator + vector2.Y() + 1.); + return Long_t(TMath::Floor((vector2.X()*fgkS1 + vector2.Y())*fgkS2)); } //______________________________________________________________________________ TVector2 AliMpSectorSegmentation::GetVector(Long_t index) const { -// Converts the long index to twovector. -// --- +/// Convert the long index to twovector. - return TVector2(floor((index-1.)/fgkSeparator), - (index-1.) - floor((index-1.)/fgkSeparator)*fgkSeparator); + return TVector2( TMath::Floor(index/fgkS1)/fgkS2, + (index - TMath::Floor(index/fgkS1)*fgkS1)/fgkS2 ); } #endif //______________________________________________________________________________ void AliMpSectorSegmentation::FillPadDimensionsMap() { -// Fills the maps between zone ids and pad dimensions. -// --- +/// Fill the maps between zone ids and pad dimensions. for (Int_t i=0; iGetNofZones(); i++) { AliMpZone* zone = fkSector->GetZone(i+1); @@ -108,7 +156,12 @@ void AliMpSectorSegmentation::FillPadDimensionsMap() fPadDimensionsMap[zoneID*10] = zone->GetPadDimensions(); #endif #ifdef WITH_ROOT - fPadDimensionsMap.Add((Long_t)(zoneID*10), + AliDebugStream(3) + << "Filling fPadDimensions[" << zoneID*10 << "] = (" + << zone->GetPadDimensions().X() << ", " + << zone->GetPadDimensions().Y() << ")" << endl; + + fPadDimensionsMap.Add((Long_t)(zoneID*10), GetIndex(zone->GetPadDimensions())); #endif } @@ -125,6 +178,12 @@ void AliMpSectorSegmentation::FillPadDimensionsMap() fPadDimensionsMap[index] = motif->GetPadDimensions(k); #endif #ifdef WITH_ROOT + AliDebugStream(3) + << "Filling fPadDimensions[" << index << "] = (" + << motif->GetPadDimensions(k).X() << ", " + << motif->GetPadDimensions(k).Y() << ") motif " + << motif->GetID().Data() << "-" << k << endl; + fPadDimensionsMap.Add((Long_t)(index), GetIndex(motif->GetPadDimensions(k))); #endif @@ -138,12 +197,11 @@ void AliMpSectorSegmentation::FillPadDimensionsMap() AliMpMotifPosition* AliMpSectorSegmentation::FindMotifPosition(const AliMpIntPair& indices) const { -// Find the motif position which contains the given pad indices -// return 0 if not found -// --- +/// Find the motif position which contains the given pad indices +/// return 0 if not found switch (fkSector->GetDirection()) { - case kX : { + case AliMp::kX : { // Case where all the pads have the same size along X direction for (Int_t irow=0; irowGetNofRows(); ++irow) { @@ -171,7 +229,7 @@ AliMpSectorSegmentation::FindMotifPosition(const AliMpIntPair& indices) const } break; //////////////////////////////////////////////////////////////////////////////// - case kY : { + case AliMp::kY : { // Case where all the pads have the same size along Y direction // look for the row which contains the indices AliMpRow* row=0; @@ -216,9 +274,8 @@ AliMpPad AliMpSectorSegmentation::PadByXDirection(const TVector2& startPosition, Double_t maxX) const { -// Find the first valid pad from starting position in the -// direction of pad lines up to distance dx. -// --- +/// Find the first valid pad from starting position in the +/// direction of pad lines up to distance dx. // Define step limits Double_t stepX = fkSector->GetMinPadDimensions().X(); @@ -230,10 +287,11 @@ AliMpSectorSegmentation::PadByXDirection(const TVector2& startPosition, pad = PadByPosition(position, false); position += TVector2(stepX, 0.); } - while ( !pad.IsValid() && position.X() < maxX ); + while ( !pad.IsValid() && + position.X() - fkSector->GetMaxPadDimensions().X() < maxX ); // Invalidate pad if it is outside limits - if ((pad.Position().X() - pad.Dimensions().X()) > maxX) + if ( (pad.Position().X() - pad.Dimensions().X()) > maxX ) pad = AliMpPad::Invalid(); return pad; @@ -244,9 +302,8 @@ AliMpPad AliMpSectorSegmentation::PadByYDirection(const TVector2& startPosition, Double_t maxY) const { -// Find the first valid pad from starting position in the -// direction of pad columns up to distance dx. -// --- +/// Find the first valid pad from starting position in the +/// direction of pad columns up to distance dx. // Define step limits Double_t stepY = fkSector->GetMinPadDimensions().Y(); @@ -258,7 +315,8 @@ AliMpSectorSegmentation::PadByYDirection(const TVector2& startPosition, pad = PadByPosition(position, false); position += TVector2(0., stepY); } - while ( !pad.IsValid() && position.Y() < maxY ); + while ( !pad.IsValid() && + position.Y() - fkSector->GetMaxPadDimensions().Y()< maxY ); // Invalidate pad if it is outside limits if ((pad.Position().Y() - pad.Dimensions().Y()) > maxY) @@ -267,33 +325,30 @@ AliMpSectorSegmentation::PadByYDirection(const TVector2& startPosition, return pad; } +// +// public methods +// + //______________________________________________________________________________ -AliMpVPadIterator* AliMpSectorSegmentation::CreateIterator() const +AliMpVPadIterator* +AliMpSectorSegmentation::CreateIterator() const { -// The inherited method cannot be used +/// Create the sector iterator - Fatal("CreateIterator", "Center pad has to be specified."); - return 0; + return new AliMpSectorPadIterator(fkSector); } - - -// -// public methods -// //______________________________________________________________________________ AliMpVPadIterator* AliMpSectorSegmentation::CreateIterator(const AliMpArea& area) const { -// Creates the are iterator. -// (The inherited method cannot be used) -// --- +/// Create the area iterator. switch (fkSector->GetDirection()) { - case kX: return new AliMpSectorAreaVPadIterator(this, area); + case AliMp::kX: return new AliMpSectorAreaVPadIterator(this, area); ;; - case kY: return new AliMpSectorAreaHPadIterator(this, area); + case AliMp::kY: return new AliMpSectorAreaHPadIterator(this, area); ;; } @@ -301,23 +356,46 @@ AliMpSectorSegmentation::CreateIterator(const AliMpArea& area) const return 0; } +//______________________________________________________________________________ +Int_t +AliMpSectorSegmentation::GetNeighbours(const AliMpPad& pad, TObjArray& neighbours, + Bool_t includeSelf, + Bool_t includeVoid) const +{ + /// Uses default implementation + return AliMpVSegmentation::GetNeighbours(pad,neighbours,includeSelf,includeVoid); +} + //______________________________________________________________________________ AliMpVPadIterator* AliMpSectorSegmentation::CreateIterator(const AliMpPad& centerPad, Bool_t includeCenter) const { -// Creates the neighbours pad iterator. -// (The inherited method cannot be used) + /// Create the neighbours pad iterator. return new AliMpNeighboursPadIterator(this, centerPad, includeCenter); } +//______________________________________________________________________________ +TVector2 +AliMpSectorSegmentation::Dimensions() const +{ + return GetSector()->Dimensions(); +} + +//______________________________________________________________________________ +AliMp::PlaneType +AliMpSectorSegmentation::PlaneType() const +{ + return GetSector()->GetPlaneType(); +} + //______________________________________________________________________________ AliMpPad AliMpSectorSegmentation::PadByLocation(const AliMpIntPair& location, Bool_t warning) const { -// Find the pad which corresponds to the given location +/// Find the pad which corresponds to the given location if ((*fPadBuffer).GetLocation()==location) return (*fPadBuffer); @@ -347,13 +425,14 @@ AliMpPad AliMpSectorSegmentation::PadByIndices(const AliMpIntPair& indices, Bool_t warning ) const { -// Find the pad which corresponds to the given indices +/// Find the pad which corresponds to the given indices if ((*fPadBuffer).GetIndices()==indices) return (*fPadBuffer); AliMpMotifPosition* motifPos = FindMotifPosition(indices); if (!motifPos) { - if (warning) Warning("PadByIndices","Pad indices not contained in any motif!"); + if (warning) + Warning("PadByIndices","Pad indices not contained in any motif!"); return AliMpPad::Invalid(); } @@ -383,7 +462,7 @@ AliMpPad AliMpSectorSegmentation::PadByPosition(const TVector2& position, Bool_t warning) const { -// Find the pad which corresponds to the given position +/// Find the pad which corresponds to the given position if ((*fPadBuffer).Position().X()==position.X() && (*fPadBuffer).Position().Y()==position.Y()) return (*fPadBuffer); @@ -423,17 +502,16 @@ AliMpPad AliMpSectorSegmentation::PadByDirection(const TVector2& startPosition, Double_t distance) const { -// Find the first valid pad from starting position in the -// direction of pad lines/columns up to the specified distance. -// Pad lines are the lines of pads in the sector with constant pad y size, -// pad columns are the columns of pads in the sector with constant pad x size. -// --- +/// Find the first valid pad from starting position in the +/// direction of pad lines/columns up to the specified distance. +/// Pad lines are the lines of pads in the sector with constant pad y size, +/// pad columns are the columns of pads in the sector with constant pad x size. switch (fkSector->GetDirection()) { - case kX: return PadByYDirection(startPosition, distance); + case AliMp::kX: return PadByYDirection(startPosition, distance); ;; - case kY: return PadByXDirection(startPosition, distance); + case AliMp::kY: return PadByXDirection(startPosition, distance); ;; } @@ -441,11 +519,34 @@ AliMpSectorSegmentation::PadByDirection(const TVector2& startPosition, return AliMpPad::Invalid(); } +//______________________________________________________________________________ +Int_t AliMpSectorSegmentation::MaxPadIndexX() const +{ +/// Return maximum pad index in x + + return fkSector->GetMaxPadIndices().GetFirst(); +} + +//______________________________________________________________________________ +Int_t AliMpSectorSegmentation::MaxPadIndexY() const +{ +/// Return maximum pad index in y + + return fkSector->GetMaxPadIndices().GetSecond(); +} + +//______________________________________________________________________________ +Int_t AliMpSectorSegmentation::NofPads() const +{ +/// Return number of pads defined in the sector + + return fkSector->GetNofPads(); +} + //______________________________________________________________________________ Bool_t AliMpSectorSegmentation::HasPad(const AliMpIntPair& indices) const { -// Does the pad specified by exist ? -// --- +/// Does the pad specified by \a indices exist ? return PadByIndices(indices,kFALSE) != AliMpPad::Invalid(); } @@ -453,8 +554,7 @@ Bool_t AliMpSectorSegmentation::HasPad(const AliMpIntPair& indices) const //______________________________________________________________________________ Bool_t AliMpSectorSegmentation::HasMotifPosition(Int_t motifPositionID) const { -// Does the motif position specified by motifPositionID exist ? -// --- +/// Does the motif position specified by motifPositionID exist ? return (fkSector->GetMotifMap()->FindMotifPosition(motifPositionID) != 0); } @@ -462,8 +562,7 @@ Bool_t AliMpSectorSegmentation::HasMotifPosition(Int_t motifPositionID) const //______________________________________________________________________________ TVector2 AliMpSectorSegmentation::GetMinPadDimensions() const { -// Returnes the dimensions of the smallest pad. -// --- +/// Returne the dimensions of the smallest pad. return fkSector->GetMinPadDimensions(); } @@ -471,13 +570,12 @@ TVector2 AliMpSectorSegmentation::GetMinPadDimensions() const //______________________________________________________________________________ Int_t AliMpSectorSegmentation::Zone(const AliMpPad& pad, Bool_t warning) const { -// Returns the zone index of the zone containing the specified pad. -// This zone index is different from the zone ID, -// as it is unique for each pad dimensions. -// It is composed in this way: -// zoneID*10 + specific index -// Specific index is present only for zones containing special motifs. -// --- +/// Return the zone index of the zone containing the specified pad. +/// This zone index is different from the zone ID, +/// as it is unique for each pad dimensions. +/// It is composed in this way: +/// zoneID*10 + specific index +/// Specific index is present only for zones containing special motifs. if (!pad.IsValid()) { if (warning) Warning("Zone(AliMpPad)", "Invalid pad"); @@ -499,13 +597,15 @@ Int_t AliMpSectorSegmentation::Zone(const AliMpPad& pad, Bool_t warning) const TVector2 dimensions = GetVector(value); if (AliMpConstants::IsEqual(dimensions, pad.Dimensions())) return (Int_t)key; - } - return 0; - + } + + AliError(Form("fPadDimensionsMap size is %d",fPadDimensionsMap.GetSize())); + #endif // Should never happen - Fatal("Zone(AliMpPad)", "not found"); + AliErrorStream() + << "Zone(AliMpPad pad) not found, where pad is: " << pad << endl; return 0; } @@ -513,8 +613,7 @@ Int_t AliMpSectorSegmentation::Zone(const AliMpPad& pad, Bool_t warning) const TVector2 AliMpSectorSegmentation::PadDimensions(Int_t zone, Bool_t warning) const { -// Returns the pad dimensions for the zone with the specified zone index. -// --- +/// Return the pad dimensions for the zone with the specified zone index. #ifdef WITH_STL PadDimensionsMapCIterator it = fPadDimensionsMap.find(zone); @@ -533,10 +632,9 @@ AliMpSectorSegmentation::PadDimensions(Int_t zone, Bool_t warning) const //______________________________________________________________________________ Bool_t AliMpSectorSegmentation::CircleTest(const AliMpIntPair& indices) const { -// Verifies that all methods for retrieving pads are consistents between them. -// Returns true if the pad with specified indices was found and verified, -// false otherwise. -// --- +/// Verify that all methods for retrieving pads are consistents between them. +/// Return true if the pad with specified indices was found and verified, +/// false otherwise. if (!HasPad(indices)) return false; @@ -568,3 +666,43 @@ Bool_t AliMpSectorSegmentation::CircleTest(const AliMpIntPair& indices) const return true; } + +//______________________________________________________________________________ +void +AliMpSectorSegmentation::Print(Option_t* opt) const +{ +/// Print the sector + + fkSector->Print(opt); +} + +//______________________________________________________________________________ +void AliMpSectorSegmentation::PrintZones() const +{ +/// Print all zones and pads dimensions from the map. + + cout << "Zones: " << endl; + +#ifdef WITH_STL + PadDimensionsMapCIterator it; + for (it = fPadDimensionsMap.begin(); it != fPadDimensionsMap.end(); ++it) { + cout << " zone: " << setw(4) << it->first; + cout << " pad dimensions: ( " + << it->second.X() << ", " << it->second.Y() << ")" << endl; + } +#endif + +#ifdef WITH_ROOT + PadDimensionsMapCIterator it(&fPadDimensionsMap); + Long_t key, value; + while ( it.Next(key, value) ) { + //cout << "Iterating over: " << key << ", " << value << endl; + TVector2 dimensions = GetVector(value); + + cout << " zone: " << setw(4) << key; + cout << " pad dimensions: ( " + << dimensions.X() << ", " << dimensions.Y() << ")" << endl; + } +#endif +} +