ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetMonitoring
python
JetMonitoringStandard.py
Go to the documentation of this file.
1
#
2
# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
#
4
5
'''@file JetMonitoringExample.py
6
@author P-A. Delsart
7
@date 2019-03-12
8
@brief Main python configuration for the Run III Jet Monitoring
9
'''
10
from
AthenaMonitoring.DQConfigFlags
import
DQDataType
11
from
JetMonitoring.JetMonitoringConfig
import
JetMonAlgSpec, HistoSpec, EventHistoSpec, SelectSpec, VarSpec
12
13
# *********************************************
14
# Define a list of histograms we want to draw for all jet containers.
15
# Write this list as a list of Jet histo specifications. Read comments below for details on specifications
16
commonHistoSpecs = [
17
# Specification can be simple string.
18
# in this case they are aliases to standard spec has defined in JetStandardHistoSpecs.knownHistos
19
"pt"
,
20
"highpt"
,
21
"m"
,
22
"eta"
,
23
"rapidity"
,
24
"phi"
,
25
"EMFrac"
,
26
"LArQuality"
,
27
"AverageLArQF"
,
28
"HECQuality"
,
29
"HECFrac"
,
30
"FracSamplingMax"
,
31
"FracSamplingMaxIndex"
,
32
"EM3Frac"
,
33
"Tile0Frac"
,
34
"CentroidR"
,
35
"OotFracClusters5"
,
36
"OotFracClusters10"
,
37
"JVF"
,
38
"JVF[0]"
,
39
"JVF[1]"
,
40
"Jvt"
,
41
"Timing"
,
42
"nconstit"
,
43
"N90Constituents"
,
44
"leadingJetsRel"
,
45
"JetConstitScaleMomentum_pt"
,
"JetEMScaleMomentum_pt"
,
"JetPileupScaleMomentum_pt"
,
"JetEtaJESScaleMomentum_pt"
,
46
"JetConstitScaleMomentum_eta"
,
"JetEMScaleMomentum_eta"
,
"JetPileupScaleMomentum_eta"
,
"JetEtaJESScaleMomentum_eta"
,
47
"JetConstitScaleMomentum_phi"
,
"JetEMScaleMomentum_phi"
,
"JetPileupScaleMomentum_phi"
,
"JetEtaJESScaleMomentum_phi"
,
48
49
50
# or we can directly add our custom histo specification in the form of a HistoSpec
51
# (HistoSpec is nothing more than a specialized python dictionnary)
52
EventHistoSpec(
'njets'
,(100,0.,100.),title=
"Number of Jets;Njets;"
),
53
EventHistoSpec(
'njetsPt20'
,(100,0.,100.),title=
"Number of Jets pT>20 GeV;Njets;"
),
54
EventHistoSpec(
'njetsPt200'
,(800,0.,8000.),title=
"Number of Jets pT>200 GeV;Njets;"
),
55
# the basic call is : HistoSpec( variable, histobins, title='histotile;xtitle,ytitle')
56
57
58
# 2D histos, by concatenating 1D histo specifications :
59
"m;pt"
,
60
"eta;pt"
,
61
"eta;phi"
,
62
"eta;Timing"
,
63
64
# TProfile2D : just use 3 variables. For now the sytem will automatically
65
# interpret it as a TProfile2D (the 3rd variable being profiled)
66
"eta;phi;e"
,
# --> Average Energy vs pt and eta
67
"eta;phi;pt"
,
# --> Average pt vs phi and eta
68
69
# Histograms build from a selection of filtered jets.
70
# Use a SelectSpec dictionary to define the selection, and the histo to be drawn from it.
71
SelectSpec(
'central'
,
# the name of the selection
72
'|eta|<0.5'
,
# selection expression. The form 'min<var<max' is automatically interpreted.
73
path=
'CentralJets'
,
# force the path where the histos are saved in the final ROOT file
74
FillerTools = [
"pt"
,
"m"
,
"eta"
,
"phi"
,
"EMFrac"
,
"Tile0Frac"
,
"LArQuality"
,
"nconstit"
,
"N90Constituents"
,
75
"JetConstitScaleMomentum_pt"
,
"JetEMScaleMomentum_pt"
,
"JetPileupScaleMomentum_pt"
,
"JetEtaJESScaleMomentum_pt"
,
76
"JetConstitScaleMomentum_eta"
,
"JetEMScaleMomentum_eta"
,
"JetPileupScaleMomentum_eta"
,
"JetEtaJESScaleMomentum_eta"
,
77
"JetConstitScaleMomentum_phi"
,
"JetEMScaleMomentum_phi"
,
"JetPileupScaleMomentum_phi"
,
"JetEtaJESScaleMomentum_phi"
,
78
] ),
79
80
SelectSpec(
'tilegap3'
,
# the name of the selection
81
'1.0<|eta|<1.4'
,
# selection expression. The form 'min<var<max' is automatically interpreted.
82
path=
'TileGap3'
,
# force the path where the histos are saved in the final ROOT file
83
FillerTools = [
"pt"
,
"m"
,
"eta"
,
"phi"
,
"EMFrac"
,
"Tile0Frac"
,
"HECFrac"
,
"LArQuality"
,
"nconstit"
,
"N90Constituents"
,
84
] ),
85
86
# another selection : only leading jets
87
SelectSpec(
'leading'
,
88
''
,
# no selection on variables
89
SelectedIndex=0,
# force 1st (leading) jet (we would set 1 for sub-leading jets)
90
path=
'LeadingJets'
,
# force the path where the histos are saved in the final ROOT file
91
FillerTools = [
"pt"
,
"m"
,
"eta"
,
"phi"
,
"EMFrac"
,
"Tile0Frac"
,
"HECFrac"
,
"LArQuality"
,
"nconstit"
,
"N90Constituents"
,
92
"JetConstitScaleMomentum_pt"
,
"JetEMScaleMomentum_pt"
,
"JetPileupScaleMomentum_pt"
,
"JetEtaJESScaleMomentum_pt"
,
93
"JetConstitScaleMomentum_eta"
,
"JetEMScaleMomentum_eta"
,
"JetPileupScaleMomentum_eta"
,
"JetEtaJESScaleMomentum_eta"
,
94
"JetConstitScaleMomentum_phi"
,
"JetEMScaleMomentum_phi"
,
"JetPileupScaleMomentum_phi"
,
"JetEtaJESScaleMomentum_phi"
,
95
] ),
96
97
# another selection : only subleading jets
98
SelectSpec(
'subleading'
,
99
''
,
# no selection on variables
100
SelectedIndex=1,
# force 2nd (sub-leading) jet
101
path=
'SubleadingJets'
,
# force the path where the histos are saved in the final ROOT file
102
FillerTools = [
"pt"
,
"m"
,
"eta"
,
"phi"
,
"EMFrac"
,
"Tile0Frac"
,
"HECFrac"
,
"LArQuality"
,
"nconstit"
,
"N90Constituents"
,
103
"JetConstitScaleMomentum_pt"
,
"JetEMScaleMomentum_pt"
,
"JetPileupScaleMomentum_pt"
,
"JetEtaJESScaleMomentum_pt"
,
104
"JetConstitScaleMomentum_eta"
,
"JetEMScaleMomentum_eta"
,
"JetPileupScaleMomentum_eta"
,
"JetEtaJESScaleMomentum_eta"
,
105
"JetConstitScaleMomentum_phi"
,
"JetEMScaleMomentum_phi"
,
"JetPileupScaleMomentum_phi"
,
"JetEtaJESScaleMomentum_phi"
,
106
] ),
107
108
# another selection : only very high pT jets
109
SelectSpec(
'highptrange2TeVto8TeV'
,
'2000<pt:GeV<8000'
,path=
'highptrange2TeVto8TeV'
,FillerTools = [
"highpt"
,
"m"
,
"eta"
,
"phi"
,
"eta;phi"
,] ),
110
SelectSpec(
'highptrange1TeVto2TeV'
,
'1000<pt:GeV<2000'
,path=
'highptrange1TeVto2TeV'
,FillerTools = [
"highpt"
,
"m"
,
"eta"
,
"phi"
,
"eta;phi"
,] ),
111
SelectSpec(
'highptrange500GeVto1TeV'
,
'500<pt:GeV<1000'
,path=
'highptrange500GeVto1TeV'
,FillerTools = [
"highpt"
,
"m"
,
"eta"
,
"phi"
,
"eta;phi"
,] ),
112
SelectSpec(
'highptrange200GeVto500GeV'
,
'200<pt:GeV<500'
,path=
'highptrange200GeVto500GeV'
,FillerTools = [
"highpt"
,
"m"
,
"eta"
,
"phi"
,
"eta;phi"
,] ),
113
114
# Selecting jets failing the LooseBad selection from the JetCleaningTool.
115
SelectSpec(
'LooseBadFailedJets'
,
'LooseBad'
, InverseJetSel=
True
,
116
FillerTools = [
"pt"
,
"phi"
,
"eta"
,
"m"
,
"EMFrac"
,
"LArQuality"
,
"Tile0Frac"
,
"HECFrac"
,
"nconstit"
,
"N90Constituents"
,
117
"phi;eta"
,
"phi;eta;e"
,
"phi;eta;pt"
,
118
]),
119
120
# Selecting jets passing the LooseBad selection from the JetCleaningTool.
121
SelectSpec(
'LooseBadJets'
,
122
'LooseBad'
,
# this is not in the form 'min<x<max', so it will be assumed 'LooseBad' is an entry existing in JetStandardHistoSpecs.knownSelector
123
FillerTools = [
"pt"
,
"eta"
,
"phi"
,
"m"
,
"EMFrac"
,
"LArQuality"
,
"Tile0Frac"
,
"HECFrac"
,
"nconstit"
,
"N90Constituents"
,
124
"phi;eta"
,
"phi;eta;e"
,
"phi;eta;pt"
,
125
] ),
126
]
# end commonHistoSpecs
127
128
# Separate these out because they cannot run in cosmics
129
jvfHistosSpec = [
130
SelectSpec(
'highJVF'
,
131
'0.3<JVF[0]'
,
# JVF is a vector<float> for each jets. Here we cut on the 0th entry of this vector
132
FillerTools = [
"pt"
,
"m"
,
"eta"
,
"phi"
,
133
] ),
134
]
135
136
topoHistosSpec = [
137
# histos common to all topo jets. Energy By Sampling layer plots.
138
HistoSpec(
"PreSamplerB"
,(100,0.,200.),title=
"Energy in PreSamplerB;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[0]'
)),
139
HistoSpec(
"EMB1"
,(100,0.,200.),title=
"Energy in EMB1;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[1]'
)),
140
HistoSpec(
"EMB2"
,(100,0.,200.),title=
"Energy in EMB2;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[2]'
)),
141
HistoSpec(
"EMB3"
,(100,0.,200.),title=
"Energy in EMB3;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[3]'
)),
142
HistoSpec(
"PreSamplerE"
,(100,0.,200.),title=
"Energy in PreSamplerE;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[4]'
)),
143
HistoSpec(
"EME1"
,(100,0.,200.),title=
"Energy in EME2;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[5]'
)),
144
HistoSpec(
"EME2"
,(100,0.,200.),title=
"Energy in EME2;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[6]'
)),
145
HistoSpec(
"EME3"
,(100,0.,200.),title=
"Energy in EME3;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[7]'
)),
146
HistoSpec(
"HEC0"
,(100,0.,200.),title=
"Energy in HEC0;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[8]'
)),
147
HistoSpec(
"HEC1"
,(100,0.,200.),title=
"Energy in HEC1;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[9]'
)),
148
HistoSpec(
"HEC2"
,(100,0.,200.),title=
"Energy in HEC2;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[10]'
)),
149
HistoSpec(
"HEC3"
,(100,0.,200.),title=
"Energy in HEC3;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[11]'
)),
150
HistoSpec(
"TileBar0"
,(100,0.,200.),title=
"Energy in TileBar0;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[12]'
)),
151
HistoSpec(
"TileBar1"
,(100,0.,200.),title=
"Energy in TileBar1;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[13]'
)),
152
HistoSpec(
"TileBar2"
,(100,0.,200.),title=
"Energy in TileBar1;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[14]'
)),
153
HistoSpec(
"TileGap1"
,(100,0.,200.),title=
"Energy in TileGap1;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[15]'
)),
154
HistoSpec(
"TileGap2"
,(100,0.,200.),title=
"Energy in TileGap2;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[16]'
)),
155
HistoSpec(
"TileGap3"
,(100,0.,200.),title=
"Energy in TileGap3;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[17]'
)),
156
HistoSpec(
"TileExt0"
,(100,0.,200.),title=
"Energy in TileExt0;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[18]'
)),
157
HistoSpec(
"TileExt1"
,(100,0.,200.),title=
"Energy in TileExt1;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[19]'
)),
158
HistoSpec(
"TileExt2"
,(100,0.,200.),title=
"Energy in TileExt2;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[20]'
)),
159
HistoSpec(
"FCAL0"
,(100,0.,200.),title=
"Energy in FCAL0;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[21]'
)),
160
HistoSpec(
"FCAL1"
,(100,0.,200.),title=
"Energy in FCAL1;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[22]'
)),
161
HistoSpec(
"FCAL2"
,(100,0.,200.),title=
"Energy in FCAL2;E;Entries"
,xvar=VarSpec(
'EnergyPerSampling[23]'
)),
162
]
163
164
pflowHistosSpec = [
165
# histos common to all PFlow jets. These are defined in JetStandardHistoSpecs.py
166
"SumPtChargedPFOPt500[0]"
,
167
"SumPtTrkPt500[0]"
,
168
"NumTrkPt500[0]"
,
169
"NumTrkPt1000[0]"
,
170
"fCharged"
,
171
]
172
173
calibToolConfigurations = {
174
"AntiKt4EMPFlowJets"
:(
"AntiKt4EMPFlow_MC23a_PreRecR22_Phase2_CalibConfig_ResPU_EtaJES_GSC_241208_InSitu.config"
,
"00-04-83"
,
"JetArea_Residual_EtaJES"
),
175
"AntiKt4EMTopoJets"
:(
"PreRec_R22_EMTopo_ResPU_EtaJES_October23_231024.config"
,
"00-04-82"
,
"JetArea_Residual_EtaJES"
),
176
"AntiKt4LCTopoJets"
:(
"JES_MC15cRecommendation_May2016_rel21.config"
,
"00-04-77"
,
"JetArea_Residual_EtaJES"
)
177
}
178
179
def
jetMonAlgConfig
( jetName, inputFlags, truthJetName='', trigger=''):
180
"""returns a specification of a JetMonitoringAlg (in the form of a JetMonAlgSpec dictionnary).
181
"""
182
183
# Just a protection in case PhysVal is using this as well
184
if
not
inputFlags.Input.isMC
and
jetName !=
"AntiKt4HIJets"
:
185
from
AthenaConfiguration.ComponentFactory
import
CompFactory
186
configfile, calibArea, calibseq_def = calibToolConfigurations[jetName]
187
toolname =
"jetcalib_DQ_{0}"
.format(jetName)
188
jct = CompFactory.JetCalibrationTool(toolname,
189
JetCollection = jetName.replace(
'Jets'
,
''
),
190
ConfigFile = configfile,
191
CalibArea = calibArea,
192
CalibSequence = calibseq_def,
193
IsData =
True
)
194
195
# we use a specialized dictionnary (JetMonAlgSpec) which will be translated into the final C++ tool
196
jetAlgConfig = JetMonAlgSpec(
197
jetName+
"MonAlg"
,
198
JetContainerName = jetName,
199
applyLatestCalibration =
True
,
200
JetCalibTool = jct,
201
TriggerChain = trigger,
202
)
203
else
:
204
jetAlgConfig = JetMonAlgSpec(
205
jetName+
"MonAlg"
,
206
JetContainerName = jetName,
207
applyLatestCalibration =
False
,
208
TriggerChain = trigger,
209
)
210
211
212
# the list of histos specifications
213
histoSpecs = []
214
215
# then add pre-defined lists as defined above :
216
histoSpecs += commonHistoSpecs
217
218
if
inputFlags.DQ.DataType
is
not
DQDataType.Cosmics:
219
histoSpecs += jvfHistosSpec
220
221
if
'Topo'
in
jetName:
222
histoSpecs += topoHistosSpec
223
if
'PFlow'
in
jetName:
224
histoSpecs += pflowHistosSpec
225
226
227
if
truthJetName !=
""
:
228
# then add histos showing efficiency and pT responses vs True
229
from
JetMonitoring.JetStandardHistoSpecs
import
responseAndEffSpecMap
230
if
truthJetName
not
in
responseAndEffSpecMap:
231
print
(
"ERROR !! can't schedule a JetHistoResponseAndEff for truth container : "
,truthJetName,
". No specification available"
)
232
return
None
233
234
histoSpecs +=[ responseAndEffSpecMap[truthJetName] ]
235
236
# finally all all histos specs to our JetMonitoringAlg specification :
237
jetAlgConfig.appendHistos( * histoSpecs)
238
239
return
jetAlgConfig
240
241
242
243
def
standardJetMonitoring
(inputFlags):
244
"""Standard jet monitoring function to be inserted from top-level algs.
245
returns an a component accumulator as given by AthMonitorCfgHelper.result()
246
Details of what goes into jet monitoring is implemented by dedicated functions such as jetMonAlgConfig().
247
"""
248
249
from
AthenaConfiguration.ComponentAccumulator
import
ComponentAccumulator
250
rv = ComponentAccumulator()
251
252
# do not run monitoring in RAWtoESD
253
if
inputFlags.DQ.Environment ==
'tier0Raw'
:
254
return
rv
255
256
from
AthenaMonitoring
import
AthMonitorCfgHelper
257
helper = AthMonitorCfgHelper(inputFlags,
'JetMonitoring'
)
258
259
# create a list of JetMonitoringAlg specifications
260
jetAlgConfs = []
261
262
if
inputFlags.Reco.EnableHI:
263
if
inputFlags.Tracking.doUPC:
264
jetAlgConfs.append(
jetMonAlgConfig
(
"AntiKt4EMPFlowJets"
, inputFlags))
265
else
:
266
jetAlgConfs.append(
jetMonAlgConfig
(
"AntiKt4HIJets"
, inputFlags))
267
else
:
268
# use the helper function defined above :
269
#jetMonAlgConfig( "AntiKt4LCTopoJets", truthJetName="AntiKt4TruthJets"), #How can we make sure truth jets are available ??
270
jetAlgConfs.append(
jetMonAlgConfig
(
"AntiKt4LCTopoJets"
, inputFlags))
271
jetAlgConfs.append(
jetMonAlgConfig
(
"AntiKt4EMTopoJets"
, inputFlags))
272
jetAlgConfs.append(
jetMonAlgConfig
(
"AntiKt4EMPFlowJets"
, inputFlags))
273
274
# Configure filter tools
275
from
AthenaMonitoring.EventFlagFilterToolConfig
import
EventFlagFilterToolCfg
276
# from AthenaMonitoring.AtlasReadyFilterConfig import AtlasReadyFilterCfg
277
from
AthenaMonitoring.BadLBFilterToolConfig
import
LArBadLBFilterToolCfg
278
# from AthenaMonitoring.FilledBunchFilterToolConfig import FilledBunchFilterToolCfg
279
280
# schedule each JetMonitoringAlg by invoking the toAlg() methods of the config specification
281
for
conf
in
jetAlgConfs:
282
alg = conf.toAlg(helper)
283
alg.FilterTools = [ EventFlagFilterToolCfg(inputFlags),helper.resobj.popToolsAndMerge(LArBadLBFilterToolCfg(inputFlags))]
284
285
rv.merge(helper.result())
# the AthMonitorCfgHelper returns an accumulator to be used by the general configuration system.
286
return
rv
print
void print(char *figname, TCanvas *c1)
Definition
TRTCalib_StrawStatusPlots.cxx:26
JetMonitoringStandard.standardJetMonitoring
standardJetMonitoring(inputFlags)
Definition
JetMonitoringStandard.py:243
JetMonitoringStandard.jetMonAlgConfig
jetMonAlgConfig(jetName, inputFlags, truthJetName='', trigger='')
Definition
JetMonitoringStandard.py:179
Generated on
for ATLAS Offline Software by
1.17.0