ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/Configuration/scripts/makePU.py
Revision: 1.5
Committed: Fri Apr 12 04:10:23 2013 UTC (12 years ago) by ahart
Content type: text/x-python
Branch: MAIN
CVS Tags: V02-03-02, V02-03-01, V02-03-00, V02-02-00, V02-01-01, V02-01-00, V01-01-00, V01-00-00, V02-00-00, V00-01-00, HEAD
Changes since 1.4: +2 -2 lines
Error occurred while calculating annotation data.
Log Message:
Changed "options" to "arguments".

File Contents

# Content
1 #!/usr/bin/env python
2
3 import sys
4 import os
5 from array import *
6 from optparse import OptionParser
7 from OSUT3Analysis.Configuration.configurationOptions import *
8 from OSUT3Analysis.Configuration.processingUtilities import *
9
10 parser = OptionParser()
11 parser = set_commandline_arguments(parser)
12 (arguments, args) = parser.parse_args()
13
14 if arguments.localConfig:
15 sys.path.append(os.getcwd())
16 exec("from " + arguments.localConfig.rstrip('.py') + " import *")
17
18 condor_dir = set_condor_output_dir(arguments)
19
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()