]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliRecPoint.cxx
Avoid cast from pointer to integer
[u/mrichter/AliRoot.git] / STEER / AliRecPoint.cxx
index 94bba4372dca0d231d1bf05469d598efc1ef3a52..a94551d9455dc2dacf9af915607781f6c0ae8020 100644 (file)
 
 /*
 $Log$
+Revision 1.8  2001/10/21 18:38:43  hristov
+Several pointers were set to zero in the default constructors to avoid memory management problems
+
+Revision 1.7  2000/11/30 07:12:49  alibrary
+Introducing new Rndm and QA classes
+
+Revision 1.6  2000/10/02 21:28:14  fca
+Removal of useless dependecies via forward declarations
+
+Revision 1.5  2000/07/11 18:24:59  fca
+Coding convention corrections + few minor bug fixes
+
+Revision 1.4  2000/05/16 08:30:02  fca
+Using automatic streamer for c arrays
+
 Revision 1.3  2000/03/20 14:22:25  fca
 New version to support new PHOS code
 
@@ -30,50 +45,80 @@ Y.Schutz new classes for reconstruction
 
 //-*-C++-*-
 //_________________________________________________________________________
-// Base Class of Cluster (empty cxx needed by Root)
+// Base Class for reconstructed space points 
+// usually coming from the clusterisation algorithms
+// run on the digits
+//
 //*-- Author : Yves Schutz  SUBATECH 
 //////////////////////////////////////////////////////////////////////////////
 
-// --- ROOT system ---
 
-#include "TObjArray.h"
+// --- ROOT system ---
 
 // --- Standard library ---
 
 // --- AliRoot header files ---
 
 #include "AliRecPoint.h"
+#include "AliGeometry.h"
+#include "AliDigitNew.h"
 
 ClassImp(AliRecPoint)
 
 
 //____________________________________________________________________________
 AliRecPoint::AliRecPoint()
+{
+  // default ctor  
+  fGeom = 0;
+  fAmp = 0.0 ; 
+  
+  fLocPos.SetXYZ(0., 0., 0.) ;
+  fLocPosM     = 0 ;
+  fMaxDigit    = 100 ; 
+  fMulDigit    = 0 ; 
+  fDigitsList  = 0 ; 
+  fMaxTrack    = 5 ; 
+  fMulTrack    = 0 ; 
+  fTracksList  = 0 ; 
+  fIndexInList = -1 ; // to be set when the point is already stored
+}
+
+//____________________________________________________________________________
+AliRecPoint::AliRecPoint(const char * opt)
 {
   // ctor  
+  fGeom = 0;
   fAmp = 0.0 ; 
   
   fLocPos.SetXYZ(0., 0., 0.) ;
   fLocPosM     = new TMatrix(3,3) ;
   fMaxDigit    = 100 ; 
   fMulDigit    = 0 ; 
-  fDigitsList  = new int[fMaxDigit]; 
+  fDigitsList  = new int[fMaxDigit]; 
   fMaxTrack    = 5 ; 
   fMulTrack    = 0 ; 
   fTracksList  = new int[fMaxTrack]; ; 
   fIndexInList = -1 ; // to be set when the point is already stored
 }
 
+//____________________________________________________________________________
+AliRecPoint::AliRecPoint(const AliRecPoint& recp)
+{
+  //
+  // Copy constructor
+  //
+  recp.Copy(*this);
+}
+
 //____________________________________________________________________________
 AliRecPoint::~AliRecPoint()
 {
   // dtor
   
   delete fLocPosM ; 
-  if ( fDigitsList )    
-    delete fDigitsList ; 
-  if ( fTracksList )    
-    delete fTracksList ;  
+  delete [] fDigitsList ; 
+  delete [] fTracksList ;  
   
 }
   
@@ -120,6 +165,33 @@ void AliRecPoint::AddDigit(AliDigitNew & digit)
 //   fTracksList[fMulTrack++]=  (int) &Track  ; 
 // }
 
+//____________________________________________________________________________
+void AliRecPoint::Copy(AliRecPoint& recp) const
+{
+  //
+  // Copy *this onto pts
+  //
+  // Copy all first
+  if(this != &recp) {
+    ((TObject*) this)->Copy((TObject&)recp);
+    recp.fAmp = fAmp;
+    recp.fGeom = fGeom;
+    recp.fIndexInList = fIndexInList;
+    recp.fLocPos = fLocPos;
+    recp.fLocPosM = new TMatrix(*fLocPosM);
+    recp.fMaxDigit = fMaxDigit;
+    recp.fMulDigit = fMulDigit;
+    recp.fMaxTrack = fMaxTrack;
+    recp.fMulTrack = fMulTrack;
+    
+    // Duplicate pointed objects
+    recp.fDigitsList = new Int_t[fMulDigit];
+    memcpy(recp.fDigitsList,fDigitsList,fMulDigit*sizeof(Int_t));
+    recp.fTracksList = new Int_t[fMulTrack];
+    memcpy(recp.fTracksList,fTracksList,fMulTrack*sizeof(Int_t));
+  }
+}
+
 //____________________________________________________________________________
 void AliRecPoint::GetCovarianceMatrix(TMatrix & mat)
 {
@@ -130,7 +202,7 @@ void AliRecPoint::GetCovarianceMatrix(TMatrix & mat)
 }
 
 //____________________________________________________________________________
-void AliRecPoint::GetLocalPosition(TVector3 & pos)
+void AliRecPoint::GetLocalPosition(TVector3 & pos) const
 {
   // returns the position of the cluster in the local reference system of the sub-detector
 
@@ -140,7 +212,15 @@ void AliRecPoint::GetLocalPosition(TVector3 & pos)
 }
 
 //____________________________________________________________________________
-void AliRecPoint::GetGlobalPosition(TVector3 & gpos, TMatrix & gmat)
+AliRecPoint & AliRecPoint::operator= (const AliRecPoint &recp)
+{
+  recp.Copy(*this);
+  return (*this);
+}
+
+
+//____________________________________________________________________________
+void AliRecPoint::GetGlobalPosition(TVector3 & gpos, TMatrix & gmat) const
 {
   // returns the position of the cluster in the global reference system of ALICE
   // and the uncertainty on this position