3 from __future__
import print_function
19 fileName =
"/afs/cern.ch/user/d/delsart/public/COMMON/NTUP_COMMON_new.root"
24 print (
"Too few arguments. Expected the following:")
25 print (
"1. Root file to dump (required)")
26 print (
"2. Tree name in the file (optional, default=\"physics\")")
27 print (
"3. Output plot file (optional, default=\"plots.pdf\")")
32 fileName = sys.argv[1]
34 treeName = sys.argv[2]
39 inFile = ROOT.TFile(fileName,
"READ")
40 tree = inFile.Get(treeName)
41 if not isinstance(tree,ROOT.TTree) :
42 print (
"File does not contain the specified tree. Is the tree name correct?")
43 print (
"File: ",fileName)
44 print (
"Tree: ",treeName)
52 from JetValidation.D3PDHistoBuildLib
import HistoBuilderFromD3PD,isSupportedType
54 builder = HistoBuilderFromD3PD(tree)
56 print (
"Adding branches...")
57 for aBranch
in sorted(tree.GetSetOfTreeBranchNames()):
58 if str.startswith(aBranch,
"jet_")
or str.startswith(aBranch,
"MET_"):
59 if isSupportedType(tree.GetBranchType(aBranch)):
60 builder.addHistos(aBranch)
62 print (
"\nRunning event loop...")
64 print (
"Done event loop!")
67 builder.dumpStructuredPDF(pdfName)
68 builder.saveHistos(pdfName.replace(
'.pdf',
'.root'))
69 builder.saveHistoBins(pdfName.replace(
'.pdf',
'.pck'))