//______________________________________________________________________________
AliMUONPolygon::AliMUONPolygon(const AliMUONPolygon& rhs)
: TObject(rhs),
-fN(0),
+fN(rhs.fN),
fX(0x0),
fY(0x0)
{
/// Copy constructor.
- ((AliMUONPolygon&)rhs).Copy(*this);
+ if ( fN > 0 )
+ {
+ fX = new Double_t[fN];
+ fY = new Double_t[fN];
+
+ for ( Int_t i = 0; i < fN; ++i )
+ {
+ fX[i] = rhs.fX[i];
+ fY[i] = rhs.fY[i];
+ }
+
+ }
+
}
//______________________________________________________________________________
/// Assignment operator
if ( this != &rhs )
{
- rhs.Copy(*this);
+ static_cast<TObject&>(*this)=rhs;
+
+ delete[] fX;
+ delete[] fY;
+
+ fX = 0;
+ fY = 0;
+
+ fN = rhs.fN;
+
+ if ( fN > 0 )
+ {
+ fX = new Double_t[fN];
+ fY = new Double_t[fN];
+
+ for ( Int_t i = 0; i < fN; ++i )
+ {
+ fX[i] = rhs.fX[i];
+ fY[i] = rhs.fY[i];
+ }
+
+ }
}
return *this;
}
return TMath::IsInside(x,y,fN,fX,fY);
}
-//______________________________________________________________________________
-void AliMUONPolygon::Copy(TObject& obj) const
-{
- /// Copy this to obj
-
- AliMUONPolygon& rhs = static_cast<AliMUONPolygon&>(obj);
-
- Double_t* x = new Double_t[fN];
- Double_t* y = new Double_t[fN];
-
- for ( Int_t i = 0; i < fN; ++i )
- {
- x[i] = fX[i];
- y[i] = fY[i];
- }
-
- delete rhs.fX;
- delete rhs.fY;
-
- rhs.fX = x;
- rhs.fY = y;
- rhs.fN = fN;
-}
-
//_____________________________________________________________________________
void
AliMUONPolygon::Close()