Skip to content

Commit

Permalink
add selecting bunch feature to estimate PU script - 90X
Browse files Browse the repository at this point in the history
  • Loading branch information
capalmer85 committed Jan 26, 2017
1 parent dfcb715 commit a412924
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion RecoLuminosity/LumiDB/scripts/estimatePileup_makeJSON_2015.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from pprint import pprint

selBXs=[]
def CalcPileup (deadTable, parameters, luminometer, mode='deadtable'):
'''Given a deadtable, will calculate parameters of pileup distribution. Return formatted
string with LumiSection, LS integrated lumi, RMS of bunch to bunch lumi and pileup.'''
Expand Down Expand Up @@ -49,7 +50,8 @@ def CalcPileup (deadTable, parameters, luminometer, mode='deadtable'):
TotalWeight2 = 0
FilledXings = 0
for xing, xingInstLumi, xingDelvLumi in instLumiArray:
#print "Inputs: lum %d: idx %d IntL %f DelivL %f" % (lumiSection, xing, xingInstLumi, xingDelvLumi)
if selBXs and xing not in selBXs:
continue
xingIntLumi = xingInstLumi * livetime # * parameters.lumiSectionLen
mean = xingInstLumi * parameters.rotationTime / parameters.lumiSectionLen
if mean > 100:
Expand All @@ -73,6 +75,8 @@ def CalcPileup (deadTable, parameters, luminometer, mode='deadtable'):
if TotalLumi >0:
MeanInt = TotalInt/TotalLumi
for xing, xingInstLumi, xingDelvlumi in instLumiArray:
if selBXs and xing not in selBXs:
continue
if xingInstLumi > threshold:
xingIntLumi = xingInstLumi * livetime # * parameters.lumiSectionLen
mean = xingInstLumi * parameters.rotationTime / parameters.lumiSectionLen
Expand Down Expand Up @@ -134,6 +138,8 @@ def CalcPileup (deadTable, parameters, luminometer, mode='deadtable'):
pileupGroup = optparse.OptionGroup (parser, "Pileup Options")
inputGroup.add_option ('--csvInput', dest = 'csvInput', type='string', default='',
help = 'Use CSV file from lumiCalc.py instead of lumiDB')
inputGroup.add_option ('--selBXs', dest = 'selBXs', type='string', default='',
help = 'CSV of BXs to use; if empty, select all')
parser.add_option_group (inputGroup)
parser.add_option_group (pileupGroup)
# parse arguments
Expand All @@ -151,6 +157,17 @@ def CalcPileup (deadTable, parameters, luminometer, mode='deadtable'):
if not options.csvInput:
raise "you must specify an input CSV file with (--csvInput)"

if options.selBXs != "":
for iBX in options.selBXs.split(","):
try:
BX=int(iBX)
if BX not in selBXs:
selBXs.append(BX)
except:
print iBX,"is not an int"
selBXs.sort()
print "selBXs",selBXs

OUTPUTLINE = ""
if options.csvInput:
# we're going to read in the CSV file and use this as not only
Expand Down

0 comments on commit a412924

Please sign in to comment.