ATLAS Offline Software
Loading...
Searching...
No Matches
python.AsgAnalysisConfig.GeneratorAnalysisBlock Class Reference
Inheritance diagram for python.AsgAnalysisConfig.GeneratorAnalysisBlock:
Collaboration diagram for python.AsgAnalysisConfig.GeneratorAnalysisBlock:

Public Member Functions

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

Public Attributes

 runNumber = config.runNumber()
 saveCutBookkeepers
 histPattern
 detailedPDFinfo
 doPDFReweighting
 outPDFName
 doHFProdFracReweighting

Detailed Description

the ConfigBlock for generator algorithms

Definition at line 375 of file AsgAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.AsgAnalysisConfig.GeneratorAnalysisBlock.__init__ ( self)

Definition at line 378 of file AsgAnalysisConfig.py.

378 def __init__ (self) :
379 super (GeneratorAnalysisBlock, self).__init__ ()
380 self.addOption ('saveCutBookkeepers', True, type=bool,
381 info="whether to save the cut bookkeepers information into the "
382 "output file.")
383 self.addOption ('runNumber', None, type=int,
384 info="the MC `runNumber`. If left empty, autoconfigure from the sample metadata.")
385 self.addOption ('cutBookkeepersSystematics', None, type=bool,
386 info="whether to also save the cut bookkeepers systematics. The "
387 "default is `None` (follows the global systematics flag). Set to "
388 "`False` or `True` to override.")
389 self.addOption ('histPattern', None, type=str,
390 info="the histogram name pattern for the cut-bookkeeper histogram names.")
391 self.addOption ('streamName', 'ANALYSIS', type=str,
392 info="name of the output stream to save the cut bookkeeper in.")
393 self.addOption ('detailedPDFinfo', False, type=bool,
394 info="save the necessary information to run the LHAPDF tool offline.")
395 self.addOption ('doPDFReweighting', False, type=bool,
396 info="perform the PDF reweighting to do the PDF sensitivity studies with the existing sample, intrinsic charm PDFs as the default here. WARNING: the reweighting closure should be validated within analysis (it has been proved to be good for Madgraph, aMC@NLO, Pythia8, Herwig, and Alpgen, but not good for Sherpa and Powheg).")
397 self.addOption ('outPDFName', [
398 "CT14nnloIC/0", "CT14nnloIC/1", "CT14nnloIC/2",
399 "CT18FC/0", "CT18FC/3", "CT18FC/6", "CT18FC/9",
400 "CT18NNLO/0", "CT18XNNLO/0",
401 "NNPDF40_nnlo_pch_as_01180/0", "NNPDF40_nnlo_as_01180/0"
402 ], type=list, info="list of PDF sets to use for PDF reweighting.")
403 self.addOption ('doHFProdFracReweighting', False, type=bool,
404 info="whether to apply HF production fraction reweighting.")
405 self.addOption ('truthParticleContainer', 'TruthParticles', type=str,
406 info="the name of the truth particle container to use for HF production fraction reweighting.")

Member Function Documentation

◆ instanceName()

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

Definition at line 407 of file AsgAnalysisConfig.py.

407 def instanceName (self) :
408 """Return the instance name for this block"""
409 return self.streamName
410

◆ makeAlgs()

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

Definition at line 411 of file AsgAnalysisConfig.py.

