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