-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNtupleParserCode.py
More file actions
32 lines (27 loc) · 863 Bytes
/
NtupleParserCode.py
File metadata and controls
32 lines (27 loc) · 863 Bytes
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
import ROOT
from ROOT import gROOT, TCanvas,TH1D,TH2D,TFile,TStyle,TLegend,TPave,TPaveStats,TPad,TPaveLabel,gStyle,gPad,TPaletteAxis,TLine
import numpy
import sys
filepath = sys.argv[1]
ntupleInFile = sys.argv[2]
f = ROOT.TFile.Open(filepath,'READ')
tree = f.Get(ntupleInFile)
listofleaves = tree.GetListOfLeaves()
# print(listofleaves)
leafNames = []
for atree in listofleaves:
print(atree.GetName())
leafNames.append(atree.GetName())
NtupleVars = []
for atree in listofleaves:
#n=0
Physvars = []
for entry in tree:
physvar = entry.GetLeaf(atree.GetName()).GetValue()
#n = n+1
Physvars.append(physvar)
Physvars = numpy.array(Physvars)
Physvars = Physvars.reshape(-1,1)
# print(numpy.shape(NtupleVars))
NtupleVars.append(Physvars)
NtupleVars = numpy.array(NtupleVars)