ATLAS Offline Software
Loading...
Searching...
No Matches
defineBlockAndAlg.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3#
4# @file egammaD3PDMaker/python/defineBlockAndAlg.py
5# @author scott snyder <snyder@bnl.gov>
6# @date Nov, 2011
7# @brief Helper to schedule an algorithm only if a block is included.
8#
9
10
11def defineAlgLODFunc (level, alg):
12 """Return a level-of-detail function that also schedules an algorithm.
13
14 LEVEL is the level of detail.
15
16 ALG is the name of the algorithm.
17"""
18
19 def lodfunc (reqlev, blockargs, hookargs):
20 if reqlev < level: return False
21 algmod = __import__ ('egammaD3PDAnalysis.' + alg + 'Config',
22 fromlist = [alg + 'Config'])
23 algfunc = getattr (algmod, alg + 'Cfg')
24 def hookfn (c, flags, acc, *args, **kw):
25 acc.merge (algfunc (flags,
26 prefix = hookargs['prefix'],
27 sgkey = hookargs['sgkey'],
28 typeName = hookargs['typeName'],
29 allowMissing = hookargs.get('allowMissing',False)))
30 return
31 hookargs['d3pdo'].defineHook (hookfn)
32 return True
33 return lodfunc
34
35def defineBlockAndAlg (d3pdo, level, blockname, blockfunc, alg,
36 **kw):
37 """Define a block, and schedule an algorithm if the block is used.
38
39 D3PDO is the D3PDObject for which the block should be defined.
40
41 LEVEL is the level of detail.
42
43 BLOCKNAME is the name of the block.
44
45 BLOCKFUNC is the function that creates the block.
46
47 ALG is the name of the algorithm.
48"""
49
50 lodfunc = defineAlgLODFunc (level, alg)
51 d3pdo.defineBlock (lodfunc, blockname, blockfunc, **kw)
52 return