ATLAS Offline Software
Loading...
Searching...
No Matches
CaloClusterTritonConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4from AthenaConfiguration.ComponentFactory import CompFactory
5
6
7def CaloClusterTritonToolCfg(flags, name="CaloClusterTritonTool", **kwargs):
8 """Configure CaloClusterTritonTool with its AthInfer::TritonTool backend."""
9 acc = ComponentAccumulator()
10
11 from AthTritonComps.TritonToolConfig import TritonToolCfg
12 kwargs.setdefault("TritonInferenceTool",
13 acc.popToolsAndMerge(TritonToolCfg(flags,
14 model_name=flags.Calo.Triton.name,
15 url=flags.Calo.Triton.url,
16 port=flags.Calo.Triton.port)))
17 kwargs.setdefault("CellEnergyThreshold", 0.005) # GeV
18
19 acc.setPrivateTools(CompFactory.CaloClusterTritonTool(name, **kwargs))
20 return acc
21
22
24 clusterContainer="CaloCalTopoClusters",
25 decorName="GNNCalibratedEnergy",
26 name="CaloClusterTritonAlg",
27 **kwargs):
28 """Schedule CaloClusterTritonAlg, which decorates clusters with the GNN energy [MeV]."""
29 acc = ComponentAccumulator()
30
31 kwargs.setdefault("CaloClusterTritonTool",
32 acc.popToolsAndMerge(CaloClusterTritonToolCfg(flags)))
33 kwargs.setdefault("ClusterContainer", clusterContainer)
34 kwargs.setdefault("ClusterGNNCalibratedEnergyKeyName", f"{clusterContainer}.{decorName}")
35 kwargs.setdefault("RapidityRange", [-2.5, 2.5])
36 kwargs.setdefault("MinClusterEnergy", 300.0) # MeV
37
38 acc.addEventAlgo(CompFactory.CaloClusterTritonAlg(name, **kwargs))
39 return acc
40
41
42
43if __name__ == "__main__":
44 import argparse
45 from AthenaConfiguration.AllConfigFlags import initConfigFlags
46 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
47 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
48
49 parser = argparse.ArgumentParser()
50 parser.add_argument("--input", nargs="+", required=True, help="Input ESD/AOD file(s) with cell links")
51 parser.add_argument("--model", required=True, help="Triton model name")
52 parser.add_argument("--url", default="localhost", help="Triton server URL")
53 parser.add_argument("--port", type=int, default=8001, help="Triton gRPC port")
54 parser.add_argument("--maxEvents", type=int, default=10)
55 args = parser.parse_args()
56
57 flags = initConfigFlags()
58 flags.Input.Files = args.input
59 flags.Exec.MaxEvents = args.maxEvents
60 flags.lock()
61
62 cfg = MainServicesCfg(flags)
63 cfg.merge(PoolReadCfg(flags))
64
65 # Cell links require the calorimeter geometry and cell container to be readable
66 from LArGeoAlgsNV.LArGMConfig import LArGMCfg
67 from TileGeoModel.TileGMConfig import TileGMCfg
68 cfg.merge(LArGMCfg(flags))
69 cfg.merge(TileGMCfg(flags))
70
71 cfg.merge(CaloClusterTritonAlgCfg(flags,
72 model_name=args.model,
73 url=args.url,
74 port=args.port))
75
76 import sys
77 sys.exit(cfg.run().isFailure())
CaloClusterTritonToolCfg(flags, name="CaloClusterTritonTool", **kwargs)
CaloClusterTritonAlgCfg(flags, clusterContainer="CaloCalTopoClusters", decorName="GNNCalibratedEnergy", name="CaloClusterTritonAlg", **kwargs)