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

Constructor & Destructor Documentation

◆ __init__()

python.AsgAnalysisConfig.GeneratorAnalysisBlock.__init__ ( self)

Definition at line 375 of file AsgAnalysisConfig.py.

375 def __init__ (self) :
376 super (GeneratorAnalysisBlock, self).__init__ ()
377 self.addOption ('saveCutBookkeepers', True, type=bool,
378 info="whether to save the cut bookkeepers information into the "
379 "output file. The default is True.")
380 self.addOption ('runNumber', None, type=int,
381 info="the MC runNumber (int). The default is None (autoconfigure "
382 "from metadata).")
383 self.addOption ('cutBookkeepersSystematics', None, type=bool,
384 info="whether to also save the cut bookkeepers systematics. The "
385 "default is None (follows the global systematics flag). Set to "
386 "False or True to override.")
387 self.addOption ('histPattern', None, type=str,
388 info="the histogram name pattern for the cut-bookkeeper histogram names")
389 self.addOption ('streamName', 'ANALYSIS', type=str,
390 info="name of the output stream to save the cut bookkeeper in. "
391 "The default is ANALYSIS.")
392 self.addOption ('detailedPDFinfo', False, type=bool,
393 info="save the necessary information to run the LHAPDF tool offline. "
394 "The default is False.")
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 "The default is False.")
406 self.addOption ('truthParticleContainer', 'TruthParticles', type=str,
407 info="the name of the truth particle container to use for HF production fraction reweighting. "
408 "The default is 'TruthParticles'. ")

Member Function Documentation

◆ instanceName()

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

Definition at line 409 of file AsgAnalysisConfig.py.

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

◆ makeAlgs()

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

Definition at line 413 of file AsgAnalysisConfig.py.

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

Member Data Documentation

◆ detailedPDFinfo

python.AsgAnalysisConfig.GeneratorAnalysisBlock.detailedPDFinfo

Definition at line 445 of file AsgAnalysisConfig.py.

◆ doHFProdFracReweighting

python.AsgAnalysisConfig.GeneratorAnalysisBlock.doHFProdFracReweighting

Definition at line 458 of file AsgAnalysisConfig.py.

◆ doPDFReweighting

python.AsgAnalysisConfig.GeneratorAnalysisBlock.doPDFReweighting

Definition at line 450 of file AsgAnalysisConfig.py.

◆ histPattern

python.AsgAnalysisConfig.GeneratorAnalysisBlock.histPattern

Definition at line 435 of file AsgAnalysisConfig.py.

◆ outPDFName

python.AsgAnalysisConfig.GeneratorAnalysisBlock.outPDFName

Definition at line 453 of file AsgAnalysisConfig.py.

◆ runNumber

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

Definition at line 421 of file AsgAnalysisConfig.py.

◆ saveCutBookkeepers

python.AsgAnalysisConfig.GeneratorAnalysisBlock.saveCutBookkeepers

Definition at line 427 of file AsgAnalysisConfig.py.


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