3 //____________________________________________________________________
4 //////////////////////////////////////////////////////////////////////
6 // class AliHBTReaderESD //
8 // Reader for ALICE Event Summary Data (ESD). //
10 // Piotr.Skowronski@cern.ch //
12 //////////////////////////////////////////////////////////////////////
17 #include <TObjString.h>
23 #include <AliESDtrack.h>
24 #include <AliKalmanTrack.h>
25 #include <AliJetEventParticles.h>
26 #include "AliJetParticlesReaderESD.h"
28 ClassImp(AliJetParticlesReaderESD)
30 AliJetParticlesReaderESD::AliJetParticlesReaderESD(Bool_t constrained,
31 const Char_t* esdfilename) :
32 AliJetParticlesReader(),
33 fConstrained(constrained),
34 fESDFileName(esdfilename),
39 fPassFlag(AliESDtrack::kTPCrefit)
44 /********************************************************************/
46 AliJetParticlesReaderESD::AliJetParticlesReaderESD(
49 const Char_t* esdfilename) :
50 AliJetParticlesReader(dirs),
51 fConstrained(constrained),
52 fESDFileName(esdfilename),
57 fPassFlag(AliESDtrack::kTPCrefit)
62 /********************************************************************/
64 AliJetParticlesReaderESD::~AliJetParticlesReaderESD()
68 if(fTree) delete fTree;
69 if(fKeyIterator) delete fKeyIterator;
70 if(fFile) delete fFile;
74 Int_t AliJetParticlesReaderESD::ReadNext()
76 //reads next event from fFile
78 do // is OK even if 0 dirs specified,
79 { // in that case we try to read from "./"
82 fFile = OpenFile(fCurrentDir);
85 Error("ReadNext","Can't get fFile for dir no. %d",fCurrentDir);
91 //fFile->GetListOfKeys()->Print();
93 if(fTree) delete fTree;
94 fTree = dynamic_cast<TTree*>(fFile->Get("esdTree"));
96 fTree->SetBranchAddress("ESD",&fESD);
98 fKeyIterator = new TIter(fFile->GetListOfKeys());
103 if(AliKalmanTrack::GetConvConst()<=0.)
104 AliKalmanTrack::SetMagneticField(0.5);
105 if(fCurrentEvent>=fTree->GetEntries())
114 fTree->GetEvent(fCurrentEvent);
117 { // "old" way via ESD objects stored in root file
118 TKey* key = (TKey*)fKeyIterator->Next();
124 delete fFile; //we have to assume there are no more ESD objects in the fFile
128 TString esdname = "ESD";
129 esdname+=fCurrentEvent;
130 if(fESD) delete fESD;
131 fESD = dynamic_cast<AliESD*>(fFile->Get(esdname));
134 Info("ReadNext","Can't find AliESD object named %s",esdname.Data());
138 delete fFile;//we have to assume there is no more ESD objects in the fFile
146 return kTRUE;//success -> read one event
147 } while(fCurrentDir < GetNumberOfDirs());
148 //end of loop over directories specified in fDirs Obj Array
149 return kFALSE; //no more directories to read
152 /**********************************************************/
154 Int_t AliJetParticlesReaderESD::ReadESD(AliESD* esd)
160 Error("ReadESD","ESD is NULL");
164 //TDatabasePDG* pdgdb = TDatabasePDG::Instance();
167 // Error("ReadESD","Can not get PDG Database Instance.");
171 Float_t mf = esd->GetMagneticField();
174 Error("ReadESD","Magnetic Field is 0. Skipping to next event.");
177 AliKalmanTrack::SetMagneticField(mf/10.);
179 Info("ReadESD","Reading Event %d",fCurrentEvent);
180 if((!fOwner) || (fEventParticles==0))
181 fEventParticles = new AliJetEventParticles();
183 const Int_t kntr = esd->GetNumberOfTracks();
184 Info("ReadESD","Found %d tracks.",kntr);
185 fEventParticles->Reset(kntr);
189 headdesc+=esd->GetRunNumber();
191 headdesc+=esd->GetEventNumber();
192 fEventParticles->SetHeader(headdesc);
194 Double_t vertexpos[3];//vertex position
195 const AliESDVertex* kvertex = esd->GetVertex();
198 Info("ReadESD","ESD returned NULL pointer to vertex - assuming (0.0,0.0,0.0)");
205 kvertex->GetXYZ(vertexpos);
207 fEventParticles->SetVertex(vertexpos[0],vertexpos[1],vertexpos[2]);
210 for (Int_t i = 0;i<kntr; i++)
212 const AliESDtrack *kesdtrack = esd->GetTrack(i);
215 Error("ReadESD","Can't get track %d", i);
219 if ((kesdtrack->GetStatus() & fPassFlag) != fPassFlag)
221 Info("ReadNext","Particle skipped: %ud.",kesdtrack->GetStatus());
225 Double_t mom[3]; //momentum
226 Double_t xyz[3]; //position
228 if (kesdtrack->GetConstrainedChi2() > 25) continue;
229 kesdtrack->GetConstrainedPxPyPz(mom);
230 kesdtrack->GetConstrainedXYZ(xyz);
232 kesdtrack->GetPxPyPz(mom);
233 kesdtrack->GetXYZ(xyz);
235 const Float_t kmass=kesdtrack->GetMass();
236 const Float_t kp2=mom[0]*mom[0]+mom[1]*mom[1]+mom[2]*mom[2];
237 const Float_t ketot=TMath::Sqrt(kmass*kmass+kp2);
238 const Float_t kpt=TMath::Sqrt(mom[0]*mom[0]+mom[1]*mom[1]);
239 const Float_t kp=TMath::Sqrt(kp2);
240 const Float_t keta=0.5*TMath::Log((kp+mom[2]+1e-30)/(kp-mom[2]+1e-30));
241 const Float_t kphi=TMath::Pi()+TMath::ATan2(-mom[1],-mom[0]);
242 //Double_t dx = xyz[0]-vertexpos[0];
243 //Double_t dy = xyz[1]-vertexpos[1];
244 //Float_t dca = TMath::Sqrt(dx*dx + dy*dy);
245 //Float_t dz = xyz[2]-vertexpos[2];
247 const Int_t kncl=kesdtrack->GetITSclusters(index)
248 +kesdtrack->GetTPCclusters(NULL)
249 +kesdtrack->GetTRDclusters(NULL);
250 if(IsAcceptedParticle(kpt,kphi,keta))
251 fEventParticles->AddParticle(mom[0],mom[1],mom[2],ketot,i,kesdtrack->GetLabel(),kncl,kpt,kphi,keta);
253 } // loop over tracks
258 /**********************************************************/
260 void AliJetParticlesReaderESD::Rewind()
264 if(fFile) delete fFile;
265 if(fKeyIterator) delete fKeyIterator;
272 /**********************************************************/
274 TFile* AliJetParticlesReaderESD::OpenFile(Int_t n)
276 //opens fFile with kine tree
278 const TString& dirname = GetDirName(n);
281 Error("OpenFiles","Can't get directory name");
284 TString filename = dirname +"/"+ fESDFileName;
285 TFile *ret = TFile::Open(filename.Data());
288 Error("OpenFiles","Can't open fFile %s",filename.Data());
293 Error("OpenFiles","Can't open fFile %s",filename.Data());