1 |
#!/usr/bin/env python
|
2 |
import sys
|
3 |
import os
|
4 |
import re
|
5 |
from optparse import OptionParser
|
6 |
from array import *
|
7 |
from decimal import *
|
8 |
|
9 |
from OSUT3Analysis.Configuration.configurationOptions import *
|
10 |
from OSUT3Analysis.Configuration.processingUtilities import *
|
11 |
|
12 |
from ROOT import TCut, TFile, TH1D, TTree, TStopwatch, TChain
|
13 |
|
14 |
watch = TStopwatch()
|
15 |
|
16 |
parser = OptionParser()
|
17 |
parser = set_commandline_arguments(parser)
|
18 |
(arguments, args) = parser.parse_args()
|
19 |
|
20 |
if not arguments.localConfig:
|
21 |
sys.exit(" You must specify a localOptions.py file with -l")
|
22 |
if arguments.localConfig:
|
23 |
sys.path.append(os.getcwd())
|
24 |
exec("from " + arguments.localConfig.rstrip('.py') + " import *")
|
25 |
if not arguments.condorDir:
|
26 |
sys.exit(" You must specify a condor directory with -c")
|
27 |
if arguments.condorDir:
|
28 |
condor_dir = "condor/%s" % arguments.condorDir
|
29 |
|
30 |
for dataset in datasets:
|
31 |
for hist in input_histograms:
|
32 |
ch = TChain("OSUAnalysis/"+hist['channel']+"/BNTree_"+hist['channel'])
|
33 |
ch.Add(condor_dir + "/" + dataset + "/hist_*.root")
|
34 |
inputFile = TFile(condor_dir + "/" + dataset + ".root", "UPDATE")
|
35 |
h = TH1D(hist['histName'], hist['histName'], hist['nbins'], hist['xMin'], hist['xMax'])
|
36 |
|
37 |
cut = TCut(hist['cutString'])
|
38 |
|
39 |
ch.Draw(hist['varToPlot']+">>"+hist['histName'], cut)
|
40 |
|
41 |
inputFile.cd("OSUAnalysis/"+hist['channel'])
|
42 |
h.Write()
|
43 |
inputFile.Close()
|
44 |
print "Histogram " + hist['histName'] + " has been added to " + condor_dir + "/"+ dataset + ".root"
|
45 |
|
46 |
watch.Stop()
|
47 |
watch.Print()
|
48 |
|
49 |
|
50 |
|