ATLAS Offline Software
Loading...
Searching...
No Matches
python.JetAnalysisConfig.SmallRJetAnalysisConfig Class Reference
Inheritance diagram for python.JetAnalysisConfig.SmallRJetAnalysisConfig:
Collaboration diagram for python.JetAnalysisConfig.SmallRJetAnalysisConfig:

Public Member Functions

 __init__ (self)
 instanceName (self)
 getUncertaintyToolSettings (self, config)
 createUncertaintyTool (self, jetUncertaintiesAlg, config, jetCollectionName, doPseudoData=False)
 makeAlgs (self, config)

Public Attributes

str systematicsModelJES = "All":
 uncertaintyAnalysisFiles
 runJERsystematicsOnData
 containerName
 recalibratePhyslite
 runUncertainties
 runJvtUpdate
 runNNJvtUpdate
 runJvtSelection
 runFJvtSelection

Detailed Description

the ConfigBlock for the small-r jet sequence

Definition at line 190 of file JetAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.JetAnalysisConfig.SmallRJetAnalysisConfig.__init__ ( self)

Definition at line 193 of file JetAnalysisConfig.py.

193 def __init__ (self) :
194 super().__init__()
195 self.addOption ('containerName', '', type=str,
196 noneAction='error',
197 info="the name of the output container after calibration.",
198 meta={'role':'container'})
199 self.addOption ('jetCollection', '', type=str,
200 noneAction='error',
201 info="the jet container to run on. It is interpreted to determine "
202 "the correct config blocks to call for small- or large-R jets.")
203 self.addOption ('runJvtUpdate', False, type=bool,
204 info="whether to update the JVT.")
205 self.addOption ('runNNJvtUpdate', False, type=bool,
206 info="whether to update the NN-JVT.")
207 self.addOption ('runJvtSelection', True, type=bool,
208 info="whether to run JVT selection.")
209 self.addOption ('runFJvtSelection', False, type=bool,
210 info="whether to run forward JVT selection.")
211 self.addOption ('jvtWP', "FixedEffPt", type=str,
212 info="which Jvt WP to apply.",
213 meta={'choices':(['FixedEffPt'],1)})
214 self.addOption ('fJvtWP', "Loose", type=str,
215 info="which fJvt WP to apply.",
216 meta={'choices':(['Loose','Tight','Tighter'],1)})
217 self.addOption ('runJvtEfficiency', True, type=bool,
218 info="whether to calculate the JVT efficiency.")
219 self.addOption ('runFJvtEfficiency', False, type=bool,
220 info="whether to calculate the forward JVT efficiency.")
221 self.addOption ('runUncertainties', True, type=bool,
222 info="whether to configure JetUncertaintiesTool.", expertMode=True)
223 self.addOption('uncertaintyAnalysisFiles', None, type=dict,
224 info="dictionary of dsids with entry corresponding to file containing gluon fraction histograms needed to calculate an analysis specific "
225 "jet flavor composition uncertainty.")
226 self.addOption ('systematicsModelJES', "Category", type=str,
227 info="the NP reduction scheme to use for JES: All, Global, Category, "
228 "Scenario. The default is Category.")
229 self.addOption ('systematicsModelJER', "Full", type=str,
230 info="the NP reduction scheme to use for JER: All, Full, Simple. The "
231 "default is Full.",
232 meta={'choices':(['All','Full','Simple'],1)})
233 self.addOption ('runJERsystematicsOnData', False, type=bool,
234 info="whether to run the All/Full JER model variations also on data samples. Expert option!",
235 expertMode=True)
236 self.addOption ('recalibratePhyslite', True, type=bool,
237 info="whether to run the `CP::JetCalibrationAlg` on PHYSLITE derivations.")
238 # Calibration tool options
239 self.addOption ('calibToolConfigFile', None, type=str,
240 info="the name of the config file to use for the jet calibration "
241 "tool. Expert option to override JetETmiss recommendations.",
242 expertMode=True)
243 self.addOption ('calibToolCalibArea', None, type=str,
244 info="name of the CVMFS area to use for the jet calibration "
245 "tool. Expert option to override JetETmiss recommendations.",
246 expertMode=True)
247 self.addOption ('calibToolCalibSeq', None, type=str,
248 info="name of the sequence to use for the jet calibration "
249 "tool (e.g. `JetArea_Residual_EtaJES_GSC`). Expert option to override "
250 "JetETmiss recommendations.",
251 expertMode=True)
252 # Uncertainties tool options
253 self.addOption ('uncertToolConfigPath', None, type=str,
254 info="name (str) of the config file to use for the jet uncertainty "
255 "tool. Expert option to override JetETmiss recommendations. The "
256 "default is None.",
257 expertMode=True)
258 self.addOption ('uncertToolCalibArea', None, type=str,
259 info="name (str) of the CVMFS area to use for the jet uncertainty "
260 "tool. Expert option to override JetETmiss recommendations. The "
261 "default is None.",
262 expertMode=True)
263 self.addOption ('uncertToolMCType', None, type=str,
264 info="data type (str) to use for the jet uncertainty tool (e.g. "
265 "'AF3' or 'MC16'). Expert option to override JetETmiss "
266 "recommendations. The default is None.",
267 expertMode=True)
268

Member Function Documentation

◆ createUncertaintyTool()

python.JetAnalysisConfig.SmallRJetAnalysisConfig.createUncertaintyTool ( self,
jetUncertaintiesAlg,
config,
jetCollectionName,
doPseudoData = False )

Definition at line 345 of file JetAnalysisConfig.py.

345 def createUncertaintyTool(self, jetUncertaintiesAlg, config, jetCollectionName, doPseudoData=False):
346
347 # Create an instance of JetUncertaintiesTool, following JetETmiss recommendations.
348 # To run Jet Energy Resolution (JER) uncertainties in the "Full" or "All" schemes,
349 # we need two sets of tools: one configured as normal (MC), the other with the
350 # exact same settings but pretending to run on data (pseudo-data).
351 # This is achieved by passing "isPseudoData=True" to the arguments.
352
353 # Retrieve the common configuration settings
354 configFile, calibArea, mcType = self.getUncertaintyToolSettings(config)
355
356 # The main tool for all JES+JER combinations
357 tool = _addJetUncertaintiesTool(config, jetUncertaintiesAlg, 'uncertaintiesTool',
358 jetCollectionName, configFile, calibArea, mcType,
359 isData=(config.dataType() is DataType.Data),
360 pseudoData=False)
361 from PathResolver import PathResolver
362 if self.uncertaintyAnalysisFiles is not None:
363 if config.dsid() in self.uncertaintyAnalysisFiles:
364 tool.AnalysisFile = PathResolver.FindCalibFile(self.uncertaintyAnalysisFiles[config.dsid()])
365
366 if config.dataType() is DataType.Data and not (doPseudoData and self.runJERsystematicsOnData):
367 # we don't want any systematics on data if we're not using the right JER model!
368 jetUncertaintiesAlg.affectingSystematicsFilter = '.*'
369 if config.dataType() is not DataType.Data and doPseudoData and not self.runJERsystematicsOnData:
370 # The secondary tool for pseudo-data JER smearing
371 _addJetUncertaintiesTool(config, jetUncertaintiesAlg, 'uncertaintiesToolPD',
372 jetCollectionName, configFile, calibArea, mcType,
373 isData=True, pseudoData=True)
374
375
static std::string FindCalibFile(const std::string &logical_file_name)

◆ getUncertaintyToolSettings()

python.JetAnalysisConfig.SmallRJetAnalysisConfig.getUncertaintyToolSettings ( self,
config )

Definition at line 273 of file JetAnalysisConfig.py.

273 def getUncertaintyToolSettings(self, config):
274
275 # Retrieve appropriate JES/JER recommendations for the JetUncertaintiesTool.
276 # We do this separately from the tool declaration, as we may need to set uo
277 # two such tools, but they have to be private.
278
279 jetInput = config.getContainerMeta(self.containerName, 'jetInput', failOnMiss=True)
280 # Config file:
281 config_file = None
282 if self.systematicsModelJES == "All" and self.systematicsModelJER == "All":
283 config_file = "R4_AllNuisanceParameters_AllJERNP.config"
284 elif "Scenario" in self.systematicsModelJES:
285 if self.systematicsModelJER != "Simple":
286 raise ValueError(
287 "Invalid uncertainty configuration - Scenario* systematicsModelJESs can "
288 "only be used together with the Simple systematicsModelJER")
289 config_file = f"R4_{self.systematicsModelJES}_SimpleJER.config"
290 elif self.systematicsModelJES in ["Global", "Category"] and self.systematicsModelJER in ["Simple", "Full"]:
291 config_file = f"R4_{self.systematicsModelJES}Reduction_{self.systematicsModelJER}JER.config"
292 else:
293 raise ValueError(
294 "Invalid combination of systematicsModelJES and systematicsModelJER settings: "
295 f"systematicsModelJES: {self.systematicsModelJES}, systematicsModelJER: {self.systematicsModelJER}" )
296
297 # Calibration area:
298 calib_area = None
299 if self.uncertToolCalibArea is not None:
300 calib_area = self.uncertToolCalibArea
301
302 # Expert override for config path:
303 if self.uncertToolConfigPath is not None:
304 config_file = self.uncertToolConfigPath
305 else:
306 if config.geometry() is LHCPeriod.Run2:
307 if config.dataType() is DataType.FastSim:
308 config_file = "rel22/Fall2024_PreRec/" + config_file
309 else:
310 if jetInput == "HI":
311 config_file = "HIJetUncertainties/Spring2023/HI" + config_file
312 else:
313 config_file = "rel22/Summer2023_PreRec/" + config_file
314 else:
315 if config.dataType() is DataType.FastSim:
316 config_file = "rel22/Winter2025_AF3_PreRec/" + config_file
317 else:
318 if jetInput == "HI":
319 config_file = "HIJetUncertainties/Spring2023/HI" + config_file
320 else:
321 config_file = "rel22/Winter2025_PreRec/" + config_file
322
323 # MC type:
324 mc_type = None
325 if self.uncertToolMCType is not None:
326 mc_type = self.uncertToolMCType
327 else:
328 if config.geometry() is LHCPeriod.Run2:
329 if config.dataType() is DataType.FastSim:
330 mc_type = "AF3"
331 else:
332 mc_type = "MC20"
333 else:
334 if config.dataType() is DataType.FastSim:
335 mc_type = "MC23AF3"
336 else:
337 if jetInput == "HI":
338 mc_type = "MC16"
339 else:
340 mc_type = "MC23"
341
342 return config_file, calib_area, mc_type
343
344

◆ instanceName()

python.JetAnalysisConfig.SmallRJetAnalysisConfig.instanceName ( self)
Return the instance name for this block

Definition at line 269 of file JetAnalysisConfig.py.

269 def instanceName (self) :
270 """Return the instance name for this block"""
271 return self.containerName
272

◆ makeAlgs()

python.JetAnalysisConfig.SmallRJetAnalysisConfig.makeAlgs ( self,
config )

Definition at line 376 of file JetAnalysisConfig.py.

