ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
python.AsgAnalysisConfig.CommonServicesConfig Class Reference
Inheritance diagram for python.AsgAnalysisConfig.CommonServicesConfig:
Collaboration diagram for python.AsgAnalysisConfig.CommonServicesConfig:

Public Member Functions

def __init__ (self)
 
def instanceName (self)
 
def makeAlgs (self, config)
 

Public Attributes

 runSystematics
 
 onlySystematicsCategories
 

Detailed Description

the ConfigBlock for common services

The idea here is that all algorithms need some common services, and I should
provide configuration blocks for those.  For now there is just a single
block, but in the future I might break out e.g. the systematics service.

Definition at line 28 of file AsgAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

def python.AsgAnalysisConfig.CommonServicesConfig.__init__ (   self)

Definition at line 36 of file AsgAnalysisConfig.py.

36  def __init__ (self) :
37  super (CommonServicesConfig, self).__init__ ()
38  self.addOption ('runSystematics', None, type=bool,
39  info="whether to turn on the computation of systematic variations. "
40  "The default is to run them on MC.")
41  self.addOption ('filterSystematics', None, type=str,
42  info="a regexp string against which the systematics names will be "
43  "matched. Only positive matches are retained and used in the evaluation "
44  "of the various algorithms.")
45  self.addOption ('onlySystematicsCategories', None, type=list,
46  info="a list of strings defining categories of systematics to enable "
47  "(only recommended for studies / partial ntuple productions). Choose amongst: "
48  "jets, electrons, muons, photons, taus, met, tracks, ftag, event. This option is overridden "
49  "by 'filterSystematics'.")
50  self.addOption ('systematicsHistogram', None , type=str,
51  info="the name (string) of the histogram to which a list of executed "
52  "systematics will be printed. The default is None (don't write out "
53  "the histogram).")
54  self.addOption ('separateWeightSystematics', False, type=bool,
55  info="if 'systematicsHistogram' is enabled, whether to create a separate "
56  "histogram holding only the names of weight-based systematics. This is useful "
57  "to help make histogramming frameworks more efficient by knowing in advance which "
58  "systematics need to recompute the observable and which don't.")
59  self.addOption ('enableExpertMode', False, type=bool,
60  info="allows CP experts and CPAlgorithm devs to use non-recommended configurations. "
61  "DO NOT USE FOR ANALYSIS.")
62 

Member Function Documentation

◆ instanceName()

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

Definition at line 63 of file AsgAnalysisConfig.py.

63  def instanceName (self) :
64  """Return the instance name for this block"""
65  return '' # no instance name, this is a singleton
66 

◆ makeAlgs()

def python.AsgAnalysisConfig.CommonServicesConfig.makeAlgs (   self,
  config 
)

Definition at line 67 of file AsgAnalysisConfig.py.

67  def makeAlgs (self, config) :
68 
69  sysService = config.createService( 'CP::SystematicsSvc', 'SystematicsSvc' )
70 
71  if self.runSystematics is False :
72  runSystematics = self.runSystematics
73  elif config.noSystematics() is not None :
74  # if option not set:
75  # check to see if set in config accumulator
76  self.runSystematics = not config.noSystematics()
77  runSystematics = self.runSystematics
78  else :
79  runSystematics = True
80 
81  if runSystematics :
82  sysService.sigmaRecommended = 1
83  if config.dataType() is DataType.Data:
84  # Only one type of allowed systematics on data: the JER variations!
85  self.onlySystematicsCategories = ['JER']
86  if self.onlySystematicsCategories is not None:
87  # Convert strings to enums and validate
88  requested_categories = []
89  for category_str in self.onlySystematicsCategories:
90  try:
91  category_enum = SystematicsCategories[category_str.upper()]
92  requested_categories += category_enum.value
93  except KeyError:
94  raise ValueError(f"Invalid systematics category passed to option 'onlySystematicsCategories': {category_str}. Must be one of {', '.join(category.name for category in SystematicsCategories)}")
95  # Construct regex pattern as logical-OR of category names
96  if len(requested_categories):
97  sysService.systematicsRegex = "^(?=.*(" + "|".join(requested_categories) + ")|$).*"
98  if self.filterSystematics is not None:
99  sysService.systematicsRegex = self.filterSystematics
100  config.createService( 'CP::SelectionNameSvc', 'SelectionNameSvc')
101 
102  if self.systematicsHistogram is not None:
103  # print out all systematics
104  allSysDumper = config.createAlgorithm( 'CP::SysListDumperAlg', 'SystematicsPrinter' )
105  allSysDumper.histogramName = self.systematicsHistogram
106 
107  if self.separateWeightSystematics:
108  # print out only the weight systematics (for more efficient histogramming down the line)
109  weightSysDumper = config.createAlgorithm( 'CP::SysListDumperAlg', 'OnlyWeightSystematicsPrinter' )
110  weightSysDumper.histogramName = f"{self.systematicsHistogram}OnlyWeights"
111  weightSysDumper.systematicsRegex = "^(GEN_|EL_EFF_|MUON_EFF_|PH_EFF_|TAUS_TRUEHADTAU_EFF_|FT_EFF_|extrapolation_pt_|JET_.*JvtEfficiency_|PRW_).*"
112 
113  if self.enableExpertMode and config._pass == 0:
114  # set any expert-mode errors to be ignored instead
115  warnings.simplefilter('ignore', ExpertModeWarning)
116  # just warning users they might be doing something dangerous
117  log = logging.getLogger('CommonServices')
118  bold = "\033[1m"
119  red = "\033[91m"
120  yellow = "\033[93m"
121  reset = "\033[0m"
122  log.warning(red +r"""
123  ________ _______ ______ _____ _______ __ __ ____ _____ ______ ______ _ _ ____ _ ______ _____
124  | ____\ \ / / __ \| ____| __ \__ __| | \/ |/ __ \| __ \| ____| | ____| \ | | /\ | _ \| | | ____| __ \
125  | |__ \ V /| |__) | |__ | |__) | | | | \ / | | | | | | | |__ | |__ | \| | / \ | |_) | | | |__ | | | |
126  | __| > < | ___/| __| | _ / | | | |\/| | | | | | | | __| | __| | . ` | / /\ \ | _ <| | | __| | | | |
127  | |____ / . \| | | |____| | \ \ | | | | | | |__| | |__| | |____ | |____| |\ |/ ____ \| |_) | |____| |____| |__| |
128  |______/_/ \_\_| |______|_| \_\ |_| |_| |_|\____/|_____/|______| |______|_| \_/_/ \_\____/|______|______|_____/
129 
130 """
131  +reset)
132  log.warning(f"{bold}{yellow}These settings are not recommended for analysis. Make sure you know what you're doing, or disable them with `enableExpertMode: False` in `CommonServices`.{reset}")
133 
134 
135 
136 @groupBlocks

Member Data Documentation

◆ onlySystematicsCategories

python.AsgAnalysisConfig.CommonServicesConfig.onlySystematicsCategories

Definition at line 85 of file AsgAnalysisConfig.py.

◆ runSystematics

python.AsgAnalysisConfig.CommonServicesConfig.runSystematics

Definition at line 76 of file AsgAnalysisConfig.py.


The documentation for this class was generated from the following file:
python.processes.powheg.ZZj_MiNNLO.ZZj_MiNNLO.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZj_MiNNLO.py:18
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10