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