AliPhysics  32b88a8 (32b88a8)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CreateFileCollection.C
Go to the documentation of this file.
1 
12 void
13 CreateFileCollection(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("$ALICE_PHYSICS/PWGLF/FORWARD/trains/ChainBuilder.C+");
21 
22  UShort_t flags = 0;
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);
29  if (!chain) {
30  Error("CreateFileCollection", "Failed to make chain");
31  return;
32  }
33  Int_t port;
34  TString host;
35  {
36  TUrl u(Form("root://%s//foo", gSystem->HostName()));
37  port = u.GetPort() * 10;
38  host = u.GetHostFQDN();
39  }
40 
41 
42  TFileCollection* fc = new TFileCollection("files");
43  TObjArray* cEs = chain->GetListOfFiles();
44  TChainElement* cE = 0;
45  TIter next(cEs);
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));
50 
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()),
54  f->GetSize());
55  f->Close();
56  fc->Add(fi);
57  }
58  fc->Print("F");
59 
60  TFile* files = TFile::Open("files.root", "RECREATE");
61  fc->Write();
62  files->Close();
63 
64 }
65 //
66 // EOF
67 //
static UShort_t CheckSource(TString &src, UShort_t flags)
Definition: ChainBuilder.C:81
TSystem * gSystem
void CreateFileCollection(const TString &dir="/data/alice/data/ppb/LHC12g/pass1/188359/", const TString &tN="esdTree", const TString &pa="AliESD*", Bool_t mc=false, Bool_t recursive=false))
static TChain * Create(const TUrl &url)
Definition: ChainBuilder.C:155
Definition: External.C:92
int Int_t
Definition: External.C:63
unsigned short UShort_t
Definition: External.C:28
bool Bool_t
Definition: External.C:53