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

Public Member Functions

def __init__ (self)
 
def instanceName (self)
 
def makeAlgs (self, config)
 

Public Attributes

 runNumber
 

Detailed Description

the ConfigBlock for generator algorithms

Definition at line 312 of file AsgAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

def python.AsgAnalysisConfig.GeneratorAnalysisBlock.__init__ (   self)

Definition at line 315 of file AsgAnalysisConfig.py.

315  def __init__ (self) :
316  super (GeneratorAnalysisBlock, self).__init__ ()
317  self.addOption ('saveCutBookkeepers', True, type=bool,
318  info="whether to save the cut bookkeepers information into the "
319  "output file. The default is True.")
320  self.addOption ('runNumber', None, type=int,
321  info="the MC runNumber (int). The default is None (autoconfigure "
322  "from metadata).")
323  self.addOption ('cutBookkeepersSystematics', None, type=bool,
324  info="whether to also save the cut bookkeepers systematics. The "
325  "default is None (follows the global systematics flag). Set to "
326  "False or True to override.")
327  self.addOption ('histPattern', None, type=str,
328  info="the histogram name pattern for the cut-bookkeeper histogram names")
329  self.addOption ('streamName', 'ANALYSIS', type=str,
330  info="name of the output stream to save the cut bookkeeper in. "
331  "The default is ANALYSIS.")
332  self.addOption ('detailedPDFinfo', False, type=bool,
333  info="save the necessary information to run the LHAPDF tool offline. "
334  "The default is False.")
335  self.addOption ('doHFProdFracReweighting', False, type=bool,
336  info="whether to apply HF production fraction reweighting. "
337  "The default is False.")
338  self.addOption ('truthParticleContainer', 'TruthParticles', type=str,
339  info="the name of the truth particle container to use for HF production fraction reweighting. "
340  "The default is 'TruthParticles'. ")

Member Function Documentation

◆ instanceName()

def python.AsgAnalysisConfig.GeneratorAnalysisBlock.instanceName (   self)
Return the instance name for this block

Definition at line 341 of file AsgAnalysisConfig.py.

341  def instanceName (self) :
342  """Return the instance name for this block"""
343  return self.streamName
344 

◆ makeAlgs()

def python.AsgAnalysisConfig.GeneratorAnalysisBlock.makeAlgs (   self,
  config 
)

Definition at line 345 of file AsgAnalysisConfig.py.

