CMS 3D CMS Logo

Classes | Functions | Variables
lumiCorrections Namespace Reference

Classes

class  correctionTerm
 
class  nonlinearSingle
 
class  nonlinearV2
 
class  nonlinearV3
 

Functions

def afterglowByFillscheme (fillscheme, afterglowPatterns)
 
def applyfinecorrectionBXV2 (bxlumi, avglumi, norm, constfactor, afterglowfactor, ncollidingbx, nonlinear_1, nonlinear_2, driftfactor)
 
def applyfinecorrectionV2 (avglumi, constfactor, afterglowfactor, ncollidingbx, nonlinear_1, nonlinear_2, driftfactor)
 
def correctionsForRangeV2 (schema, inputRange, correctionTerm)
 
def driftcorrectionsForRange (schema, inputRange, correctionTerm, startrun=160403)
 
def pixelcorrectionsForRange (schema, inputRange)
 

Variables

 authpath
 
 cpp2sqltype
 
 debugON
 
 driftresult
 
 isReadOnly
 
 myconstr
 
 schema
 
 session
 
 svc
 
 True
 

Function Documentation

def lumiCorrections.afterglowByFillscheme (   fillscheme,
  afterglowPatterns 
)
search in the list of (pattern,afterglowfactor) for a match in regex

Definition at line 22 of file lumiCorrections.py.

Referenced by correctionsForRangeV2(), and pixelcorrectionsForRange().

22 def afterglowByFillscheme(fillscheme,afterglowPatterns):
23  '''
24  search in the list of (pattern,afterglowfactor) for a match in regex
25  '''
26  for (apattern,cfactor) in afterglowPatterns:
27  if re.match(apattern,fillscheme):
28  return cfactor
29  return 1.0
30 
31 #=======================================================================================================
32 #below : correction formula version_2
33 #======================================================================================================
def afterglowByFillscheme(fillscheme, afterglowPatterns)
def lumiCorrections.applyfinecorrectionBXV2 (   bxlumi,
  avglumi,
  norm,
  constfactor,
  afterglowfactor,
  ncollidingbx,
  nonlinear_1,
  nonlinear_2,
  driftfactor 
)

Definition at line 85 of file lumiCorrections.py.

References objects.autophobj.float.

85 def applyfinecorrectionBXV2(bxlumi,avglumi,norm,constfactor,afterglowfactor,ncollidingbx,nonlinear_1,nonlinear_2,driftfactor):
86  if bxlumi<=0:#do nothing about the negative bx lumi
87  return bxlumi
88  correctbxlumi=bxlumi*norm*constfactor*afterglowfactor*driftfactor
89  if ncollidingbx and ncollidingbx!=0:
90  dldt=avglumi/float(ncollidingbx)
91  nonlinearTerm=1.0+nonlinear_1*dldt+nonlinear_2*dldt*dldt
92  correctbxlumi=correctbxlumi/nonlinearTerm
93  #print 'avglumi,nonlinearfactor,nonlinearTerm ',avglumi,nonlinearfactor,nonlinearTerm
94  #print 'bxlumi,avglumi,norm,const,after',bxlumi,avglumi,norm,constfactor,afterglowfactor,correctbxlumi
95  return correctbxlumi
96 
def applyfinecorrectionBXV2(bxlumi, avglumi, norm, constfactor, afterglowfactor, ncollidingbx, nonlinear_1, nonlinear_2, driftfactor)
def lumiCorrections.applyfinecorrectionV2 (   avglumi,
  constfactor,
  afterglowfactor,
  ncollidingbx,
  nonlinear_1,
  nonlinear_2,
  driftfactor 
)
input :
     avglumi : normalized lumi with 6370
     constfactor,afterglowfactor,ncollidingbx,nonlinear_1,nonlinear_2
     driftfactor: default

Definition at line 97 of file lumiCorrections.py.

References objects.autophobj.float.

