ATLAS Offline Software
Loading...
Searching...
No Matches
TrackAnalysisConfig.py
Go to the documentation of this file.
2# @file TrackAnalysisConfig
3#
4# @author sutt@cern.ch
5# @date Tue 7 Jul 2026 12:10:43 BST
6#
7# Configures the track analyses for IDTPM2,
8# currently quite trigger biased, but can easily
9# be modified to look less trigger specific
10#
11# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
12#
13
14
15from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
16# from AthenaConfiguration.ComponentFactory import CompFactory
17# from AthenaCommon.Logging import logging
18
19from TrigIDR4Monitoring.MonTool import createMonTool
20
21from TrigInDetAnalysisExample.chainString import chainString
22
23
24def createTrackAnalysis( flags, name="TrackAnalysis", chains=[], label="", kak=None ):
25
26 # newer releases don't allow you to modify flags during the configuration,
27 # so we sack off the input flags and just duplicate and create our own.
28 # need two at the moment, since we use the same tool for the
29 # reference track selection, and the test track selection, so need
30 # different settings of the flags for each
31 # we are implementing a better solution at the moment, where we can
32 # actually tell tools what the domain of the flags is that they should use
33
34 # from AthenaConfiguration.AllConfigFlags import initConfigFlags
35 # flags = initConfigFlags()
36
37 # if isinstance( chains, list ) :
38 # print( "" )
39 # for ch in chains : print( "list chain: ", ch )
40
41
42 from AthenaConfiguration.ComponentFactory import CompFactory
43
44 if isinstance( chains, list ) : chain = chains[0]
45 else : chain = chains
46
47 cs = chainString( chain )
48
49 # print( "RoiKey: ", cs.roi, " :: ", name )
50
51 from TrigIDR4Monitoring.ParticleSelectorConfig import ParticleSelectorCfg
52
53 from TrigIDR4Monitoring.MatchingConfig import TrackViewMatchingToolCfg
54
55 # flags.addFlag("RoiKey", cs.roi ) # do we still need that at all ?
56
57 # for electrons ...
58 # setFlagIfNotSet( flags, "minET", 14000 )
59 # setFlagIfNotSet( flags, "minETovpt", 0.8 )
60
61 # flags2.addFlag("UseOfflineTool", False )
62
63 tool = CompFactory.IDTPM2.TrackAnalysis(name)
64
65 # for electrons ...
66
67 if flags.has("Reference") : tool.Reference = flags.Reference
68
69 if flags.has("ReferencePdgIdTag") : tool.ReferencePdgId = flags.ReferencePdgIdTag
70 if flags.has("MinTagPT") : tool.MinTagPT = flags.MinTagPT
71 if flags.has("MinTagMass") : tool.MinTagMass = flags.MinTagMass
72 if flags.has("MaxTagMass") : tool.MaxTagMass = flags.MaxTagMass
73
74 if flags.has("useDecorations") : tool.useDecorations = flags.useDecorations
75
76
77 if len(chains) > 1 :
78 tool.TagChain = chains[1]
79 if flags.has("ReferenceTag") : tool.ReferenceTag = flags.ReferenceTag
80 if flags.has("ReferencePdgIdTag") : tool.ReferencePdgIdTag = flags.ReferencePdgIdTag
81
82 # don't want the vertex analysis if no vertices are specified
83 if cs.vtx : tool.Fillers = [ "Tier0", "TrackParameters", "Resolutions", "Efficiencies", "SiHits", "TRTHits", "Vertices" ]
84 else : tool.Fillers = [ "Tier0", "TrackParameters", "Resolutions", "Efficiencies", "SiHits", "TRTHits" ]
85
86 # tool.Fillers = [ "Resolutions" ]
87
88 montool = createMonTool( flags, label, chain, tool.Fillers )
89
90 # print( "in montool: ", montool.name )
91
92 tool.montool = montool
93
94# tool.ReferenceSelector = mktool( TrackSelectorCfg( flags.RefSelector, name="ReferenceSelector_" + sanitise(name) ), kak )
95# tool.TestSelector = mktool( TrackSelectorCfg( flags.TestSelector, name="TestSelector_" + sanitise(name) ), kak )
96
97 tool.ReferenceSelector = mktool( ParticleSelectorCfg( flags.RefSelector, name="ReferenceSelector_" + sanitise(name) ), kak )
98 tool.TestSelector = mktool( ParticleSelectorCfg( flags.TestSelector, name="TestSelector_" + sanitise(name) ), kak )
99
100 tool.TrackMatchingTool = mktool( TrackViewMatchingToolCfg( flags.Matcher, name="TrackViewMatchingTool_" + sanitise(name) ), kak )
101
102 # tool.VertexQualitySelectionTool = mktool( VertexQualitySelectionToolCfg( flags, name="VertexQualitySelectionTool_" + sanitise(name) ), kak )
103
104 # VertexQualitySelectionTool = name="VertexQualitySelectionTool"+flags.PhysVal.IDTPM2.currentTrkAna.anaTag
105
106 # kak.printConfig(withDetails=True, summariseProps=True)
107
108 return tool
109
110
111
112def setFlagIfNotSet( flags, attr, value ) :
113 if flags.hasFlag(attr):
114 if flags._flagdict[attr].get(value) == -9999:
115 flags._flagdict[attr].set(value)
116 return
117 else:
118 flags.addFlag(attr,value)
119
120
121# just lazy, and like the code to be neater
122def mktool( ca, kak=None ):
123 if kak is not None:
124 return kak.popToolsAndMerge(ca)
125 else:
126 return ComponentAccumulator().popToolsAndMerge(ca)
127
128
129def sanitise(s: str) -> str:
130 """
131 Replace all ':' and '=' characters in the string with '_'.
132 """
133 return s.replace(":", "_").replace("=", "_")
134
135
STL class.
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:312
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:132
createTrackAnalysis(flags, name="TrackAnalysis", chains=[], label="", kak=None)
setFlagIfNotSet(flags, attr, value)