3 * @author Christian Holm Christensen <cholm@nbi.dk>
4 * @date Thu Nov 17 11:35:08 2011
6 * @brief Script to run the QATrender and QAPlotter in one go
8 * @ingroup pwglf_forward_qa_scripts
11 * Scan directory (and possibly sub-directories) for trending files
13 * @param dir Start directory
14 * @param list List to add file names to
15 * @param recursive Whether to scan recursively
17 * @return true on success
19 * @deprecated Use the RunFileQA and RunFinalQA instead.
20 * @ingroup pwglf_forward_qa_scripts
22 Bool_t ScanDirectory(TSystemDirectory* dir, TList* list,
25 TString fnPattern = "trending_";
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());
38 Warning("ScanDirectory", "No files found in %s", dir->GetName());
45 // Sort list of files and check if we should add it
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());
63 if (gSystem->GetPathInfo(full.Data(), fs)) {
64 Warning("ScanDirectory", "Cannot stat %s (%s)", full.Data(),
65 gSystem->WorkingDirectory());
68 // Check if this is a directory
69 if (file->IsDirectory(full)) {
71 TSystemDirectory* d = new TSystemDirectory(file->GetName(),
73 if (ScanDirectory(d,chain,type,recursive,mc))
80 // If this is not a root file, ignore
81 if (!name.EndsWith(".root")) {
82 // Info("ScanDirectory", "Ignoring non-ROOT file %s", name.Data());
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());
94 // Info("ScanDirectory", "Adding %s", full.Data());
95 toAdd.Add(new TObjString(full));
98 TIter nextAdd(&toAdd);
100 while ((s = static_cast<TObjString*>(nextAdd()))) {
101 // Info("ScanDirectory", "Adding %s", s->GetString().Data());
104 if (toAdd.GetEntries() > 0) ret = true;
106 gSystem->ChangeDirectory(oldDir);
110 * Get the list of trending files
112 * @param input Start directory
114 * @return List of files
116 * @ingroup pwglf_forward_qa_scripts
119 GetListOfFiles(const char* input=".")
121 TList* ret = new TList;
123 // if (dir == ".") dir = "";
125 TString savdir(gSystem->WorkingDirectory());
126 TSystemDirectory d(gSystem->BaseName(dir.Data()), dir.Data());
127 if (!ScanDirectory(&d, ret, false)) {
131 gSystem->ChangeDirectory(savdir);
132 if (ret) ret->Sort();
137 * Run the QATrender and QAPlotter.
139 * The QATrender is run over the list of files (runs) to produce the
140 * file <tt>forward_trending.root</tt> which contains a TTree of QA
141 * information - one entry per run.
143 * The QATrender will also produce two files per run:
145 * - <tt>qa_<i>runNo</i>.root</tt> which contains TCanvas objects of
146 * the finished plots.
148 * - <tt>qa_<i>runNo</i>.pdf</tt> which is a PDF of the TCanvases
151 * The QAPlotter is then run over the <tt>forward_trending.root</tt>
152 * file and produces two files
154 * - <tt>qa_<i>first-run</i>-<i>last-run</i>.root</tt> which contains
155 * TCanvas objects of the finished plots. It also contains the
156 * TMultiGraph objects painted in the canvases.
158 * - <tt>qa_<i>first-run</i>-<i>last-run</i>.pdf</tt> which is a PDF
159 * of the TCanvases mentioned above.
161 * The QAPlotter will also produce PNGs of each canvas.
163 * if @a runNo is larger than zero, given, then only the that run will
164 * be processed and only by QATrender. In addition, PNGs of each
165 * canvas is produced.
167 * @param runNo (optional) Run number. If greater than 0, only this
168 * run will be processed
169 * @param input Input directory
170 * @param what (expert) Flag of what to do
173 * @ingroup pwglf_forward_qa_scripts
176 RunQAOld(const char* input=".", Bool_t keep=true, Int_t runNo=-1,
179 gROOT->SetMacroPath(Form(".:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2/qa:"
180 "$(ALICE_ROOT)/PWGLF/FORWARD/analysis2/corrs:%s",
181 gROOT->GetMacroPath()));
182 gSystem->AddIncludePath("-I${ALICE_ROOT}/PWGLF/FORWARD/analysis2/qa");
183 gSystem->Load("libGpad");
184 gSystem->Load("libTree");
186 if (runNo > 0) what = 0x1; // Only do first pass
188 gROOT->LoadMacro("QATrender.C+g");
189 gROOT->LoadMacro("QAPlotter.C+g");
191 QATrender t(keep, runNo > 0);
194 if (runNo < 0) l = GetListOfFiles(input);
196 TObjString* s = new TObjString("");
197 s->String() = gSystem->ConcatFileName(input, Form("trending_%09d.root",
203 Error("RunQA", "No trending files found");
209 while ((s = static_cast<TObjString*>(next()))) {
210 Info("Run", "Adding file %s", s->GetName());
211 t.AddFile(s->GetName());