ATLAS Offline Software
Loading...
Searching...
No Matches
JetCalibTestAlgConfig.py
Go to the documentation of this file.
1#!/usr/bin/env python
2
3# Script to run JetCalibTestAlg
4#
5# Example useage:
6# JetCalibTestAlgConfig.py \
7# --configFile=JetCalibTools/calibConfigExample.yaml \
8# --evtMax 5 \
9# --filesInput /eos/atlas/atlascerngroupdisk/perf-jets/Hackathon/mc23_13p6TeV.830187.H7EG_H72NNPDF30NLO_jetjet_Lund_JZ1.deriv.DAOD_PHYS.e8551_s4159_r15224_p6266/DAOD_PHYS.40788428._000097.pool.root.1
10# --debugAlg
11#
12# --debugAlg prints the per-jet pT DEBUG messages from JetCalibTestAlg;
13# use --level DEBUG instead to get DEBUG output from every component.
14
15from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
16from AthenaConfiguration.ComponentFactory import CompFactory
17from JetCalibTools.JetCalibStepsConfig import calibToolFromConfigFile
18
19def JetCalibTestAlgCfg(flags, name="JetCalibTestAlg",
20 configFile="JetCalibTools/calibConfigExample.yaml", **kwargs):
21 acc = ComponentAccumulator()
22
23 # Configure the jet calibration tool from a YAML config file
24 jetCalibTool = calibToolFromConfigFile(
25 flags,
26 configFile = configFile,
27 name = "JetCalibTool",
28 calibSeqKey='Default',
29 )
30
31 alg = CompFactory.JetCalibTestAlg(
32 name,
33 JetCalibTool = jetCalibTool,
34 JetContainerKey = "AntiKt4EMPFlowJets",
35 **kwargs
36 )
37 acc.addEventAlgo(alg)
38 return acc
39
40if __name__=='__main__':
41
42 # Setup logs
43 from AthenaCommon.Logging import log
44 from AthenaCommon.Constants import INFO
45 log.setLevel(INFO)
46
47 from AthenaConfiguration.AllConfigFlags import initConfigFlags
48
49 flags = initConfigFlags()
50 # Defaults, overridable on the command line with --filesInput and --evtMax
51 defaultInputFile = '/eos/atlas/atlascerngroupdisk/perf-jets/Hackathon/mc23_13p6TeV.830187.H7EG_H72NNPDF30NLO_jetjet_Lund_JZ1.deriv.DAOD_PHYS.e8551_s4159_r15224_p6266/DAOD_PHYS.40788428._000097.pool.root.1'
52 flags.Input.Files = [defaultInputFile]
53 flags.Exec.MaxEvents = 10
54
55 # --configFile command-line option to specify YAML config file
56 parser = flags.getArgumentParser()
57 parser.add_argument("--configFile", default="JetCalibTools/calibConfigExample.yaml",
58 help="jet calibration YAML config (PathResolver or local path)")
59 parser.add_argument("--debugAlg", action="store_true",
60 help="print DEBUG messages from JetCalibTestAlg only, "
61 "leaving all other components at the global output level")
62 args = flags.fillFromArgs(parser=parser)
63 flags.lock()
64
65 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
66 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
67 cfg = MainServicesCfg(flags)
68 cfg.merge(PoolReadCfg(flags))
69
70 algName = "JetCalibTestAlg"
71 alg = JetCalibTestAlgCfg(flags, name=algName, configFile=args.configFile)
72 cfg.merge(alg)
73
74 if args.debugAlg:
75 msgSvc = cfg.getService("MessageSvc")
76 msgSvc.setDebug = list(msgSvc.setDebug) + [algName]
77
78 cfg.run(flags.Exec.MaxEvents)
JetCalibTestAlgCfg(flags, name="JetCalibTestAlg", configFile="JetCalibTools/calibConfigExample.yaml", **kwargs)