-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaddhistos.py
More file actions
47 lines (34 loc) · 1.13 KB
/
addhistos.py
File metadata and controls
47 lines (34 loc) · 1.13 KB
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
import math,ROOT,sys,os
from ROOT import gROOT, TFile, TChain, TTree, TH1F, TF1,SetOwnership
if __name__ == '__main__':
gROOT.Reset()
outfile="hltmenu_8TeV_7.0e33_20130930_QCDRate.root"
outf = TFile(outfile,"RECREATE");
SetOwnership( outf, False ) # tell python not to take ownership
print "Output written to: ", outfile
narg=len(sys.argv)
if narg < 2 :
print 'Usage: python addhistos.py files*.root'
sys.exit(1)
rootfiles = []
for ifile in range(1,narg):
rootfiles.append(sys.argv[ifile])
for f in range(0, narg-1):
print rootfiles[f]
infile = TFile.Open(rootfiles[f])
histInd = infile.Get("individual")
histCum = infile.Get("cumulative")
nevt = infile.Get("NEVTS")
if f==0:
histInd_all = histInd.Clone()
histCum_all = histCum.Clone()
NEVTS = nevt.Clone()
else:
histInd_all.Add(histInd)
histCum_all.Add(histCum)
NEVTS.Add(nevt)
outf.cd()
histInd_all.Write()
histCum_all.Write()
NEVTS.Write()
outf.Close()