From a41292414ed1176ec560c98eec3b4e55862bec4d Mon Sep 17 00:00:00 2001 From: capalmer85 Date: Thu, 26 Jan 2017 20:31:22 +0100 Subject: [PATCH] add selecting bunch feature to estimate PU script - 90X --- .../scripts/estimatePileup_makeJSON_2015.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/RecoLuminosity/LumiDB/scripts/estimatePileup_makeJSON_2015.py b/RecoLuminosity/LumiDB/scripts/estimatePileup_makeJSON_2015.py index 7c4bd57a76cb4..04be08aa6b1c8 100755 --- a/RecoLuminosity/LumiDB/scripts/estimatePileup_makeJSON_2015.py +++ b/RecoLuminosity/LumiDB/scripts/estimatePileup_makeJSON_2015.py @@ -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.''' @@ -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: @@ -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 @@ -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 @@ -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