CMS 3D CMS Logo

Classes | Functions | Variables
pileupCalc Namespace Reference

Classes

class  EquidistantBinning
 

Functions

def fillPileupHistogram (lumiInfo, calcOption, binning, hContents, minbXsec, run, ls)
 
def MyErf (xInput)
 
def parseInputFile (inputfilename)
 
def poisson (x, par)
 

Variables

 action
 
 binning
 
 choices
 
 default
 
 description
 
 dest
 
 float
 
 hContents
 
 help
 
 histFile
 
 inpf
 
 inputfilecontent
 
 inputPileupRange
 
 inputRange
 
 int
 
 LSPUlist
 
 lumiInfo
 
 options
 
 output
 
 parser
 

## Main Program

More...
 
 pileupHist
 
 req_group
 
 required
 
 Sqrt2
 
 type
 
 VERSION
 

Function Documentation

◆ fillPileupHistogram()

def pileupCalc.fillPileupHistogram (   lumiInfo,
  calcOption,
  binning,
  hContents,
  minbXsec,
  run,
  ls 
)
lumiinfo:[intlumi per LS, mean interactions ]

intlumi is the deadtime corrected average integrated lumi per lumisection

Definition at line 69 of file pileupCalc.py.

References MyErf(), poisson(), and print().

69 def fillPileupHistogram(lumiInfo, calcOption, binning, hContents, minbXsec, run, ls):
70  '''
71  lumiinfo:[intlumi per LS, mean interactions ]
72 
73  intlumi is the deadtime corrected average integrated lumi per lumisection
74  '''
75 
76  LSintLumi = lumiInfo[0]
77  RMSInt = lumiInfo[1]*minbXsec
78  AveNumInt = lumiInfo[2]*minbXsec
79 
80  # First, re-constitute lumi distribution for this LS from RMS:
81  if RMSInt > 0:
82  areaAbove = MyErf((AveNumInt-binning.edges)/Sqrt2/RMSInt)
83 
84  ProbFromRMS = .5*(areaAbove[:-1]-areaAbove[1:])
85  else:
86  ProbFromRMS = np.zeros(hContents.shape)
87  obs = binning.find(AveNumInt)
88  if ( obs < binning.num ) and ( AveNumInt >= 1.0E-5 ): # just ignore zero values
89  ProbFromRMS[obs] = 1.0
90 
91  if calcOption == 'true': # Just put distribution into histogram
92  if RMSInt > 0:
93  hContents += ProbFromRMS*LSintLumi
94  totalProb = np.sum(ProbFromRMS)
95 
96  if 1.0-totalProb > 0.01:
97  print("Run %d, LS %d: Significant probability density outside of your histogram (mean %.2f," % (run, ls, AveNumInt))
98  print("rms %.2f, integrated probability %.3f). Consider using a higher value of --maxPileupBin." % (RMSInt, totalProb))
99  else:
100  hContents[obs] += LSintLumi
101  else: # have to convolute with a poisson distribution to get observed Nint
102  if not hasattr(binning, "poissConv"):
104  binning.poissConv = poisson(
105  binning.edges[:-1,np.newaxis],
106  binning.centers[np.newaxis,:])
108  prob = np.sum(binning.poissConv * ProbFromRMS[np.newaxis,:], axis=1)
109  hContents += prob*LSintLumi
110  #if ( not np.all(ProbFromRMS == 0) ) and 1.0-np.sum(prob) > 0.01:
111  # print("Run %d, LS %d: significant probability density outside of your histogram, %f" % (run, ls, np.sum(prob)))
112  # print("Consider using a higher value of --maxPileupBin")
113 
def fillPileupHistogram(lumiInfo, calcOption, binning, hContents, minbXsec, run, ls)
Definition: pileupCalc.py:69
def poisson(x, par)
Definition: pileupCalc.py:49
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def MyErf(xInput)
Definition: pileupCalc.py:24

◆ MyErf()

def pileupCalc.MyErf (   xInput)

Definition at line 24 of file pileupCalc.py.

Referenced by fillPileupHistogram().