97 def applyfinecorrectionV2(avglumi,constfactor,afterglowfactor,ncollidingbx,nonlinear_1,nonlinear_2,driftfactor):
98  '''
99  input :
100  avglumi : normalized lumi with 6370
101  constfactor,afterglowfactor,ncollidingbx,nonlinear_1,nonlinear_2
102  driftfactor: default
103  '''
104  #print avglumi,constfactor,afterglowfactor,ncollidingbx,nonlinear_1,nonlinear_2,driftfactor
105  instlumi=avglumi*afterglowfactor*constfactor*driftfactor
106  if ncollidingbx and ncollidingbx!=0:
107  dldt=avglumi/float(ncollidingbx)
108  nonlinearTerm=1.0+nonlinear_1*dldt+nonlinear_2*dldt*dldt
109  instlumi=instlumi/nonlinearTerm
110  #print 'avglumi,const,after,nonlinear,instlumi ',avglumi,constfactor,afterglowfactor,nonlinearfactor,instlumi
111  return instlumi
112 
def applyfinecorrectionV2(avglumi, constfactor, afterglowfactor, ncollidingbx, nonlinear_1, nonlinear_2, driftfactor)
def lumiCorrections.correctionsForRangeV2 (   schema,
  inputRange,
  correctionTerm 
)
decide on the corrections to apply in the input range depending on amodetag,egev and runrange
select fillschemepattern,correctionfactor from fillscheme; 
   [(fillschemepattern,afterglow),...]
select fillnum,runnum,fillscheme,ncollidingbunches,egev from cmsrunsummary where amodetag='PROTPYHS' and egev>3000
    {runnum: (fillnum,fillscheme,ncollidingbunches),...}
input: correctionTerm correction terms used in the formula
output:
    {runnum:(constantfactor,afterglowfactor,ncollidingbx,nonlinearfactor1,nonlinearfactor2)}

Definition at line 113 of file lumiCorrections.py.

References afterglowByFillscheme(), nameDealer.cmsrunsummaryTableName(), data, nameDealer.fillschemeTableName(), createfilelist.int, and GetRecoTauVFromDQM_MC_cff.next.

