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

Constructor & Destructor Documentation

◆ __init__()

python.AsgAnalysisConfig.GeneratorAnalysisBlock.__init__ ( self)

Definition at line 395 of file AsgAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

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

Definition at line 425 of file AsgAnalysisConfig.py.

425 def instanceName (self) :
426 """Return the instance name for this block"""
427 return self.streamName or "DEFAULT"
428

◆ makeAlgs()

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

Definition at line 429 of file AsgAnalysisConfig.py.

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

Member Data Documentation

◆ detailedPDFinfo

python.AsgAnalysisConfig.GeneratorAnalysisBlock.detailedPDFinfo

Definition at line 464 of file AsgAnalysisConfig.py.

◆ doHFProdFracReweighting

python.AsgAnalysisConfig.GeneratorAnalysisBlock.doHFProdFracReweighting

Definition at line 477 of file AsgAnalysisConfig.py.

◆ doPDFReweighting

python.AsgAnalysisConfig.GeneratorAnalysisBlock.doPDFReweighting

Definition at line 469 of file AsgAnalysisConfig.py.

◆ histPattern

python.AsgAnalysisConfig.GeneratorAnalysisBlock.histPattern

Definition at line 454 of file AsgAnalysisConfig.py.

◆ outPDFName

python.AsgAnalysisConfig.GeneratorAnalysisBlock.outPDFName

Definition at line 472 of file AsgAnalysisConfig.py.

◆ runNumber

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

Definition at line 440 of file AsgAnalysisConfig.py.

◆ saveCutBookkeepers

python.AsgAnalysisConfig.GeneratorAnalysisBlock.saveCutBookkeepers

Definition at line 446 of file AsgAnalysisConfig.py.


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