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