199 **kw):
200
201
202 log = logging.getLogger ('CaloClusterCorrection')
203
204 tryhier = False
205
206
207
208 if version is None:
209
210
211 v = getattr (flags.Calo.ClusterCorrection, self.version_override_flag_name)
212 if v:
213 version = v
214
215 if version is None:
216
217
218
219 geom = flags.GeoModel.AtlasVersion
220 datasource = 'geant4' if flags.Input.isMC else 'data'
221 (version, tryhier) = self.geom_match (datasource, geom)
222
223
224 generation = self.get_generation(flags)
225
226
227 if source is None:
228 source = flags.Calo.ClusterCorrection.defaultSource
229
230 if not isinstance (source, list):
231 source = [source]
232 if CALOCORR_COOL not in source:
233 tryhier = False
234
235 if tryhier and version[0] != '@':
236 cl = corrclass
237 if flags.Input.isMC:
238 cl = cl[0:4] + 'Ofl' + cl[4:]
239 version = "@%s-%s%s" % (cl, generation, version)
240
241
242
243
244 if version[0] != '@' and len(source) > 0:
245 if CALOCORR_COOL in source:
246 source.remove (CALOCORR_COOL)
247
248 (vcorrlist, version) = self.lookup_version (flags, version, corrclass)
249
250
251 if corrlist is None:
252 corrlist = vcorrlist
253
254 log.debug ("%s corrections for %s (%s) using version %s" %
255 (self.name, key, suffix, version))
256
257
258 out = ComponentAccumulator()
259 tools = []
260 for cspec in corrlist:
261 (func, this_version, this_order, extra_args) = \
262 split_version_spec (cspec)
263
264
265
266 if this_version == '' or extra_args == []:
267 for vcspec in vcorrlist:
268 if vcspec[0] == func:
269 (vfunc, vversion, vorder, vextra_args) = \
270 split_version_spec (vcspec)
271 if this_version == '':
272 this_version = vversion
273 if extra_args == []:
274 extra_args = vextra_args
275 if this_order == 0:
276 this_order = vorder
277 break
278
279 elif version[0] == '@' and not corrlist:
280 this_version = version
281
282 if this_version == '@':
283 this_version = version
284
285
286 this_args = dict (extra_args)
287 this_key = key
288 this_suffix = suffix
289 this_cells_name = cells_name
290 this_source = source
291
292 corrname = func.__name__
293
294
295 for (k, v) in kw.items():
296 if k == corrname + '_suffix':
297 this_suffix = v
298 elif k == corrname + '_key':
299 this_key = v
300 elif k == corrname + '_cells_name':
301 this_cells_name = v
302 elif k == corrname + '_source':
303 this_source = v
304 elif k == corrname + '_version':
305 this_version = v
306 elif k == corrname + '_order':
307 this_order = v
308 elif k.startswith (corrname + '_'):
309 this_args[k[len(corrname)+1:]] = v
310
311
312 ca = func (flags,
313 this_cells_name,
314 this_suffix,
315 this_version,
316 this_key,
317 this_source,
318 generation = generation,
319 order = this_order,
320 **this_args)
321 tools.append (out.popToolsAndMerge (ca))
322
323 out.setPrivateTools (tools)
324 return out
325
326