]>
Commit | Line | Data |
---|---|---|
97a28f97 | 1 | #if !defined(__CINT__) || defined(__MAKECINT__) |
2 | #include <string.h> | |
3 | #include "TFile.h" | |
4 | #include "TTree.h" | |
5 | #include "TKey.h" | |
6 | #include "Riostream.h" | |
7 | #include "TCanvas.h" | |
8 | #include "TPad.h" | |
9 | #include "TText.h" | |
10 | #include "TError.h" | |
11 | #endif | |
12 | ||
13 | // Make a pdf with all QA plots | |
14 | // A. SHABETAI | |
15 | ||
16 | TFile* sourceFile; | |
17 | TObject* Myobj; | |
18 | TCanvas* canvasDefault; | |
19 | TString Mypath; | |
20 | const char* title; | |
21 | ||
22 | void recurseOverKeys( TDirectory *target, TString f); | |
23 | ||
24 | //--------------------------------------------------------------------------------------- | |
25 | void MakeQAPdf(const char* fileName, int outputWidth = 600, int outputHeight = 600) | |
26 | { | |
27 | ||
28 | sourceFile = TFile::Open(fileName); | |
29 | ||
30 | canvasDefault = new TCanvas("canvasDefault","testCanvas",outputWidth,outputHeight); | |
31 | TString f = TString(fileName).ReplaceAll(".root",""); | |
32 | ||
33 | canvasDefault->Print(Form("%s%s",f.Data(),".pdf[")); | |
34 | gErrorIgnoreLevel = kInfo + 1; | |
35 | ||
36 | // Now actually find all the directories, canvas, and make a pdf.. | |
37 | recurseOverKeys(sourceFile,f); | |
38 | ||
39 | gPad->Print(Form("%s%s",f.Data(),".pdf]"),Form("Title:%s/%s",Mypath.Data(),title)); | |
40 | gErrorIgnoreLevel = -1; | |
41 | sourceFile->Close(); | |
42 | ||
43 | } | |
44 | ||
45 | //--------------------------------------------------------------------------------------- | |
46 | void recurseOverKeys( TDirectory *target,TString f ) | |
47 | { | |
48 | ||
49 | TString path = TString((char*)strstr( target->GetPath(), ":" )); | |
50 | path.Remove(0, 2); | |
51 | ||
52 | gErrorIgnoreLevel = kInfo + 1; | |
53 | ||
54 | sourceFile->cd(path.Data()); | |
55 | ||
56 | Mypath = path; | |
57 | Mypath.ReplaceAll("CaloQA_",""); | |
58 | Mypath.ReplaceAll("default","trigMB"); | |
59 | Mypath.ReplaceAll("trig",""); | |
60 | ||
61 | TDirectory *current_sourcedir = gDirectory; | |
62 | ||
63 | TKey *key; | |
64 | TIter nextkey(current_sourcedir->GetListOfKeys()); | |
65 | ||
66 | while ((key = (TKey*)nextkey())) | |
67 | { | |
68 | ||
69 | Myobj = key->ReadObj(); | |
70 | ||
71 | if (TString(Myobj->IsA()->GetName()).Contains("TCanvas")) | |
72 | { | |
73 | title = Myobj->GetTitle(); | |
74 | ||
75 | ((TCanvas*)Myobj)->Print(Form("%s%s",f.Data(),".pdf"),Form("Title:%s/%s",Mypath.Data(),title)); | |
76 | } | |
77 | else if ( Myobj->IsA()->InheritsFrom( "TDirectory" ) ) | |
78 | { | |
79 | ||
80 | // Myobj is now the starting point of another iteration | |
81 | // obj still knows its depth within the target file via | |
82 | // GetPath(), so we can still figure out where we are in the recursion | |
83 | recurseOverKeys( (TDirectory*)Myobj, f ); | |
84 | ||
85 | } // end of IF a TDriectory | |
86 | ||
87 | } // end of LOOP over keys | |
88 | ||
89 | } |