]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/trains/CreateFileCollection.C
/home/abercuci/usr/AliRoot/REF/.git/COMMIT_EDITMSG
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / trains / CreateFileCollection.C
CommitLineData
33438b4c 1/**
2 * Create a file collection in a ROOT file
3 *
4 * @param dir Input directory
5 * @param tN Tree name
6 * @param pa File name pattern
7 * @param mc If true, simulations
8 * @param recursive Scan recursively
9 *
10 * @ingroup pwglf_forward_trains_helper
11 */
fdfd93b4 12void
13CreateFileCollection(const TString& dir="/data/alice/data/ppb/LHC12g/pass1/188359/",
14 const TString& tN="esdTree",
15 const TString& pa="AliESD",
16 Bool_t mc=false,
17 Bool_t recursive=false)
18)
19{
20 gROOT->LoadMacro("ChainBuilder.C+");
21
22 UShort_t type = ChainBuilder::CheckSource(dir);
23 Info("", "type=%d", type);
24 TChain* chain = ChainBuilder::Create(dir, tN, pa, mc, recursive);
25 if (!chain) {
26 Error("CreateFileCollection", "Failed to make chain");
27 return;
28 }
29 Int_t port;
30 TString host;
31 {
32 TUrl u(Form("root://%s//foo", gSystem->HostName()));
33 port = u.GetPort() * 10;
34 host = u.GetHostFQDN();
35 }
36
37
38 TFileCollection* fc = new TFileCollection("files");
39 TObjArray* cEs = chain->GetListOfFiles();
40 TChainElement* cE = 0;
41 TIter next(cEs);
42 while ((cE= static_cast<TChainElement*>(next()))) {
43 TString fN(cE->GetTitle());
44 TFile* f = TFile::Open(fN, "READ");
45 TTree* t = static_cast<TTree*>(f->Get(tN));
46
47 fN.Prepend(Form("root://%s:%d/", host.Data(), port));
48 TFileInfo* fi = new TFileInfo(Form("%s tree:%s,%d",
49 fN.Data(), tN.Data(), t->GetEntries()),
50 f->GetSize());
51 f->Close();
52 fc->Add(fi);
53 }
54 fc->Print("F");
55
56 TFile* files = TFile::Open("files.root", "RECREATE");
57 fc->Write();
58 files->Close();
59
60}
33438b4c 61//
62// EOF
63//