+ // copy ctor
+ fType = rp.fType ;
+ fIndexInList = rp.fIndexInList ;
+
+ 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 = AliPID::kSPECIESCN;
+ for(Int_t i = 0; i<nSPECIES ; i++)
+ fPID[i]=rp.fPID[i];
+}
+
+//____________________________________________________________________________
+AliPHOSRecParticle & AliPHOSRecParticle::operator = (const AliPHOSRecParticle &)
+{
+ Fatal("operator =", "not implemented");
+ return *this;
+}
+
+//____________________________________________________________________________
+Int_t AliPHOSRecParticle::GetNPrimaries() const
+{
+ return -1;
+}
+
+//____________________________________________________________________________
+Int_t AliPHOSRecParticle::GetNPrimariesToRecParticles() const
+{
+ // Get the number of primaries at the origine of the RecParticle
+ Int_t rv = 0 ;
+ AliRunLoader* rl = AliRunLoader::Instance() ;
+ AliPHOSLoader * phosLoader = static_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
+ Int_t emcRPindex = static_cast<AliPHOSTrackSegment*>(phosLoader->TrackSegments()->At(GetPHOSTSIndex()))->GetEmcIndex();
+ static_cast<AliPHOSEmcRecPoint*>(phosLoader->EmcRecPoints()->At(emcRPindex))->GetPrimaries(rv) ;
+ return rv ;
+}
+
+//____________________________________________________________________________
+const TParticle * AliPHOSRecParticle::GetPrimary() const
+{
+ // Get the primary particle at the origine of the RecParticle and
+ // which has deposited the largest energy in SDigits
+ AliRunLoader* rl = AliRunLoader::Instance() ;
+ AliPHOSLoader * phosLoader = static_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
+ rl->GetEvent(rl->GetEventNumber()) ;
+ rl->LoadKinematics("READ");
+ rl->LoadSDigits("READ");
+
+ if(GetNPrimaries() == 0)
+ return 0 ;
+ if(GetNPrimaries() == 1)
+ return GetPrimary(0) ;
+ Int_t AbsId = 0;
+ Int_t module ;
+
+ // Get PHOS Geometry object
+ AliPHOSGeometry *geom;
+ if (!(geom = AliPHOSGeometry::GetInstance()))
+ geom = AliPHOSGeometry::GetInstance("IHEP","");
+ Double_t x,z ;
+//DP to be fixed: Why do we use this method here??? M.B. use RecPoint???
+ Double_t vtx[3]={0.,0.,0.} ;
+ geom->ImpactOnEmc(vtx,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 = phosLoader->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 ;
+ }
+ }
+ }
+ if(iPrim >= 0)
+ return rl->Stack()->Particle(iPrim) ;
+ else
+ return 0 ;
+}
+
+//____________________________________________________________________________
+Int_t AliPHOSRecParticle::GetPrimaryIndex() const
+{
+ // Get the primary track index in TreeK which deposits the most energy
+ // in Digits which forms EmcRecPoint, which produces TrackSegment,
+ // which the RecParticle is created from
+
+
+ AliRunLoader* rl = AliRunLoader::Instance() ;
+ AliPHOSLoader * phosLoader = static_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
+ rl->GetEvent(rl->GetEventNumber()) ;
+ rl->LoadHits("READ");
+ rl->LoadDigits("READ");
+ rl->LoadRecPoints("READ");
+ rl->LoadTracks("READ");
+
+ // Get TrackSegment corresponding to this RecParticle
+ const AliPHOSTrackSegment *ts = phosLoader->TrackSegment(fPHOSTrackSegment);
+
+ // Get EmcRecPoint corresponding to this TrackSegment
+ Int_t emcRecPointIndex = ts->GetEmcIndex();
+
+ const AliPHOSEmcRecPoint *emcRecPoint = phosLoader->EmcRecPoint(emcRecPointIndex);
+
+ // Get the list of digits forming this EmcRecParticle
+ Int_t nDigits = emcRecPoint->GetDigitsMultiplicity();
+ Int_t *digitList = emcRecPoint->GetDigitsList();
+
+ // Find the digit with maximum amplitude
+ Int_t maxAmp = 0;
+ Int_t bestDigitIndex = -1;
+ for (Int_t iDigit=0; iDigit<nDigits; iDigit++) {
+ const AliPHOSDigit * digit = phosLoader->Digit(digitList[iDigit]);
+ if (digit->GetAmp() > maxAmp) {
+ maxAmp = digit->GetAmp();
+ bestDigitIndex = iDigit;
+ }
+ }
+ if (bestDigitIndex>-1) {
+ const AliPHOSDigit * digit = phosLoader->Digit(digitList[bestDigitIndex]);
+ if (digit==0) return -12345;