]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSRecParticle.cxx
The new class AliTrackReference used (M.Ivanov)
[u/mrichter/AliRoot.git] / PHOS / AliPHOSRecParticle.cxx
index d83fea178ae6e5c8667ca1091684518188b48479..e92de231c9555adb9101bec7fbbb3338a5ab3522 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-
 /* $Id$ */
-
 //_________________________________________________________________________
 //  A Reconstructed Particle in PHOS    
-//  To become a general class of AliRoot ?        
+//  To become a general class of AliRoot ?       
+//  Why should I put meaningless comments
+//  just to satisfy
+//  the code checker                 
 //       
 //*-- Author: Yves Schutz (SUBATECH)
 
 
 // --- Standard library ---
 
-#include <assert.h>
 
 // --- AliRoot header files ---
 
 #include "AliPHOSRecParticle.h"
-#include "TPad.h"
-#include "AliPHOSIndexToObject.h"
+#include "AliPHOSGetter.h" 
+#include "TParticle.h"
 
 ClassImp(AliPHOSRecParticle)
 
 
-//____________________________________________________________________________
- AliPHOSRecParticle::AliPHOSRecParticle(AliPHOSTrackSegment * ts)
-{
-  // ctor
-  fPHOSTrackSegment = ts->GetIndexInList() ;
-  fIndexInList      = -1 ;
-  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)
 {
   // copy ctor
 
   fPHOSTrackSegment = rp.fPHOSTrackSegment ; 
+  fDebug            = kFALSE ; 
   fType             = rp.fType ; 
   fIndexInList      = rp.fIndexInList ;
 
@@ -81,60 +66,38 @@ ClassImp(AliPHOSRecParticle)
   fPolarTheta  = rp.fPolarTheta;
   fPolarPhi    = rp.fPolarPhi;
   fParticlePDG = rp.fParticlePDG; 
+  
 }
 
 //____________________________________________________________________________
-Int_t * AliPHOSRecParticle::GetPrimaries(Int_t & number) 
-{
-  // Retrieves all the primary particles at the origine of this reconstructed particle
-
-  AliPHOSTrackSegment * ts = GetPHOSTrackSegment() ;
-
-  Int_t emcnumber = 0 ; 
-  Int_t * emclist = ts->GetPrimariesEmc(emcnumber) ;
-  
-  Int_t ppsdlnumber = 0 ;
-  Int_t * ppsdllist = ts->GetPrimariesPpsdLow(ppsdlnumber) ;
-  Int_t ppsdunumber = 0 ; 
-  Int_t * ppsdulist = ts->GetPrimariesPpsdUp(ppsdunumber) ;
-
-  number = emcnumber + ppsdlnumber + ppsdunumber ;
-  Int_t * list   = new Int_t[number] ;
-  
-  Int_t index ; 
-  for ( index = 0 ; index < emcnumber ; index++)
-    list[index] = emclist[index] ;
-
-  Int_t jndex ; 
-  for ( jndex = 0 ; jndex < ppsdlnumber ; jndex++) {
-    assert(index < number) ;
-    list[index] = ppsdllist[jndex] ;
-    index++ ; 
-  }
-
-  for ( jndex = 0 ; jndex < ppsdunumber ; jndex++) {
-    assert(index < number) ;
-    list[index] = ppsdulist[jndex] ;
-    index++ ; 
-  }
+const Int_t AliPHOSRecParticle::GetNPrimaries() const  
+{ 
 
-  delete emclist ;
-  delete ppsdllist ;
-  delete ppsdulist ;
-
-  return list ; 
+  Int_t rv = 0 ;
+  AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; 
+  gime->EmcRecPoint(gime->TrackSegment(GetPHOSTSIndex())->GetEmcIndex())->GetPrimaries(rv) ; 
+  return rv ; 
 }
 
 //____________________________________________________________________________
-AliPHOSTrackSegment * AliPHOSRecParticle::GetPHOSTrackSegment() const 
+const TParticle * AliPHOSRecParticle::GetPrimary(Int_t index) const  
 {
-  // Retrieves the PHOS track segment at the origine of this reconstructed particle
-
-  AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
-  return please->GimeTrackSegment( fPHOSTrackSegment ) ;
-
+  if ( index > GetNPrimaries() ) { 
+    if (fDebug) 
+      cout << "WARNING : AliPHOSRecParticle::GetPrimary -> " << index << " is larger that the number of primaries " 
+          <<  GetNPrimaries() << endl ;
+    return 0 ; 
+  } else { 
+    Int_t dummy ; 
+    AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; 
+    Int_t primaryindex = gime->EmcRecPoint(gime->TrackSegment(GetPHOSTSIndex())->GetEmcIndex())->GetPrimaries(dummy)[index] ; 
+    if (primaryindex >= 10000000) { // it comes from backgroundfile 
+      if (fDebug) 
+       cout << "WARNING : AliPHOSRecParticle::GetPrimary -> not a signal primary" << endl ;
+      return 0 ; 
+    } else 
+      return gime->Primary(primaryindex) ; 
+  } 
+  return 0 ; 
 }
 
-
-