ATLAS Offline Software
TrigDJHypoConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaCommon.Logging import logging
4 log = logging.getLogger('TrigDJHypoTools')
5 
6 #Object cuts sets used to configure the cuts which define prompt and displaced tracks
7 object_cuts_sets = {"set1": {"min_trk_pt": 1.0, "trk_d0cut": 3.0, "max_z0st": 3.0, "d0_sigcut": 10.0}}
8 
9 #cuts applied for each config value
10 config_dict = {
11  "3d2p":{
12  "object_cuts": "set1",
13  "min_disp_trk": 3,
14  "max_prompt_trk": 2,
15  "other_frac": 0.75,
16  "max_jet_rank": 2
17  },
18  "1p":{
19  "object_cuts": "set1",
20  "min_disp_trk": 0,
21  "max_prompt_trk": 1,
22  "other_frac": 0.75,
23  "max_jet_rank": 2
24  },
25  "x3d1p":{
26  "object_cuts": "set1",
27  "min_disp_trk": 3,
28  "max_prompt_trk": 1,
29  "other_frac": 0.75,
30  "prompt_stage_max_prompt_trk": 2,
31  "max_jets": 1,
32  "max_jet_rank": 0
33  },
34  "2p":{
35  "object_cuts": "set1",
36  "min_disp_trk": 0,
37  "max_prompt_trk": 2,
38  "other_frac": 0.75,
39  "max_jet_rank": 2
40  }
41 }
42 
43 
44 def TrigDJExtractThreshold(chainDict):
45  threshold = [i['threshold'] for i in chainDict['chainParts'] if i['signature'] == 'UnconventionalTracking' and 'dispjet' in i['chainPartName']]
46 
47  if len(threshold) != 1:
48  raise RuntimeError("Cannot support mutiple occurrences of dispjet in chain {}".format(chainDict['chainName']))
49 
50  return int(threshold[0])
51 
52 
53 
54 def TrigDJGetConfigValue(chainDict, key):
55  values = [i[key] for i in chainDict['chainParts'] if i['signature'] == 'UnconventionalTracking' and 'dispjet' in i['chainPartName'] and key in i]
56 
57  if len(values) != 1:
58  raise RuntimeError("Invalid chain dictionary for Displaced Jet Trigger, unable to find config value '{}' in {}".format(key, str(chainDict)))
59 
60  return values[0]
61 
62 def TrigDJEnableMonitoring(chainDict):
63  return 'idMon:online' in chainDict['monGroups']
64 
65 def TrigDJHypoPromptToolFromDict(flags, chainDict):
66  """ Use menu decoded chain dictionary to configure the tool """
67 
68  name = chainDict['chainName']
69  threshold = TrigDJExtractThreshold(chainDict)
70 
71  cfg_name = TrigDJGetConfigValue(chainDict, "dispjetConfig")
72  cfg = config_dict[cfg_name]
73 
74  if cfg is None:
75  raise RuntimeError("Unknown displaced jet config key: '{}'".format(cfg_name))
76 
77  obj_cuts = object_cuts_sets[cfg["object_cuts"]]
78 
79  if obj_cuts is None:
80  raise RuntimeError("Incorrectly configured displaced jet config key: '{}' Object cut set '{}' does not exist".format(cfg_name, cfg["object_cuts"]))
81 
82  from AthenaConfiguration.ComponentFactory import CompFactory
83  tool = CompFactory.DisplacedJetPromptHypoTool(name)
84 
85  #configure from the object defintion set first
86  tool.min_trk_pt = obj_cuts["min_trk_pt"]
87  tool.trk_d0cut = obj_cuts["trk_d0cut"]
88  tool.max_z0st = obj_cuts["max_z0st"]
89  tool.d0sigcut = obj_cuts["d0_sigcut"]
90  tool.cut_name = cfg["object_cuts"]
91 
92  tool.max_prompt_trk = cfg["max_prompt_trk"]
93  tool.min_jet_pt = float(threshold)
94 
95  if "prompt_stage_max_prompt_trk" in cfg:
96  tool.max_prompt_trk = cfg["prompt_stage_max_prompt_trk"]
97 
98  #monitoring
99  if TrigDJEnableMonitoring(chainDict):
100  from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
101  monTool = GenericMonitoringTool(flags, "DJPrompt_MonTool_"+name)
102 
103  monTool.defineHistogram("trk_d0sig", type='TH1F', path='EXPERT', title="Track d0sig", xbins=200, xmin=0.0, xmax=200.0)
104  monTool.defineHistogram("trk_z0st", type='TH1F', path='EXPERT', title="Track z0st", xbins=200, xmin=0.0, xmax=20.0)
105  monTool.defineHistogram("trk_d0", type='TH1F', path='EXPERT', title="Track d0", xbins=200, xmin=0.0, xmax=20.0)
106  monTool.defineHistogram("nprompt", type='TH1F', path='EXPERT', title="nPrompt tracks per Jet", xbins=20, xmin=0, xmax=20)
107  monTool.defineHistogram("pass_jet_pt", type='TH1F', path='EXPERT', title="pT of Jets passing the prompt selection", xbins=35, xmin=50, xmax=400)
108  monTool.defineHistogram("pass_jet_eta", type='TH1F', path='EXPERT', title="eta of Jets passing the prompt selection", xbins=30, xmin=-3, xmax=3)
109 
110  tool.MonTool = monTool
111 
112  return tool
113 
114 
115 def TrigDJHypoDispToolFromDict(flags, chainDict):
116  """ Use menu decoded chain dictionary to configure the tool """
117 
118  name = chainDict['chainName']
119 
120  cfg_name = TrigDJGetConfigValue(chainDict, "dispjetConfig")
121  cfg = config_dict[cfg_name]
122 
123  if cfg is None:
124  raise RuntimeError("Unknown displaced jet config key: '{}'".format(cfg_name))
125 
126  obj_cuts = object_cuts_sets[cfg["object_cuts"]]
127 
128  if obj_cuts is None:
129  raise RuntimeError("Incorrectly configured displaced jet config key: '{}' Object cut set '{}' does not exist".format(cfg_name, cfg["object_cuts"]))
130 
131  from AthenaConfiguration.ComponentFactory import CompFactory
132  tool = CompFactory.DisplacedJetDispHypoTool(name)
133 
134  #configure from the object defintion set first
135  tool.min_trk_pt = obj_cuts["min_trk_pt"]
136  tool.trk_d0cut = obj_cuts["trk_d0cut"]
137  tool.max_z0st = obj_cuts["max_z0st"]
138  tool.d0sigcut = obj_cuts["d0_sigcut"]
139  tool.cut_name = cfg["object_cuts"]
140 
141  tool.nother_frac = cfg["other_frac"]
142  tool.min_disp_trk = cfg["min_disp_trk"]
143  tool.max_prompt_trk = cfg["max_prompt_trk"]
144 
145  #monitoring
146  if TrigDJEnableMonitoring(chainDict):
147  from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
148  monTool = GenericMonitoringTool(flags, "DJDisp_MonTool_"+name)
149 
150  monTool.defineHistogram("trk_d0sig", type='TH1F', path='EXPERT', title="Track d0sig", xbins=200, xmin=0.0, xmax=200.0)
151  monTool.defineHistogram("trk_z0st", type='TH1F', path='EXPERT', title="Track z0st", xbins=200, xmin=0.0, xmax=20.0)
152  monTool.defineHistogram("trk_d0", type='TH1F', path='EXPERT', title="Track d0", xbins=200, xmin=0.0, xmax=20.0)
153  monTool.defineHistogram("nprompt", type='TH1F', path='EXPERT', title="nPrompt tracks per Jet", xbins=20, xmin=0, xmax=20)
154  monTool.defineHistogram("ndisp", type='TH1F', path='EXPERT', title="nDisplaced tracks per Jet", xbins=20, xmin=0, xmax=20)
155  monTool.defineHistogram("frac_other", type='TH1F', path='EXPERT', title="Fraction of tracks which fail all cuts", xbins=20, xmin=0, xmax=1.1)
156  monTool.defineHistogram("pass_jet_pt", type='TH1F', path='EXPERT', title="pT of Jets passing the displaced selection", xbins=35, xmin=50, xmax=400)
157  monTool.defineHistogram("pass_jet_eta", type='TH1F', path='EXPERT', title="eta of Jets passing the displaced selection", xbins=30, xmin=-3, xmax=3)
158 
159  tool.MonTool = monTool
160 
161  return tool
162 
164  name = chainDict['chainName']
165 
166  from AthenaConfiguration.ComponentFactory import CompFactory
167  tool = CompFactory.DisplacedJetRankComboHypoTool(name)
168 
169  cfg_names = [i["dispjetConfig"] for i in chainDict['chainParts'] if i['signature'] == 'UnconventionalTracking' and 'dispjet' in i['chainPartName'] and "dispjetConfig" in i]
170  cfgs = [config_dict[i] for i in cfg_names]
171  max_jets = [i["max_jets"] for i in cfgs if "max_jets" in i]
172  max_rank = [i["max_jet_rank"] for i in cfgs if "max_jet_rank" in i]
173 
174  if len(max_jets) > 0:
175  tool.max_jets = max(max_jets)
176 
177  if len(max_rank) > 0:
178  tool.max_jet_rank = max(max_rank)
179 
180 
181  return tool
max
#define max(a, b)
Definition: cfImp.cxx:41
vtune_athena.format
format
Definition: vtune_athena.py:14
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.TrigDJHypoConfig.TrigDJGetConfigValue
def TrigDJGetConfigValue(chainDict, key)
Definition: TrigDJHypoConfig.py:54
GenericMonitoringTool
Definition: GenericMonitoringTool.h:53
python.TrigDJHypoConfig.TrigDJHypoPromptToolFromDict
def TrigDJHypoPromptToolFromDict(flags, chainDict)
Definition: TrigDJHypoConfig.py:65
python.TrigDJHypoConfig.TrigDJComboHypoToolFromDict
def TrigDJComboHypoToolFromDict(chainDict)
Definition: TrigDJHypoConfig.py:163
python.TrigDJHypoConfig.TrigDJHypoDispToolFromDict
def TrigDJHypoDispToolFromDict(flags, chainDict)
Definition: TrigDJHypoConfig.py:115
python.TrigDJHypoConfig.TrigDJEnableMonitoring
def TrigDJEnableMonitoring(chainDict)
Definition: TrigDJHypoConfig.py:62
python.TrigDJHypoConfig.TrigDJExtractThreshold
def TrigDJExtractThreshold(chainDict)
Definition: TrigDJHypoConfig.py:44
str
Definition: BTagTrackIpAccessor.cxx:11
readCCLHist.float
float
Definition: readCCLHist.py:83