2 * Create a file collection in a ROOT file
4 * @param dir Input directory
6 * @param pa File name pattern
7 * @param mc If true, simulations
8 * @param recursive Scan recursively
10 * @ingroup pwglf_forward_trains_helper
13 CreateFileCollection(const TString& dir="/data/alice/data/ppb/LHC12g/pass1/188359/",
14 const TString& tN="esdTree",
15 const TString& pa="AliESD*",
17 Bool_t recursive=false)
20 gROOT->LoadMacro("$ALICE_ROOT/PWGLF/FORWARD/trains/ChainBuilder.C+");
23 if (recursive) flags |= ChainBuilder::kRecursive;
24 if (mc) flags |= ChainBuilder::kMC;
25 UShort_t type = ChainBuilder::CheckSource(dir, flags);
26 Info("", "type=%d, dir=%s tN=%s pa=%s, flags=0x%x", type,
27 dir.Data(), tN.Data(), pa.Data(), flags);
28 TChain* chain = ChainBuilder::Create(type, dir, tN, pa, flags);
30 Error("CreateFileCollection", "Failed to make chain");
36 TUrl u(Form("root://%s//foo", gSystem->HostName()));
37 port = u.GetPort() * 10;
38 host = u.GetHostFQDN();
42 TFileCollection* fc = new TFileCollection("files");
43 TObjArray* cEs = chain->GetListOfFiles();
44 TChainElement* cE = 0;
46 while ((cE= static_cast<TChainElement*>(next()))) {
47 TString fN(cE->GetTitle());
48 TFile* f = TFile::Open(fN, "READ");
49 TTree* t = static_cast<TTree*>(f->Get(tN));
51 fN.Prepend(Form("root://%s:%d/", host.Data(), port));
52 TFileInfo* fi = new TFileInfo(Form("%s tree:%s,%d",
53 fN.Data(), tN.Data(), t->GetEntries()),
60 TFile* files = TFile::Open("files.root", "RECREATE");