delete esd; delete hltesd;
esd = NULL; hltesd = NULL;
- // create the file and tree with ESD additions
- TFile *filef=0; TTree *treef=0; AliESDfriend *esdf=0;
+ // create the branch with ESD additions
+ AliESDfriend *esdf=0;
if (fWriteESDfriend) {
- filef = TFile::Open("AliESDfriends.root", "RECREATE");
- if (!filef->IsOpen()) {
- AliError("opening AliESDfriends.root failed");
- }
- treef = new TTree("esdFriendTree", "Tree with ESD friends");
- treef->Branch("ESDfriend", "AliESDfriend", &esdf);
+ TBranch *br=tree->Branch("ESDfriend.", "AliESDfriend", &esdf);
+ br->SetFile("AliESDfriends.root");
}
- gROOT->cd();
-
AliVertexerTracks tVertexer;
if(fDiamondProfile) tVertexer.SetVtxStart(fDiamondProfile);
esd->SetPrimaryVertex(tVertexer.FindPrimaryVertex(esd));
// write ESD
- tree->Fill();
- // write HLT ESD
- hlttree->Fill();
-
- // write ESD friend
if (fWriteESDfriend) {
esdf=new AliESDfriend();
esd->GetESDfriend(esdf);
- treef->Fill();
}
+ tree->Fill();
+
+ // write HLT ESD
+ hlttree->Fill();
if (fCheckPointLevel > 0) WriteESD(esd, "final");
- delete esd; delete hltesd;
- esd = NULL; hltesd = NULL;
+ delete esd; delete esdf; delete hltesd;
+ esd = NULL; esdf=NULL; hltesd = NULL;
}
AliInfo(Form("Execution time for filling ESD : R:%.2fs C:%.2fs",
stopwatch.RealTime(),stopwatch.CpuTime()));
file->cd();
+ tree->SetBranchStatus("ESDfriend*",0);
tree->Write();
hlttree->Write();
- if (fWriteESDfriend) {
- filef->cd();
- treef->Write(); delete treef; filef->Close(); delete filef;
- }
-
// Create tags for the events in the ESD tree (the ESD tree is always present)
// In case of empty events the tags will contain dummy values
CreateTag(file);
#if !defined( __CINT__) || defined(__MAKECINT__)
#include <Riostream.h>
#include <TFile.h>
- #include <TTree.h>
+ #include <TChain.h>
#include "AliESD.h"
#include "AliESDfriend.h"
+ #include "AliTrackPointArray.h"
#endif
void ReadESDfriend(Bool_t readFriend=kTRUE) {
- TFile f("AliESDs.root");
- TTree *esdTree=(TTree*)f.Get("esdTree");
+ Char_t *name[]={
+ //Put here the names of the ESD files to be chained
+ "AliESDs.root"
+ };
+ Int_t n=sizeof(name)/sizeof(Char_t *);
+ TChain *esdTree=new TChain("esdTree");
+ for (Int_t i=0; i<n; i++) esdTree->AddFile(name[i]);
+
AliESD *ev=0;
esdTree->SetBranchAddress("ESD",&ev);
- // Attach the tree with ESD friends
+ // Attach the branch with ESD friends
AliESDfriend *evf=0;
if (readFriend) {
- esdTree->AddFriend("esdFriendTree","AliESDfriends.root");
- esdTree->SetBranchAddress("ESDfriend",&evf);
+ esdTree->SetBranchStatus("ESDfriend*",1);
+ esdTree->SetBranchAddress("ESDfriend.",&evf);
}
Int_t nev=esdTree->GetEntries();
for (Int_t i=0; i<nev; i++) {
- cout<<"Event number: "<<i<<endl;
esdTree->GetEntry(i);
+ cout<<endl<<"Event number: "<<i<<endl;
+ Int_t n=ev->GetNumberOfTracks();
+ cout<<"Number of tracks: "<<n<<endl;
+ if (n==0) continue;
+
ev->SetESDfriend(evf); //Attach the friend to the ESD
// Now the attached information can be accessed via pointer to ESD.
// Example: indices of the TPC clusters associated with the track number 0.
const AliESDtrack *t=ev->GetTrack(0);
- Int_t idx[AliESDfriendTrack::kMaxTPCcluster], n=t->GetTPCclusters(idx);
- cout<<"Number of TPC clusters: "<<n<<endl;
- cout<<"Index of the 7th TPC cluster: "<<idx[7]<<endl<<endl;
+ Int_t idx[AliESDfriendTrack::kMaxTPCcluster];
+ n=t->GetTPCclusters(idx);
+ cout<<"Track number 0"<<endl;
+ cout<<" Number of TPC clusters: "<<n<<endl;
+ cout<<" Index of the 7th TPC cluster: "<<idx[7]<<endl;
+
+ // Example: track points associated with the track number 0.
+ const AliTrackPointArray *pa=t->GetTrackPointArray();
+ if (pa==0) continue;
+ n=pa->GetNPoints();
+ const Float_t *x=pa->GetX();
+ cout<<" Number of track points: "<<n<<endl;
+ if (n>7)
+ cout<<" X coordinate of the 7th track point: "<<x[7]<<endl;
+
}
delete esdTree;