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

Constructor & Destructor Documentation

◆ __init__()

python.AsgAnalysisConfig.GeneratorAnalysisBlock.__init__ ( self)

Definition at line 402 of file AsgAnalysisConfig.py.

402 def __init__ (self) :
403 super (GeneratorAnalysisBlock, self).__init__ ()
404 self.addOption ('saveCutBookkeepers', True, type=bool,
405 info="whether to save the cut bookkeepers information into the "
406 "output file.")
407 self.addOption ('runNumber', None, type=int,
408 info="the MC `runNumber`. If left empty, autoconfigure from the sample metadata.")
409 self.addOption ('cutBookkeepersSystematics', None, type=bool,
410 info="whether to also save the cut bookkeepers systematics. The "
411 "default is `None` (follows the global systematics flag). Set to "
412 "`False` or `True` to override.")
413 self.addOption ('histPattern', None, type=str,
414 info="the histogram name pattern for the cut-bookkeeper histogram names.")
415 self.addOption ('streamName', None, type=str,
416 info="name of the output stream to save the cut bookkeeper in.")
417 self.addOption ('detailedPDFinfo', False, type=bool,
418 info="save the necessary information to run the LHAPDF tool offline.")
419 self.addOption ('doPDFReweighting', False, type=bool,
420 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).")
421 self.addOption ('outPDFName', [
422 "CT14nnloIC/0", "CT14nnloIC/1", "CT14nnloIC/2",
423 "CT18FC/0", "CT18FC/3", "CT18FC/6", "CT18FC/9",
424 "CT18NNLO/0", "CT18XNNLO/0",
425 "NNPDF40_nnlo_pch_as_01180/0", "NNPDF40_nnlo_as_01180/0"
426 ], type=list, info="list of PDF sets to use for PDF reweighting.")
427 self.addOption ('doHFProdFracReweighting', False, type=bool,
428 info="whether to apply HF production fraction reweighting.")
429 self.addOption ('truthParticleContainer', 'TruthParticles', type=str,
430 info="the name of the truth particle container to use for HF production fraction reweighting.")
431

Member Function Documentation

◆ instanceName()

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

Definition at line 432 of file AsgAnalysisConfig.py.

432 def instanceName (self) :
433 """Return the instance name for this block"""
434 return self.streamName or "DEFAULT"
435

◆ makeAlgs()

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

Definition at line 436 of file AsgAnalysisConfig.py.

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

Member Data Documentation

◆ detailedPDFinfo

python.AsgAnalysisConfig.GeneratorAnalysisBlock.detailedPDFinfo

Definition at line 471 of file AsgAnalysisConfig.py.

◆ doHFProdFracReweighting

python.AsgAnalysisConfig.GeneratorAnalysisBlock.doHFProdFracReweighting

Definition at line 484 of file AsgAnalysisConfig.py.

◆ doPDFReweighting

python.AsgAnalysisConfig.GeneratorAnalysisBlock.doPDFReweighting

Definition at line 476 of file AsgAnalysisConfig.py.

◆ histPattern

python.AsgAnalysisConfig.GeneratorAnalysisBlock.histPattern

Definition at line 461 of file AsgAnalysisConfig.py.

◆ outPDFName

python.AsgAnalysisConfig.GeneratorAnalysisBlock.outPDFName

Definition at line 479 of file AsgAnalysisConfig.py.

◆ runNumber

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

Definition at line 447 of file AsgAnalysisConfig.py.

◆ saveCutBookkeepers

python.AsgAnalysisConfig.GeneratorAnalysisBlock.saveCutBookkeepers

Definition at line 453 of file AsgAnalysisConfig.py.


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