ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/RateMonShiftTool_dev/dumpToPDF.C
Revision: 1.1
Committed: Thu Apr 26 16:47:26 2012 UTC (13 years ago) by fantasia
Content type: text/plain
Branch: MAIN
CVS Tags: V00-00-32
Log Message:
files to certify runs and print the plots to a pdf

File Contents

# User Rev Content
1 fantasia 1.1 //This script will take all the rate comparison plots from a
2     //root file and print them into a single pdf for easy viewing
3     //Usage: root -b -l -q 'dumpToPDF.C("infile.root")'
4    
5     void
6     dumpToPDF(string inName){
7     TFile *fin = TFile::Open(inName.c_str(), "read"); assert(fin);
8    
9     string outName = inName;
10     outName.replace(outName.find(".root"), 5, ".pdf");
11    
12     TCanvas c1;
13     c1.Print(Form("%s[", outName.c_str()), "pdf"); //Open .pdf
14    
15     //get list of keys
16     int nplots = fin->GetNkeys();
17     TList* plots = fin->GetListOfKeys();
18     for(int i=0; i<nplots; ++i){
19     TKey* key = (TKey*) plots->At(i);
20     if(!fin->GetKey(key->GetName())){
21     cout<<"Didn't find "<<key<<". Removing."<<endl;
22     }
23     TCanvas* c = (TCanvas*) fin->Get(key->GetName());
24     string bookmarkName = "Title: ";
25     bookmarkName += key->GetName();
26     c->Print(outName.c_str(), bookmarkName.c_str());
27     }
28    
29     c1.Print(Form("%s]", outName.c_str()), "pdf"); //Close .pdf
30    
31     }