ATLAS Offline Software
Public Member Functions | Public Attributes | Private Attributes | List of all members
python.ConfigFactory.ConfigFactory Class Reference
Collaboration diagram for python.ConfigFactory.ConfigFactory:

Public Member Functions

def __init__ (self, addDefaultBlocks=True)
 
def addAlgConfigBlock (self, algName, alg, defaults=None, pos=None, superBlocks=None)
 
def printAlgs (self, printOpts=True)
 
def makeConfig (self, name, **kwargs)
 
def addDefaultAlgs (self)
 

Public Attributes

 ROOTNAME
 

Private Attributes

 _algs
 
 _order
 

Detailed Description

This class provides a configuration manager that is intended to allow the user to:
    - define and configure functions that return an algSequence(?) object

Definition at line 108 of file ConfigFactory.py.

Constructor & Destructor Documentation

◆ __init__()

def python.ConfigFactory.ConfigFactory.__init__ (   self,
  addDefaultBlocks = True 
)

Definition at line 112 of file ConfigFactory.py.

112  def __init__(self, addDefaultBlocks=True):
113  self.ROOTNAME = 'root' # constant
114  self._algs = {}
115  self._order = {self.ROOTNAME: []}
116  if addDefaultBlocks:
117  self.addDefaultAlgs()
118 
119 

Member Function Documentation

◆ addAlgConfigBlock()

def python.ConfigFactory.ConfigFactory.addAlgConfigBlock (   self,
  algName,
  alg,
  defaults = None,
  pos = None,
  superBlocks = None 
)
Add class to list of available algorithms

Definition at line 120 of file ConfigFactory.py.

120  def addAlgConfigBlock(self, algName, alg, defaults=None, pos=None, superBlocks=None):
121  """Add class to list of available algorithms"""
122  if not callable(alg):
123  raise ValueError(f"{algName} is not a callable.")
124  opts = getFuncArgs(alg)
125 
126  if superBlocks is None:
127  superBlocks = [self.ROOTNAME]
128  elif not isinstance(superBlocks, list):
129  superBlocks = [superBlocks]
130 
131  # add new alg block to subAlgs dict of super block
132  for block in superBlocks:
133  if block not in self._order:
134  self._order[block] = []
135  order = self._order[block]
136 
137  if block == self.ROOTNAME:
138  algs = self._algs
139  else:
140  if block not in self._algs:
141  raise ValueError(f"{block} not added")
142  algs = self._algs[block].subAlgs
143 
144  if alg in algs:
145  raise ValueError(f"{algName} has already been added.")
146 
147  # create FactoryBlock with alg information
148  algs[algName] = FactoryBlock(
149  alg=alg,
150  algName=algName,
151  options=opts,
152  defaults=defaults,
153  subAlgs={}
154  )
155  # insert into order (list)
156  if pos is None:
157  order.append(algName)
158  elif pos in order:
159  order.insert(order.index(pos), algName)
160  else:
161  raise ValueError(f"{pos} does not exit in already added config blocks")
162  return
163 
164 

◆ addDefaultAlgs()

def python.ConfigFactory.ConfigFactory.addDefaultAlgs (   self)
add algorithms and options

Definition at line 212 of file ConfigFactory.py.

