ATLAS Offline Software
BootstrapGeneratorConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 # AnaAlgorithm import(s):
4 from AnalysisAlgorithmsConfig.ConfigBlock import ConfigBlock
5 from AnalysisAlgorithmsConfig.ConfigAccumulator import DataType
6 
7 class BootstrapGeneratorConfig(ConfigBlock):
8  '''ConfigBlock for the bootstrap generator'''
9 
10  def __init__(self):
11  super(BootstrapGeneratorConfig, self).__init__()
12  self.addOption ('nReplicas', 1000, type=int,
13  info="the number (int) of bootstrap replicas to generate. "
14  "The default is 1000.")
15  self.addOption ('decoration', None, type=str,
16  info="the name of the output vector branch containing the "
17  "bootstrapped weights. The default is bootstrapWeights.")
18  self.addOption ('runOnMC', False, type=bool,
19  info="toggle to force running on MC samples. The default is "
20  "False, i.e. run only on data.")
21 
22  def makeAlgs(self, config):
23  if config.dataType() is not DataType.Data and not self.runOnMC:
24  print("Skipping the configuration of CP::BootstrapGeneratorAlg since we are not running on data. "
25  "Set the option 'runOnMC' to True if you want to force the bootstrapping of MC too.")
26  return
27 
28  alg = config.createAlgorithm( 'CP::BootstrapGeneratorAlg', 'BootstrapGenerator')
29  alg.nReplicas = self.nReplicas
30  alg.isData = config.dataType() is DataType.Data
31  if self.decoration:
32  alg.decorationName = self.decoration
33  else:
34  alg.decorationName = "bootstrapWeights_%SYS%"
35 
36  config.addOutputVar ('EventInfo', alg.decorationName, alg.decorationName.split("_%SYS%")[0], noSys=True)
37 
38  return
39 
41  nReplicas = None,
42  decoration = None,
43  runOnMC = None):
44  """
45  Setup a simple bootstrapping algorithm
46 
47  Keyword arguments:
48  nReplicas -- the number of bootstrap replicas to generate
49  decoration -- the name of the output vector branch containing the bootstrapped weights
50  runOnMC -- toggle to force running on MC samples (default: only data)
51  """
52 
53  config = BootstrapGeneratorConfig()
54  config.setOptionValue ('nReplicas', nReplicas)
55  config.setOptionValue ('decoration', decoration)
56  config.setOptionValue ('runOnMC', runOnMC)
57  seq.append (config)
python.BootstrapGeneratorConfig.BootstrapGeneratorConfig.makeAlgs
def makeAlgs(self, config)
Definition: BootstrapGeneratorConfig.py:22
python.BootstrapGeneratorConfig.BootstrapGeneratorConfig
Definition: BootstrapGeneratorConfig.py:7
python.BootstrapGeneratorConfig.BootstrapGeneratorConfig.__init__
def __init__(self)
Definition: BootstrapGeneratorConfig.py:10
python.BootstrapGeneratorConfig.makeBootstrapGeneratorConfig
def makeBootstrapGeneratorConfig(seq, nReplicas=None, decoration=None, runOnMC=None)
Definition: BootstrapGeneratorConfig.py:40
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28