113 def correctionsForRangeV2(schema,inputRange,correctionTerm):
114  '''
115  decide on the corrections to apply in the input range depending on amodetag,egev and runrange
116  select fillschemepattern,correctionfactor from fillscheme;
117  [(fillschemepattern,afterglow),...]
118  select fillnum,runnum,fillscheme,ncollidingbunches,egev from cmsrunsummary where amodetag='PROTPYHS' and egev>3000
119  {runnum: (fillnum,fillscheme,ncollidingbunches),...}
120  input: correctionTerm correction terms used in the formula
121  output:
122  {runnum:(constantfactor,afterglowfactor,ncollidingbx,nonlinearfactor1,nonlinearfactor2)}
123  '''
124  runs=[]
125  result={}
126  constfactor=1.0 #default
127  afterglow=1.0 #default
128  ncollidingbunches=0 #default
129  nonlinear_1=1.0 #default
130  nonlinear_2=1.0 #default
131  if isinstance(inputRange,str):
132  runs.append(int(inputRange))
133  else:
134  runs=inputRange
135  for r in runs:
136  if r<150008 :
137  result[r]=(constfactor,afterglow,ncollidingbunches,nonlinear_1, nonlinear_2)
138  afterglows=[]
141  qHandle=schema.newQuery()
142  try:
143  qHandle.addToTableList(s)
144  qResult=coral.AttributeList()
145  qResult.extend('FILLSCHEMEPATTERN','string')
146  qResult.extend('CORRECTIONFACTOR','float')
147  qHandle.defineOutput(qResult)
148  qHandle.addToOutputList('FILLSCHEMEPATTERN')
149  qHandle.addToOutputList('CORRECTIONFACTOR')
150  cursor=qHandle.execute()
151  while next(cursor):
152  fillschemePattern=cursor.currentRow()['FILLSCHEMEPATTERN'].data()
153  afterglowfac=cursor.currentRow()['CORRECTIONFACTOR'].data()
154  afterglows.append((fillschemePattern,afterglowfac))
155  except :
156  del qHandle
157  raise
158  del qHandle
159  qHandle=schema.newQuery()
160  try:
161  qHandle.addToTableList(r)
162  qHandle.addToOutputList('FILLNUM', 'fillnum')
163  qHandle.addToOutputList('RUNNUM', 'runnum')
164  qHandle.addToOutputList('FILLSCHEME','fillscheme')
165  qHandle.addToOutputList('NCOLLIDINGBUNCHES','ncollidingbunches')
166  qResult=coral.AttributeList()
167  qResult.extend('fillnum','unsigned int')
168  qResult.extend('runnum','unsigned int')
169  qResult.extend('fillscheme','string')
170  qResult.extend('ncollidingbunches','unsigned int')
171  qConditionStr='AMODETAG=:amodetag AND EGEV>=:egev'#filter out lowenergy and non-proton runs
172  qCondition=coral.AttributeList()
173  qCondition.extend('amodetag','string')
174  qCondition.extend('egev','unsigned int')
175  qCondition['amodetag'].setData('PROTPHYS')
176  qCondition['egev'].setData(3000)
177  qHandle.defineOutput(qResult)
178  qHandle.setCondition(qConditionStr,qCondition)
179  cursor=qHandle.execute()
180  while next(cursor):
181  runnum=cursor.currentRow()['runnum'].data()
182  #print 'runnum ',runnum
183  if runnum not in runs or runnum in result:
184  continue
185  fillnum=cursor.currentRow()['fillnum'].data()
186  afterglow=1.0
187  constfactor=correctionTerm.constfactor
188  nonlinear_1=correctionTerm.t1
189  nonlinear_2=correctionTerm.t2
190  ncollidingbunches=0
191  if cursor.currentRow()['ncollidingbunches']:
192  ncollidingbunches=cursor.currentRow()['ncollidingbunches'].data()
193  fillscheme=''
194  if cursor.currentRow()['fillscheme']:
195  fillscheme=cursor.currentRow()['fillscheme'].data()
196  if fillscheme and len(fillscheme)!=0:
197  if fillnum>=2124: #afterglow'salready applied by lumidaq in hf root for fill<2124
198  afterglow=afterglowByFillscheme(fillscheme,afterglows)
199  result[runnum]=(constfactor,afterglow,ncollidingbunches,nonlinear_1,nonlinear_2)
200  except :
201  del qHandle
202  raise
203  del qHandle
204  for run in runs:
205  if run not in result.keys():
206  result[run]=(constfactor,afterglow,ncollidingbunches,nonlinear_1,nonlinear_2)
207  return result
208 #=======================================================================================================
209 #below : below correction formula version_1, default untill April 2012, no more used.
210 #======================================================================================================
211 #def applyfinecorrectionBX(bxlumi,avglumi,norm,constfactor,afterglowfactor,nonlinearfactor):
212 # if bxlumi<=0:
213 # return bxlumi
214 # correctbxlumi=bxlumi*norm*constfactor*afterglowfactor
215 # if constfactor!=1.0 and nonlinearfactor!=0:
216 # if avglumi<0:
217 # avglumi=0.0
218 # nonlinearTerm=1.0+avglumi*nonlinearfactor#0.076/ncollidinbunches
219 # correctbxlumi=correctbxlumi/nonlinearTerm
220 # #print 'avglumi,nonlinearfactor,nonlinearTerm ',avglumi,nonlinearfactor,nonlinearTerm
221 # #print 'bxlumi,avglumi,norm,const,after',bxlumi,avglumi,norm,constfactor,afterglowfactor,correctbxlumi
222 # return correctbxlumi
223 
224 #def applyfinecorrection(avglumi,constfactor,afterglowfactor,nonlinearfactor):
225 # instlumi=avglumi*afterglowfactor*constfactor
226 # if nonlinearfactor!=0 and constfactor!=1.0:
227 # nonlinearTerm=1.0+avglumi*nonlinearfactor#0.076/ncollidinbunches
228 # instlumi=instlumi/nonlinearTerm
229 # #print 'avglumi,const,after,nonlinear,instlumi ',avglumi,constfactor,afterglowfactor,nonlinearfactor,instlumi
230 # return instlumi
231 
232 #def correctionsForRange(schema,inputRange,correctionTerm):
233 # '''
234 # select fillschemepattern,correctionfactor from fillscheme;
235 # [(fillschemepattern,afterglow),...]
236 # select fillnum,runnum,fillscheme,ncollidingbunches,egev from cmsrunsummary where amodetag='PROTPYHS' and egev>3000
237 # {runnum: (fillnum,fillscheme,ncollidingbunches),...}
238 # output:
239 # {runnum:(constantfactor,afterglowfactor,nonlinearfactor)}
240 # '''
241 # runs=[]
242 # result={}
243 # if isinstance(inputRange,str):
244 # runs.append(int(inputRange))
245 # else:
246 # runs=inputRange
247 # for r in runs:
248 # if r<150008 :
249 # result[r]=(1.0,1.0,0.0)
250 # afterglows=[]
251 # constfactor=correctionTerm.constfactor
252 # s=nameDealer.fillschemeTableName()
253 # r=nameDealer.cmsrunsummaryTableName()
254 # qHandle=schema.newQuery()
255 # try:
256 # qHandle.addToTableList(s)
257 # qResult=coral.AttributeList()
258 # qResult.extend('FILLSCHEMEPATTERN','string')
259 # qResult.extend('CORRECTIONFACTOR','float')
260 # qHandle.defineOutput(qResult)
261 # qHandle.addToOutputList('FILLSCHEMEPATTERN')
262 # qHandle.addToOutputList('CORRECTIONFACTOR')
263 # cursor=qHandle.execute()
264 # while cursor.next():
265 # fillschemePattern=cursor.currentRow()['FILLSCHEMEPATTERN'].data()
266 # afterglowfac=cursor.currentRow()['CORRECTIONFACTOR'].data()
267 # afterglows.append((fillschemePattern,afterglowfac))
268 # except :
269 # del qHandle
270 # raise
271 # del qHandle
272 # qHandle=schema.newQuery()
273 # try:
274 # qHandle.addToTableList(r)
275 # qHandle.addToOutputList('FILLNUM', 'fillnum')
276 # qHandle.addToOutputList('RUNNUM', 'runnum')
277 # qHandle.addToOutputList('FILLSCHEME','fillscheme')
278 # qHandle.addToOutputList('NCOLLIDINGBUNCHES','ncollidingbunches')
279 # qResult=coral.AttributeList()
280 # qResult.extend('fillnum','unsigned int')
281 # qResult.extend('runnum','unsigned int')
282 # qResult.extend('fillscheme','string')
283 # qResult.extend('ncollidingbunches','unsigned int')
284 # qConditionStr='AMODETAG=:amodetag AND EGEV>=:egev'
285 # qCondition=coral.AttributeList()
286 # qCondition.extend('amodetag','string')
287 # qCondition.extend('egev','unsigned int')
288 # qCondition['amodetag'].setData('PROTPHYS')
289 # qCondition['egev'].setData(3000)
290 # qHandle.defineOutput(qResult)
291 # qHandle.setCondition(qConditionStr,qCondition)
292 # cursor=qHandle.execute()
293 # while cursor.next():
294 # runnum=cursor.currentRow()['runnum'].data()
295 # #print 'runnum ',runnum
296 # if runnum not in runs or result.has_key(runnum):
297 # continue
298 # fillnum=cursor.currentRow()['fillnum'].data()
299 # constfactor=correctionTerm.constfactor
300 # afterglow=1.0
301 # nonlinear=correctionTerm.t1
302 # nonlinearPerBX=0.0
303 # ncollidingbunches=0
304 # if cursor.currentRow()['ncollidingbunches']:
305 # ncollidingbunches=cursor.currentRow()['ncollidingbunches'].data()
306 # fillscheme=''
307 # if cursor.currentRow()['fillscheme']:
308 # fillscheme=cursor.currentRow()['fillscheme'].data()
309 # if fillscheme and len(fillscheme)!=0:
310 # afterglow=afterglowByFillscheme(fillscheme,afterglows)
311 # if ncollidingbunches and ncollidingbunches!=0:
312 # nonlinearPerBX=float(1)/float(ncollidingbunches)
313 # nonlinear=nonlinearPerBX*nonlinear
314 # result[runnum]=(constfactor,afterglow,nonlinear)
315 # except :
316 # del qHandle
317 # raise
318 # del qHandle
319 # for run in runs:
320 # if run not in result.keys():
321 # result[run]=(1.0,1.0,0.0) #those have no fillscheme 2011 runs
322 # return result
323 #=======================================================================================================
324 #below : correction on pixellumi, afterglow only
325 #======================================================================================================
def afterglowByFillscheme(fillscheme, afterglowPatterns)
def fillschemeTableName()
Definition: nameDealer.py:13
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def cmsrunsummaryTableName()
Definition: nameDealer.py:16
def correctionsForRangeV2(schema, inputRange, correctionTerm)
def lumiCorrections.driftcorrectionsForRange (   schema,
  inputRange,
  correctionTerm,
  startrun = 160403 
)
select intglumi from intglumi where runnum=:runnum and startrun=:startrun
input : inputRange. str if a single run, [runs] if a list of runs
output: {run:driftcorrection}