376 def makeAlgs (self, config) :
377
378 # Self-select: only run for radius-4 jets
379 if config.getContainerMeta(self.containerName, 'jetRadius', failOnMiss=True) != 4:
380 return
381
382
383 jetCollectionName = config.getContainerMeta(self.containerName, 'jetCollectionName', failOnMiss=True)
384
385 jetInput = config.getContainerMeta(self.containerName, 'jetInput', failOnMiss=True)
386
387 if jetInput not in ["EMTopo", "EMPFlow", "HI"]:
388 raise ValueError(
389 f"Unsupported input type '{jetInput}' for R=0.4 jets!" )
390
391 if self.jvtWP not in ["FixedEffPt"]:
392 raise ValueError(
393 f"Unsupported NNJvt WP '{self.jvtWP}'" )
394
395 if self.fJvtWP not in ["Loose", "Tight", "Tighter"]:
396 raise ValueError(
397 f"Unsupported fJvt WP '{self.fJvtWP}'" )
398
399 if not config.isPhyslite() or self.recalibratePhyslite:
400 # Create calibration tool as public so it can be shared
401 # (e.g. with FTAG1LITE's JetCalibratedPtDecoratorAlg).
402 # Must be created before the algorithm so EventLoop
403 # initialises the tool first.
404 calibToolName = 'JetCalibTool_' + jetCollectionName[:-4]
405 calibTool = config.createPublicTool( 'JetCalibrationTool', calibToolName )
406 calibTool.JetCollection = jetCollectionName[:-4]
407 # Get the correct string to use in the config file name
408 if jetInput == "EMPFlow":
409 if config.geometry() is LHCPeriod.Run2:
410 configFile = "PreRec_R22_PFlow_ResPU_EtaJES_GSC_February23_230215.config"
411 calibTool.CalibArea = "00-04-82"
412 elif config.geometry() >= LHCPeriod.Run3:
413 configFile = "AntiKt4EMPFlow_MC23a_PreRecR22_Phase2_CalibConfig_ResPU_EtaJES_GSC_241208_InSitu.config"
414 calibTool.CalibArea = "00-04-83"
415 elif jetInput == "HI":
416 if config.geometry() is LHCPeriod.Run2:
417 configFile = "JES_MC16_HI_Jan2021_5TeV.config"
418 elif config.geometry() is LHCPeriod.Run3:
419 configFile = "AntiKt4HI_MC23_EtaJES_Run3PreRec_Run2VJet_Run3EtaInt_5p36TeV.config"
420 calibTool.CalibArea = "00-04-83"
421 else:
422 raise ValueError(
423 f"Unsupported geometry '{config.geometry()}' for HI jet calibration!")
424 else:
425 if config.dataType() is DataType.FastSim:
426 configFile = f"JES_MC16Recommendation_AFII_{jetInput}_Apr2019_Rel21.config"
427 else:
428 configFile = f"JES_MC16Recommendation_Consolidated_{jetInput}_Apr2019_Rel21.config"
429 if self.calibToolCalibArea is not None:
430 calibTool.CalibArea = self.calibToolCalibArea
431 if self.calibToolConfigFile is not None:
432 configFile = self.calibToolConfigFile
433 calibTool.ConfigFile = configFile
434 if config.dataType() is DataType.Data:
435 if jetInput == "HI":
436 calibTool.CalibSequence = 'EtaJES_Insitu'
437 else:
438 calibTool.CalibSequence = 'JetArea_Residual_EtaJES_GSC_Insitu'
439 else:
440 if jetInput == "EMPFlow":
441 calibTool.CalibSequence = 'JetArea_Residual_EtaJES_GSC'
442 elif jetInput == "HI":
443 calibTool.CalibSequence = 'EtaJES'
444 else:
445 calibTool.CalibSequence = 'JetArea_Residual_EtaJES_GSC_Smear'
446 if self.calibToolCalibSeq is not None:
447 calibTool.CalibSequence = self.calibToolCalibSeq
448 calibTool.IsData = (config.dataType() is DataType.Data)
449 # Prepare the jet calibration algorithm
450 alg = config.createAlgorithm( 'CP::JetCalibrationAlg', 'JetCalibrationAlg' )
451 alg.HIsetup = jetInput == "HI"
452 alg.calibrationTool = f'{calibTool.getType()}/{calibTool.getName()}'
453 alg.jets = config.readName (self.containerName)
454 alg.jetsOut = config.copyName (self.containerName)
455
456 # Jet uncertainties
457 if self.runUncertainties:
458 alg = config.createAlgorithm( 'CP::JetUncertaintiesAlg', 'JetUncertaintiesAlg' )
459 self.createUncertaintyTool(alg, config, jetCollectionName, doPseudoData=( self.systematicsModelJER in ["Full","All"] ))
460 alg.jets = config.readName (self.containerName)
461 alg.jetsOut = config.copyName (self.containerName)
462 alg.preselection = config.getPreselection (self.containerName, '')
463
464 # Set up the JVT update algorithm:
465 if self.runJvtUpdate :
466 alg = config.createAlgorithm( 'CP::JvtUpdateAlg', 'JvtUpdateAlg' )
467 config.addPrivateTool( 'jvtTool', 'JetVertexTaggerTool' )
468 alg.jvtTool.JetContainer = self.jetCollection
469 alg.jvtTool.SuppressInputDependence=True
470 alg.jets = config.readName (self.containerName)
471 alg.jetsOut = config.copyName (self.containerName)
472 alg.preselection = config.getPreselection (self.containerName, '')
473
474 if self.runNNJvtUpdate:
475 assert jetInput=="EMPFlow", "NN JVT only defined for PFlow jets"
476 alg = config.createAlgorithm( 'CP::JetDecoratorAlg', 'NNJvtUpdateAlg' )
477 config.addPrivateTool( 'decorator', 'JetPileupTag::JetVertexNNTagger' )
478 alg.jets = config.readName (self.containerName)
479 alg.jetsOut = config.copyName (self.containerName)
480 # Set this actually to the *output* collection
481 alg.decorator.JetContainer = alg.jetsOut.replace ('%SYS%', 'NOSYS')
482 alg.decorator.SuppressInputDependence=True
483 alg.decorator.SuppressOutputDependence=True
484
485 # Set up the jet efficiency scale factor calculation algorithm
486 # Change the truthJetCollection property to AntiKt4TruthWZJets if preferred
487 if self.runJvtSelection :
488 assert jetInput=="EMPFlow", "NNJvt WPs and SFs only valid for PFlow jets"
489 warnings.warn_explicit(
490 "jvtWP, runJvtSelection and runJvtEfficiency"
491 " are deprecated - please use a"
492 " JVTWorkingPoint block instead.",
493 ConfigDeprecationWarning, filename='', lineno=0)
494
495 alg = config.createAlgorithm('CP::AsgSelectionAlg', 'JvtSelectionAlg')
496 config.addPrivateTool('selectionTool', 'CP::NNJvtSelectionTool')
497 alg.selectionTool.JetContainer = config.readName(self.containerName)
498 alg.selectionTool.JvtMomentName = "NNJvt"
499 alg.selectionTool.WorkingPoint = self.jvtWP
500 alg.selectionTool.MaxPtForJvt = 60*GeV
501 alg.selectionDecoration = "jvt_selection,as_char"
502 alg.particles = config.readName(self.containerName)
503
504 if self.runJvtEfficiency and config.dataType() is not DataType.Data:
505 alg = config.createAlgorithm( 'CP::JvtEfficiencyAlg', 'JvtEfficiencyAlg' )
506 config.addPrivateTool( 'efficiencyTool', 'CP::NNJvtEfficiencyTool' )
507 alg.efficiencyTool.JetContainer = config.readName(self.containerName)
508 alg.efficiencyTool.MaxPtForJvt = 60*GeV
509 alg.efficiencyTool.WorkingPoint = self.jvtWP
510 if config.geometry() is LHCPeriod.Run2:
511 alg.efficiencyTool.SFFile = "JetJvtEfficiency/May2024/NNJvtSFFile_Run2_EMPFlow.root"
512 else:
513 alg.efficiencyTool.SFFile = "JetJvtEfficiency/May2024/NNJvtSFFile_Run3_EMPFlow.root"
514 alg.selection = 'jvt_selection,as_char'
515 alg.scaleFactorDecoration = 'jvt_effSF_%SYS%'
516 alg.outOfValidity = 2
517 alg.outOfValidityDeco = 'no_jvt'
518 alg.skipBadEfficiency = False
519 alg.jets = config.readName (self.containerName)
520 alg.preselection = config.getPreselection (self.containerName, '')
521 config.addOutputVar (self.containerName, alg.scaleFactorDecoration, 'jvtEfficiency')
522 config.addSelection (self.containerName, 'baselineJvt', 'jvt_selection,as_char', preselection=False)
523
524 if self.runFJvtSelection :
525 assert jetInput=="EMPFlow", "fJvt WPs and SFs only valid for PFlow jets"
526 warnings.warn_explicit(
527 "fJvtWP, runFJvtSelection and runFJvtEfficiency"
528 " are deprecated - please use a"
529 " FJVTWorkingPoint block instead.",
530 ConfigDeprecationWarning, filename='', lineno=0)
531
532 alg = config.createAlgorithm('CP::AsgSelectionAlg', 'FJvtSelectionAlg')
533 config.addPrivateTool('selectionTool', 'CP::FJvtSelectionTool')
534 alg.selectionTool.JetContainer = config.readName(self.containerName)
535 alg.selectionTool.JvtMomentName = "DFCommonJets_fJvt"
536 alg.selectionTool.WorkingPoint = self.fJvtWP
537 alg.selectionDecoration = "fjvt_selection,as_char"
538 alg.particles = config.readName(self.containerName)
539
540 if self.runFJvtEfficiency and config.dataType() is not DataType.Data:
541 alg = config.createAlgorithm( 'CP::JvtEfficiencyAlg', 'FJvtEfficiencyAlg' )
542 config.addPrivateTool( 'efficiencyTool', 'CP::FJvtEfficiencyTool' )
543 alg.efficiencyTool.JetContainer = config.readName(self.containerName)
544 alg.efficiencyTool.WorkingPoint = self.fJvtWP
545 if config.geometry() is LHCPeriod.Run2:
546 alg.efficiencyTool.SFFile = "JetJvtEfficiency/May2024/fJvtSFFile_Run2_EMPFlow.root"
547 else:
548 alg.efficiencyTool.SFFile = "JetJvtEfficiency/May2024/fJvtSFFile_Run3_EMPFlow.root"
549 alg.selection = 'fjvt_selection,as_char'
550 alg.scaleFactorDecoration = 'fjvt_effSF_%SYS%'
551 alg.outOfValidity = 2
552 alg.outOfValidityDeco = 'no_fjvt'
553 alg.skipBadEfficiency = False
554 alg.jets = config.readName (self.containerName)
555 alg.preselection = config.getPreselection (self.containerName, '')
556 config.addOutputVar (self.containerName, alg.scaleFactorDecoration, 'fjvtEfficiency')
557 config.addSelection (self.containerName, 'baselineFJvt', 'fjvt_selection,as_char', preselection=False)
558
559 # Additional decorations
560 alg = config.createAlgorithm( 'CP::AsgEnergyDecoratorAlg', 'AsgEnergyDecoratorAlg' )
561 alg.particles = config.readName (self.containerName)
562
563 config.addOutputVar (self.containerName, 'e_%SYS%', 'e')
564
565

