CMS 3D CMS Logo

Functions | Variables
pileupCalc Namespace Reference

Functions

def fillPileupHistogram (lumiInfo, calcOption, hist, minbXsec, Nbins, run, ls)
 
def MyErf (input)
 
def parseInputFile (inputfilename)
 

Variables

 action
 
 choices
 
 default
 
 description
 
 dest
 
 float
 
 help
 
 histFile
 
 inpf
 
 inputfilecontent
 
 inputPileupRange
 
 inputRange
 
 int
 
 LSPUlist
 
 lumiInfo
 
 nbins
 
 options
 
 output
 
 parser
 
 pileupHist
 
 req_group
 
 required
 
 type
 
 upper
 
 VERSION
 

Function Documentation

◆ fillPileupHistogram()

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

intlumi is the deadtime corrected average integrated lumi per lumisection

Definition at line 56 of file pileupCalc.py.

56 def fillPileupHistogram (lumiInfo, calcOption, hist, minbXsec, Nbins, run, ls):
57  '''
58  lumiinfo:[intlumi per LS, mean interactions ]
59 
60  intlumi is the deadtime corrected average integrated lumi per lumisection
61  '''
62 
63  LSintLumi = lumiInfo[0]
64  RMSInt = lumiInfo[1]*minbXsec
65  AveNumInt = lumiInfo[2]*minbXsec
66 
67  #coeff = 0
68 
69  #if RMSInt > 0:
70  # coeff = 1.0/RMSInt/sqrt(6.283185)
71 
72  #expon = 2.0*RMSInt*RMSInt
73 
74  Sqrt2 = sqrt(2)
75 
76 
77 
78  ProbFromRMS = []
79  BinWidth = hist.GetBinWidth(1)
80 
81  # First, re-constitute lumi distribution for this LS from RMS:
82  if RMSInt > 0:
83 
84  AreaLnew = -10.
85  AreaL = 0
86 
87  for obs in range (Nbins):
88  #Old Gaussian normalization; inaccurate for small rms and large bins
89  #val = hist.GetBinCenter(obs+1)
90  #prob = coeff*exp(-1.0*(val-AveNumInt)*(val-AveNumInt)/expon)
91  #ProbFromRMS.append(prob)
92 
93  left = hist.GetBinLowEdge(obs+1)
94  right = left+BinWidth
95 
96  argR = (AveNumInt-right)/Sqrt2/RMSInt
97  AreaR = MyErf(argR)
98 
99  if AreaLnew<-5.:
100  argL = (AveNumInt-left)/Sqrt2/RMSInt
101  AreaL = MyErf(argL)
102  else:
103  AreaL = AreaLnew
104  AreaLnew = AreaR # save R bin value for L next time
105 
106  NewProb = (AreaL-AreaR)*0.5
107 
108  ProbFromRMS.append(NewProb)
109 
110  #print left, right, argL, argR, AreaL, AreaR, NewProb
111 
112  else:
113  obs = hist.FindBin(AveNumInt)
114  for bin in range (Nbins):
115  ProbFromRMS.append(0.0)
116  if obs<Nbins+1:
117  ProbFromRMS[obs] = 1.0
118  if AveNumInt < 1.0E-5:
119  ProbFromRMS[obs] = 0. # just ignore zero values
120 
121  if calcOption == 'true': # Just put distribution into histogram
122  if RMSInt > 0:
123  totalProb = 0
124  for obs in range (Nbins):
125  prob = ProbFromRMS[obs]
126  val = hist.GetBinCenter(obs+1)
127  #print obs, val, RMSInt,coeff,expon,prob
128  totalProb += prob
129  hist.Fill (val, prob * LSintLumi)
130 
131  if 1.0-totalProb > 0.01:
132  print("Run %d, LS %d: Significant probability density outside of your histogram (mean %.2f," % (run, ls, AveNumInt))
133  print("rms %.2f, integrated probability %.3f). Consider using a higher value of --maxPileupBin." % (RMSInt, totalProb))
134  else:
135  hist.Fill(AveNumInt,LSintLumi)
136  else: # have to convolute with a poisson distribution to get observed Nint
137  totalProb = 0
138  Peak = 0
139  BinWidth = hist.GetBinWidth(1)
140  for obs in range (Nbins):
141  Peak = hist.GetBinCenter(obs+1)
142  RMSWeight = ProbFromRMS[obs]
143  for bin in range (Nbins):
144  val = hist.GetBinCenter(bin+1)-0.5*BinWidth
145  prob = ROOT.TMath.Poisson (val, Peak)
146  totalProb += prob
147  hist.Fill (val, prob * LSintLumi * RMSWeight)
148 
149  if 1.0-totalProb > 0.01:
150  print("Run %d, LS %d: significant probability density outside of your histogram" % (run, ls))
151  print("Consider using a higher value of --maxPileupBin")
152 
153 
154  return hist
155 
156 
157 

