1 |
peller |
1.1 |
import ROOT
|
2 |
|
|
from ROOT import TFile
|
3 |
|
|
from printcolor import printc
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
def copytree(pathIN,pathOUT,prefix,file,Aprefix,Acut):
|
7 |
|
|
input = TFile.Open("%s/%s%s.root" %(pathIN,prefix,file),'read')
|
8 |
|
|
output = TFile.Open("%s/%s%s%s.root" %(pathOUT,prefix,Aprefix,file),'recreate')
|
9 |
|
|
|
10 |
|
|
input.cd()
|
11 |
|
|
obj = ROOT.TObject
|
12 |
|
|
for key in ROOT.gDirectory.GetListOfKeys():
|
13 |
|
|
input.cd()
|
14 |
|
|
obj = key.ReadObj()
|
15 |
peller |
1.2 |
#print obj.GetName()
|
16 |
peller |
1.1 |
if obj.GetName() == 'tree':
|
17 |
|
|
continue
|
18 |
|
|
output.cd()
|
19 |
peller |
1.2 |
#print key.GetName()
|
20 |
peller |
1.1 |
obj.Write(key.GetName())
|
21 |
|
|
|
22 |
|
|
inputTree = input.Get("tree")
|
23 |
|
|
nEntries = inputTree.GetEntries()
|
24 |
|
|
output.cd()
|
25 |
|
|
print '\n\t copy file: %s with cut: %s' %(file,Acut)
|
26 |
|
|
outputTree = inputTree.CopyTree(Acut)
|
27 |
|
|
kEntries = outputTree.GetEntries()
|
28 |
|
|
printc('blue','',"\t before cuts\t %s" %nEntries)
|
29 |
|
|
printc('green','',"\t survived\t %s" %kEntries)
|
30 |
|
|
#print "\t Factor for Scaling is %s" %factor
|
31 |
|
|
outputTree.AutoSave()
|
32 |
|
|
#Count.Scale(factor)
|
33 |
|
|
#CountWithPU.Scale(factor)
|
34 |
|
|
#CountWithPU2011B.Scale(factor)
|
35 |
|
|
input.Close()
|
36 |
peller |
1.3 |
output.Close() |