345  def makeAlgs (self, config) :
346 
347  if config.dataType() is DataType.Data:
348  # there are no generator weights in data!
349  return
350  try:
351  from AthenaCommon.Logging import logging
352  except ImportError:
353  import logging
354  log = logging.getLogger('makeGeneratorAnalysisSequence')
355 
356  if self.runNumber is None:
357  self.runNumber = config.runNumber()
358 
359  if self.saveCutBookkeepers and not self.runNumber:
360  raise ValueError ("invalid run number: " + str(self.runNumber))
361 
362  # Set up the CutBookkeepers algorithm:
363  if self.saveCutBookkeepers:
364  alg = config.createAlgorithm('CP::AsgCutBookkeeperAlg', 'CutBookkeeperAlg')
365  alg.RootStreamName = self.streamName
366  alg.runNumber = self.runNumber
367  if self.cutBookkeepersSystematics is None:
368  alg.enableSystematics = not config.noSystematics()
369  else:
370  alg.enableSystematics = self.cutBookkeepersSystematics
371  if self.histPattern:
372  alg.histPattern = self.histPattern
373  config.addPrivateTool( 'truthWeightTool', 'PMGTools::PMGTruthWeightTool' )
374 
375  # Set up the weights algorithm:
376  alg = config.createAlgorithm( 'CP::PMGTruthWeightAlg', 'PMGTruthWeightAlg' )
377  config.addPrivateTool( 'truthWeightTool', 'PMGTools::PMGTruthWeightTool' )
378  alg.decoration = 'generatorWeight_%SYS%'
379  config.addOutputVar ('EventInfo', 'generatorWeight_%SYS%', 'weight_mc')
380 
381  if self.detailedPDFinfo:
382  alg = config.createAlgorithm( 'CP::PDFinfoAlg', 'PDFinfoAlg', reentrant=True )
383  for var in ["PDFID1","PDFID2","PDGID1","PDGID2","Q","X1","X2","XF1","XF2"]:
384  config.addOutputVar ('EventInfo', var, 'PDFinfo_' + var, noSys=True)
385 
386  if self.doHFProdFracReweighting:
387  generatorInfo = config.autoconfigFlags().Input.GeneratorsInfo
388  log.info(f"Loaded generator info: {generatorInfo}")
389 
390  DSID = "000000"
391 
392  if not generatorInfo:
393  log.warning("No generator info found.")
394  DSID = "000000"
395  elif isinstance(generatorInfo, dict):
396  if "Pythia8" in generatorInfo:
397  DSID = "410470"
398  elif "Sherpa" in generatorInfo and "2.2.8" in generatorInfo["Sherpa"]:
399  DSID = "421152"
400  elif "Sherpa" in generatorInfo and "2.2.10" in generatorInfo["Sherpa"]:
401  DSID = "700122"
402  elif "Sherpa" in generatorInfo and "2.2.11" in generatorInfo["Sherpa"]:
403  log.warning("HF production fraction reweighting is not configured for Sherpa 2.2.11. Using weights for Sherpa 2.2.10 instead.")
404  DSID = "700122"
405  elif "Sherpa" in generatorInfo and "2.2.12" in generatorInfo["Sherpa"]:
406  log.warning("HF production fraction reweighting is not configured for Sherpa 2.2.12. Using weights for Sherpa 2.2.10 instead.")
407  DSID = "700122"
408  elif "Sherpa" in generatorInfo and "2.2.14" in generatorInfo["Sherpa"]:
409  log.warning("HF production fraction reweighting is not configured for Sherpa 2.2.14. New weights need to be calculated.")
410  DSID = "000000"
411  elif "Sherpa" in generatorInfo and "2.2.1" in generatorInfo["Sherpa"]:
412  DSID = "410250"
413  elif "Herwig7" in generatorInfo and "7.1.3" in generatorInfo["Herwig7"]:
414  DSID = "411233"
415  elif "Herwig7" in generatorInfo and "7.2.1" in generatorInfo["Herwig7"]:
416  DSID = "600666"
417  elif "Herwig7" in generatorInfo and "7." in generatorInfo["Herwig7"]:
418  DSID = "410558"
419  elif "amc@NLO" in generatorInfo:
420  DSID = "410464"
421  else:
422  log.warning(f"HF production fraction reweighting is not configured for this generator: {generatorInfo}")
423  log.warning("New weights need to be calculated.")
424  DSID = "000000"
425  else:
426  log.warning("Failed to determine generator from metadata")
427  DSID = "000000"
428 
429  log.info(f"Using HF production fraction weights calculated using DSID {DSID}")
430  if DSID == "000000":
431  log.warning("HF production fraction reweighting will return dummy weights of 1.0")
432 
433  alg = config.createAlgorithm( 'CP::SysTruthWeightAlg', 'SysTruthWeightAlg' + self.streamName )
434  config.addPrivateTool( 'sysTruthWeightTool', 'PMGTools::PMGHFProductionFractionTool' )
435  alg.decoration = 'prodFracWeight_%SYS%'
436  alg.TruthParticleContainer = self.truthParticleContainer
437  alg.sysTruthWeightTool.ShowerGenerator = DSID
438  config.addOutputVar ('EventInfo', 'prodFracWeight_%SYS%', 'weight_HF_prod_frac')
439 

Member Data Documentation

◆ runNumber

python.AsgAnalysisConfig.GeneratorAnalysisBlock.runNumber

Definition at line 357 of file AsgAnalysisConfig.py.


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