15 |
|
from OSUT3Analysis.Configuration.configurationOptions import * |
16 |
|
from OSUT3Analysis.Configuration.processingUtilities import * |
17 |
|
|
18 |
< |
from ROOT import TChain, TCut, TDirectory, TFile, TH1D, TStopwatch, TTree, gROOT |
18 |
> |
from ROOT import TChain, TCut, TDirectory, TFile, TH1D, TH2D, TStopwatch, TTree, gROOT |
19 |
|
|
20 |
|
gROOT.SetBatch(True) # This is to prevent pop-up graphical windows |
21 |
|
|
50 |
|
cmd = "condor_submit condor/"+arguments.condorDir+"/"+dataset+"/condorBNTree.sub" |
51 |
|
os.system(cmd) |
52 |
|
print "Submitting job: %s " % cmd |
53 |
+ |
|
54 |
+ |
print "Once condor jobs have finished, merge the composite datasets and then make plots with:" |
55 |
+ |
print " makeBNTreePlot.py -q -l " + arguments.localConfig + " -c " + arguments.condorDir |
56 |
+ |
print " makePlots.py -l " + arguments.localConfig + " -c " + arguments.condorDir |
57 |
|
|
58 |
|
return |
59 |
|
|
60 |
|
|
61 |
< |
watch = TStopwatch() |
61 |
> |
watch = TStopwatch() |
62 |
> |
watch1 = TStopwatch() |
63 |
> |
|
64 |
|
|
65 |
|
parser = OptionParser() |
66 |
|
parser = set_commandline_arguments(parser) |
86 |
|
#save a list of datasets with composite datasets split up |
87 |
|
split_datasets = split_composite_datasets(datasets, composite_dataset_definitions) |
88 |
|
|
89 |
+ |
if arguments.quickMerge and arguments.runOnCondor: |
90 |
+ |
print "Cannot use -q (--quickMerge) and -C (--runOnCondor) options simultaneously. Please choose one or the other." |
91 |
+ |
exit() |
92 |
+ |
|
93 |
|
if arguments.runOnCondor: |
94 |
|
RunOnCondor(arguments, split_datasets) |
95 |
< |
exit() |
86 |
< |
|
87 |
< |
print "Running interactively instead" |
88 |
< |
|
95 |
> |
exit() |
96 |
|
|
97 |
|
#write new histogram to dataset |
98 |
< |
for dataset in split_datasets: |
99 |
< |
for hist in input_histograms: |
100 |
< |
#chain trees together |
101 |
< |
ch = TChain("OSUAnalysis/"+hist['channel']+"/BNTree_"+hist['channel']) |
102 |
< |
ch.Add(condor_dir + "/" + dataset + "/hist_*.root") |
103 |
< |
print "Looping over chain with # entries = %f" % ch.GetEntries() |
104 |
< |
|
105 |
< |
outputFile = TFile(condor_dir + "/" + dataset + ".root", "UPDATE") |
106 |
< |
if not outputFile or outputFile.IsZombie(): print "Could not open file: %s/%s.root" % (condor_dir, dataset) |
107 |
< |
outputFile.cd("OSUAnalysis/"+hist['channel']) |
108 |
< |
|
109 |
< |
deleteString = hist['histName'] + ";*" # delete all existing instances of the object |
110 |
< |
currentDir = outputFile.GetDirectory("OSUAnalysis/"+hist['channel']); |
111 |
< |
if not currentDir: print "Could not find directory OSUAnalysis/%s in file %s" % (hist['channel'], outputFile.GetName()) |
112 |
< |
currentDir.Delete(deleteString); |
113 |
< |
|
114 |
< |
h = TH1D(hist['histName'], hist['histName'], hist['nbins'], hist['xMin'], hist['xMax']) |
115 |
< |
h.Sumw2() # Needed to get weights correct. |
116 |
< |
cut = TCut(hist['cutString']) |
117 |
< |
ch.Draw(hist['varToPlot']+">>"+hist['histName'], cut) |
118 |
< |
h.Write() |
119 |
< |
outputFile.Close() |
120 |
< |
print "Histogram " + hist['histName'] + " has been added to " + condor_dir + "/"+ dataset + ".root" |
98 |
> |
if not arguments.quickMerge: |
99 |
> |
for dataset in split_datasets: |
100 |
> |
for hist in input_histograms: |
101 |
> |
#chain trees together |
102 |
> |
ch = TChain("OSUAnalysis/"+hist['channel']+"/BNTree_"+hist['channel']) |
103 |
> |
ch.Add(condor_dir + "/" + dataset + "/hist_*.root") |
104 |
> |
print ("Looping over chain with # entries = %f; split time = " % ch.GetEntries()), |
105 |
> |
watch1.Stop(); watch1.Print(); watch1.Start() |
106 |
> |
|
107 |
> |
outputFile = TFile(condor_dir + "/" + dataset + ".root", "UPDATE") |
108 |
> |
if not outputFile or outputFile.IsZombie(): print "Could not open file: %s/%s.root" % (condor_dir, dataset) |
109 |
> |
outputFile.cd("OSUAnalysis/"+hist['channel']) |
110 |
> |
|
111 |
> |
deleteString = hist['histName'] + ";*" # delete all existing instances of the object |
112 |
> |
currentDir = outputFile.GetDirectory("OSUAnalysis/"+hist['channel']); |
113 |
> |
if not currentDir: print "Could not find directory OSUAnalysis/%s in file %s" % (hist['channel'], outputFile.GetName()) |
114 |
> |
currentDir.Delete(deleteString); |
115 |
> |
if 'nbinsY' in hist: # only make a 2D histogram if the key "nbinsY" is defined |
116 |
> |
h = TH2D(hist['histName'], hist['histName'], |
117 |
> |
hist['nbins'], hist['xMin'], hist['xMax'], |
118 |
> |
hist['nbinsY'], hist['yMin'], hist['yMax']) |
119 |
> |
else: |
120 |
> |
h = TH1D(hist['histName'], hist['histName'], hist['nbins'], hist['xMin'], hist['xMax']) |
121 |
> |
h.Sumw2() # Needed to get weights correct. |
122 |
> |
cut = TCut(hist['cutString']) |
123 |
> |
ch.Draw(hist['varToPlot']+">>"+hist['histName'], cut) |
124 |
> |
h.Write() |
125 |
> |
outputFile.Close() |
126 |
> |
print "Histogram " + hist['histName'] + " has been added to " + condor_dir + "/"+ dataset + ".root" |
127 |
|
|
128 |
|
#merge output if composite dataset |
129 |
|
for composite_dataset in composite_datasets: |
139 |
|
print "Merging output for composite dataset: " + composite_dataset |
140 |
|
os.system(command) |
141 |
|
|
142 |
+ |
print ("Total time: "), |
143 |
|
watch.Stop() |
144 |
|
watch.Print() |
145 |
|
|