69 def setCalibration(self, calibPayload):
70 self.nPar = calibPayload['NumOfParameters']
71 self.fType = calibPayload['Function']
72 self.muToLumi = calibPayload['MuToLumi']
73 blob = calibPayload['Parameters']
74 s=blob.read()
75 self.parVec = bConvertList(s, 4, self.nPar)
76
77 if self.verbose:
78 print(
'LumiCalibrator.setCalibration for %s found %d parameters: ' % (self.fType, self.nPar))
80 print(
' muToLumi = %f' % self.muToLumi)
81
82
83 algname = self.fType
84 polyPos = algname.find("_PolyCorr")
85 currPos = algname.find("_CurrCorr")
86
87 if polyPos > 0 and currPos > 0:
88 algname = algname[:-18]
89 elif polyPos > 0 or currPos > 0:
90 algname = algname[:-9]
91
92 if self.verbose:
93 print(
'LumiCalibrator.setCalibration - Found poly: %d curr: %d' % (polyPos, currPos))
94
95 if polyPos > currPos:
96
97 if self.verbose:
98 print(
'LumiCalibrator.setCalibration - reading polynomial from', self.parVec[-4:-1])
99
100 self.polyParC = self.parVec.pop()
101 self.polyParB = self.parVec.pop()
102 self.polyParA = self.parVec.pop()
103 self.polyVersion = self.parVec.pop()
104 self.nPar -= 4
105
106 if currPos > 0:
107
108
109 self.calibrate(0.1)
110 npar = self.nParUsed
111 self.currType = 1
112
113 self.currVersion = int(self.parVec[npar])
114 if self.verbose:
115 print(
'LumiCalibrator.setCalibration - found %d parameters in %s' % (npar, algname))
116 print(
'LumiCalibrator.setCalibration - reading current vers %d from position %d' % (self.currVersion, npar))
117
118 if self.currVersion == 4:
119 self.currType = int(self.parVec.pop())
120 self.nPar -= 1
121
122 if self.currVersion >= 3:
123 self.currParC = self.parVec.pop()
124 self.nPar -= 1
125
126 self.currParB = self.parVec.pop()
127 self.currParA = self.parVec.pop()
128 self.currVersion = self.parVec.pop()
129 self.nPar -= 3
130
131 if self.verbose:
132 print(
'LumiCalibrator.setCalibration found current correction %d type %d' % (self.currVersion, self.currType))
133
134 elif currPos > polyPos:
135
136
137 self.calibrate(0.1)
138 npar = self.nParUsed
139 self.currType = 1
140
141 if self.verbose:
142 print(
'LumiCalibrator.setCalibration - found %d parameters in %s' % (npar, algname))
143 if polyPos > 0:
144 npar += 4
145
146 self.currVersion = int(self.parVec[npar])
147
148 if self.verbose:
149 print(
'LumiCalibrator.setCalibration - reading current vers %d from position %d' % (self.currVersion, npar))
150
151 if self.currVersion == 4:
152 self.currType = int(self.parVec.pop())
153 self.nPar -= 1
154
155 if self.currVersion >= 3:
156 self.currParC = self.parVec.pop()
157 self.nPar -= 1
158
159 self.currParB = self.parVec.pop()
160 self.currParA = self.parVec.pop()
161 self.currVersion = self.parVec.pop()
162 self.nPar -= 3
163
164 if self.verbose:
165 print(
'LumiCalibrator.setCalibration found current correction %d type %d' % (self.currVersion, self.currType))
166
167 if polyPos > 0:
168 if self.verbose:
169 print(
'LumiCalibrator.setCalibration - reading polynomial from list' , self.parVec[-4:])
170
171 self.polyParC = self.parVec.pop()
172 self.polyParB = self.parVec.pop()
173 self.polyParA = self.parVec.pop()
174 self.polyVersion = self.parVec.pop()
175 self.nPar -= 4
176
177