References MyErf(), print(), and mathSSE.sqrt().

◆ MyErf()

def pileupCalc.MyErf (   input)

Definition at line 24 of file pileupCalc.py.

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

References funct.abs(), and JetChargeProducer_cfi.exp.

Referenced by fillPileupHistogram().

◆ 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')
17  inputfilecontent=selectf.read()
18  p=pileupParser.pileupParser(inputfilecontent)
19 
20 # p=inputFilesetParser.inputFilesetParser(inputfilename)
21  runlsbyfile=p.runsandls()
22  return runlsbyfile
23 

Variable Documentation

◆ action

pileupCalc.action

Definition at line 172 of file pileupCalc.py.

◆ choices

pileupCalc.choices

Definition at line 179 of file pileupCalc.py.

◆ default

pileupCalc.default

Definition at line 183 of file pileupCalc.py.

◆ description

pileupCalc.description

Definition at line 168 of file pileupCalc.py.

◆ dest

pileupCalc.dest

Definition at line 173 of file pileupCalc.py.

◆ float

pileupCalc.float

Definition at line 183 of file pileupCalc.py.

◆ help

pileupCalc.help

Definition at line 172 of file pileupCalc.py.

◆ histFile

pileupCalc.histFile

Definition at line 250 of file pileupCalc.py.

◆ inpf

pileupCalc.inpf

Definition at line 215 of file pileupCalc.py.

◆ inputfilecontent

pileupCalc.inputfilecontent

Definition at line 216 of file pileupCalc.py.

◆ inputPileupRange

pileupCalc.inputPileupRange

Definition at line 221 of file pileupCalc.py.

◆ inputRange

pileupCalc.inputRange

◆ int

pileupCalc.int

Definition at line 186 of file pileupCalc.py.

◆ LSPUlist

pileupCalc.LSPUlist

Definition at line 231 of file pileupCalc.py.

◆ lumiInfo

pileupCalc.lumiInfo

Definition at line 236 of file pileupCalc.py.

Referenced by operator<<().

◆ nbins

pileupCalc.nbins

Definition at line 212 of file pileupCalc.py.

◆ options

pileupCalc.options

Definition at line 194 of file pileupCalc.py.

◆ output

pileupCalc.output

Definition at line 195 of file pileupCalc.py.

◆ parser

pileupCalc.parser

autotoc_md311

## Main Program

autotoc_md313

Definition at line 168 of file pileupCalc.py.

◆ pileupHist

pileupCalc.pileupHist

Definition at line 208 of file pileupCalc.py.

◆ req_group

pileupCalc.req_group

Definition at line 171 of file pileupCalc.py.

◆ required

pileupCalc.required

Definition at line 173 of file pileupCalc.py.

◆ type

pileupCalc.type

Definition at line 183 of file pileupCalc.py.

◆ upper

pileupCalc.upper

◆ VERSION

pileupCalc.VERSION

Definition at line 4 of file pileupCalc.py.

pileupParser.pileupParser
Definition: pileupParser.py:4
pileupCalc.MyErf
def MyErf(input)
Definition: pileupCalc.py:24
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
pileupCalc.fillPileupHistogram
def fillPileupHistogram(lumiInfo, calcOption, hist, minbXsec, Nbins, run, ls)
Definition: pileupCalc.py:56
pileupCalc.parseInputFile
def parseInputFile(inputfilename)
Definition: pileupCalc.py:12
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6