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 382 of file AsgAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.AsgAnalysisConfig.GeneratorAnalysisBlock.__init__ ( self)

Definition at line 385 of file AsgAnalysisConfig.py.

385 def __init__ (self) :
386 super (GeneratorAnalysisBlock, self).__init__ ()
387 self.addOption ('saveCutBookkeepers', True, type=bool,
388 info="whether to save the cut bookkeepers information into the "
389 "output file.")
390 self.addOption ('runNumber', None, type=int,
391 info="the MC `runNumber`. If left empty, autoconfigure from the sample metadata.")
392 self.addOption ('cutBookkeepersSystematics', None, type=bool,
393 info="whether to also save the cut bookkeepers systematics. The "
394 "default is `None` (follows the global systematics flag). Set to "
395 "`False` or `True` to override.")
396 self.addOption ('histPattern', None, type=str,
397 info="the histogram name pattern for the cut-bookkeeper histogram names.")
398 self.addOption ('streamName', None, type=str,
399 info="name of the output stream to save the cut bookkeeper in.")
400 self.addOption ('detailedPDFinfo', False, type=bool,
401 info="save the necessary information to run the LHAPDF tool offline.")
402 self.addOption ('doPDFReweighting', False, type=bool,
403 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).")
404 self.addOption ('outPDFName', [
405 "CT14nnloIC/0", "CT14nnloIC/1", "CT14nnloIC/2",
406 "CT18FC/0", "CT18FC/3", "CT18FC/6", "CT18FC/9",
407 "CT18NNLO/0", "CT18XNNLO/0",
408 "NNPDF40_nnlo_pch_as_01180/0", "NNPDF40_nnlo_as_01180/0"
409 ], type=list, info="list of PDF sets to use for PDF reweighting.")
410 self.addOption ('doHFProdFracReweighting', False, type=bool,
411 info="whether to apply HF production fraction reweighting.")
412 self.addOption ('truthParticleContainer', 'TruthParticles', type=str,
413 info="the name of the truth particle container to use for HF production fraction reweighting.")
414

Member Function Documentation

◆ instanceName()

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

Definition at line 415 of file AsgAnalysisConfig.py.

415 def instanceName (self) :
416 """Return the instance name for this block"""
417 return self.streamName or "DEFAULT"
418

◆ makeAlgs()

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

Definition at line 419 of file AsgAnalysisConfig.py.

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

Member Data Documentation

◆ detailedPDFinfo

python.AsgAnalysisConfig.GeneratorAnalysisBlock.detailedPDFinfo

Definition at line 454 of file AsgAnalysisConfig.py.

◆ doHFProdFracReweighting

python.AsgAnalysisConfig.GeneratorAnalysisBlock.doHFProdFracReweighting

Definition at line 467 of file AsgAnalysisConfig.py.

◆ doPDFReweighting

python.AsgAnalysisConfig.GeneratorAnalysisBlock.doPDFReweighting

Definition at line 459 of file AsgAnalysisConfig.py.

◆ histPattern

python.AsgAnalysisConfig.GeneratorAnalysisBlock.histPattern

Definition at line 444 of file AsgAnalysisConfig.py.

◆ outPDFName

python.AsgAnalysisConfig.GeneratorAnalysisBlock.outPDFName

Definition at line 462 of file AsgAnalysisConfig.py.

◆ runNumber

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

Definition at line 430 of file AsgAnalysisConfig.py.

◆ saveCutBookkeepers

python.AsgAnalysisConfig.GeneratorAnalysisBlock.saveCutBookkeepers

Definition at line 436 of file AsgAnalysisConfig.py.


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