10 return [key.GetName()
for key
in gDirectory.GetListOfKeys()]
11 TFile.GetKeyNames = GetKeyNames
15 tokens = histName.split(
"_")
20 print "Too few arguments. Expected the following:"
21 print " 1. Input file"
22 print " 2. Output file"
23 print " 3. Name of component to add"
24 print " 4. Number of dimensions"
25 print " 5. Ranges in a special format"
26 print " Format: xmin,xmax;ymin,max;zmin,zmax"
27 print " Example: 15,2500;-4.5,4.5"
30 inputFile = TFile.Open(sys.argv[1],
"READ")
31 outputFile = TFile.Open(sys.argv[2],
"RECREATE")
32 compName = sys.argv[3]
33 numDim =
int(sys.argv[4])
37 if numDim != 1
and numDim != 2
and numDim != 3:
38 print "Unexpected number of dimensions:",numDim
40 binTokens = binning.split(
";")
41 if len(binTokens) != numDim:
42 print "Binning specifications and nDim don't match, %d vs %d"%(len(binTokens),numDim)
45 for aToken
in binTokens:
46 rangeTokens = aToken.split(
",")
47 if len(rangeTokens) != 2:
48 print "Unexpected number of range tokens:",len(rangeTokens)
49 bins.append([
float(rangeTokens[0]),
float(rangeTokens[1])])
54 for histName
in inputFile.GetKeyNames():
56 if not (jetDef
in jetDefs):
57 jetDefs.append(jetDef)
58 hist = inputFile.Get(histName)
64 histName = compName+
"_"+aDef
68 hist = TH1D(histName,histName,1,bins[0][0],bins[0][1])
69 hist.SetBinContent(1,0)
71 hist = TH2D(histName,histName,1,bins[0][0],bins[0][1],1,bins[1][0],bins[1][1])
72 hist.SetBinContent(1,1,0)
74 hist = TH3D(histName,histName,1,bins[0][0],bins[0][1],1,bins[1][0],bins[1][1],1,bins[2][0],bins[2][1])
75 hist.SetBinContent(1,1,1,0)
77 print "Adding empty %dD histogram of name %s"%(numDim,histName)