CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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. More...
 
tuple parameters = LumiQueryAPI.ParametersObject()
 

## Main Program

More...
 
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.

References mathSSE.sqrt().

13 
14 def CalcPileup (deadTable, parameters, mode='deadtable'):
15  '''Given a deadtable, will calculate parameters of pileup distribution. Return formatted
16  string with LumiSection, LS integrated lumi, RMS of bunch to bunch lumi and pileup.'''
17 
18  LumiString = ""
19  LumiArray = []
20 
21  for lumiSection, deadArray in sorted (deadTable.iteritems()):
22  numerator = 0
23  if mode == 'csv':
24  numerator = float (deadArray[1])
25  denominator = float (deadArray[0])
26  instLumiArray = deadArray[2]
27  livetime = 1
28  if numerator < 0:
29  numerator = 0
30  if denominator:
31  livetime = numerator / denominator
32 
33  else:
34  print "no csv input! Doh!"
35  return
36  # totalInstLumi = reduce(lambda x, y: x+y, instLumiArray) # not needed
37  if lumiSection > 0:
38  TotalLumi = 0
39  TotalInt = 0
40  TotalInt2 = 0
41  TotalWeight = 0
42  TotalWeight2 = 0
43  FilledXings = 0
44  for xing, xingInstLumi in instLumiArray:
45  xingIntLumi = xingInstLumi * parameters.lumiSectionLen * livetime
46  mean = xingInstLumi * parameters.rotationTime
47  if mean > 100:
48  if runNumber:
49  print "mean number of pileup events > 100 for run %d, lum %d : m %f l %f" % \
50  (runNumber, lumiSection, mean, xingInstLumi)
51  else:
52  print "mean number of pileup events > 100 for lum %d: m %f l %f" % \
53  (lumiSection, mean, xingInstLumi)
54 # print "mean number of pileup events for lum %d: m %f idx %d l %f" % (lumiSection, mean, xing, xingIntLumi)
55 
56  if xingInstLumi > 0.1:
57 
58  TotalLumi = TotalLumi+xingIntLumi
59  TotalInt+= mean*xingIntLumi
60  FilledXings = FilledXings+1
61  #print "xing inst lumi %f %f %d" % (xingIntLumi,TotalLumi,FilledXings)
62 
63  #compute weighted mean, then loop again to get weighted RMS
64  MeanInt = 0
65  if TotalLumi >0:
66  MeanInt = TotalInt/TotalLumi
67  for xing, xingInstLumi in instLumiArray:
68  if xingInstLumi > 0.1:
69  xingIntLumi = xingInstLumi * parameters.lumiSectionLen * livetime
70  mean = xingInstLumi * parameters.rotationTime
71  TotalInt2+= xingIntLumi*(mean-MeanInt)*(mean-MeanInt)
72  TotalWeight+= xingIntLumi
73  TotalWeight2+= xingIntLumi*xingIntLumi
74 
75 
76 
77  if ((lumiSection > 0)):
78  #print " LS, Total lumi, filled xings %d, %f, %d" %(lumiSection,TotalLumi,FilledXings)
79  if FilledXings > 0:
80  AveLumi = TotalLumi/FilledXings
81  else:
82  AveLumi = 0
83  RMSLumi = 0
84  Denom = TotalWeight*TotalWeight-TotalWeight2
85  if TotalLumi > 0 and Denom > 0:
86  RMSLumi = sqrt(TotalWeight/(TotalWeight*TotalWeight-TotalWeight2)*TotalInt2)
87  LumiString = "[%d,%2.4e,%2.4e,%2.4e]," % (lumiSection, TotalLumi, RMSLumi, MeanInt)
88  LumiArray.append(lumiSection)
89  LumiArray.append(TotalLumi) # should really weight by total lumi in LS
90  LumiArray.append(RMSLumi)
91  LumiArray.append(MeanInt)
92 
93  return LumiArray
94 
95 
T sqrt(T t)
Definition: SSEVec.h:48

Variable Documentation

list estimatePileup_makeJSON.aveLumi = 0

Definition at line 194 of file estimatePileup_makeJSON.py.

dictionary estimatePileup_makeJSON.csvDict = {}

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.

dictionary estimatePileup_makeJSON.GapDict = {}

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.

int estimatePileup_makeJSON.InGap = 0

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.

list estimatePileup_makeJSON.LastDelivered = 0

Definition at line 146 of file estimatePileup_makeJSON.py.

tuple estimatePileup_makeJSON.lastindex = len(OUTPUTLINE)

Definition at line 213 of file estimatePileup_makeJSON.py.

estimatePileup_makeJSON.lastLumiS = 0

Definition at line 186 of file estimatePileup_makeJSON.py.

estimatePileup_makeJSON.LastValidLumi = []

Definition at line 145 of file estimatePileup_makeJSON.py.

tuple estimatePileup_makeJSON.LumiArray
Initial value:
1 = CalcPileup(lumiDict, parameters,
2  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.

estimatePileup_makeJSON.OldRun = -1

Definition at line 141 of file estimatePileup_makeJSON.py.

list estimatePileup_makeJSON.output = args[0]

Definition at line 128 of file estimatePileup_makeJSON.py.

tuple estimatePileup_makeJSON.outputfile = open(output,'w')

Definition at line 252 of file estimatePileup_makeJSON.py.

Referenced by DTTrigTest.DTTrigTest(), SiStripGainCosmicCalculator.getNewObject(), and PFTauElecRejectionBenchmarkAnalyzer.PFTauElecRejectionBenchmarkAnalyzer().

estimatePileup_makeJSON.OUTPUTLINE = ""

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.

tuple estimatePileup_makeJSON.parser
Initial value:
1 = optparse.OptionParser("Usage: %prog [--options] output.root",
2  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.

list estimatePileup_makeJSON.peakratio = lumiInfo[0]

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.

list estimatePileup_makeJSON.pileup = LastValidLumi[3]

Definition at line 193 of file estimatePileup_makeJSON.py.

Referenced by FTSLuminosityFromPileupSummaryInfo.analyze(), and FFTGenericScaleCalculator.FFTGenericScaleCalculator().

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.

dictionary estimatePileup_makeJSON.runLumiDict = {}

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.

list estimatePileup_makeJSON.trunc = OUTPUTLINE[0:lastindex]

Definition at line 214 of file estimatePileup_makeJSON.py.

Referenced by LHEWriter.beginRun(), SiStripRawProcessingFactory.create_Suppressor(), LaserSorter.createOutStream(), SiPixelLorentzAngle.endJob(), EcalSelectiveReadoutValidation.initAsciiFile(), EcalSelectiveReadoutProducer.produce(), edm::service::RandomNumberGeneratorService.saveStatesToFile(), gen::Pythia6Service.setSLHAFromHeader(), jsoncollector::FastMonitor.snap(), ThePEGInterface.ThePEGInterface(), cond.toUNIX(), RPCFw.TtoUT(), RPCFw.UTtoT(), L1RCTLutWriter.writeEicLutFile(), L1RCTLutWriter.writeJscLutFile(), L1RCTLutWriter.writeRcLutFile(), L1RCTLutWriter.writeThresholdsFile(), and HtrXmlPatternTool.writeXML().

list estimatePileup_makeJSON.xingInstLumiArray
Initial value:
1 = [( int(orbit), float(lum) ) \
2  for orbit, lum in zip( pieces[10::2],
3  pieces[11::2] ) ]

Definition at line 172 of file estimatePileup_makeJSON.py.