3 |
|
//Usage: root -b -l -q 'dumpToPDF.C("infile.root")' |
4 |
|
|
5 |
|
void |
6 |
< |
dumpToPDF(string inName){ |
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 |
< |
TList* plots = fin->GetListOfKeys(); |
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* key = (TKey*) plots->At(i); |
28 |
< |
if(!fin->GetKey(key->GetName())){ |
29 |
< |
cout<<"Didn't find "<<key<<". Removing."<<endl; |
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 = (TCanvas*) fin->Get(key->GetName()); |
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 += key->GetName(); |
50 |
> |
bookmarkName += plot->GetName(); |
51 |
> |
|
52 |
|
c->Print(outName.c_str(), bookmarkName.c_str()); |
53 |
|
} |
54 |
|
|