1 |
|
#!/usr/bin/env python |
2 |
+ |
|
3 |
+ |
# Must specify options with -l argument, e.g.: |
4 |
+ |
# > makeBNTreePlot.py -l sampleBNTreePlotConfig.py |
5 |
+ |
|
6 |
+ |
|
7 |
|
import sys |
8 |
|
import os |
9 |
|
import re |
14 |
|
from OSUT3Analysis.Configuration.configurationOptions import * |
15 |
|
from OSUT3Analysis.Configuration.processingUtilities import * |
16 |
|
|
17 |
< |
from ROOT import TCut, TFile, TH1D, TTree, TStopwatch, TChain |
17 |
> |
from ROOT import TChain, TCut, TDirectory, TFile, TH1D, TStopwatch, TTree, gROOT |
18 |
> |
|
19 |
> |
gROOT.SetBatch(True) # This is to prevent pop-up graphical windows |
20 |
|
|
21 |
|
watch = TStopwatch() |
22 |
|
|
47 |
|
ch.Add(condor_dir + "/" + dataset + "/hist_*.root") |
48 |
|
|
49 |
|
inputFile = TFile(condor_dir + "/" + dataset + ".root", "UPDATE") |
50 |
+ |
inputFile.cd("OSUAnalysis/"+hist['channel']) |
51 |
+ |
|
52 |
+ |
deleteString = hist['histName'] + ";*" # delete all existing instances of the object |
53 |
+ |
currentDir = inputFile.GetDirectory("OSUAnalysis/"+hist['channel']); |
54 |
+ |
currentDir.Delete(deleteString); |
55 |
+ |
|
56 |
|
h = TH1D(hist['histName'], hist['histName'], hist['nbins'], hist['xMin'], hist['xMax']) |
57 |
|
cut = TCut(hist['cutString']) |
58 |
< |
|
46 |
< |
ch.Draw(hist['varToPlot']+">>"+hist['histName'], cut) |
47 |
< |
|
48 |
< |
inputFile.cd("OSUAnalysis/"+hist['channel']) |
58 |
> |
ch.Draw(hist['varToPlot']+">>"+hist['histName'], cut) |
59 |
|
h.Write() |
60 |
|
inputFile.Close() |
61 |
|
print "Histogram " + hist['histName'] + " has been added to " + condor_dir + "/"+ dataset + ".root" |