ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbb/python/copytree.py
Revision: 1.6
Committed: Wed Jan 16 16:22:46 2013 UTC (12 years, 3 months ago) by peller
Content type: text/x-python
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +0 -0 lines
State: FILE REMOVED
Log Message:
reorganized the whole repository. Macros im myutils, config files in subdirectories. Config file split in parts. Path config file restructured. Moved all path options to the path config. Changed the code accordingly.

File Contents

# Content
1 import ROOT
2 from ROOT import TFile
3 from printcolor import printc
4
5
6 def copytree(pathIN,pathOUT,prefix,newprefix,file,Aprefix,Acut):
7
8 print "##### COPY TREE - BEGIN ######"
9 print "Input File : %s/%s%s.root " %(pathIN,prefix,file)
10 print "Output File : %s/%s%s%s.root" %(pathOUT,newprefix,Aprefix,file)
11
12 input = TFile.Open("%s/%s%s.root" %(pathIN,prefix,file),'read')
13 output = TFile.Open("%s/%s%s%s.root" %(pathOUT,newprefix,Aprefix,file),'recreate')
14
15 input.cd()
16 obj = ROOT.TObject
17 for key in ROOT.gDirectory.GetListOfKeys():
18 input.cd()
19 obj = key.ReadObj()
20 #print obj.GetName()
21 if obj.GetName() == 'tree':
22 continue
23 output.cd()
24 #print key.GetName()
25 obj.Write(key.GetName())
26
27 inputTree = input.Get("tree")
28 nEntries = inputTree.GetEntries()
29 output.cd()
30 print '\n\t copy file: %s with cut: %s' %(file,Acut)
31 outputTree = inputTree.CopyTree(Acut)
32 kEntries = outputTree.GetEntries()
33 printc('blue','',"\t before cuts\t %s" %nEntries)
34 printc('green','',"\t survived\t %s" %kEntries)
35 #print "\t Factor for Scaling is %s" %factor
36 outputTree.AutoSave()
37 output.ls()
38 #Count.Scale(factor)
39 #CountWithPU.Scale(factor)
40 #CountWithPU2011B.Scale(factor)
41 print "Writing output file"
42 output.Write()
43 print "Closing output file"
44 output.Close()
45 print "Closing input file"
46 input.Close()
47
48 print "##### COPY TREE - END ######"