212  def addDefaultAlgs(self):
213  """add algorithms and options"""
214 
215  # CommonServices
216  from AsgAnalysisAlgorithms.AsgAnalysisConfig import CommonServicesConfig
217  self.addAlgConfigBlock(algName="CommonServices", alg=CommonServicesConfig)
218 
219  # pileup reweighting
220  from AsgAnalysisAlgorithms.AsgAnalysisConfig import PileupReweightingBlock
221  self.addAlgConfigBlock(algName="PileupReweighting", alg=PileupReweightingBlock)
222 
223  # event cleaning
224  from AsgAnalysisAlgorithms.EventCleaningConfig import EventCleaningBlock
225  self.addAlgConfigBlock(algName="EventCleaning", alg=EventCleaningBlock)
226 
227  # trigger
228  from TriggerAnalysisAlgorithms.TriggerAnalysisConfig import Trigger
229  self.addAlgConfigBlock(algName="Trigger", alg=Trigger)
230  from TriggerAnalysisAlgorithms.TriggerAnalysisSFConfig import TriggerAnalysisSFBlock
231  self.addAlgConfigBlock(algName="TriggerMatching", alg=TriggerAnalysisSFBlock)
232 
233  # jets
234  from JetAnalysisAlgorithms.JetAnalysisConfig import makeJetAnalysisConfig
235  self.addAlgConfigBlock(algName="Jets", alg=makeJetAnalysisConfig)
236  from JetAnalysisAlgorithms.JetJvtAnalysisConfig import JetJvtAnalysisConfig
237  self.addAlgConfigBlock(algName="JVT", alg=JetJvtAnalysisConfig,
238  superBlocks="Jets")
239  from JetAnalysisAlgorithms.BJetCalibAnalysisConfig import BJetCalibAnalysisConfig
240  self.addAlgConfigBlock(algName="BJetCalib", alg=BJetCalibAnalysisConfig,
241  superBlocks="Jets")
242  from FTagAnalysisAlgorithms.FTagAnalysisConfig import FTagConfig
243  self.addAlgConfigBlock(algName="FlavourTagging", alg=FTagConfig,
244  defaults={'selectionName': ''},
245  superBlocks="Jets")
246  from FTagAnalysisAlgorithms.FTagEventSFAnalysisConfig import FTagEventSFConfig
247  self.addAlgConfigBlock(algName="FlavourTaggingEventSF",
248  alg=FTagEventSFConfig,
249  defaults={'selectionName': ''},
250  superBlocks="Jets")
251 
252  # electrons
253  from EgammaAnalysisAlgorithms.ElectronAnalysisConfig import ElectronCalibrationConfig
254  self.addAlgConfigBlock(algName="Electrons", alg=ElectronCalibrationConfig)
255  from EgammaAnalysisAlgorithms.ElectronAnalysisConfig import ElectronWorkingPointConfig
256  self.addAlgConfigBlock(algName="WorkingPoint", alg=ElectronWorkingPointConfig,
257  superBlocks="Electrons")
258  from EgammaAnalysisAlgorithms.ElectronAnalysisConfig import ElectronTriggerAnalysisSFBlock
259  self.addAlgConfigBlock(algName="TriggerSF", alg=ElectronTriggerAnalysisSFBlock,
260  superBlocks="Electrons")
261 
262  # photons
263  from EgammaAnalysisAlgorithms.PhotonAnalysisConfig import PhotonCalibrationConfig
264  self.addAlgConfigBlock(algName="Photons", alg=PhotonCalibrationConfig)
265  from EgammaAnalysisAlgorithms.PhotonAnalysisConfig import PhotonWorkingPointConfig
266  self.addAlgConfigBlock(algName="WorkingPoint", alg=PhotonWorkingPointConfig,
267  superBlocks="Photons")
268  from EgammaAnalysisAlgorithms.PhotonExtraVariablesConfig import PhotonExtraVariablesBlock
269  self.addAlgConfigBlock(algName="ExtraVariables", alg=PhotonExtraVariablesBlock,
270  superBlocks="Photons")
271 
272  # muons
273  from MuonAnalysisAlgorithms.MuonAnalysisConfig import MuonCalibrationConfig
274  self.addAlgConfigBlock(algName="Muons", alg=MuonCalibrationConfig)
275  from MuonAnalysisAlgorithms.MuonAnalysisConfig import MuonWorkingPointConfig
276  self.addAlgConfigBlock(algName="WorkingPoint", alg=MuonWorkingPointConfig,
277  superBlocks="Muons")
278  from MuonAnalysisAlgorithms.MuonAnalysisConfig import MuonTriggerAnalysisSFBlock
279  self.addAlgConfigBlock(algName="TriggerSF", alg=MuonTriggerAnalysisSFBlock,
280  superBlocks="Muons")
281 
282  # tauJets
283  from TauAnalysisAlgorithms.TauAnalysisConfig import TauCalibrationConfig
284  self.addAlgConfigBlock(algName="TauJets", alg=TauCalibrationConfig)
285  from TauAnalysisAlgorithms.TauAnalysisConfig import TauWorkingPointConfig
286  self.addAlgConfigBlock(algName="WorkingPoint", alg=TauWorkingPointConfig,
287  superBlocks="TauJets")
288  from TauAnalysisAlgorithms.TauAnalysisConfig import TauTriggerAnalysisSFBlock
289  self.addAlgConfigBlock(algName="TriggerSF", alg=TauTriggerAnalysisSFBlock,
290  superBlocks="TauJets")
291 
292  # SystObjectLink
293  from AsgAnalysisAlgorithms.SystObjectLinkConfig import SystObjectLinkBlock
294  self.addAlgConfigBlock(algName="SystObjectLink", alg=SystObjectLinkBlock,
295  superBlocks=[self.ROOTNAME, "Jets", "Electrons", "Photons", "Muons", "TauJets"])
296 
297  # Particle-level truth algorithms
298  from TruthParticleLevelAnalysisAlgorithms.ParticleLevelElectronsConfig import ParticleLevelElectronsBlock
299  self.addAlgConfigBlock(algName="PL_Electrons", alg=ParticleLevelElectronsBlock)
300  from TruthParticleLevelAnalysisAlgorithms.ParticleLevelMuonsConfig import ParticleLevelMuonsBlock
301  self.addAlgConfigBlock(algName="PL_Muons", alg=ParticleLevelMuonsBlock)
302  from TruthParticleLevelAnalysisAlgorithms.ParticleLevelNeutrinosConfig import ParticleLevelNeutrinosBlock
303  self.addAlgConfigBlock(algName="PL_Neutrinos", alg=ParticleLevelNeutrinosBlock)
304  from TruthParticleLevelAnalysisAlgorithms.ParticleLevelJetsConfig import ParticleLevelJetsBlock
305  self.addAlgConfigBlock(algName="PL_Jets", alg=ParticleLevelJetsBlock)
306  from TruthParticleLevelAnalysisAlgorithms.ParticleLevelTausConfig import ParticleLevelTausBlock
307  self.addAlgConfigBlock(algName="PL_Taus", alg=ParticleLevelTausBlock)
308  from TruthParticleLevelAnalysisAlgorithms.ParticleLevelPhotonsConfig import ParticleLevelPhotonsBlock
309  self.addAlgConfigBlock(algName="PL_Photons", alg=ParticleLevelPhotonsBlock)
310  from TruthParticleLevelAnalysisAlgorithms.ParticleLevelMissingETConfig import ParticleLevelMissingETBlock
311  self.addAlgConfigBlock(algName="PL_MissingET", alg=ParticleLevelMissingETBlock)
312  from TruthParticleLevelAnalysisAlgorithms.ParticleLevelOverlapRemovalConfig import ParticleLevelOverlapRemovalBlock
313  self.addAlgConfigBlock(algName="PL_OverlapRemoval", alg=ParticleLevelOverlapRemovalBlock)
314 
315  # IFF truth classification
316  from AsgAnalysisAlgorithms.AsgAnalysisConfig import IFFLeptonDecorationBlock
317  self.addAlgConfigBlock(algName="IFFClassification", alg=IFFLeptonDecorationBlock,
318  superBlocks=["Electrons", "Muons",
319  "PL_Electrons", "PL_Muons"])
320  # MCTC truth classification
321  from AsgAnalysisAlgorithms.AsgAnalysisConfig import MCTCLeptonDecorationBlock
322  self.addAlgConfigBlock(algName="MCTCClassification", alg=MCTCLeptonDecorationBlock,
323  superBlocks=["Electrons", "Muons", "TauJets",
324  "PL_Electrons", "PL_Muons", "PL_Taus"])
325 
326  # generator level analysis
327  from AsgAnalysisAlgorithms.AsgAnalysisConfig import GeneratorAnalysisBlock
328  self.addAlgConfigBlock(algName="GeneratorLevelAnalysis", alg=GeneratorAnalysisBlock)
329 
330  # pT/Eta Selection
331  from AsgAnalysisAlgorithms.AsgAnalysisConfig import PtEtaSelectionBlock
332  self.addAlgConfigBlock(algName="PtEtaSelection", alg=PtEtaSelectionBlock,
333  defaults={'selectionName': ''},
334  superBlocks=[self.ROOTNAME,
335  "Jets", "Electrons", "Photons", "Muons", "TauJets",
336  "PL_Jets", "PL_Electrons", "PL_Photons", "PL_Muons", "PL_Taus", "PL_Neutrinos"])
337 
338  # met
339  from MetAnalysisAlgorithms.MetAnalysisConfig import MetAnalysisConfig
340  self.addAlgConfigBlock(algName="MissingET", alg=MetAnalysisConfig)
341 
342  # overlap removal
343  from AsgAnalysisAlgorithms.OverlapAnalysisConfig import OverlapAnalysisConfig
344  self.addAlgConfigBlock(algName="OverlapRemoval", alg=OverlapAnalysisConfig,
345  defaults={'configName': 'OverlapRemoval'})
346 
347  # object-based cutflow
348  from AsgAnalysisAlgorithms.AsgAnalysisConfig import ObjectCutFlowBlock
349  self.addAlgConfigBlock(algName='ObjectCutFlow', alg=ObjectCutFlowBlock)
350 
351  # jet reclustering
352  from JetAnalysisAlgorithms.JetReclusteringConfig import JetReclusteringBlock
353  self.addAlgConfigBlock(algName="JetReclustering", alg=JetReclusteringBlock)
354 
355  # event selection
356  from EventSelectionAlgorithms.EventSelectionConfig import makeMultipleEventSelectionConfigs
357  self.addAlgConfigBlock(algName='EventSelection', alg=makeMultipleEventSelectionConfigs)
358 
359  # event-based cutflow
360  from AsgAnalysisAlgorithms.AsgAnalysisConfig import EventCutFlowBlock
361  self.addAlgConfigBlock(algName='EventCutFlow', alg=EventCutFlowBlock,
362  defaults={'containerName': 'EventInfo', 'selectionName': ''})
363 
364  # bootstraps
365  from AsgAnalysisAlgorithms.BootstrapGeneratorConfig import BootstrapGeneratorConfig
366  self.addAlgConfigBlock(algName='Bootstraps', alg=BootstrapGeneratorConfig)
367 
368  # per-event scale factor calculation
369  from AsgAnalysisAlgorithms.AsgAnalysisConfig import PerEventSFBlock
370  self.addAlgConfigBlock(algName='PerEventSF', alg=PerEventSFBlock)
371 
372  # per-event unified lepton scale factor calculation
373  from AsgAnalysisAlgorithms.LeptonSFCalculatorConfig import LeptonSFCalculatorBlock
374  self.addAlgConfigBlock(algName='LeptonSF', alg=LeptonSFCalculatorBlock)
375 
376  # thinning
377  from AsgAnalysisAlgorithms.AsgAnalysisConfig import OutputThinningBlock
378  self.addAlgConfigBlock(algName="Thinning", alg=OutputThinningBlock,
379  defaults={'configName': 'Thinning'})
380 
381  # selection decorations
382  from AsgAnalysisAlgorithms.AsgAnalysisConfig import SelectionDecorationBlock
383  self.addAlgConfigBlock(algName='SelectionDecoration',
384  alg=SelectionDecorationBlock)
385 
386  # di-tau mass calculator
387  from TauAnalysisAlgorithms.DiTauMassConfig import DiTauMassBlock
388  self.addAlgConfigBlock(algName="DiTauMMC", alg=DiTauMassBlock)
389 
390  # IFF fake background estimator
391  from AsgAnalysisAlgorithms.FakeBkgConfig import FakeBkgBlock
392  self.addAlgConfigBlock(algName='FakeBkgCalculator', alg=FakeBkgBlock)
393 
394  # VGamma overlap removal
395  from AsgAnalysisAlgorithms.VGammaORConfig import VGammaORBlock
396  self.addAlgConfigBlock(algName='VGammaOR', alg=VGammaORBlock)
397 
398  # output
399  from AsgAnalysisAlgorithms.OutputAnalysisConfig import OutputAnalysisConfig
400  self.addAlgConfigBlock(algName="Output", alg=OutputAnalysisConfig,
401  defaults={'configName': 'Output'})
402 
403  # IOStats printouts
404  from AsgAnalysisAlgorithms.AsgAnalysisConfig import IOStatsBlock
405  self.addAlgConfigBlock(algName="IOStats", alg=IOStatsBlock)
406 
407  return

