]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSRecParticle.cxx
new slow simulation up to RawData
[u/mrichter/AliRoot.git] / PHOS / AliPHOSRecParticle.cxx
index 8add627439ffccd22df3c88ec62a6ce6dec26312..60dec667ddea50b9c3cb742b9955ac9aa7ce491e 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 ---
 
+// --- AliRoot header files ---
 #include "AliPHOSRecParticle.h"
+#include "AliPHOSGetter.h" 
+#include "AliPHOSGeometry.h" 
 
-ClassImp(AliPHOSRecParticle)
+//____________________________________________________________________________
+  AliPHOSRecParticle::AliPHOSRecParticle(): fPHOSTrackSegment(0)  ,  fDebug( kFALSE )
+{
+  // ctor
+  const Int_t nSPECIES = AliESDtrack::kSPECIESN;
+  for(Int_t i = 0; i<nSPECIES ; i++)
+    fPID[i]=0.;
+}
 
 
 //____________________________________________________________________________
- AliPHOSRecParticle::AliPHOSRecParticle(AliPHOSTrackSegment * ts)
+ AliPHOSRecParticle::AliPHOSRecParticle(const AliPHOSRecParticle & rp)
+   : AliPHOSFastRecParticle(rp)
 {
-  // ctor
-  fPHOSTrackSegment = new AliPHOSTrackSegment(*ts) ; 
-  fE                = ts->GetEnergy() ; 
-  TVector3 momdir   = ts->GetMomentumDirection() ;
-  fPx               = fE * momdir.X() ; 
-  fPy               = fE * momdir.Y() ; 
-  fPz               = fE * momdir.Z() ; 
+  // copy ctor
 
-  fType = kUNDEFINED ; // undefined
-                            
-  if( ts->GetPpsdUp() == 0 ) {     // Neutral
+  fPHOSTrackSegment = rp.fPHOSTrackSegment ; 
+  fDebug            = kFALSE ; 
+  fType             = rp.fType ; 
+  fIndexInList      = rp.fIndexInList ;
 
-    if( ts->GetPpsdLow() == 0 )    // Neutral  
-      fType = kNEUTRAL ;   
-    else                           // Gamma
-      fType = kGAMMA ;               
-  }
-  else                            // Charged           
-    fType = kCHARGED ;   
-  
+  fPdgCode     = rp.fPdgCode;
+  fStatusCode  = rp.fStatusCode;
+  fMother[0]   = rp.fMother[0];
+  fMother[1]   = rp.fMother[1];
+  fDaughter[0] = rp.fDaughter[0];
+  fDaughter[1] = rp.fDaughter[1];
+  fWeight      = rp.fWeight;
+  fCalcMass    = rp.fCalcMass;
+  fPx          = rp.fPx;
+  fPy          = rp.fPy;
+  fPz          = rp.fPz;
+  fE           = rp.fE;
+  fVx          = rp.fVx;
+  fVy          = rp.fVy;
+  fVz          = rp.fVz;
+  fVt          = rp.fVt;
+  fPolarTheta  = rp.fPolarTheta;
+  fPolarPhi    = rp.fPolarPhi;
+  fParticlePDG = rp.fParticlePDG; 
+  const Int_t nSPECIES = AliESDtrack::kSPECIESN;
+  for(Int_t i = 0; i<nSPECIES ; i++)
+    fPID[i]=rp.fPID[i];
 }
 
 //____________________________________________________________________________
