+//____________________________________________________________________________
+void AliPHOSGammaJet::CreateParticleListFromESD(TClonesArray * pl,
+ TClonesArray * plCh,
+ TClonesArray * plNe,
+ TClonesArray * plNePHOS,
+ const AliESD * esd){
+
+ //Create a list of particles from the ESD. These particles have been measured
+ //by the Central Tracking system (TPC), PHOS and EMCAL
+ //(EMCAL not available for the moment).
+ //Info("CreateParticleListFromESD","Inside");
+
+ Int_t index = pl->GetEntries() ;
+ Int_t npar = 0 ;
+ Double_t pid[AliPID::kSPECIESN];
+
+ //########### PHOS ##############
+ //Info("CreateParticleListFromESD","Fill ESD PHOS list");
+ Int_t begphos = esd->GetFirstPHOSParticle();
+ Int_t endphos = esd->GetFirstPHOSParticle() +
+ esd->GetNumberOfPHOSParticles() ;
+ Int_t indexNePHOS = plNePHOS->GetEntries() ;
+ if(strstr(fOptionGJ,"deb all"))
+ Info("CreateParticleListFromESD","PHOS: first particle %d, last particle %d",
+ begphos,endphos);
+
+ for (npar = begphos; npar < endphos; npar++) {//////////////PHOS track loop
+ AliESDtrack * track = esd->GetTrack(npar) ; // retrieve track from esd
+
+ //Create a TParticle to fill the particle list
+
+ Double_t en = track->GetPHOSsignal() ;
+ Double_t * p = new Double_t();
+ track->GetPHOSposition(p) ;
+ TVector3 pos(p[0],p[1],p[2]) ;
+ Double_t phi = pos.Phi();
+ Double_t theta= pos.Theta();
+ Double_t px = en*TMath::Cos(phi)*TMath::Sin(theta);;
+ Double_t py = en*TMath::Sin(phi)*TMath::Sin(theta);
+ Double_t pz = en*TMath::Cos(theta);
+
+ TParticle * particle = new TParticle() ;
+ particle->SetMomentum(px,py,pz,en) ;
+
+ //Select only photons
+
+ track->GetPHOSpid(pid);
+ //cout<<"pid "<<pid[AliPID::kPhoton]<<endl ;
+ if( pid[AliPID::kPhoton] > 0.75)
+ new((*plNePHOS)[indexNePHOS++]) TParticle(*particle) ;
+ }
+
+ //########### TPC #####################
+ //Info("CreateParticleListFromESD","Fill ESD TPC list");
+ Int_t begtpc = 0 ;
+ Int_t endtpc = esd->GetNumberOfTracks() ;
+ Int_t indexCh = plCh->GetEntries() ;
+ if(strstr(fOptionGJ,"deb all"))
+ Info("CreateParticleListFromESD","TPC: first particle %d, last particle %d",
+ begtpc,endtpc);
+
+ for (npar = begtpc; npar < endtpc; npar++) {////////////// track loop
+ AliESDtrack * track = esd->GetTrack(npar) ; // retrieve track from esd
+
+ Double_t en = track ->GetTPCsignal() ;
+ TVector3 mom = track->P3() ;
+ Double_t px = mom.Px();
+ Double_t py = mom.Py();
+ Double_t pz = mom.Pz(); //Check with TPC people if this is correct.
+
+ //cout<<"TPC signal "<<en<<endl;
+ //cout<<"px "<<px<<"; py "<<py<<"; pz "<<pz<<endl;
+ TParticle * particle = new TParticle() ;
+ particle->SetMomentum(px,py,pz,en) ;
+
+ new((*plCh)[indexCh++]) TParticle(*particle) ;
+ new((*pl)[index++]) TParticle(*particle) ;
+
+ }
+
+ //################ EMCAL ##############
+ Double_t v[3] ; //vertex ;
+ esd->GetVertex()->GetXYZ(v) ;
+ //##########Uncomment when ESD for EMCAL works ##########
+ //Info("CreateParticleListFromESD","Fill ESD EMCAL list");
+
+ Int_t begem = esd->GetFirstEMCALParticle();
+ Int_t endem = esd->GetFirstEMCALParticle() +
+ esd->GetNumberOfEMCALParticles() ;
+ Int_t indexNe = plNe->GetEntries() ;
+ if(strstr(fOptionGJ,"deb all"))
+ Info("CreateParticleListFromESD","EMCAL: first particle %d, last particle %d",
+ begem,endem);
+
+ for (npar = begem; npar < endem; npar++) {//////////////EMCAL track loop
+ AliESDtrack * track = esd->GetTrack(npar) ; // retrieve track from esd
+
+ Double_t en = track->GetEMCALsignal() ;
+ Double_t *p = new Double_t();
+ track->GetEMCALposition(p) ;
+ TVector3 pos(p[0],p[1],p[2]) ;
+ Double_t phi = pos.Phi();
+ Double_t theta= pos.Theta();
+ Double_t px = en*TMath::Cos(phi)*TMath::Sin(theta);;
+ Double_t py = en*TMath::Sin(phi)*TMath::Sin(theta);
+ Double_t pz = en*TMath::Cos(theta);
+ //cout<<"EMCAL signal "<<en<<endl;
+ //cout<<"px "<<px<<"; py "<<py<<"; pz "<<pz<<endl;
+ //TParticle * particle = new TParticle() ;
+ //particle->SetMomentum(px,py,pz,en) ;
+
+ Int_t pdg = 0;
+ // //Uncomment if PID IS WORKING, photon and pi0 idenitification.
+ // //if( pid[AliPID::kPhoton] > 0.75) //This has to be fixen.
+ // //pdg = 22;
+ // //else if( pid[AliPID::kPi0] > 0.75)
+ // //pdg = 111;
+ pdg = 22; //No PID, assume all photons
+ TParticle * particle = new TParticle(pdg, 1, -1, -1, -1, -1,
+ px, py, pz, en, v[0], v[1], v[2], 0);
+
+ new((*plNe)[indexNe++]) TParticle(*particle) ;
+ new((*pl)[index++]) TParticle(*particle) ;
+ }
+
+ // Info("CreateParticleListFromESD","End Inside");
+
+}