/* $Id$ */ // Helper macros for creating chains TChain* CreateESDChain(const char* aDataDir = "ESDfiles.txt", Int_t aRuns = 20, Int_t offset = 0) { // creates chain of files in a given directory or file containing a list. // In case of directory the structure is expected as: // //AliESDs.root // //AliESDs.root // ... if (!aDataDir) return 0; Long_t id, size, flags, modtime; if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime)) { printf("%s not found.\n", aDataDir); return 0; } TChain* chain = new TChain("esdTree"); TChain* chaingAlice = 0; if (flags & 2) { TString execDir(gSystem->pwd()); TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir); TList* dirList = baseDir->GetListOfFiles(); Int_t nDirs = dirList->GetEntries(); gSystem->cd(execDir); Int_t count = 0; for (Int_t iDir=0; iDirAt(iDir); if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0) continue; if (offset > 0) { --offset; continue; } if (count++ == aRuns) break; TString presentDirName(aDataDir); presentDirName += "/"; presentDirName += presentDir->GetName(); chain->Add(presentDirName + "/AliESDs.root/esdTree"); } } else { // Open the input stream ifstream in; in.open(aDataDir); Int_t count = 0; // Read the input list of files and add them to the chain TString esdfile; while(in.good()) { in >> esdfile; if (!esdfile.Contains("root")) continue; // protection if (offset > 0) { --offset; continue; } if (count++ == aRuns) break; // add esd file chain->Add(esdfile); } in.close(); } return chain; } void LookupWrite(TChain* chain, const char* target) { // looks up the chain and writes the remaining files to the text file target chain->Lookup(); TObjArray* list = chain->GetListOfFiles(); TIterator* iter = list->MakeIterator(); TObject* obj = 0; ofstream outfile; outfile.open(target); while ((obj = iter->Next())) outfile << obj->GetTitle() << "#AliESDs.root" << endl; outfile.close(); delete iter; }