-TString AliPHOSRecParticle::Name()
+const Int_t AliPHOSRecParticle::GetNPrimaries() const  
+{ 
+  return -1;
+}
+
+//____________________________________________________________________________
+const Int_t AliPHOSRecParticle::GetNPrimariesToRecParticles() const  
+{ 
+  // Get the number of primaries at the origine of the RecParticle
+  Int_t rv = 0 ;
+  AliPHOSGetter * gime = AliPHOSGetter::Instance() ; 
+  Int_t emcRPindex = dynamic_cast<AliPHOSTrackSegment*>(gime->TrackSegments()->At(GetPHOSTSIndex()))->GetEmcIndex();
+  dynamic_cast<AliPHOSEmcRecPoint*>(gime->EmcRecPoints()->At(emcRPindex))->GetPrimaries(rv) ; 
+  return rv ; 
+}
+
+//____________________________________________________________________________
+const TParticle * AliPHOSRecParticle::GetPrimary() const  
 {
-  TString  name ; 
-  switch (fType) {
-  case kGAMMA:
-    name = "PHOTON" ;
-    break ; 
-   case kELECTRON:
-     name = "ELECTRON" ;
-    break ; 
-  case kNEUTRAL:
-    name = "NEUTRAL" ;
-    break ; 
-   case kCHARGEDHADRON:
-    name = "CHARGED HADRON" ;
-    break ; 
-  case kNEUTRALHADRON:
-    name = "NEUTRAL HADRON" ; 
-    break ; 
-  case kNEUTRALEM:
-    name = "NEUTRAL EM" ; 
-    break ; 
+  // Get the primary particle at the origine of the RecParticle and 
+  // which has deposited the largest energy in SDigits
+  AliPHOSGetter * gime = AliPHOSGetter::Instance() ; 
+  if (!gime) 
+    Error("GetPrimary", "Getter not yet instantiated") ; 
+  gime->Event(gime->EventNumber(), "SRTPX") ; 
+  if(GetNPrimaries() == 0)
+    return 0 ;
+  if(GetNPrimaries() == 1)
+    return GetPrimary(0) ;
+  Int_t AbsId = 0;
+  Int_t module ;
+  const AliPHOSGeometry * geom = gime->PHOSGeometry() ;
+   Double_t x,z ;
+  geom->ImpactOnEmc(static_cast<double>(Theta()),static_cast<double>(Phi()), module,z,x);
+  Int_t amp = 0 ;
+  Int_t iPrim=-1 ;
+  if(module != 0){
+    geom->RelPosToAbsId(module,x,z,AbsId) ;
+   TClonesArray * sdigits = gime->SDigits() ;
+   AliPHOSDigit * sdig ;
+    
+   for(Int_t i = 0 ; i < sdigits->GetEntriesFast() ; i++){
+     sdig = static_cast<AliPHOSDigit *>(sdigits->At(i)) ;
+     if((sdig->GetId() == AbsId)){
+       if((sdig->GetAmp() > amp) && (sdig->GetNprimary())){
+        amp = sdig->GetAmp() ;
+        iPrim = sdig->GetPrimary(1) ;
+       } 
+       // do not scan rest of list
+       if(sdig->GetId() > AbsId)
+        continue ; 
+     }
+   }
   }
-  return name ; 
+  if(iPrim >= 0)
+    return gime->Primary(iPrim) ;
+  else
+    return 0 ;
+} 
+  
+//____________________________________________________________________________
+const TParticle * AliPHOSRecParticle::GetPrimary(Int_t index) const  
+{
+  // Get one of the primary particles at the origine of the RecParticle
+  if ( index > GetNPrimariesToRecParticles() ) { 
+    if (fDebug) 
+      Warning("GetPrimary", "AliPHOSRecParticle::GetPrimary -> %d is larger that the number of primaries %d", 
+             index, GetNPrimaries()) ;
+    return 0 ; 
+  } 
+  else { 
+    Int_t dummy ; 
+    AliPHOSGetter * gime = AliPHOSGetter::Instance() ; 
+
+    Int_t emcRPindex = dynamic_cast<AliPHOSTrackSegment*>(gime->TrackSegments()->At(GetPHOSTSIndex()))->GetEmcIndex();
+    Int_t primaryindex = dynamic_cast<AliPHOSEmcRecPoint*>(gime->EmcRecPoints()->At(emcRPindex))->GetPrimaries(dummy)[index] ; 
+    return gime->Primary(primaryindex) ;
+   } 
+  //  return 0 ; 
 }
 
 //____________________________________________________________________________
-void AliPHOSRecParticle::Print()
+void AliPHOSRecParticle::SetPID(Int_t type, Double_t weight)
 {
-  cout << "AliPHOSRecParticle > " << "type is  " << Name() << endl 
-       << "                     " << "Energy = " << fE << endl 
-       << "                     " << "Px     = " << fPx << endl 
-       << "                     " << "Py     = " << fPy << endl 
-       << "                     " << "Pz     = " << fPz << endl ; 
+  // Set the probability densities that this reconstructed particle
+  // has a type of i:
+  // i       particle types
+  // ----------------------
+  // 0       electron
+  // 1       muon
+  // 2       pi+-
+  // 3       K+-
+  // 4       p/pbar
+  // 5       photon
+  // 6       pi0 at high pt
+  // 7       neutron
+  // 8       K0L
+  // 9       Conversion electron
+  
+  fPID[type] = weight ; 
 }