]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSRecParticle.cxx
Added 2 methos to retrieve the primary particles
[u/mrichter/AliRoot.git] / PHOS / AliPHOSRecParticle.cxx
index 47bac8c9bf8ed2f39cadfc997b7d41b731405bb8..463902b858268dc124bd743c178a5bb221f347e9 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-
+/* $Id$ */
 //_________________________________________________________________________
-// Reconstructed Particle
-//*-- Y. Schutz:   SUBATECH 
-//////////////////////////////////////////////////////////////////////////////
+//  A Reconstructed Particle in PHOS    
+//  To become a general class of AliRoot ?       
+//  Why should I put meaningless comments
+//  just to satisfy
+//  the code checker                 
+//       
+//*-- Author: Yves Schutz (SUBATECH)
+
 
 // --- ROOT system ---
 
 // --- Standard library ---
 
+
 // --- AliRoot header files ---
 
 #include "AliPHOSRecParticle.h"
-#include "TPad.h"
+#include "AliPHOSGetter.h" 
+#include "TParticle.h"
 
 ClassImp(AliPHOSRecParticle)
 
 
-//____________________________________________________________________________
- AliPHOSRecParticle::AliPHOSRecParticle(AliPHOSTrackSegment * ts)
-{
-  // ctor
-  fPHOSTrackSegment = new AliPHOSTrackSegment(*ts) ; 
-  Float_t kenergy   = ts->GetEnergy() ; 
-  TVector3 momdir   = ts->GetMomentumDirection() ;
-  fPx               = kenergy * momdir.X() ; 
-  fPy               = kenergy * momdir.Y() ; 
-  fPz               = kenergy * momdir.Z() ; 
-  fType             = kUNDEFINED ;  
-  fE                = kenergy ;    // !!! all particles have mass = 0 
-}
-
 //____________________________________________________________________________
  AliPHOSRecParticle::AliPHOSRecParticle(const AliPHOSRecParticle & rp)
 {
-  fPHOSTrackSegment = new AliPHOSTrackSegment( *( rp.GetPHOSTrackSegment()) ) ; 
+  // copy ctor
+
+  fPHOSTrackSegment = rp.fPHOSTrackSegment ; 
   fType             = rp.fType ; 
+  fIndexInList      = rp.fIndexInList ;
+
   fPdgCode     = rp.fPdgCode;
   fStatusCode  = rp.fStatusCode;
   fMother[0]   = rp.fMother[0];
@@ -69,13 +65,33 @@ ClassImp(AliPHOSRecParticle)
   fPolarTheta  = rp.fPolarTheta;
   fPolarPhi    = rp.fPolarPhi;
   fParticlePDG = rp.fParticlePDG; 
+  
+}
+
+//____________________________________________________________________________
+const Int_t AliPHOSRecParticle::GetNPrimaries() const  
+{ 
+
+  Int_t rv = 0 ;
+  AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; 
+  gime->EmcRecPoint(gime->TrackSegment(GetPHOSTSIndex())->GetEmcIndex())->GetPrimaries(rv) ; 
+  return rv ; 
 }
 
 //____________________________________________________________________________
- AliPHOSRecParticle::~AliPHOSRecParticle()
+const TParticle * AliPHOSRecParticle::GetPrimary(Int_t index) const  
 {
-  if(!fPHOSTrackSegment) {
-    delete fPHOSTrackSegment ;
-    fPHOSTrackSegment = 0 ; 
-  } 
+  if ( index > GetNPrimaries() ) 
+    cout << "WARNING : AliPHOSRecParticle::GetPrimary -> " << index << " is larger that the number of primaries " 
+        <<  GetNPrimaries() << endl ; 
+  else { 
+    Int_t dummy ; 
+    AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; 
+    Int_t primaryindex = gime->EmcRecPoint(gime->TrackSegment(GetPHOSTSIndex())->GetEmcIndex())->GetPrimaries(dummy)[index] ; 
+    if (primaryindex >= 10000000) 
+      cout << "WARNING : AliPHOSRecParticle::GetPrimary -> not a signal primary" << endl ; 
+    else 
+      return gime->Primary(primaryindex) ; 
+  }
+  return 0 ; 
 }