1 |
lantonel |
1.1 |
#!/usr/bin/env python
|
2 |
|
|
|
3 |
|
|
import sys
|
4 |
|
|
import os
|
5 |
|
|
from array import *
|
6 |
lantonel |
1.4 |
from optparse import OptionParser
|
7 |
lantonel |
1.2 |
from OSUT3Analysis.Configuration.configurationOptions import *
|
8 |
lantonel |
1.3 |
from OSUT3Analysis.Configuration.processingUtilities import *
|
9 |
lantonel |
1.1 |
|
10 |
lantonel |
1.4 |
parser = OptionParser()
|
11 |
lantonel |
1.3 |
parser = set_commandline_arguments(parser)
|
12 |
lantonel |
1.4 |
(arguments, args) = parser.parse_args()
|
13 |
lantonel |
1.1 |
|
14 |
ahart |
1.5 |
if arguments.localConfig:
|
15 |
lantonel |
1.1 |
sys.path.append(os.getcwd())
|
16 |
ahart |
1.5 |
exec("from " + arguments.localConfig.rstrip('.py') + " import *")
|
17 |
lantonel |
1.1 |
|
18 |
lantonel |
1.3 |
condor_dir = set_condor_output_dir(arguments)
|
19 |
lantonel |
1.1 |
|
20 |
|
|
from ROOT import TFile, gROOT, gStyle, gDirectory, TStyle, THStack, TH1F, TCanvas, TString, TLegend, TArrow, THStack, TIter, TKey, TPaveLabel
|
21 |
|
|
|
22 |
|
|
gROOT.SetBatch()
|
23 |
|
|
outputFile = TFile(condor_dir + "/pu.root", "RECREATE")
|
24 |
|
|
|
25 |
|
|
processed_datasets = []
|
26 |
|
|
|
27 |
|
|
#### check which input datasets have valid output files
|
28 |
|
|
for sample in datasets:
|
29 |
|
|
fileName = condor_dir + "/" + sample + ".root"
|
30 |
|
|
if not os.path.exists(fileName):
|
31 |
|
|
continue
|
32 |
|
|
testFile = TFile(fileName)
|
33 |
|
|
if not (testFile.IsZombie()):
|
34 |
|
|
processed_datasets.append(sample)
|
35 |
|
|
|
36 |
|
|
if len(processed_datasets) is 0:
|
37 |
|
|
sys.exit("No datasets have been processed")
|
38 |
|
|
|
39 |
|
|
#### open first input file and re-make its directory structure in the output file
|
40 |
|
|
testFile = TFile(condor_dir + "/" + processed_datasets[0] + ".root")
|
41 |
|
|
testFile.cd()
|
42 |
|
|
for key in testFile.GetListOfKeys():
|
43 |
|
|
if (key.GetClassName() != "TDirectoryFile"):
|
44 |
|
|
continue
|
45 |
|
|
rootDirectory = key.GetName()
|
46 |
|
|
|
47 |
|
|
for sample in processed_datasets: # loop over different samples as listed in configurationOptions.py
|
48 |
|
|
inputFile = TFile(condor_dir + "/" + sample + ".root")
|
49 |
|
|
if(inputFile.IsZombie()):
|
50 |
|
|
continue
|
51 |
|
|
Histogram = inputFile.Get(rootDirectory+"/pu").Clone()
|
52 |
|
|
Histogram.SetDirectory(0)
|
53 |
|
|
outputFile.cd()
|
54 |
|
|
Histogram.Write (sample)
|
55 |
|
|
|
56 |
|
|
outputFile.Close()
|