ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/RateMonShiftTool_dev/dumpToPDF.C
Revision: 1.2
Committed: Mon May 7 14:27:47 2012 UTC (12 years, 11 months ago) by fantasia
Content type: text/plain
Branch: MAIN
CVS Tags: V00-01-10, V-00-01-10, V00-01-09, V00-01-08, V00-01-07, V00-01-06, V00-01-05, V00-01-04, V00-01-03, V00-01-02, V00-01-01, V00-00-34, V00-00-33, MenuAnalyzer_V00-00-02, MenuAnalyzer_V00-00-01, MenuAnalyzer_V1
Changes since 1.1: +33 -7 lines
Log Message:
improvement

File Contents

# Content
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, string fitName){
7 TFile *fin = TFile::Open(inName.c_str(), "read"); assert(fin);
8
9
10 string outName = inName;
11 outName.replace(outName.find(".root"), 5, ".pdf");
12
13 //fitName = "HLT_10LS_delivered_vs_rate_Run190949-191090.root";
14 TFile *fFit = TFile::Open(fitName.c_str(), "read"); assert(fFit);
15
16 TCanvas c1;
17 c1.Print(Form("%s[", outName.c_str()), "pdf"); //Open .pdf
18
19 //get list of keys
20 int nplots = fin->GetNkeys();
21 int nfits = fFit->GetNkeys();
22 printf("nplots: %i, nfits: %i\n", nplots, nfits);
23 assert(nplots == nfits);
24 TList* plots = fin->GetListOfKeys();
25 TList* fits = fFit->GetListOfKeys();
26 for(int i=0; i<nplots; ++i){
27 TKey* plot = (TKey*) plots->At(i);
28 TKey* fit = (TKey*) fits->At(i);//assume they're in the same order for now
29
30 if(!fin->GetKey(plot->GetName())){
31 cout<<"Didn't find "<<plot<<". Removing."<<endl;
32 abort();
33 }
34 if(!fFit->GetKey(fit->GetName())){
35 cout<<"Didn't find "<<fit<<". Removing."<<endl;
36 abort();
37 }
38 TCanvas* c = new TCanvas();
39 c->Divide(1,2);
40
41 TCanvas* cPlot = (TCanvas*) fin->Get(plot->GetName());
42 c->cd(1);
43 cPlot->DrawClonePad();
44
45 TCanvas* cFit = (TCanvas*) fFit->Get(fit->GetName());
46 c->cd(2);
47 cFit->DrawClonePad();
48
49 string bookmarkName = "Title: ";
50 bookmarkName += plot->GetName();
51
52 c->Print(outName.c_str(), bookmarkName.c_str());
53 }
54
55 c1.Print(Form("%s]", outName.c_str()), "pdf"); //Close .pdf
56
57 }