ATLAS Offline Software
Loading...
Searching...
No Matches
JetCalibAlgConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3"""
4JetCalibAlgConfig
5
6This module is currently demonstrates a ConfigBlock for a single JetCalibAlg using the new Jet calibration tools.
7It is loosely inspired from
8
9"""
10# AnaAlgorithm import(s):
11from AnalysisAlgorithmsConfig.ConfigBlock import ConfigBlock
12from AnaAlgorithm.DualUseConfig import isAthena
13
14# Jet config imports
15from JetCalibTools.JetCalibStepsConfig import calibToolFromConfigFile
16
17class JetCalibAlgConfig(ConfigBlock):
18
19 def __init__(self):
20 super(JetCalibAlgConfig, self).__init__()
21
22 self.addOption('inputJets', '', type=str)
23 self.addOption('calibratedJets', '', type=str, meta={'role':'container'})
24 self.addOption('context', 'AnalysisLatest', type=str)
25 self.addOption('CalibFile', '', type=str) # expert override: skips YAML index lookup
26
27 def makeAlgs(self, config):
28
29 config.setSourceName (self.calibratedJets, self.inputJets, originalName = self.inputJets)
30
31 if config.wantCopy (self.calibratedJets) :
32 alg = config.createAlgorithm( 'CP::AsgShallowCopyAlg', 'JetShallowCopyAlg' )
33 alg.input = config.readName (self.calibratedJets)
34 alg.output = config.copyName (self.calibratedJets)
35
36 alg = config.createAlgorithm('CP::JetCalibAlg', 'JetCalibAlg')
37 alg.jets = config.readName(self.calibratedJets)
38 alg.OutputLevel = 3
39
40 if self.CalibFile:
41 calibFile = self.CalibFile
42 else:
43 from JetCalibTools.JetCalibToolsCfg import get_calib_cfg_path, get_jet_collection_name
44 jetcollection = self.inputJets
45 if jetcollection.endswith('Jets'):
46 jetcollection = jetcollection[:-4]
47 jetcollection = get_jet_collection_name(jetcollection)
48 calibFile = get_calib_cfg_path(self.context, jetcollection)
49
50 calibtool = calibToolFromConfigFile(config.flags, calibFile, name=self.inputJets+"Calib")
51 calibtool.OutputLevel=3
52
53 if isAthena:
54 # In this case calibtool is a regular configurable and the usual syntax works:
55 alg.calibrationTool = calibtool
56 else:
57 # AnalysisBase : use the special JetAnalysisCommon syntax to propagate the config of this tool:
58 calibtool.toToolInAnaAlg(alg, "calibrationTool")
59
60
61
62
63
64