◆ makeConfig()

def python.ConfigFactory.ConfigFactory.makeConfig (   self,
  name,
**  kwargs 
)
Returns:
    configSeq: configSequence object

Definition at line 195 of file ConfigFactory.py.

195  def makeConfig(self, name, **kwargs):
196  """
197  Returns:
198  configSeq: configSequence object
199  """
200  try:
201  if '.' in name:
202  algContext, algName = name.split('.')
203  block = self._algs[algContext].subAlgs[algName]
204  else:
205  block = self._algs[name]
206  except KeyError:
207  raise ValueError(f"{name} config block not found. Make sure context is correct.")
208  configSeq, _ = block.makeConfig(kwargs)
209  return configSeq
210 
211 

◆ printAlgs()

def python.ConfigFactory.ConfigFactory.printAlgs (   self,
  printOpts = True 
)
Prints algorithms exposed to configuration

Definition at line 165 of file ConfigFactory.py.

165  def printAlgs(self, printOpts=True):
166  """Prints algorithms exposed to configuration"""
167  printed = [] # some subblocks exist for multiple superblocks
168  def printAlg(algs):
169  for alg, algInfo in algs.items():
170  algName = algInfo.alg.__name__
171  algOptions = algInfo.options
172  if algName not in printed:
173  printed.append(algName)
174  logCPAlgCfgFactory.info(f"\033[4m{alg}\033[0m -> \033[4m{algName}\033[0m")
175  if printOpts:
176  try:
177  if inspect.isclass(algInfo.alg):
178  # block
179  algInfo.alg().printOptions(verbose=printOpts)
180  else:
181  # make function
182  seq = ConfigSequence()
183  algInfo.alg(seq=seq)
184  seq.printOptions(verbose=printOpts)
185  except Exception:
186  # either a TypeError or something else due to missing args
187  # try to print something for casses with required args
188  for opt in algOptions:
189  logCPAlgCfgFactory.info(f" {opt}")
190  printAlg(algInfo.subAlgs)
191  printAlg(self._algs)
192  return
193 
194 

Member Data Documentation

◆ _algs

python.ConfigFactory.ConfigFactory._algs
private

Definition at line 114 of file ConfigFactory.py.

◆ _order

python.ConfigFactory.ConfigFactory._order
private

Definition at line 115 of file ConfigFactory.py.

◆ ROOTNAME

python.ConfigFactory.ConfigFactory.ROOTNAME

Definition at line 113 of file ConfigFactory.py.


The documentation for this class was generated from the following file:
python.ConfigFactory.getFuncArgs
def getFuncArgs(func)
Definition: ConfigFactory.py:35
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18