X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2Fmapping%2FAliMpPad.cxx;h=38bc60b7722a642d8c2261fd1a84ade54d0c63aa;hb=36276a112e9fb12735ed234d9c7500045aa8cf56;hp=0e63de185b4562eaa72de64fdce4aa83c1b02d1a;hpb=dee1d5f18d249b20534cefbbba1f0a292b1c9a5d;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/mapping/AliMpPad.cxx b/MUON/mapping/AliMpPad.cxx index 0e63de185b4..38bc60b7722 100755 --- a/MUON/mapping/AliMpPad.cxx +++ b/MUON/mapping/AliMpPad.cxx @@ -14,26 +14,30 @@ **************************************************************************/ // $Id$ -// $MpId: AliMpPad.cxx,v 1.6 2005/08/26 15:43:36 ivana Exp $ +// $MpId: AliMpPad.cxx,v 1.9 2006/05/24 13:58:29 ivana Exp $ // Category: basic -// + +//----------------------------------------------------------------------------- // Class AliMpPad // --------------- // Class which encapsuate all informations about a pad // Included in AliRoot: 2003/05/02 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay - -#include +// root [0] .x testSectorAreaIterator.C +// Real time 0:00:56, CP time 36.270 +//----------------------------------------------------------------------------- #include "AliMpPad.h" +#include "AliLog.h" + +#include +#include +/// \cond CLASSIMP ClassImp(AliMpPad) +/// \endcond -////////////////////////////////////////////////////////// -// -// This class encapsulate all the information about a pad -// -////////////////////////////////////////////////////////// +const Int_t AliMpPad::fgkMaxNofLocations = 6; // // foreign operators @@ -42,7 +46,7 @@ ClassImp(AliMpPad) //_____________________________________________________________________________ Bool_t operator==(const TVector2& v1,const TVector2& v2) { -return v1.X()==v2.X() && v1.Y()==v2.Y(); + return v1.X()==v2.X() && v1.Y()==v2.Y(); } @@ -53,11 +57,16 @@ ostream& operator<<(ostream& out,const TVector2& v) return out; } + //_____________________________________________________________________________ AliMpPad::AliMpPad(const AliMpIntPair& location,const AliMpIntPair& indices, const TVector2& position,const TVector2& dimensions, Bool_t validity) : TObject(), + fLocations(0), +#ifdef WITH_ROOT + fNofLocations(0), +#endif fLocation(location), fIndices(indices), fPosition(position), @@ -75,6 +84,10 @@ AliMpPad::AliMpPad(const AliMpIntPair& location,const AliMpIntPair& indices, //_____________________________________________________________________________ AliMpPad::AliMpPad() : TObject(), + fLocations(0), +#ifdef WITH_ROOT + fNofLocations(0), +#endif fLocation(AliMpIntPair::Invalid()), fIndices(AliMpIntPair::Invalid()), fPosition(-1.,-1.), @@ -86,91 +99,191 @@ AliMpPad::AliMpPad() //_____________________________________________________________________________ -AliMpPad::AliMpPad(const AliMpPad& src) - : TObject(src) +AliMpPad::AliMpPad(const AliMpPad& rhs) + : TObject(rhs), + fLocations(0), +#ifdef WITH_ROOT + fNofLocations(0), +#endif + fLocation(AliMpIntPair::Invalid()), + fIndices(AliMpIntPair::Invalid()), + fPosition(-1.,-1.), + fDimensions(0.,0.), + fValidity(false) { /// Copy constructor - *this = src; + *this = rhs; } //_____________________________________________________________________________ AliMpPad::~AliMpPad() { /// Destructor + +#ifdef WITH_STL + delete fLocations; +#endif + +#ifdef WITH_ROOT + delete [] fLocations; +#endif } //_____________________________________________________________________________ -AliMpPad& AliMpPad::operator = (const AliMpPad& src) +AliMpPad& AliMpPad::operator = (const AliMpPad& rhs) { /// Assignment operator // check assignment to self - if (this == &src) return *this; + if (this == &rhs) return *this; // base class assignment - TObject::operator=(src); + TObject::operator=(rhs); // assignment operator - fLocation = src.fLocation; - fIndices = src.fIndices; - fPosition.Set(src.fPosition); - fDimensions.Set(src.fDimensions); - fValidity = src.fValidity; + fLocation = rhs.fLocation; + fIndices = rhs.fIndices; + fPosition.Set(rhs.fPosition); + fDimensions.Set(rhs.fDimensions); + fValidity = rhs.fValidity; + + fLocations = 0; + +#ifdef WITH_STL + if ( rhs.GetNofLocations() ) { + fLocations = new IntPairVector(rhs.GetNofLocations()); + + for (Int_t i=0; ipush_back(location); + return true; +#endif + +#ifdef WITH_ROOT + if ( ! fLocations) + fLocations = new AliMpIntPair[fgkMaxNofLocations]; + + fLocations[fNofLocations++] = location; + return true; +#endif +} + +//_____________________________________________________________________________ +void AliMpPad::PrintOn(ostream& out) const +{ +/// Prints all pad data. + + if ( !fValidity ) { + out << "Pad::Invalid"; + return; + } + + out << "Pad: Location " << fLocation + << " Indices " << fIndices + << " Position " << fPosition + << " Dimensions " << fDimensions; + + 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 +{ +/// Return i-th other location associated with this pad + + if ( !fLocations || i<0 || i>=GetNofLocations() ) + return AliMpIntPair::Invalid(); + +#ifdef WITH_STL + return (*fLocations)[i]; +#endif + +#ifdef WITH_ROOT + return fLocations[i]; +#endif +} + +//_____________________________________________________________________________ +Bool_t AliMpPad::HasLocation(const AliMpIntPair& location) const +{ +/// Return true if given location is present either as fLocation +/// or in the collectio + + if (fLocation == location) return true; + + for ( Int_t i=0; i