AliPhysics  cda3415 (cda3415)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RunQAOld.C
Go to the documentation of this file.
1 
22 Bool_t ScanDirectory(TSystemDirectory* dir, TList* list,
23  bool recursive=false)
24 {
25  TString fnPattern = "trending_";
26 
27  // Assume failure
28  Bool_t ret = false;
29 
30  // Get list of files, and go back to old working directory
31  TString oldDir(gSystem->WorkingDirectory());
32  TList* files = dir->GetListOfFiles();
33  if (!gSystem->ChangeDirectory(oldDir)) {
34  Error("ScanDirectory", "Failed to go back to %s", oldDir.Data());
35  return false;
36  }
37  if (!files) {
38  Warning("ScanDirectory", "No files found in %s", dir->GetName());
39  return false;
40  }
41  // files->ls();
42 
43  TList toAdd;
44 
45  // Sort list of files and check if we should add it
46  // files->Sort();
47  TIter next(files);
48  TSystemFile* file = 0;
49  while ((file = static_cast<TSystemFile*>(next()))) {
50  TString name(file->GetName());
51  TString title(file->GetTitle());
52  TString full(gSystem->ConcatFileName(file->GetTitle(), name.Data()));
53  if (file->IsA() == TSystemDirectory::Class()) full = title;
54  // Ignore special links
55  // Info("ScanDirectory", "name=%s title=%s full=%s",
56  // name.Data(), title.Data(), full.Data());
57  if (name == "." || name == "..") {
58  // Info("ScanDirectory", "Ignoring %s", name.Data());
59  continue;
60  }
61 
62  FileStat_t fs;
63  if (gSystem->GetPathInfo(full.Data(), fs)) {
64  Warning("ScanDirectory", "Cannot stat %s (%s)", full.Data(),
65  gSystem->WorkingDirectory());
66  continue;
67  }
68  // Check if this is a directory
69  if (file->IsDirectory(full)) {
70  if (recursive) {
71  TSystemDirectory* d = new TSystemDirectory(file->GetName(),
72  full.Data());
73  if (ScanDirectory(d,chain,type,recursive,mc))
74  ret = true;
75  delete d;
76  }
77  continue;
78  }
79 
80  // If this is not a root file, ignore
81  if (!name.EndsWith(".root")) {
82  // Info("ScanDirectory", "Ignoring non-ROOT file %s", name.Data());
83  continue;
84  }
85 
86  // If this file does not contain AliESDs, ignore
87  if (!name.Contains(fnPattern)) {
88  // Info("ScanDirectory", "%s does not match pattern %s",
89  // name.Data(), fnPattern.Data());
90  continue;
91  }
92 
93  // Add
94  // Info("ScanDirectory", "Adding %s", full.Data());
95  toAdd.Add(new TObjString(full));
96  }
97 
98  TIter nextAdd(&toAdd);
99  TObjString* s = 0;
100  while ((s = static_cast<TObjString*>(nextAdd()))) {
101  // Info("ScanDirectory", "Adding %s", s->GetString().Data());
102  list->Add(s);
103  }
104  if (toAdd.GetEntries() > 0) ret = true;
105 
106  gSystem->ChangeDirectory(oldDir);
107  return ret;
108 }
118 TList*
119 GetListOfFiles(const char* input=".")
120 {
121  TList* ret = new TList;
122  TString dir(input);
123  // if (dir == ".") dir = "";
124 
125  TString savdir(gSystem->WorkingDirectory());
126  TSystemDirectory d(gSystem->BaseName(dir.Data()), dir.Data());
127  if (!ScanDirectory(&d, ret, false)) {
128  delete ret;
129  ret = 0;
130  }
131  gSystem->ChangeDirectory(savdir);
132  if (ret) ret->Sort();
133  return ret;
134 }
135 
175 void
176 RunQAOld(const char* input=".", Bool_t keep=true, Int_t runNo=-1,
177  UShort_t what=0x3)
178 {
179  gROOT->SetMacroPath(Form(".:$(ALICE_PHYSICS)/PWGLF/FORWARD/analysis2/qa:"
180  "$(ALICE_PHYSICS)/PWGLF/FORWARD/analysis2/corrs:%s",
181  gROOT->GetMacroPath()));
182  gSystem->AddIncludePath("-I${ALICE_PHYSICS}/PWGLF/FORWARD/analysis2/qa");
183  gSystem->Load("libGpad");
184  gSystem->Load("libTree");
185 
186  if (runNo > 0) what = 0x1; // Only do first pass
187 
188  gROOT->LoadMacro("QATrender.C+g");
189  gROOT->LoadMacro("QAPlotter.C+g");
190  if (what & 0x1) {
191  QATrender t(keep, runNo > 0);
192 
193  TList* l = 0;
194  if (runNo < 0) l = GetListOfFiles(input);
195  else {
196  TObjString* s = new TObjString("");
197  s->String() = gSystem->ConcatFileName(input, Form("trending_%09d.root",
198  runNo));
199  l = new TList;
200  l->Add(s);
201  }
202  if (!l) {
203  Error("RunQA", "No trending files found");
204  return;
205  }
206  // l->ls();
207  TIter next(l);
208  TObjString* s = 0;
209  while ((s = static_cast<TObjString*>(next()))) {
210  Info("Run", "Adding file %s", s->GetName());
211  t.AddFile(s->GetName());
212  }
213  t.Run();
214  }
215  if (what & 0x2) {
216  QAPlotter p;
217  p.Run();
218  }
219 }
220 //
221 // EOF
222 //
const char * title
Definition: MakeQAPdf.C:26
TSystem * gSystem
TList * list
void Run()
Definition: QAPlotter.C:312
Bool_t ScanDirectory(TSystemDirectory *dir, TList *list, bool recursive=false)
Definition: RunQAOld.C:22
void RunQAOld(const char *input=".", Bool_t keep=true, Int_t runNo=-1, UShort_t what=0x3)
Definition: RunQAOld.C:176
Bool_t Run()
Definition: QATrender.C:663
int Int_t
Definition: External.C:63
TList * GetListOfFiles(const char *input=".")
Definition: RunQAOld.C:119
TFile * file
unsigned short UShort_t
Definition: External.C:28
bool Bool_t
Definition: External.C:53
void AddFile(const char *filename)
Definition: QATrender.C:654