X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2Fmapping%2FAliMpPad.cxx;h=82fc7270dc635f63d4b40a5657eb9dbfe31f4161;hb=e10bfadc9b14e7c99b26fcd6ff8d1d0a2e04c024;hp=38bc60b7722a642d8c2261fd1a84ade54d0c63aa;hpb=c9d734d44852d9e35fa548f28591234494f9d1ff;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/mapping/AliMpPad.cxx b/MUON/mapping/AliMpPad.cxx index 38bc60b7722..82fc7270dc6 100755 --- a/MUON/mapping/AliMpPad.cxx +++ b/MUON/mapping/AliMpPad.cxx @@ -28,6 +28,7 @@ //----------------------------------------------------------------------------- #include "AliMpPad.h" +#include "AliMpEncodePair.h" #include "AliLog.h" #include @@ -39,38 +40,45 @@ ClassImp(AliMpPad) const Int_t AliMpPad::fgkMaxNofLocations = 6; -// -// foreign operators -// - //_____________________________________________________________________________ -Bool_t operator==(const TVector2& v1,const TVector2& v2) -{ - return v1.X()==v2.X() && v1.Y()==v2.Y(); -} - - -//_____________________________________________________________________________ -ostream& operator<<(ostream& out,const TVector2& v) +AliMpPad::AliMpPad(Int_t manuId, Int_t channel, + Int_t ix, Int_t iy, + Double_t x, Double_t y, + Double_t dx, Double_t dy, + Bool_t validity) + : TObject(), + fNofLocations(0), + fLLocations(0), + fLLocation(AliMp::Pair(manuId, channel)), + fLIndices(AliMp::Pair(ix, iy)), + fPositionX(x), + fPositionY(y), + fDimensionX(dx), + fDimensionY(dy), + fValidity(validity) { - out << '(' << v.X() << ',' << v.Y() << ')'; - return out; +/// Standard constructor \n +/// Be carefull : this constructor doesn't check the validity of +/// the correspondance between location and indices. +/// By default, validity is set true. +/// It is aimed to be used by MSegmentation methods, and never from outside.... } - //_____________________________________________________________________________ -AliMpPad::AliMpPad(const AliMpIntPair& location,const AliMpIntPair& indices, - const TVector2& position,const TVector2& dimensions, +AliMpPad::AliMpPad(Int_t manuId, Int_t channel, + MpPair_t indices, + Double_t x, Double_t y, + Double_t dx, Double_t dy, Bool_t validity) : TObject(), - fLocations(0), -#ifdef WITH_ROOT fNofLocations(0), -#endif - fLocation(location), - fIndices(indices), - fPosition(position), - fDimensions(dimensions), + fLLocations(0), + fLLocation(AliMp::Pair(manuId, channel)), + fLIndices(indices), + fPositionX(x), + fPositionY(y), + fDimensionX(dx), + fDimensionY(dy), fValidity(validity) { /// Standard constructor \n @@ -80,35 +88,33 @@ AliMpPad::AliMpPad(const AliMpIntPair& location,const AliMpIntPair& indices, /// It is aimed to be used by MSegmentation methods, and never from outside.... } - //_____________________________________________________________________________ AliMpPad::AliMpPad() : TObject(), - fLocations(0), -#ifdef WITH_ROOT fNofLocations(0), -#endif - fLocation(AliMpIntPair::Invalid()), - fIndices(AliMpIntPair::Invalid()), - fPosition(-1.,-1.), - fDimensions(0.,0.), + fLLocations(0), + fLLocation(0), + fLIndices(0), + fPositionX(-1.), + fPositionY(-1.), + fDimensionX(-1.), + fDimensionY(-1.), fValidity(false) { /// Default constructor - creates pad in invalid state } - //_____________________________________________________________________________ AliMpPad::AliMpPad(const AliMpPad& rhs) - : TObject(rhs), - fLocations(0), -#ifdef WITH_ROOT + : TObject(), fNofLocations(0), -#endif - fLocation(AliMpIntPair::Invalid()), - fIndices(AliMpIntPair::Invalid()), - fPosition(-1.,-1.), - fDimensions(0.,0.), + fLLocations(0), + fLLocation(0), + fLIndices(0), + fPositionX(-1.), + fPositionY(-1.), + fDimensionX(-1.), + fDimensionY(-1.), fValidity(false) { /// Copy constructor @@ -121,13 +127,7 @@ AliMpPad::~AliMpPad() { /// Destructor -#ifdef WITH_STL - delete fLocations; -#endif - -#ifdef WITH_ROOT - delete [] fLocations; -#endif + delete [] fLLocations; } //_____________________________________________________________________________ @@ -142,31 +142,21 @@ AliMpPad& AliMpPad::operator = (const AliMpPad& rhs) TObject::operator=(rhs); // assignment operator - fLocation = rhs.fLocation; - fIndices = rhs.fIndices; - fPosition.Set(rhs.fPosition); - fDimensions.Set(rhs.fDimensions); + fLLocation = rhs.fLLocation; + fLIndices = rhs.fLIndices; + fPositionX = rhs.fPositionX; + fPositionY = rhs.fPositionY; + fDimensionX = rhs.fDimensionX; + fDimensionY = rhs.fDimensionY; fValidity = rhs.fValidity; - fLocations = 0; - -#ifdef WITH_STL - if ( rhs.GetNofLocations() ) { - fLocations = new IntPairVector(rhs.GetNofLocations()); - - for (Int_t i=0; i right.GetIx() ) return kFALSE; + if ( left.GetIy() < right.GetIy() ) return kTRUE; + return kFALSE; } //_____________________________________________________________________________ -Bool_t AliMpPad::AddLocation(const AliMpIntPair& location, Bool_t warn) +Bool_t AliMpPad::AddLocation(Int_t localBoardId, Int_t localBoardChannel, + Bool_t warn) { /// Add location to the collection if not yet present and /// if collection is not yet full \n @@ -227,41 +222,65 @@ Bool_t AliMpPad::AddLocation(const AliMpIntPair& location, Bool_t warn) // Check maximum number limit if ( GetNofLocations() == fgkMaxNofLocations ) { if (warn) { - AliWarningStream() << "Cannot add location: " - << location - << " Maximum number has been reached." << endl; + AliWarningStream() << "Cannot add location: (" + << localBoardId << "," << localBoardChannel << ")." + << " Maximum number has been reached." << endl; } return false; } // Check if location is present - if ( HasLocation(location) ) { + if ( HasLocation(localBoardId, localBoardChannel) ) { if (warn) { AliWarningStream() << "Cannot add location: " - << location - << " Location is already present." << endl; + << localBoardId << "," << localBoardChannel << ")." + << " Location is already present." << endl; } return false; } // Add location -#ifdef WITH_STL - if (! fLocations ) - fLocations = new IntPairVector(); - - fLocations->push_back(location); - return true; -#endif - -#ifdef WITH_ROOT - if ( ! fLocations) - fLocations = new AliMpIntPair[fgkMaxNofLocations]; + if ( ! fLLocations) + fLLocations = new MpPair_t[fgkMaxNofLocations]; - fLocations[fNofLocations++] = location; + fLLocations[fNofLocations++] + = AliMp::Pair(localBoardId, localBoardChannel); + return true; -#endif } +//_____________________________________________________________________________ +Int_t AliMpPad::GetManuId() const +{ +/// Return pad manu Id + + return AliMp::PairFirst(fLLocation); +} + +//_____________________________________________________________________________ +Int_t AliMpPad::GetManuChannel() const +{ +/// Return pad manu channel + + return AliMp::PairSecond(fLLocation); +} + +//_____________________________________________________________________________ +Int_t AliMpPad::GetIx() const +{ +/// Return pad index ix + + return AliMp::PairFirst(fLIndices); +} + +//_____________________________________________________________________________ +Int_t AliMpPad::GetIy() const +{ +/// Return pad index iy + + return AliMp::PairSecond(fLIndices); +} + //_____________________________________________________________________________ void AliMpPad::PrintOn(ostream& out) const { @@ -272,17 +291,21 @@ void AliMpPad::PrintOn(ostream& out) const return; } - out << "Pad: Location " << fLocation - << " Indices " << fIndices - << " Position " << fPosition - << " Dimensions " << fDimensions; + out << "Pad: Location "; + AliMp::PairPut(out, fLLocation) + << " Indices "; + AliMp::PairPut(out,fLIndices) + << " Position " + << "(" << fPositionX << "," << fPositionY << ")" + << " Dimensions " + << "(" << fDimensionX << "," << fDimensionY << ")"; if ( GetNofLocations() ) { out << endl; out << " Other locations: "; for (Int_t i=0; isize(); -#endif - -#ifdef WITH_ROOT return fNofLocations; -#endif } //_____________________________________________________________________________ -AliMpIntPair AliMpPad::GetLocation(Int_t i) const +MpPair_t AliMpPad::GetLocation(Int_t i) const { /// Return i-th other location associated with this pad - if ( !fLocations || i<0 || i>=GetNofLocations() ) - return AliMpIntPair::Invalid(); + if ( !fLLocations || i<0 || i>=GetNofLocations() ) + return 0; -#ifdef WITH_STL - return (*fLocations)[i]; -#endif - -#ifdef WITH_ROOT - return fLocations[i]; -#endif + return fLLocations[i]; +} + +//_____________________________________________________________________________ +Int_t AliMpPad::GetLocalBoardId(Int_t i) const +{ +/// Return i-th other local board Id associated with this pad + + if ( !fLLocations || i<0 || i>=GetNofLocations() ) + return 0; + + return AliMp::PairFirst(fLLocations[i]); +} + +//_____________________________________________________________________________ +Int_t AliMpPad::GetLocalBoardChannel(Int_t i) const +{ +/// Return i-th other local board channel associated with this pad + + if ( !fLLocations || i<0 || i>=GetNofLocations() ) + return 0; + + return AliMp::PairSecond(fLLocations[i]); } //_____________________________________________________________________________ -Bool_t AliMpPad::HasLocation(const AliMpIntPair& location) const +Bool_t AliMpPad::HasLocation(Int_t localBoardId, Int_t localBoardChannel) const { -/// Return true if given location is present either as fLocation +/// Return true if given location is present either as fLLocation /// or in the collectio - if (fLocation == location) return true; + MpPair_t location = AliMp::Pair(localBoardId, localBoardChannel); + + if (fLLocation == location) return true; for ( Int_t i=0; i