411 def makeAlgs (self, config) :
412
413 if config.dataType() is DataType.Data:
414 # there are no generator weights in data!
415 return
416 log = logging.getLogger('makeGeneratorAnalysisSequence')
417
418 if self.runNumber is None:
419 self.runNumber = config.runNumber()
420
421 if self.saveCutBookkeepers and not self.runNumber:
422 raise ValueError ("invalid run number: " + str(self.runNumber))
423
424 # Set up the CutBookkeepers algorithm:
425 if self.saveCutBookkeepers:
426 alg = config.createAlgorithm('CP::AsgCutBookkeeperAlg', 'CutBookkeeperAlg')
427 alg.RootStreamName = self.streamName
428 alg.runNumber = self.runNumber
429 if self.cutBookkeepersSystematics is None:
430 alg.enableSystematics = not config.noSystematics()
431 else:
432 alg.enableSystematics = self.cutBookkeepersSystematics
433 if self.histPattern:
434 alg.histPattern = self.histPattern
435 config.addPrivateTool( 'truthWeightTool', 'PMGTools::PMGTruthWeightTool' )
436
437 # Set up the weights algorithm:
438 alg = config.createAlgorithm( 'CP::PMGTruthWeightAlg', 'PMGTruthWeightAlg' )
439 config.addPrivateTool( 'truthWeightTool', 'PMGTools::PMGTruthWeightTool' )
440 alg.decoration = 'generatorWeight_%SYS%'
441 config.addOutputVar ('EventInfo', 'generatorWeight_%SYS%', 'weight_mc')
442
443 if self.detailedPDFinfo:
444 alg = config.createAlgorithm( 'CP::PDFinfoAlg', 'PDFinfoAlg', reentrant=True )
445 for var in ["PDFID1","PDFID2","PDGID1","PDGID2","Q","X1","X2","XF1","XF2"]:
446 config.addOutputVar ('EventInfo', var, 'PDFinfo_' + var, noSys=True)
447
448 if self.doPDFReweighting:
449 alg = config.createAlgorithm( 'CP::PDFReweightAlg', 'PDFReweightAlg', reentrant=True )
450
451 for pdf_set in self.outPDFName:
452 config.addOutputVar('EventInfo', f'PDFReweightSF_{pdf_set.replace("/", "_")}',
453 f'PDFReweightSF_{pdf_set.replace("/", "_")}', noSys=True)
454
455
456 if self.doHFProdFracReweighting:
457 generatorInfo = config.flags.Input.GeneratorsInfo
458 log.info(f"Loaded generator info: {generatorInfo}")
459
460 DSID = "000000"
461
462 if not generatorInfo:
463 log.warning("No generator info found.")
464 DSID = "000000"
465 elif isinstance(generatorInfo, dict):
466 if "Pythia8" in generatorInfo:
467 DSID = "410470"
468 elif "Sherpa" in generatorInfo and "2.2.8" in generatorInfo["Sherpa"]:
469 DSID = "421152"
470 elif "Sherpa" in generatorInfo and "2.2.10" in generatorInfo["Sherpa"]:
471 DSID = "700122"
472 elif "Sherpa" in generatorInfo and "2.2.11" in generatorInfo["Sherpa"]:
473 log.warning("HF production fraction reweighting is not configured for Sherpa 2.2.11. Using weights for Sherpa 2.2.10 instead.")
474 DSID = "700122"
475 elif "Sherpa" in generatorInfo and "2.2.12" in generatorInfo["Sherpa"]:
476 log.warning("HF production fraction reweighting is not configured for Sherpa 2.2.12. Using weights for Sherpa 2.2.10 instead.")
477 DSID = "700122"
478 elif "Sherpa" in generatorInfo and "2.2.14" in generatorInfo["Sherpa"]:
479 log.warning("HF production fraction reweighting is not configured for Sherpa 2.2.14. New weights need to be calculated.")
480 DSID = "000000"
481 elif "Sherpa" in generatorInfo and "2.2.1" in generatorInfo["Sherpa"]:
482 DSID = "410250"
483 elif "Herwig7" in generatorInfo and "7.1.3" in generatorInfo["Herwig7"]:
484 DSID = "411233"
485 elif "Herwig7" in generatorInfo and "7.2.1" in generatorInfo["Herwig7"]:
486 DSID = "600666"
487 elif "Herwig7" in generatorInfo and "7." in generatorInfo["Herwig7"]:
488 DSID = "410558"
489 elif "amc@NLO" in generatorInfo:
490 DSID = "410464"
491 else:
492 log.warning(f"HF production fraction reweighting is not configured for this generator: {generatorInfo}")
493 log.warning("New weights need to be calculated.")
494 DSID = "000000"
495 else:
496 log.warning("Failed to determine generator from metadata")
497 DSID = "000000"
498
499 log.info(f"Using HF production fraction weights calculated using DSID {DSID}")
500 if DSID == "000000":
501 log.warning("HF production fraction reweighting will return dummy weights of 1.0")
502
503 alg = config.createAlgorithm( 'CP::SysTruthWeightAlg', 'SysTruthWeightAlg' + self.streamName )
504 config.addPrivateTool( 'sysTruthWeightTool', 'PMGTools::PMGHFProductionFractionTool' )
505 alg.decoration = 'prodFracWeight_%SYS%'
506 alg.TruthParticleContainer = self.truthParticleContainer
507 alg.sysTruthWeightTool.ShowerGenerator = DSID
508 config.addOutputVar ('EventInfo', 'prodFracWeight_%SYS%', 'weight_HF_prod_frac')
509

Member Data Documentation

◆ detailedPDFinfo

python.AsgAnalysisConfig.GeneratorAnalysisBlock.detailedPDFinfo

Definition at line 443 of file AsgAnalysisConfig.py.

◆ doHFProdFracReweighting

python.AsgAnalysisConfig.GeneratorAnalysisBlock.doHFProdFracReweighting

Definition at line 456 of file AsgAnalysisConfig.py.

◆ doPDFReweighting

python.AsgAnalysisConfig.GeneratorAnalysisBlock.doPDFReweighting

Definition at line 448 of file AsgAnalysisConfig.py.

◆ histPattern

python.AsgAnalysisConfig.GeneratorAnalysisBlock.histPattern

Definition at line 433 of file AsgAnalysisConfig.py.

◆ outPDFName

python.AsgAnalysisConfig.GeneratorAnalysisBlock.outPDFName

Definition at line 451 of file AsgAnalysisConfig.py.

◆ runNumber

python.AsgAnalysisConfig.GeneratorAnalysisBlock.runNumber = config.runNumber()

Definition at line 419 of file AsgAnalysisConfig.py.

◆ saveCutBookkeepers

python.AsgAnalysisConfig.GeneratorAnalysisBlock.saveCutBookkeepers

Definition at line 425 of file AsgAnalysisConfig.py.


The documentation for this class was generated from the following file: