CMS 3D CMS Logo

Functions | Variables

estimatePileup_makeJSON Namespace Reference

Functions

def CalcPileup

Variables

int aveLumi = 0
dictionary csvDict = {}
tuple events = open(options.csvInput, 'r')
dictionary GapDict = {}
string help = 'Use CSV file from lumiCalc.py instead of lumiDB'
int InGap = 0
tuple inputGroup = optparse.OptionGroup(parser, "Input Options")
int LastDelivered = 0
tuple lastindex = len(OUTPUTLINE)
int lastLumiS = 0
list LastValidLumi = []
tuple LumiArray
string LumiString = "[%d,%2.4e,%2.4e,%2.4e],"
int OldRun = 1
list output = args[0]
tuple outputfile = open(output,'w')
string OUTPUTLINE = ""
 Let's start the fun.
tuple parameters = LumiQueryAPI.ParametersObject()
 ######################## ## ## ################## ## ## ## ## Main Program ## ## ## ## ################## ## ## ######################## ##
tuple parser
list peakratio = lumiInfo[0]
tuple pieces = sepRE.split(line.strip())
list pileup = LastValidLumi[3]
tuple pileupGroup = optparse.OptionGroup(parser, "Pileup Options")
list record = lumiInfo[1]
dictionary runLumiDict = {}
tuple sepRE = re.compile(r'[\s,;:]+')
list trunc = OUTPUTLINE[0:lastindex]
list xingInstLumiArray

Function Documentation

def estimatePileup_makeJSON::CalcPileup (   deadTable,
  parameters,
  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.

Definition at line 13 of file estimatePileup_makeJSON.py.

00014                                                         :
00015     '''Given a deadtable, will calculate parameters of pileup distribution. Return formatted
00016     string with LumiSection, LS integrated lumi, RMS of bunch to bunch lumi and pileup.'''
00017 
00018     LumiString = ""
00019     LumiArray = []
00020 
00021     for lumiSection, deadArray in sorted (deadTable.iteritems()):
00022         numerator = 0
00023         if mode == 'csv':
00024             numerator     = float (deadArray[1])
00025             denominator   = float (deadArray[0])
00026             instLumiArray =        deadArray[2]
00027             livetime = 1
00028             if numerator < 0:
00029                 numerator = 0
00030             if denominator:
00031                 livetime = numerator / denominator
00032 
00033         else:
00034             print "no csv input! Doh!"
00035             return
00036         # totalInstLumi = reduce(lambda x, y: x+y, instLumiArray) # not needed
00037         if lumiSection > 0:
00038              TotalLumi = 0 
00039              TotalInt = 0
00040              TotalInt2 = 0
00041              TotalWeight = 0
00042              TotalWeight2 = 0
00043              FilledXings = 0
00044              for xing, xingInstLumi in instLumiArray:
00045                 xingIntLumi = xingInstLumi * parameters.lumiSectionLen * livetime
00046                 mean = xingInstLumi * parameters.rotationTime
00047                 if mean > 100:
00048                     if runNumber:
00049                         print "mean number of pileup events > 100 for run %d, lum %d : m %f l %f" % \
00050                           (runNumber, lumiSection, mean, xingInstLumi)
00051                     else:
00052                         print "mean number of pileup events > 100 for lum %d: m %f l %f" % \
00053                           (lumiSection, mean, xingInstLumi)
00054 #                print "mean number of pileup events for lum %d: m %f idx %d l %f" % (lumiSection, mean, xing, xingIntLumi)
00055 
00056                 if xingInstLumi > 0.1:
00057 
00058                     TotalLumi = TotalLumi+xingIntLumi
00059                     TotalInt+= mean*xingIntLumi
00060                     FilledXings = FilledXings+1
00061                     #print "xing inst lumi %f %f %d" % (xingIntLumi,TotalLumi,FilledXings)
00062 
00063              #compute weighted mean, then loop again to get weighted RMS       
00064              MeanInt = 0
00065              if TotalLumi >0:
00066                  MeanInt = TotalInt/TotalLumi
00067              for xing, xingInstLumi in instLumiArray:
00068                  if xingInstLumi > 0.1:
00069                      xingIntLumi = xingInstLumi * parameters.lumiSectionLen * livetime
00070                      mean = xingInstLumi * parameters.rotationTime
00071                      TotalInt2+= xingIntLumi*(mean-MeanInt)*(mean-MeanInt)
00072                      TotalWeight+= xingIntLumi
00073                      TotalWeight2+= xingIntLumi*xingIntLumi
00074 
00075 
00076 
00077         if ((lumiSection > 0)):
00078             #print " LS, Total lumi, filled xings %d, %f, %d" %(lumiSection,TotalLumi,FilledXings)
00079             if FilledXings > 0:
00080                 AveLumi = TotalLumi/FilledXings
00081             else:
00082                 AveLumi = 0
00083             RMSLumi = 0
00084             Denom = TotalWeight*TotalWeight-TotalWeight2
00085             if TotalLumi > 0 and Denom > 0:
00086                 RMSLumi = sqrt(TotalWeight/(TotalWeight*TotalWeight-TotalWeight2)*TotalInt2)
00087             LumiString = "[%d,%2.4e,%2.4e,%2.4e]," % (lumiSection, TotalLumi, RMSLumi, MeanInt)
00088             LumiArray.append(lumiSection)
00089             LumiArray.append(TotalLumi)  # should really weight by total lumi in LS
00090             LumiArray.append(RMSLumi)
00091             LumiArray.append(MeanInt)
00092             
00093     return LumiArray
00094     
00095 


Variable Documentation

Definition at line 194 of file estimatePileup_makeJSON.py.

Definition at line 152 of file estimatePileup_makeJSON.py.

tuple estimatePileup_makeJSON::events = open(options.csvInput, 'r')

Definition at line 140 of file estimatePileup_makeJSON.py.

Definition at line 144 of file estimatePileup_makeJSON.py.

string estimatePileup_makeJSON::help = 'Use CSV file from lumiCalc.py instead of lumiDB'

Definition at line 116 of file estimatePileup_makeJSON.py.

Definition at line 143 of file estimatePileup_makeJSON.py.

tuple estimatePileup_makeJSON::inputGroup = optparse.OptionGroup(parser, "Input Options")

Definition at line 113 of file estimatePileup_makeJSON.py.

Definition at line 146 of file estimatePileup_makeJSON.py.

Definition at line 213 of file estimatePileup_makeJSON.py.

Definition at line 186 of file estimatePileup_makeJSON.py.

Definition at line 145 of file estimatePileup_makeJSON.py.

Initial value:
00001 CalcPileup(lumiDict, parameters,
00002                                      mode='csv')

Definition at line 226 of file estimatePileup_makeJSON.py.

string estimatePileup_makeJSON::LumiString = "[%d,%2.4e,%2.4e,%2.4e],"

Definition at line 197 of file estimatePileup_makeJSON.py.

Definition at line 141 of file estimatePileup_makeJSON.py.

Definition at line 128 of file estimatePileup_makeJSON.py.

Let's start the fun.

Definition at line 134 of file estimatePileup_makeJSON.py.

tuple estimatePileup_makeJSON::parameters = LumiQueryAPI.ParametersObject()

######################## ## ## ################## ## ## ## ## Main Program ## ## ## ## ################## ## ## ######################## ##

Definition at line 110 of file estimatePileup_makeJSON.py.

Initial value:
00001 optparse.OptionParser("Usage: %prog [--options] output.root",
00002                                     description = "Script to estimate average instantaneous bunch crossing luminosity using xing instantaneous luminosity information. Output is JSON format file with one entry per LumiSection")

Definition at line 111 of file estimatePileup_makeJSON.py.

Definition at line 192 of file estimatePileup_makeJSON.py.

tuple estimatePileup_makeJSON::pieces = sepRE.split(line.strip())

Definition at line 153 of file estimatePileup_makeJSON.py.

Definition at line 193 of file estimatePileup_makeJSON.py.

tuple estimatePileup_makeJSON::pileupGroup = optparse.OptionGroup(parser, "Pileup Options")

Definition at line 114 of file estimatePileup_makeJSON.py.

list estimatePileup_makeJSON::record = lumiInfo[1]

Definition at line 188 of file estimatePileup_makeJSON.py.

Definition at line 151 of file estimatePileup_makeJSON.py.

tuple estimatePileup_makeJSON::sepRE = re.compile(r'[\s,;:]+')

Definition at line 139 of file estimatePileup_makeJSON.py.

Initial value:
00001 [( int(orbit), float(lum) ) \
00002                                      for orbit, lum in zip( pieces[9::2],
00003                                                             pieces[10::2] ) ]

Definition at line 172 of file estimatePileup_makeJSON.py.