ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbb/python/copytree.py
(Generate patch)

Comparing UserCode/VHbb/python/copytree.py (file contents):
Revision 1.1 by peller, Tue May 8 10:37:17 2012 UTC vs.
Revision 1.5 by bortigno, Wed Dec 5 13:07:24 2012 UTC

# Line 3 | Line 3 | from ROOT import TFile
3   from printcolor import printc
4  
5          
6 < def copytree(pathIN,pathOUT,prefix,file,Aprefix,Acut):
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,prefix,Aprefix,file),'recreate')
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()
20 >        #print obj.GetName()
21          if obj.GetName() == 'tree':
22              continue
23          output.cd()
24 <        print key.GetName()
24 >        #print key.GetName()
25          obj.Write(key.GetName())
26  
27      inputTree = input.Get("tree")
# Line 29 | Line 34 | def copytree(pathIN,pathOUT,prefix,file,
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 <    input.Close()
41 >    print "Writing output file"
42 >    output.Write()
43 >    print "Closing output file"
44      output.Close()
45 < '''
38 < def copytree(pathIN,pathOUT,prefix,file,Aprefix,Acut):
39 <    input = TFile.Open("%s/%s%s.root" %(pathIN,prefix,file),'read')
40 <    Count = input.Get("Count")
41 <    CountWithPU = input.Get("CountWithPU")
42 <    CountWithPU2011B = input.Get("CountWithPU2011B")
43 <    inputTree = input.Get("tree")
44 <    nEntries = inputTree.GetEntries()
45 <    output = TFile.Open("%s/%s%s%s.root" %(pathOUT,prefix,Aprefix,file),'recreate')
46 <    print '\n\t copy file: %s with cut: %s' %(file,Acut)
47 <    outputTree = inputTree.CopyTree(Acut)
48 <    kEntries = outputTree.GetEntries()
49 <    printc('blue','',"\t before cuts\t %s" %nEntries)
50 <    printc('green','',"\t survived\t %s" %kEntries)
51 <    #print "\t Factor for Scaling is %s" %factor
52 <    outputTree.AutoSave()
53 <    #Count.Scale(factor)
54 <    Count.Write()
55 <    CountWithPU.Write()
56 <    #CountWithPU.Scale(factor)
57 <    CountWithPU2011B.Write()
58 <    #CountWithPU2011B.Scale(factor)
45 >    print "Closing input file"
46      input.Close()
60    output.Close()
61
62 '''
63
47  
48 <                
48 >    print "##### COPY TREE - END ######"

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines