AliPhysics  db95e02 (db95e02)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RunFinalQA.C
Go to the documentation of this file.
1 
10 //____________________________________________________________________
23 Bool_t ScanDirectory(TSystemDirectory* dir,
24  TList* list,
25  const char* pattern,
26  bool recursive=false)
27 {
28  TString fnPattern = pattern;
29 
30  // Assume failure
31  Bool_t ret = false;
32 
33  // Get list of files, and go back to old working directory
34  TString oldDir(gSystem->WorkingDirectory());
35  TList* files = dir->GetListOfFiles();
36  if (!gSystem->ChangeDirectory(oldDir)) {
37  Error("ScanDirectory", "Failed to go back to %s", oldDir.Data());
38  return false;
39  }
40  if (!files) {
41  Warning("ScanDirectory", "No files found in %s", dir->GetName());
42  return false;
43  }
44  // files->ls();
45 
46  TList toAdd;
47 
48  // Sort list of files and check if we should add it
49  // files->Sort();
50  TIter next(files);
51  TSystemFile* file = 0;
52  while ((file = static_cast<TSystemFile*>(next()))) {
53  TString name(file->GetName());
54  TString title(file->GetTitle());
55  TString full(gSystem->ConcatFileName(file->GetTitle(), name.Data()));
56  if (file->IsA() == TSystemDirectory::Class()) full = title;
57  if (name == "." || name == "..") {
58  continue;
59  }
60 
61  FileStat_t fs;
62  if (gSystem->GetPathInfo(full.Data(), fs)) {
63  Warning("ScanDirectory", "Cannot stat %s (%s)", full.Data(),
64  gSystem->WorkingDirectory());
65  continue;
66  }
67  // Check if this is a directory
68  if (file->IsDirectory(full)) {
69  if (recursive) {
70  TSystemDirectory* d = new TSystemDirectory(file->GetName(),
71  full.Data());
72  if (ScanDirectory(d,list,pattern,recursive))
73  ret = true;
74  delete d;
75  }
76  continue;
77  }
78 
79  // If this is not a root file, ignore
80  if (!name.EndsWith(".root")) {
81  continue;
82  }
83 
84  // If this file does not contain AliESDs, ignore
85  if (!name.Contains(fnPattern)) {
86  continue;
87  }
88 
89  // Add
90  toAdd.Add(new TObjString(full));
91  }
92 
93  TIter nextAdd(&toAdd);
94  TObjString* s = 0;
95  while ((s = static_cast<TObjString*>(nextAdd()))) {
96  list->Add(s);
97  }
98  if (toAdd.GetEntries() > 0) ret = true;
99 
100  gSystem->ChangeDirectory(oldDir);
101  return ret;
102 }
103 //____________________________________________________________________
113 TList*
114 GetListOfFiles(const char* input=".")
115 {
116  TList* ret = new TList;
117  TString dir(input);
118  // if (dir == ".") dir = "";
119 
120  TString savdir(gSystem->WorkingDirectory());
121  TSystemDirectory d(gSystem->BaseName(dir.Data()), dir.Data());
122  if (!ScanDirectory(&d, ret, "tree_", false)) {
123  delete ret;
124  ret = 0;
125  }
126  gSystem->ChangeDirectory(savdir);
127  if (ret) ret->Sort();
128  return ret;
129 }
130 
131 //____________________________________________________________________
142 void
143 RunFinalQA(const char* dir, Int_t prodYear=0, const char* prodLetter="",
144  Bool_t useVar=false)
145 {
146  int ret = 0;
147  gROOT->SetMacroPath(Form(".:%s",gROOT->GetMacroPath()));
148  gSystem->Load("libGpad");
149  gSystem->Load("libTree");
150 
151  gROOT->LoadMacro("QABase.h+g");
152  gROOT->LoadMacro("QAPlotter.C+g");
153 
154  Info("RunFinalQA", "Final QA: %d%c (variance: %s)",
155  prodYear, prodLetter[0], (useVar ? "true" : "false"));
156  QAPlotter p(prodYear, prodLetter[0], useVar);
157 
158  TList* l = GetListOfFiles(dir);
159  TIter next(l);
160  TObject* o = 0;
161  while ((o = next())) {
162  p.AddFile(o->GetName());
163  }
164 
165  p.Run();
166 }
167 //
168 // EOF
169 //
const char * title
Definition: MakeQAPdf.C:26
TSystem * gSystem
TList * list
void Run()
Definition: QAPlotter.C:312
void AddFile(const char *filename)
Definition: QAPlotter.C:262
int Int_t
Definition: External.C:63
Bool_t ScanDirectory(TSystemDirectory *dir, TList *list, const char *pattern, bool recursive=false)
Definition: RunFinalQA.C:23
void RunFinalQA(const char *dir, Int_t prodYear=0, const char *prodLetter="", Bool_t useVar=false)
Definition: RunFinalQA.C:143
TList * GetListOfFiles(const char *input=".")
Definition: RunFinalQA.C:114
TFile * file
bool Bool_t
Definition: External.C:53