ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/Configuration/scripts/makeBNTreePlot.py
(Generate patch)

Comparing UserCode/OSUT3Analysis/Configuration/scripts/makeBNTreePlot.py (file contents):
Revision 1.12 by wulsin, Wed Jun 12 09:15:32 2013 UTC vs.
Revision 1.13 by wulsin, Thu Jun 13 08:34:22 2013 UTC

# Line 1 | Line 1
1   #!/usr/bin/env python
2  
3 < # Must specify options with -l argument, e.g.:  
4 < # > makeBNTreePlot.py -l sampleBNTreePlotConfig.py  
3 > # Must specify options with -l argument, and condor directory with -c argument, e.g.:  
4 > # > makeBNTreePlot.py -l sampleBNTreePlotConfig.py -c myCondorDir
5 >
6 > # Additional arugments specify the running mode:
7 > # -D <dataset>:  Run on a single dataset (typically for testing)
8 > # -C:  Submit jobs to run on condor over all datasets
9 > # BNTreeUseScript=True (set in sampleBNTreePlotConfig.py):  run BNTreeScript root macro (also set in sampleBNTreePlotConfig.py),
10 > #    which must take as arguments the condor directory, dataset, and channel
11  
12  
13   import sys
# Line 97 | Line 103 | if arguments.runOnCondor:
103   #write new histogram to dataset
104   if not arguments.quickMerge:
105      for dataset in split_datasets:
106 <        for hist in input_histograms:
107 <            #chain trees together
108 <            ch = TChain("OSUAnalysis/"+hist['channel']+"/BNTree_"+hist['channel'])
109 <            ch.Add(condor_dir + "/" + dataset + "/hist_*.root")
110 <            print ("Looping over chain with # entries = %f; split time = " % ch.GetEntries()),
111 <            watch1.Stop(); watch1.Print(); watch1.Start()
112 <            
113 <            outputFile = TFile(condor_dir + "/" + dataset + ".root", "UPDATE")
114 <            if not outputFile or outputFile.IsZombie():  print "Could not open file: %s/%s.root" % (condor_dir, dataset)  
115 <            outputFile.cd("OSUAnalysis/"+hist['channel'])
116 <                
117 <            deleteString = hist['histName'] + ";*"  # delete all existing instances of the object
118 <            currentDir = outputFile.GetDirectory("OSUAnalysis/"+hist['channel']);
119 <            if not currentDir: print "Could not find directory OSUAnalysis/%s in file %s" % (hist['channel'], outputFile.GetName())  
120 <            currentDir.Delete(deleteString);
121 <            if 'nbinsY' in hist:  # only make a 2D histogram if the key "nbinsY" is defined  
122 <                h = TH2D(hist['histName'], hist['histName'],
123 <                         hist['nbins'],  hist['xMin'], hist['xMax'],
124 <                         hist['nbinsY'], hist['yMin'], hist['yMax'])
125 <            else:            
126 <                h = TH1D(hist['histName'], hist['histName'], hist['nbins'], hist['xMin'], hist['xMax'])
127 <            h.Sumw2()  # Needed to get weights correct.  
128 <            cut = TCut(hist['cutString'])
129 <            ch.Draw(hist['varToPlot']+">>"+hist['histName'], cut)  
130 <            h.Write()
131 <            outputFile.Close()
132 <            print "Histogram " + hist['histName'] + " has been added to " + condor_dir + "/"+ dataset + ".root"
106 >        if BNTreeUseScript:
107 >            chainName = "OSUAnalysis/" + BNTreeChannel + "/BNTree_" + BNTreeChannel
108 >            command = "root -l -b -q '" + BNTreeScript + "+(\"" + condor_dir + "\",\"" + dataset + "\",\"" + chainName + "\")'"  
109 >            print "About to execute command:  " + command  
110 >            os.system(command)
111 >        else:
112 >            for hist in input_histograms:
113 >                #chain trees together
114 >                ch = TChain("OSUAnalysis/"+hist['channel']+"/BNTree_"+hist['channel'])
115 >                ch.Add(condor_dir + "/" + dataset + "/hist_*.root")
116 >                print ("Looping over chain with # entries = %f; split time = " % ch.GetEntries()),
117 >                watch1.Stop(); watch1.Print(); watch1.Start()
118 >
119 >                outputFile = TFile(condor_dir + "/" + dataset + ".root", "UPDATE")
120 >                if not outputFile or outputFile.IsZombie():  print "Could not open file: %s/%s.root" % (condor_dir, dataset)  
121 >                outputFile.cd("OSUAnalysis/"+hist['channel'])
122 >
123 >                deleteString = hist['histName'] + ";*"  # delete all existing instances of the object
124 >                currentDir = outputFile.GetDirectory("OSUAnalysis/"+hist['channel']);
125 >                if not currentDir: print "Could not find directory OSUAnalysis/%s in file %s" % (hist['channel'], outputFile.GetName())  
126 >                currentDir.Delete(deleteString);
127 >                if 'nbinsY' in hist:  # only make a 2D histogram if the key "nbinsY" is defined  
128 >                    h = TH2D(hist['histName'], hist['histName'],
129 >                             hist['nbins'],  hist['xMin'], hist['xMax'],
130 >                             hist['nbinsY'], hist['yMin'], hist['yMax'])
131 >                else:            
132 >                    h = TH1D(hist['histName'], hist['histName'], hist['nbins'], hist['xMin'], hist['xMax'])
133 >                h.Sumw2()  # Needed to get weights correct.  
134 >                cut = TCut(hist['cutString'])
135 >                ch.Draw(hist['varToPlot']+">>"+hist['histName'], cut)  
136 >                h.Write()
137 >                outputFile.Close()
138 >                print "Histogram " + hist['histName'] + " has been added to " + condor_dir + "/"+ dataset + ".root"
139  
140   #merge output if composite dataset
141   for composite_dataset in composite_datasets:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines