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 |
fantasia |
1.2 |
dumpToPDF(string inName, string fitName){
|
7 |
fantasia |
1.1 |
TFile *fin = TFile::Open(inName.c_str(), "read"); assert(fin);
|
8 |
|
|
|
9 |
fantasia |
1.2 |
|
10 |
fantasia |
1.1 |
string outName = inName;
|
11 |
|
|
outName.replace(outName.find(".root"), 5, ".pdf");
|
12 |
|
|
|
13 |
fantasia |
1.2 |
//fitName = "HLT_10LS_delivered_vs_rate_Run190949-191090.root";
|
14 |
|
|
TFile *fFit = TFile::Open(fitName.c_str(), "read"); assert(fFit);
|
15 |
|
|
|
16 |
fantasia |
1.1 |
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 |
fantasia |
1.2 |
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 |
fantasia |
1.1 |
for(int i=0; i<nplots; ++i){
|
27 |
fantasia |
1.2 |
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 |
fantasia |
1.1 |
}
|
38 |
fantasia |
1.2 |
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 |
fantasia |
1.1 |
string bookmarkName = "Title: ";
|
50 |
fantasia |
1.2 |
bookmarkName += plot->GetName();
|
51 |
|
|
|
52 |
fantasia |
1.1 |
c->Print(outName.c_str(), bookmarkName.c_str());
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
c1.Print(Form("%s]", outName.c_str()), "pdf"); //Close .pdf
|
56 |
|
|
|
57 |
|
|
}
|