forked from SridharaDasu/SimpleRootTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdumpPlots.C
53 lines (30 loc) · 1.03 KB
/
dumpPlots.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
void dumpPlots(std::string fileName) {
TFile *file = new TFile(fileName.c_str());
TIter next(file->GetListOfKeys());
// Loop over directories
TKey *key;
while( (key = (TKey*) next()) ) {
std::cout << key->GetClassName() << " / " << key->GetName()<< std::endl;
auto dir = (TDirectoryFile*) file->Get(key->GetName());
TIter nextTree(dir->GetListOfKeys());
TKey *treeKey;
while( (treeKey = (TKey*) nextTree()) ) {
std::cout << treeKey->GetClassName() << " / " << treeKey->GetName()<< std::endl;
auto tree = (TTree*) dir->Get(treeKey->GetName());
tree->ls();
tree->SetLineColor(kRed);
TIter nextLeaf(tree->GetListOfLeaves());
TLeaf *leaf;
while( (leaf = (TLeaf*) nextLeaf()) ) {
std::cout << leaf->GetName()<< std::endl;
TCanvas *canvas = new TCanvas();
tree->Draw(leaf->GetName());
std::string fileName(tree->GetName());
fileName += "-";
fileName += leaf->GetName();
fileName += ".png";
canvas->SaveAs(fileName.c_str());
}
}
}
}