Member Data Documentation

◆ containerName

python.JetAnalysisConfig.SmallRJetAnalysisConfig.containerName

Definition at line 379 of file JetAnalysisConfig.py.

◆ recalibratePhyslite

python.JetAnalysisConfig.SmallRJetAnalysisConfig.recalibratePhyslite

Definition at line 399 of file JetAnalysisConfig.py.

◆ runFJvtSelection

python.JetAnalysisConfig.SmallRJetAnalysisConfig.runFJvtSelection

Definition at line 524 of file JetAnalysisConfig.py.

◆ runJERsystematicsOnData

python.JetAnalysisConfig.SmallRJetAnalysisConfig.runJERsystematicsOnData

Definition at line 366 of file JetAnalysisConfig.py.

◆ runJvtSelection

python.JetAnalysisConfig.SmallRJetAnalysisConfig.runJvtSelection

Definition at line 487 of file JetAnalysisConfig.py.

◆ runJvtUpdate

python.JetAnalysisConfig.SmallRJetAnalysisConfig.runJvtUpdate

Definition at line 465 of file JetAnalysisConfig.py.

◆ runNNJvtUpdate

python.JetAnalysisConfig.SmallRJetAnalysisConfig.runNNJvtUpdate

Definition at line 474 of file JetAnalysisConfig.py.

◆ runUncertainties

python.JetAnalysisConfig.SmallRJetAnalysisConfig.runUncertainties

Definition at line 457 of file JetAnalysisConfig.py.

◆ systematicsModelJES

str python.JetAnalysisConfig.SmallRJetAnalysisConfig.systematicsModelJES = "All":

Definition at line 282 of file JetAnalysisConfig.py.

◆ uncertaintyAnalysisFiles

python.JetAnalysisConfig.SmallRJetAnalysisConfig.uncertaintyAnalysisFiles

Definition at line 363 of file JetAnalysisConfig.py.


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