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", type);
27 TChain* chain = ChainBuilder::Create(type, dir, tN, pa, flags);
29 Error("CreateFileCollection", "Failed to make chain");
35 TUrl u(Form("root://%s//foo", gSystem->HostName()));
36 port = u.GetPort() * 10;
37 host = u.GetHostFQDN();
41 TFileCollection* fc = new TFileCollection("files");
42 TObjArray* cEs = chain->GetListOfFiles();
43 TChainElement* cE = 0;
45 while ((cE= static_cast<TChainElement*>(next()))) {
46 TString fN(cE->GetTitle());
47 TFile* f = TFile::Open(fN, "READ");
48 TTree* t = static_cast<TTree*>(f->Get(tN));
50 fN.Prepend(Form("root://%s:%d/", host.Data(), port));
51 TFileInfo* fi = new TFileInfo(Form("%s tree:%s,%d",
52 fN.Data(), tN.Data(), t->GetEntries()),
59 TFile* files = TFile::Open("files.root", "RECREATE");