Definition at line 34 of file lumiCorrections.py.

References data, createfilelist.int, nameDealer.intglumiTableName(), GetRecoTauVFromDQM_MC_cff.next, and edm.print().

34 def driftcorrectionsForRange(schema,inputRange,correctionTerm,startrun=160403):
35  '''
36  select intglumi from intglumi where runnum=:runnum and startrun=:startrun
37  input : inputRange. str if a single run, [runs] if a list of runs
38  output: {run:driftcorrection}
39  '''
40  result={}
41  runs=[]
42  if isinstance(inputRange,str):
43  runs.append(int(inputRange))
44  else:
45  runs=inputRange
46  for r in runs:
47  defaultresult=1.0
48  intglumi=0.0
49  lint=0.0
50  if r<150008 :# no drift corrections for 2010 data
51  result[r]=defaultresult
52  continue
53  if r>189738: # no drift correction for 2012 data
54  result[r]=defaultresult
55  continue
56  qHandle=schema.newQuery()
57  try:
58  qHandle.addToTableList(nameDealer.intglumiTableName())
59  qResult=coral.AttributeList()
60  qResult.extend('INTGLUMI','float')
61  qHandle.addToOutputList('INTGLUMI')
62  qConditionStr='RUNNUM=:runnum AND STARTRUN=:startrun'
63  qCondition=coral.AttributeList()
64  qCondition.extend('runnum','unsigned int')
65  qCondition.extend('startrun','unsigned int')
66  qCondition['runnum'].setData(int(r))
67  qCondition['startrun'].setData(int(startrun))
68  qHandle.setCondition(qConditionStr,qCondition)
69  qHandle.defineOutput(qResult)
70  cursor=qHandle.execute()
71  while next(cursor):
72  intglumi=cursor.currentRow()['INTGLUMI'].data()
73  lint=intglumi*6.37*1.0e-9 #(convert to /fb)
74  #print lint
75  except :
76  del qHandle
77  raise
78  del qHandle
79  if not lint:
80  print('[WARNING] null intglumi for run ',r,' ')
81  result[r]=defaultresult+correctionTerm.drift*lint
82  #print 'lint ',lint,' result ',result
83  return result
84 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def intglumiTableName()
Definition: nameDealer.py:88
def driftcorrectionsForRange(schema, inputRange, correctionTerm, startrun=160403)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def lumiCorrections.pixelcorrectionsForRange (   schema,
  inputRange 
)
select fillschemepattern,correctionfactor from fillscheme; 
   [(fillschemepattern,afterglow),...]
