AliPhysics  db95e02 (db95e02)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MakeQAPdf.C
Go to the documentation of this file.
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 
21 
22 TFile* sourceFile;
24 TCanvas* canvasDefault;
26 const char* title;
27 
28 void recurseOverKeys( TDirectory *target, TString f);
29 
30 //---------------------------------------------------------------------------------------
31 void MakeQAPdf(const char* fileName, int outputWidth = 600, int outputHeight = 600)
32 {
33 
34  sourceFile = TFile::Open(fileName);
35 
36  canvasDefault = new TCanvas("canvasDefault","testCanvas",outputWidth,outputHeight);
37  TString f = TString(fileName).ReplaceAll(".root","");
38 
39  canvasDefault->Print(Form("%s%s",f.Data(),".pdf["));
40  gErrorIgnoreLevel = kInfo + 1;
41 
42  // Now actually find all the directories, canvas, and make a pdf..
44 
45  gPad->Print(Form("%s%s",f.Data(),".pdf]"),Form("Title:%s/%s",Mypath.Data(),title));
46  gErrorIgnoreLevel = -1;
47  sourceFile->Close();
48 
49 }
50 
51 //---------------------------------------------------------------------------------------
52 void recurseOverKeys( TDirectory *target,TString f )
53 {
54 
55  TString path = TString((char*)strstr( target->GetPath(), ":" ));
56  path.Remove(0, 2);
57 
58  gErrorIgnoreLevel = kInfo + 1;
59 
60  sourceFile->cd(path.Data());
61 
62  Mypath = path;
63  Mypath.ReplaceAll("CaloQA_","");
64  Mypath.ReplaceAll("default","trigMB");
65  Mypath.ReplaceAll("trig","");
66 
67  TDirectory *current_sourcedir = gDirectory;
68 
69  TKey *key;
70  TIter nextkey(current_sourcedir->GetListOfKeys());
71 
72  while ((key = (TKey*)nextkey()))
73  {
74 
75  Myobj = key->ReadObj();
76 
77  if (TString(Myobj->IsA()->GetName()).Contains("TCanvas"))
78  {
79  title = Myobj->GetTitle();
80 
81  ((TCanvas*)Myobj)->Print(Form("%s%s",f.Data(),".pdf"),Form("Title:%s/%s",Mypath.Data(),title));
82  }
83  else if ( Myobj->IsA()->InheritsFrom( "TDirectory" ) )
84  {
85 
86  // Myobj is now the starting point of another iteration
87  // obj still knows its depth within the target file via
88  // GetPath(), so we can still figure out where we are in the recursion
89  recurseOverKeys( (TDirectory*)Myobj, f );
90 
91  } // end of IF a TDriectory
92 
93  } // end of LOOP over keys
94 
95 }
TString Mypath
Definition: MakeQAPdf.C:25
const char * title
Definition: MakeQAPdf.C:26
TString fileName
TObject * Myobj
Definition: MakeQAPdf.C:23
TFile * sourceFile
Definition: MakeQAPdf.C:22
void recurseOverKeys(TDirectory *target, TString f)
Definition: MakeQAPdf.C:52
void MakeQAPdf(const char *fileName, int outputWidth=600, int outputHeight=600)
Definition: MakeQAPdf.C:31
TCanvas * canvasDefault
Definition: MakeQAPdf.C:24