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

Constructor & Destructor Documentation

◆ __init__()

python.AsgAnalysisConfig.GeneratorAnalysisBlock.__init__ ( self)

Definition at line 398 of file AsgAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

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

Definition at line 428 of file AsgAnalysisConfig.py.

428 def instanceName (self) :
429 """Return the instance name for this block"""
430 return self.streamName or "DEFAULT"
431

◆ makeAlgs()

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

Definition at line 432 of file AsgAnalysisConfig.py.

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

Member Data Documentation

◆ detailedPDFinfo

python.AsgAnalysisConfig.GeneratorAnalysisBlock.detailedPDFinfo

Definition at line 467 of file AsgAnalysisConfig.py.

◆ doHFProdFracReweighting

python.AsgAnalysisConfig.GeneratorAnalysisBlock.doHFProdFracReweighting

Definition at line 480 of file AsgAnalysisConfig.py.

◆ doPDFReweighting

python.AsgAnalysisConfig.GeneratorAnalysisBlock.doPDFReweighting

Definition at line 472 of file AsgAnalysisConfig.py.

◆ histPattern

python.AsgAnalysisConfig.GeneratorAnalysisBlock.histPattern

Definition at line 457 of file AsgAnalysisConfig.py.

◆ outPDFName

python.AsgAnalysisConfig.GeneratorAnalysisBlock.outPDFName

Definition at line 475 of file AsgAnalysisConfig.py.

◆ runNumber

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

Definition at line 443 of file AsgAnalysisConfig.py.

◆ saveCutBookkeepers

python.AsgAnalysisConfig.GeneratorAnalysisBlock.saveCutBookkeepers

Definition at line 449 of file AsgAnalysisConfig.py.


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