select fillnum,runnum,fillscheme from cmsrunsummary where amodetag='PROTPHYS' 
    {runnum: (fillnum,fillscheme),...}
output:
    {runnum:(afterglowfactor)}

Definition at line 326 of file lumiCorrections.py.

References afterglowByFillscheme(), nameDealer.cmsrunsummaryTableName(), data, nameDealer.fillschemeTableName(), createfilelist.int, and GetRecoTauVFromDQM_MC_cff.next.

326 def pixelcorrectionsForRange(schema,inputRange):
327  '''
328  select fillschemepattern,correctionfactor from fillscheme;
329  [(fillschemepattern,afterglow),...]
330  select fillnum,runnum,fillscheme from cmsrunsummary where amodetag='PROTPHYS'
331  {runnum: (fillnum,fillscheme),...}
332  output:
333  {runnum:(afterglowfactor)}
334  '''
335  runs=[]
336  result={}
337  if isinstance(inputRange,str):
338  runs.append(int(inputRange))
339  else:
340  runs=inputRange
341  afterglows=[]
344  qHandle=schema.newQuery()
345  try:
346  qHandle.addToTableList(s)
347  qResult=coral.AttributeList()
348  qResult.extend('FILLSCHEMEPATTERN','string')
349  qResult.extend('PIXELCORRECTIONFACTOR','float')
350  qHandle.defineOutput(qResult)
351  qHandle.addToOutputList('FILLSCHEMEPATTERN')
352  qHandle.addToOutputList('PIXELCORRECTIONFACTOR')
353  cursor=qHandle.execute()
354  while next(cursor):
355  fillschemePattern=cursor.currentRow()['FILLSCHEMEPATTERN'].data()
356  afterglowfac=cursor.currentRow()['PIXELCORRECTIONFACTOR'].data()
357  afterglows.append((fillschemePattern,afterglowfac))
358  except :
359  del qHandle
360  raise
361  del qHandle
362  qHandle=schema.newQuery()
363  try:
364  qConditionStr='FILLNUM>:minfillnum'
365  qCondition=coral.AttributeList()
366  qCondition.extend('minfillnum','unsigned int')
367  qCondition['minfillnum'].setData(1600)
368  qHandle.addToTableList(r)
369  qHandle.addToOutputList('FILLNUM', 'fillnum')
370  qHandle.addToOutputList('RUNNUM', 'runnum')
371  qHandle.addToOutputList('FILLSCHEME','fillscheme')
372  qResult=coral.AttributeList()
373  qResult.extend('fillnum','unsigned int')
374  qResult.extend('runnum','unsigned int')
375  qResult.extend('fillscheme','string')
376  qHandle.setCondition(qConditionStr,qCondition)
377  qHandle.defineOutput(qResult)
378  cursor=qHandle.execute()
379  while next(cursor):
380  runnum=cursor.currentRow()['runnum'].data()
381  if runnum not in runs or runnum in result:
382  continue
383  fillnum=cursor.currentRow()['fillnum'].data()
384  afterglow=1.0
385  fillscheme=''
386  if cursor.currentRow()['fillscheme']:
387  fillscheme=cursor.currentRow()['fillscheme'].data()
388  if fillscheme and len(fillscheme)!=0:
389  afterglow=afterglowByFillscheme(fillscheme,afterglows)
390  result[runnum]=afterglow
391  except :
392  del qHandle
393  raise
394  del qHandle
395  for run in runs:
396  if run not in result.keys():
397  result[run]=1.0 #those have no fillscheme
398  return result
399 
def pixelcorrectionsForRange(schema, inputRange)
def afterglowByFillscheme(fillscheme, afterglowPatterns)
def fillschemeTableName()
Definition: nameDealer.py:13
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def cmsrunsummaryTableName()
Definition: nameDealer.py:16

Variable Documentation

lumiCorrections.authpath

Definition at line 404 of file lumiCorrections.py.

lumiCorrections.cpp2sqltype

Definition at line 405 of file lumiCorrections.py.

lumiCorrections.debugON

Definition at line 404 of file lumiCorrections.py.

lumiCorrections.driftresult

Definition at line 409 of file lumiCorrections.py.

lumiCorrections.isReadOnly

Definition at line 405 of file lumiCorrections.py.

lumiCorrections.myconstr

Definition at line 403 of file lumiCorrections.py.

lumiCorrections.schema

Definition at line 407 of file lumiCorrections.py.

lumiCorrections.session

Definition at line 405 of file lumiCorrections.py.

lumiCorrections.svc

Definition at line 404 of file lumiCorrections.py.

lumiCorrections.True

Definition at line 405 of file lumiCorrections.py.