ATLAS Offline Software
Loading...
Searching...
No Matches
TTreeHelper.py
Go to the documentation of this file.
1"""
2TreePlotter.py
3
4Created by Andreas Salzburger on 2009-04-16.
5
6"""
7
8import sys
9import os
10from ROOT import TFile
11
13 """TreePlotter helper class in python"""
14 def __init__(self, *args):
15 super(TTreeSelector, self).__init__()
16 # open the file
17 try :
18 self.file = TFile.Open(args[0])
19 except IndexError :
20 print ('[!] You need to specify a file name in the argument list')
21 # get the hashlist and entries
22 self.hashlist = self.file.GetListOfKeys()
24 print ('[>] File [',args[0],'] sucessfully loaded')
25
26 def loadTrees(self, arg):
27 """load Trees method: loads trees that match one of the arguments in name"""
28 treedict = {}
29 for itree in range(0,self.entries):
30 treename = self.hashlist.At(itree).GetName()
31 if treename.find(arg) >= 0 :
32 tree = self.file.Get(treename)
33 treedict[treename] = tree
34 print ('[>] ',len(treedict),'Trees loaded matching the selection:', arg)
35 return treedict
TGraphErrors * GetEntries(TH2F *histo)
T * Get(TFile &f, const std::string &n, const std::string &dir="", const chainmap_t *chainmap=0, std::vector< std::string > *saved=0)
get a histogram given a path, and an optional initial directory if histogram is not found,...