74 def makeAlgs (self, config) :
76 sysService = config.createService(
'CP::SystematicsSvc',
'SystematicsSvc' )
78 if self.runSystematics
is False :
79 runSystematics = self.runSystematics
80 elif config.noSystematics()
is not None :
83 self.runSystematics =
not config.noSystematics()
84 runSystematics = self.runSystematics
89 sysService.sigmaRecommended = 1
90 if config.dataType()
is DataType.Data:
92 self.onlySystematicsCategories = [
'JER']
93 if self.onlySystematicsCategories
is not None:
95 requested_categories = []
96 for category_str
in self.onlySystematicsCategories:
98 category_enum = SystematicsCategories[category_str.upper()]
99 requested_categories += category_enum.value
101 raise ValueError(f
"Invalid systematics category passed to option 'onlySystematicsCategories': {category_str}. Must be one of {', '.join(category.name for category in SystematicsCategories)}")
103 if len(requested_categories):
104 sysService.systematicsRegex =
"^(?=.*(" +
"|".
join(requested_categories) +
")|$).*"
105 if self.filterSystematics
is not None:
106 sysService.systematicsRegex = self.filterSystematics
107 config.createService(
'CP::SelectionNameSvc',
'SelectionNameSvc')
109 if self.systematicsHistogram
is not None:
111 allSysDumper = config.createAlgorithm(
'CP::SysListDumperAlg',
'SystematicsPrinter' )
112 allSysDumper.histogramName = self.systematicsHistogram
113 allSysDumper.RootStreamName = self.streamName
115 if self.separateWeightSystematics:
117 weightSysDumper = config.createAlgorithm(
'CP::SysListDumperAlg',
'OnlyWeightSystematicsPrinter' )
118 weightSysDumper.histogramName = f
"{self.systematicsHistogram}OnlyWeights"
119 weightSysDumper.systematicsRegex =
"^(GEN_|EL_EFF_|MUON_EFF_|PH_EFF_|TAUS_TRUEHADTAU_EFF_|FT_EFF_|extrapolation_pt_|JET_.*JvtEfficiency_|PRW_).*"
121 if self.metadataHistogram
is not None:
124 raise ValueError (
"Writing out the metadata histogram requires to pass config flags")
125 metadataHistAlg = config.createAlgorithm(
'CP::MetadataHistAlg',
'MetadataHistAlg' )
126 metadataHistAlg.histogramName = self.metadataHistogram
127 metadataHistAlg.dataType =
str(config.dataType().value)
128 metadataHistAlg.campaign =
str(config.dataYear())
if config.dataType()
is DataType.Data
else str(config.campaign().value)
129 metadataHistAlg.mcChannelNumber =
str(config.dsid())
130 if config.dataType()
is DataType.Data:
133 from AthenaConfiguration.AutoConfigFlags
import GetFileMD
134 metadata =
GetFileMD(config.flags.Input.Files)
135 amiTags = metadata.get(
"AMITag",
"not found!")
136 etag =
str(amiTags.split(
"_")[0])
137 metadataHistAlg.etag = etag
139 if self.enableExpertMode
and config._pass == 0:
141 warnings.simplefilter(
'ignore', ExpertModeWarning)
143 log = logging.getLogger(
'CommonServices')
148 log.warning(red +
r"""
149 ________ _______ ______ _____ _______ __ __ ____ _____ ______ ______ _ _ ____ _ ______ _____
150 | ____\ \ / / __ \| ____| __ \__ __| | \/ |/ __ \| __ \| ____| | ____| \ | | /\ | _ \| | | ____| __ \
151 | |__ \ V /| |__) | |__ | |__) | | | | \ / | | | | | | | |__ | |__ | \| | / \ | |_) | | | |__ | | | |
152 | __| > < | ___/| __| | _ / | | | |\/| | | | | | | | __| | __| | . ` | / /\ \ | _ <| | | __| | | | |
153 | |____ / . \| | | |____| | \ \ | | | | | | |__| | |__| | |____ | |____| |\ |/ ____ \| |_) | |____| |____| |__| |
154 |______/_/ \_\_| |______|_| \_\ |_| |_| |_|\____/|_____/|______| |______|_| \_/_/ \_\____/|______|______|_____/
158 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}")