4 luminorm and correction functions.
5 The result of the functions are correction factors, not final luminosity
6 all functions take 5 run time parameters, and arbituary named params
9 def fPoly(self,luminonorm,intglumi,nBXs,whatev,whatav,a0=1.0,a1=0.0,a2=0.0,drift=0.0,c1=0.0,afterglow=''):
11 input: luminonorm unit Hz/ub
12 output: correction factor to be applied on lumi in Hz/ub
16 avglumi=c1*luminonorm/nBXs
19 afterglowmap=ast.literal_eval(afterglow)
20 for (bxthreshold,correction)
in afterglowmap:
21 if nBXs >= bxthreshold :
22 Afterglow = correction
24 if drift
and intglumi:
25 driftterm=1.0+drift*intglumi
26 result=a0*Afterglow/(1+a1*avglumi+a2*avglumi*avglumi)*driftterm
29 def fPolyScheme(self,luminonorm,intglumi,nBXs,fillschemeStr,fillschemePatterns,a0=1.0,a1=0.0,a2=0.0,drift=0.0,c1=0.0):
31 input: luminonorm unit Hz/ub
32 input: fillschemePatterns [(patternStr,afterglow])
33 output: correction factor to be applied on lumi in Hz/ub
37 avglumi=c1*luminonorm/nBXs
39 if fillschemeStr
and fillschemePatterns:
40 for apattern,cfactor
in fillschemePatterns.items():
41 if re.match(apattern,fillschemeStr):
44 if drift
and intglumi:
45 driftterm=1.0+drift*intglumi
46 result=a0*Afterglow/(1+a1*avglumi+a2*avglumi*avglumi)*driftterm
52 myfunc=getattr(fac,funcName,
None)
53 except AttributeError:
54 print '[ERROR] unknown correction function '+funcName
57 return myfunc(*args,**kwds)
59 raise ValueError(
'uncallable function '+funcName)
60 if __name__ ==
'__main__':
62 luminonorm=0.5061*1.0e3
65 constParams={
'a0':1.0}
66 argvals=[luminonorm,intglumi,nBXs,0.0,0.0]
67 print 'no correction lumi in Hz/ub ',luminonorm*
normFunctionCaller(
'fPoly',*argvals,**constParams)
68 polyParams={
'a0':7.268,
'a1':0.063,
'a2':-0.0037,
'drift':0.01258,
'c1':6.37,
'afterglow':
'[(213,0.992), (321,0.99), (423,0.988), (597,0.985), (700,0.984), (873,0.981), (1041,0.979), (1179,0.977),(1317,0.975)]'}
69 print 'poly corrected lumi in Hz/ub',luminonorm*
normFunctionCaller(
'fPoly',*argvals,**polyParams)
70 polyParams={
'a0':7.268,
'a1':0.063,
'a2':-0.0037,
'drift':0.0,
'c1':6.37,
'afterglow':
'[(213,0.992), (321,0.99), (423,0.988), (597,0.985), (700,0.984), (873,0.981), (1041,0.979), (1179,0.977),(1317,0.975)]'}
71 print 'poly corrected without drift in Hz/ub ',luminonorm*
normFunctionCaller(
'fPoly',*argvals,**polyParams)
72 constParams={
'a0':7.268}
73 print 'const corrected lumi in Hz/ub',luminonorm*
normFunctionCaller(
'fPoly',*argvals,**constParams)