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