24 def MyErf(xInput):
25  # Abramowitz and Stegun approximations for Erf (equations 7.1.25-28)
26  X = np.abs(xInput)
27 
28  p = 0.47047
29  b1 = 0.3480242
30  b2 = -0.0958798
31  b3 = 0.7478556
32 
33  T = 1.0/(1.0+p*X)
34  cErf = 1.0 - (b1*T + b2*T*T + b3*T*T*T)*np.exp(-1.0*X*X)
35 
36  # Alternate Erf approximation:
37  #A1 = 0.278393
38  #A2 = 0.230389
39  #A3 = 0.000972
40  #A4 = 0.078108
41 
42  #term = 1.0+ A1*X+ A2*X*X+ A3*X*X*X+ A4*X*X*X*X
43  #denom = term*term*term*term
44 
45  #dErf = 1.0 - 1.0/denom
46 
47  return np.where(xInput < 0, -cErf, cErf)
48 
def MyErf(xInput)
Definition: pileupCalc.py:24

◆ parseInputFile()

def pileupCalc.parseInputFile (   inputfilename)
output ({run:[ls:[inlumi, meanint]]})

Definition at line 12 of file pileupCalc.py.

12 def parseInputFile(inputfilename):
13  '''
14  output ({run:[ls:[inlumi, meanint]]})
15  '''
16  selectf=open(inputfilename,'r') inputfilecontent=selectf.read()
17  p=pileupParser.pileupParser(inputfilecontent)
18 
19 # p=inputFilesetParser.inputFilesetParser(inputfilename)
20  runlsbyfile=p.runsandls()
21  return runlsbyfile
22 
23 
def parseInputFile(inputfilename)
Definition: pileupCalc.py:12

◆ poisson()

def pileupCalc.poisson (   x,
  par 
)

Definition at line 49 of file pileupCalc.py.

Referenced by fillPileupHistogram().

49 def poisson(x, par):
50 
51  return np.where(x == 0., np.exp(-par),
52  np.exp(x*np.log(par)-loggamma(x+1)-par))
53 
def poisson(x, par)
Definition: pileupCalc.py:49

Variable Documentation

◆ action

pileupCalc.action

Definition at line 128 of file pileupCalc.py.

◆ binning

◆ choices

pileupCalc.choices

Definition at line 135 of file pileupCalc.py.

◆ default

pileupCalc.default

Definition at line 139 of file pileupCalc.py.

◆ description

pileupCalc.description

Definition at line 124 of file pileupCalc.py.

◆ dest

pileupCalc.dest

Definition at line 129 of file pileupCalc.py.

◆ float

pileupCalc.float

Definition at line 139 of file pileupCalc.py.

◆ hContents

pileupCalc.hContents

Definition at line 164 of file pileupCalc.py.

◆ help

pileupCalc.help

Definition at line 128 of file pileupCalc.py.

◆ histFile

pileupCalc.histFile

Definition at line 209 of file pileupCalc.py.

◆ inpf

pileupCalc.inpf

Definition at line 166 of file pileupCalc.py.

◆ inputfilecontent

pileupCalc.inputfilecontent

Definition at line 167 of file pileupCalc.py.

◆ inputPileupRange

pileupCalc.inputPileupRange

Definition at line 172 of file pileupCalc.py.

◆ inputRange

◆ int

pileupCalc.int

Definition at line 142 of file pileupCalc.py.

◆ LSPUlist

pileupCalc.LSPUlist

Definition at line 182 of file pileupCalc.py.

◆ lumiInfo

pileupCalc.lumiInfo

Definition at line 187 of file pileupCalc.py.

Referenced by operator<<().

◆ options

pileupCalc.options

Definition at line 150 of file pileupCalc.py.

◆ output

pileupCalc.output

Definition at line 151 of file pileupCalc.py.

◆ parser

pileupCalc.parser

## Main Program

Definition at line 124 of file pileupCalc.py.

◆ pileupHist

pileupCalc.pileupHist

Definition at line 204 of file pileupCalc.py.

◆ req_group

pileupCalc.req_group

Definition at line 127 of file pileupCalc.py.

◆ required

pileupCalc.required

Definition at line 129 of file pileupCalc.py.

◆ Sqrt2

pileupCalc.Sqrt2

Definition at line 67 of file pileupCalc.py.

◆ type

pileupCalc.type

Definition at line 139 of file pileupCalc.py.

◆ VERSION

pileupCalc.VERSION

Definition at line 4 of file pileupCalc.py.