AliPhysics  ef3b16e (ef3b16e)
CreateIndex.C
Go to the documentation of this file.
1 
18 Bool_t LoadLib(const char* libName)
19 {
20  if (gSystem->Load(libName) < 0) {
21  Error("GridTerminate", "Failed to load library %s",libName);
22  return false;
23  }
24  Info("GridTerminate","Loaded library %s",libName);
25  return true;
26 }
34 Bool_t LoadPar(const char* parName)
35 {
36  if (!AliAnalysisAlien::SetupPar(parName)) {
37  Error("GridTerminate","Failed to load PAR %s",parName);
38  return false;
39  }
40  Info("GridTerminate","Loaded package %s",parName);
41  return true;
42 }
43 
44 
45 void
47  const TString& tree="esdTree",
48  const char* remote=0,
49  const char* plibs=0,
50  const char* ppars=0,
51  const char* psrcs=0)
52 {
53  gROOT->SetMacroPath(Form("$ALICE_PHYSICS/PWGLF/FORWARD/trains:%s",
54  gROOT->GetMacroPath()));
55  gROOT->LoadMacro("ChainBuilder.C+");
56  gROOT->Macro("$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C");
57 
58  gSystem->AddDynamicPath("/usr/lib");
59 
60  // Load basic ROOT libraries
61  if (gSystem->Load("libTree") < 0) return false;
62  if (gSystem->Load("libGeom") < 0) return false;
63  if (gSystem->Load("libVMC") < 0) return false;
64  if (gSystem->Load("libPhysics") < 0) return false;
65  if (gSystem->Load("libMinuit") < 0) return false;
66 
67  // Load basic AliROOT libraries
68  if (gSystem->Load("libSTEERBase") < 0) return false;
69  if (gSystem->Load("libESD") < 0) return false;
70  if (gSystem->Load("libAOD") < 0) return false;
71  if (gSystem->Load("libANALYSIS") < 0) return false;
72  if (gSystem->Load("libOADB") < 0) return false;
73  if (gSystem->Load("libANALYSISalice") < 0) return false;
74 
75  // Load libraries
76  TString libs(plibs);
77  if (!libs.IsNull()) {
78  TObjArray* libsArray = libs.Tokenize(" ");
79  TObjString* lib = 0;
80  TIter nextLib(libsArray);
81  while ((lib = static_cast<TObjString*>(nextLib()))) {
82  const TString& libName = lib->String();
83  if (libName.Contains("libSTEERBase") ||
84  libName.Contains("libESD") ||
85  libName.Contains("libAOD") ||
86  libName.Contains("libANALYSIS") ||
87  libName.Contains("libOADB") ||
88  libName.Contains("libANALYSISalice")) continue;
89  if (!libName.Contains(".so")) continue;
90  if (!LoadLib(libName.Data())) return false;
91  }
92  libsArray->Delete();
93  }
94  Bool_t local = (!remote || remote[0] == '\0');
95  Bool_t localLibsNotPar = false;
96 
97  // Load packages
98  TString pars(ppars);
99  if (!pars.IsNull()) {
100  TObjArray* parArray = pars.Tokenize(" ");
101  TObjString* par = 0;
102  TIter nextPar(parArray);
103  while ((par = static_cast<TObjString*>(nextPar()))) {
104  TString parName(par->String());
105  if (parName.EndsWith(".par")) parName.ReplaceAll(".par", "");
106  if (parName.EqualTo("STEERBase") ||
107  parName.EqualTo("ESD") ||
108  parName.EqualTo("AOD") ||
109  parName.EqualTo("ANALYSIS") ||
110  parName.EqualTo("OADB") ||
111  parName.EqualTo("ANALYSISalice")) continue;
112  Bool_t ret = true;
113  if (local && localLibsNotPar)
114  ret = LoadLib(Form("lib%s.so", parName.Data()));
115  else
116  ret = LoadPar(parName.Data());
117  if (!ret) return false;
118  }
119  }
120 
121  // Load sources
122  TString srcs(psrcs);
123  if (!srcs.IsNull()) {
124  TObjArray* srcArray = srcs.Tokenize(" ");
125  TObjString* src = 0;
126  TIter nextSrc(srcArray);
127  while ((src = static_cast<TObjString*>(nextSrc()))) {
128  const TString& srcName = src->String();
129  gROOT->ProcessLine(Form(".L %s+g", srcName.Data()));
130  }
131  }
132 
133  Bool_t mc = false;
134  Bool_t zip = false;
135  if (tree.BeginsWith("mc")) {
136  mc = true;
137  zip = true;
138  tree.Remove(0,2);
139  }
140  if (tree.BeginsWith("zip")) {
141  zip = true;
142  tree.Remove(0,3);
143  }
144 
145  TString pat("*.root");
146  if (tree.EqualTo("esdTree", TString::kIgnoreCase)) pat="AliESDs*";
147  else if (tree.EqualTo("aodTree", TString::kIgnoreCase)) pat="AliAOD*";
148  else Warning("", "Unknown tree: %s, pattern set to *.root", tree.Data());
149  if (zip) {
150  pat.Prepend("root_archive.zip@");
151  pat.ReplaceAll("*", ".root");
152  pat.ReplaceAll(".zip", "*.zip");
153  }
154 
155 
156  TString opts;
157  opts.Append(Form("pattern=%s", pat.Data()));
158  opts.Append("&check");
159  opts.Append("&clean");
160  opts.Append("&recursive");
161  opts.Append("&verbose");
162  if (mc) opts.Append("&mc");
163 
164  TString realDir(dir);
165  if (!remote) realDir = gSystem->ExpandPathName(dir.Data());
166  if (realDir.EqualTo(".")) realDir = gSystem->WorkingDirectory();
167 
168  TUrl url;
169  url.SetProtocol("local");
170  url.SetPort(0);
171  url.SetFile(realDir);
172  url.SetAnchor(tree);
173  url.SetOptions(opts);
174 
175  Printf("Running ChainBuilder::CreateCollection(\"%s/index.root\",\"%s\")",
176  realDir.Data(), url.GetUrl());
177  TString out(Form("%s/%s.root", realDir.Data(),
178  !remote ? "index" : "remote"));
179  ChainBuilder::CreateCollection(out, url, remote);
180 }
181 
182 
183 
184 
void CreateIndex(const TString &dir, const TString &tree="esdTree", const char *remote=0, const char *plibs=0, const char *ppars=0, const char *psrcs=0)
Definition: CreateIndex.C:46
const char * url
TSystem * gSystem
Bool_t LoadPar(const char *parName)
Definition: CreateIndex.C:34
Definition: External.C:92
static void CreateCollection(const TString &output, const TUrl &url, const char *remote=0)
Definition: ChainBuilder.C:364
Bool_t LoadLib(const char *libName)
Definition: CreateIndex.C:18
void SetupPar(char *pararchivename)
Execute multiplicity task.
Definition: ana.C:166
bool Bool_t
Definition: External.C:53
TDirectoryFile * dir