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 192 of file JetAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.JetAnalysisConfig.SmallRJetAnalysisConfig.__init__ ( self)

Definition at line 195 of file JetAnalysisConfig.py.

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

Member Function Documentation

◆ createUncertaintyTool()

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

Definition at line 347 of file JetAnalysisConfig.py.

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

◆ getUncertaintyToolSettings()

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

Definition at line 275 of file JetAnalysisConfig.py.

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

◆ instanceName()

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

Definition at line 271 of file JetAnalysisConfig.py.

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

◆ makeAlgs()

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

Definition at line 378 of file JetAnalysisConfig.py.

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

Member Data Documentation

◆ containerName

python.JetAnalysisConfig.SmallRJetAnalysisConfig.containerName

Definition at line 381 of file JetAnalysisConfig.py.

◆ recalibratePhyslite

python.JetAnalysisConfig.SmallRJetAnalysisConfig.recalibratePhyslite

Definition at line 401 of file JetAnalysisConfig.py.

◆ runFJvtSelection

python.JetAnalysisConfig.SmallRJetAnalysisConfig.runFJvtSelection

Definition at line 526 of file JetAnalysisConfig.py.

◆ runJERsystematicsOnData

python.JetAnalysisConfig.SmallRJetAnalysisConfig.runJERsystematicsOnData

Definition at line 368 of file JetAnalysisConfig.py.

◆ runJvtSelection

python.JetAnalysisConfig.SmallRJetAnalysisConfig.runJvtSelection

Definition at line 489 of file JetAnalysisConfig.py.

◆ runJvtUpdate

python.JetAnalysisConfig.SmallRJetAnalysisConfig.runJvtUpdate

Definition at line 467 of file JetAnalysisConfig.py.

◆ runNNJvtUpdate

python.JetAnalysisConfig.SmallRJetAnalysisConfig.runNNJvtUpdate

Definition at line 476 of file JetAnalysisConfig.py.

◆ runUncertainties

python.JetAnalysisConfig.SmallRJetAnalysisConfig.runUncertainties

Definition at line 459 of file JetAnalysisConfig.py.

◆ systematicsModelJES

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

Definition at line 284 of file JetAnalysisConfig.py.

◆ uncertaintyAnalysisFiles

python.JetAnalysisConfig.SmallRJetAnalysisConfig.uncertaintyAnalysisFiles

Definition at line 365 of file JetAnalysisConfig.py.


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