the ConfigBlock for pileup reweighting
Definition at line 98 of file AsgAnalysisConfig.py.
◆ __init__()
def python.AsgAnalysisConfig.PileupReweightingBlock.__init__ |
( |
|
self | ) |
|
Definition at line 101 of file AsgAnalysisConfig.py.
102 super (PileupReweightingBlock, self).__init__ ()
103 self.addOption (
'campaign',
None, type=
None,
104 info=
"the MC campaign for the PRW auto-configuration.")
105 self.addOption (
'files',
None, type=
None,
106 info=
"the input files being processed (list of strings). "
107 "Alternative to auto-configuration.")
108 self.addOption (
'useDefaultConfig',
True, type=bool,
109 info=
"whether to use the central PRW files. The default is True.")
110 self.addOption (
'userLumicalcFiles',
None, type=
None,
111 info=
"user-provided lumicalc files (list of strings). Alternative "
112 "to auto-configuration.")
113 self.addOption (
'userLumicalcFilesPerCampaign',
None, type=
None,
114 info=
"user-provided lumicalc files (dictionary of list of strings, "
115 "with MC campaigns as the keys). Alternative to auto-configuration.")
116 self.addOption (
'userPileupConfigs',
None, type=
None,
117 info=
"user-provided PRW files (list of strings). Alternative to "
118 "auto-configuration. Alternative to auto-configuration.")
119 self.addOption (
'userPileupConfigsPerCampaign',
None, type=
None,
120 info=
"user-provided PRW files (dictionary of list of strings, with "
121 "MC campaigns as the keys)")
122 self.addOption (
'postfix',
'', type=str,
123 info=
"a postfix to apply to decorations and algorithm names. "
124 "Typically not needed unless several instances of PileupReweighting are scheduled.")
125 self.addOption (
'alternativeConfig',
False, type=bool,
126 info=
"whether this is used as an additional alternative config for PileupReweighting. "
127 "Will only store the alternative pile up weight in that case.")
◆ makeAlgs()
def python.AsgAnalysisConfig.PileupReweightingBlock.makeAlgs |
( |
|
self, |
|
|
|
config |
|
) |
| |
Definition at line 130 of file AsgAnalysisConfig.py.
130 def makeAlgs (self, config) :
132 from Campaigns.Utils
import Campaign
135 from AthenaCommon.Logging
import logging
138 log = logging.getLogger(
'makePileupAnalysisSequence')
140 if config.isPhyslite()
and not self.alternativeConfig:
142 log.info(f
'Physlite does not need pileup reweighting. Variables will be copied from input instead. {config.isPhyslite}')
143 config.addOutputVar (
'EventInfo',
'runNumber',
'runNumber', noSys=
True)
144 config.addOutputVar (
'EventInfo',
'eventNumber',
'eventNumber', noSys=
True)
145 if config.dataType()
is not DataType.Data:
146 config.addOutputVar (
'EventInfo',
'mcChannelNumber',
'mcChannelNumber', noSys=
True)
147 config.addOutputVar (
'EventInfo',
'PileupWeight_%SYS%',
'weight_pileup')
148 if config.geometry()
is LHCPeriod.Run2:
149 config.addOutputVar (
'EventInfo',
'beamSpotWeight',
'weight_beamspot', noSys=
True)
153 if self.files
is None and config.autoconfigFlags()
is not None:
154 self.files = config.autoconfigFlags().Input.Files
156 campaign = self.campaign
159 if config.dataType()
is not DataType.Data
and self.campaign
is None:
161 if config.campaign()
is not None and config.campaign()
is not Campaign.Unknown:
162 campaign = config.campaign()
163 log.info(f
'Auto-configuring campaign for PRW from flags: {campaign.value}')
166 if self.files
is not None:
167 from Campaigns.Utils
import getMCCampaign
169 if campaign
and campaign
is not Campaign.Unknown:
170 log.info(f
'Auto-configuring campaign for PRW from files: {campaign.value}')
172 log.info(
'Campaign could not be determined.')
176 toolLumicalcFiles = []
180 if (config.dataType()
is not DataType.Data
and
181 config.geometry()
is not LHCPeriod.Run4):
183 if self.userPileupConfigs
is not None and self.userPileupConfigsPerCampaign
is not None:
184 raise ValueError(
'Both userPileupConfigs and userPileupConfigsPerCampaign specified, '
185 'use only one of the options!')
186 if self.userPileupConfigsPerCampaign
is not None:
188 raise Exception(
'userPileupConfigsPerCampaign requires campaign to be configured!')
189 if campaign
is Campaign.Unknown:
190 raise Exception(
'userPileupConfigsPerCampaign used, but campaign = Unknown!')
192 toolConfigFiles = self.userPileupConfigsPerCampaign[campaign.value][:]
193 log.info(
'Using user provided per-campaign PRW configuration')
194 except KeyError
as e:
195 raise KeyError(f
'Unconfigured campaign {e} for userPileupConfigsPerCampaign!')
197 elif self.userPileupConfigs
is not None:
198 toolConfigFiles = self.userPileupConfigs[:]
199 log.info(
'Using user provided PRW configuration')
202 if self.useDefaultConfig
and self.files
is None:
203 raise ValueError(
'useDefaultConfig requires files to be configured! '
204 'Either pass them as an option or use flags.')
206 from PileupReweighting.AutoconfigurePRW
import getConfigurationFiles
207 if campaign
and campaign
is not Campaign.Unknown:
210 useDefaultConfig=self.useDefaultConfig,
211 data_type=config.dataType())
212 if self.useDefaultConfig:
213 log.info(
'Auto-configuring universal/default PRW config')
215 log.info(
'Auto-configuring per-sample PRW config files based on input files')
217 log.info(
'No campaign specified, no PRW config files configured')
220 if self.userLumicalcFilesPerCampaign
is not None and self.userLumicalcFiles
is not None:
221 raise ValueError(
'Both userLumicalcFiles and userLumicalcFilesYear specified, '
222 'use only one of the options!')
223 if self.userLumicalcFilesPerCampaign
is not None:
225 toolLumicalcFiles = self.userLumicalcFilesPerCampaign[campaign.value][:]
226 log.info(
'Using user-provided per-campaign lumicalc files')
227 except KeyError
as e:
228 raise KeyError(f
'Unconfigured campaign {e} for userLumicalcFilesPerCampaign!')
229 elif self.userLumicalcFiles
is not None:
230 toolLumicalcFiles = self.userLumicalcFiles[:]
231 log.info(
'Using user-provided lumicalc files')
233 if campaign
and campaign
is not Campaign.Unknown:
234 from PileupReweighting.AutoconfigurePRW
import getLumicalcFiles
236 log.info(
'Using auto-configured lumicalc files')
238 log.info(
'No campaign specified, no lumicalc files configured for PRW')
240 log.info(
'Data needs no lumicalc and PRW configuration files')
243 if config.geometry()
is LHCPeriod.Run4:
244 log.warning (
'Pileup reweighting is not yet supported for Run 4 geometry')
245 alg = config.createAlgorithm(
'CP::EventDecoratorAlg',
'EventDecoratorAlg'+self.postfix )
246 alg.uint32Decorations = {
'RandomRunNumber' :
247 config.autoconfigFlags().Input.RunNumbers[0] }
250 alg = config.createAlgorithm(
'CP::PileupReweightingAlg',
251 'PileupReweightingAlg'+self.postfix )
252 config.addPrivateTool(
'pileupReweightingTool',
'CP::PileupReweightingTool' )
253 alg.pileupReweightingTool.ConfigFiles = toolConfigFiles
254 if not toolConfigFiles
and config.dataType()
is not DataType.Data:
255 log.info(
"No PRW config files provided. Disabling reweighting")
257 alg.pileupWeightDecoration =
""
259 alg.pileupWeightDecoration =
"PileupWeight" + self.postfix +
"_%SYS%"
260 alg.pileupReweightingTool.LumiCalcFiles = toolLumicalcFiles
262 if not self.alternativeConfig:
263 config.addOutputVar (
'EventInfo',
'runNumber',
'runNumber', noSys=
True)
264 config.addOutputVar (
'EventInfo',
'eventNumber',
'eventNumber', noSys=
True)
266 if config.dataType()
is not DataType.Data:
267 config.addOutputVar (
'EventInfo',
'mcChannelNumber',
'mcChannelNumber', noSys=
True)
268 if config.geometry()
is LHCPeriod.Run2:
269 config.addOutputVar (
'EventInfo',
'beamSpotWeight',
'weight_beamspot', noSys=
True)
271 if config.dataType()
is not DataType.Data
and toolConfigFiles:
272 config.addOutputVar (
'EventInfo',
'PileupWeight' + self.postfix +
'_%SYS%',
273 'weight_pileup'+self.postfix)
◆ files
python.AsgAnalysisConfig.PileupReweightingBlock.files |
The documentation for this class was generated from the following file: