6 @file TileJetMonitorAlgorithm.py
7 @brief Python configuration of TileJetMonitorAlgorithm algorithm for the Run III
13 ''' Function to configure TileJetMonitorAlgorithm algorithm in the monitoring system.'''
17 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
20 from TileGeoModel.TileGMConfig
import TileGMCfg
23 from LArGeoAlgsNV.LArGMConfig
import LArGMCfg
26 from TileConditions.TileCablingSvcConfig
import TileCablingSvcCfg
29 from TileConditions.TileBadChannelsConfig
import TileBadChanToolCfg
34 from AthenaMonitoring
import AthMonitorCfgHelper
35 helper = AthMonitorCfgHelper(flags,
'TileMonitoring')
38 from AthenaConfiguration.ComponentFactory
import CompFactory
39 tileJetMonAlg = helper.addAlgorithm(CompFactory.TileJetMonitorAlgorithm,
'TileJetMonAlg')
41 tileJetMonAlg.TileBadChanTool = badChanTool
42 tileJetMonAlg.TriggerChain =
''
44 if flags.Tile.doTimingHistogramsForGain
in [0, 1]:
45 kwargs.setdefault(
'Do1DHistograms',
True)
46 if flags.Tile.doTimingHistogramsForGain == 0:
48 kwargs.setdefault(
'ChannelEnergyMin', 15000)
49 kwargs.setdefault(
'ChannelEnergyMax', 50000)
50 kwargs.setdefault(
'Gain', 0)
54 kwargs.setdefault(
'ChannelEnergyMin', 2000)
55 kwargs.setdefault(
'ChannelEnergyMax', 4000)
56 kwargs.setdefault(
'Gain', 1)
58 for k, v
in kwargs.items():
59 setattr(tileJetMonAlg, k, v)
61 DoEnergyProfiles = kwargs.get(
'DoEnergyProfiles', tileJetMonAlg._descriptors[
'DoEnergyProfiles'].default)
63 Do1DHistograms = kwargs.get(
'Do1DHistograms', tileJetMonAlg._descriptors[
'Do1DHistograms'].default)
64 DoEnergyDiffHistograms = kwargs.get(
'DoEnergyDiffHistograms', tileJetMonAlg._descriptors[
'DoEnergyDiffHistograms'].default)
66 from AthenaMonitoring.DQConfigFlags
import DQDataType
67 if flags.DQ.DataType
not in (DQDataType.HeavyIon, DQDataType.Cosmics):
69 jvtTool = CompFactory.JetVertexTaggerTool()
70 jetContainer = kwargs.get(
'JetContainer', tileJetMonAlg._descriptors[
'JetContainer'].default)
71 jvtTool.JetContainer =
str(jetContainer)
72 tileJetMonAlg.JVT = jvtTool
74 jetCleaningTool = CompFactory.JetCleaningTool()
75 jetCleaningTool.CutLevel =
"LooseBad"
76 jetCleaningTool.DoUgly =
False
77 jetCleaningTool.JetContainer =
str(jetContainer)
79 tileJetMonAlg.JetCleaningTool = jetCleaningTool
80 result.addPublicTool(jetCleaningTool)
83 jetTrackingEtaLimit = 2.4
84 eventCleaningTool = CompFactory.ECUtils.EventCleaningTool()
85 eventCleaningTool.JetCleaningTool = jetCleaningTool
86 eventCleaningTool.PtCut = jetPtMin
87 eventCleaningTool.EtaCut = jetTrackingEtaLimit
88 eventCleaningTool.JvtDecorator =
"passJvt"
89 eventCleaningTool.OrDecorator =
"passOR"
90 eventCleaningTool.CleaningLevel = jetCleaningTool.CutLevel
91 eventCleaningTool.JetContainer =
str(jetContainer)
92 eventCleaningTool.SuppressInputDependence =
True
93 eventCleaningTool.SuppressOutputDependence =
True
95 tileJetMonAlg.EventCleaningTool = eventCleaningTool
96 tileJetMonAlg.JetTrackingEtaLimit = jetTrackingEtaLimit
97 tileJetMonAlg.JetPtMin = jetPtMin
99 tileJetMonAlg.DoEventCleaning =
True
100 tileJetMonAlg.DoJetCleaning =
True
104 tileJetMonAlg.DoEventCleaning =
False
105 tileJetMonAlg.DoJetCleaning =
False
107 if flags.Reco.EnableHI:
108 if flags.Tracking.doUPC:
109 tileJetMonAlg.JetContainer =
'AntiKt4EMPFlowJets'
111 tileJetMonAlg.JetContainer =
'AntiKt4HIJets'
114 executeTimeGroup = helper.addGroup(tileJetMonAlg,
'TileJetMonExecuteTime',
'Tile/')
115 executeTimeGroup.defineHistogram(
'TIME_execute', path =
'Jet', type=
'TH1F',
116 title =
'Time for execute TileJetMonAlg algorithm;time [#mus]',
117 xbins = 300, xmin = 0, xmax = 300000)
121 from TileMonitoring.TileMonitoringCfgHelper
import addValueVsModuleAndChannelMaps, getPartitionName
122 runNumber = flags.Input.RunNumbers[0]
126 channelTimeDQGroup = helper.addGroup(tileJetMonAlg,
'TileJetChanTimeDQ',
'Tile/Jet/')
128 path =
'DQ', type =
'TProfile2D', value=
'time', run =
str(runNumber))
132 partitions = [
'LBA',
'LBC',
'EBA',
'EBC']
135 channelTimeGroup = helper.addGroup(tileJetMonAlg,
'TileJetChanTime',
'Tile/Jet/ChanTime/')
136 for partition
in partitions:
137 title =
'Partition ' + partition +
': Tile Channel Time;time [ns];N'
138 name =
'channelTime' + partition
140 channelTimeGroup.defineHistogram(name, title = title, path = path, type =
'TH1F',
141 xbins = 600, xmin = -30.0, xmax = 30.0)
144 for partition
in [
'EBA',
'EBC']:
145 title =
'Partition ' + partition +
': Tile Channel Time (without scintillators);time [ns];N'
146 name =
'channelTime' + partition +
'_NoScint'
148 channelTimeGroup.defineHistogram(name, title = title, path = path, type =
'TH1F',
149 xbins = 600, xmin = -30.0, xmax = 30.0)
153 energiesHG = [500, 1000, 2000, 4000, 6000, 8000, 10000, 13000, 16000, 20000]
154 energiesLG = [25000, 30000, 40000, 50000, 65000, 80000]
155 energiesALL = {
'LG' : energiesLG,
'HG' : energiesHG}
156 tileJetMonAlg.CellEnergyUpperLimitsHG = energiesHG
157 tileJetMonAlg.CellEnergyUpperLimitsLG = energiesLG
159 samples_LB = [
'A',
'BC',
'D',
'B9']
160 samples_EB = [
'A',
'B',
'C10',
'D4',
'E1',
'E2',
'E3',
'E4']
163 cellTimeGroup = helper.addGroup(tileJetMonAlg,
'TileJetCellTime',
'Tile/Jet/CellTime/')
164 for partition
in partitions:
167 energies = energiesALL[gain]
168 for index
in range(0, len(energies) + 1):
169 toEnergy = energies[index]
if index < len(energies)
else None
170 fromEnergy = energies[index - 1]
if index > 0
else None
172 title_suffix =
' > ' +
str(fromEnergy) +
' MeV; time [ns]'
174 title_suffix =
' < ' +
str(toEnergy) +
' MeV; time [ns]'
176 title_suffix =
' [' +
str(fromEnergy) +
' .. ' +
str(toEnergy) +
') MeV; time [ns]'
179 if (partition ==
'LBA')
or (partition ==
'LBC'):
180 for samp
in range(0,len(samples_LB)):
181 name =
'Cell_time_' + partition +
'_' + samples_LB[samp] +
'_' + gain +
'_slice_' +
str(index)
182 title =
'Partition ' + partition +
', sampling ' + samples_LB[samp] +
': ' + gain +
' Tile Cell time in energy range' + title_suffix
183 cellTimeGroup.defineHistogram(name, title = title, path = partition, type =
'TH1F',
184 xbins = 600, xmin = -30.0, xmax = 30.0)
186 for samp
in range(0,len(samples_EB)):
187 name =
'Cell_time_' + partition +
'_' + samples_EB[samp] +
'_' + gain +
'_slice_' +
str(index)
188 title =
'Partition ' + partition +
', sampling ' + samples_EB[samp] +
': ' + gain +
' Tile Cell time in energy range' + title_suffix
189 cellTimeGroup.defineHistogram(name, title = title, path = partition, type =
'TH1F',
190 xbins = 600, xmin = -30.0, xmax = 30.0)
196 cellEnergyProfileGroup = helper.addGroup(tileJetMonAlg,
'TileJetCellEnergyProfile',
'Tile/Jet/CellTime/')
197 for partition
in partitions:
200 if (partition ==
'LBA')
or (partition ==
'LBC'):
201 for samp
in range(0,len(samples_LB)):
202 name =
'index_' + partition +
'_' + samples_LB[samp] +
'_' + gain
203 name +=
',energy_' + partition +
'_' + samples_LB[samp] +
'_' + gain
204 name +=
';Cell_ene_' + partition +
'_' + samples_LB[samp] +
'_' + gain +
'_prof'
205 title =
'Partition ' + partition +
', sampling ' + samples_LB[samp] +
': ' + gain +
' Tile Cell energy profile;Slice;Energy [MeV]'
206 xmax = len(energiesALL[gain]) + 0.5
207 nbins = len(energiesALL[gain]) + 1
208 cellEnergyProfileGroup.defineHistogram(name, title = title, path = partition, type =
'TProfile',
209 xbins = nbins, xmin = -0.5, xmax = xmax)
211 for samp
in range(0,len(samples_EB)):
212 name =
'index_' + partition +
'_' + samples_EB[samp] +
'_' + gain
213 name +=
',energy_' + partition +
'_' + samples_EB[samp] +
'_' + gain
214 name +=
';Cell_ene_' + partition +
'_' + samples_EB[samp] +
'_' + gain +
'_prof'
215 title =
'Partition ' + partition +
', sampling ' + samples_EB[samp] +
': ' + gain +
' Tile Cell energy profile;Slice;Energy [MeV]'
216 xmax = len(energiesALL[gain]) + 0.5
217 nbins = len(energiesALL[gain]) + 1
218 cellEnergyProfileGroup.defineHistogram(name, title = title, path = partition, type =
'TProfile',
219 xbins = nbins, xmin = -0.5, xmax = xmax)
225 cellEnergyGroup = helper.addGroup(tileJetMonAlg,
'TileJetCellEnergy',
'Tile/Jet/CellTime/')
226 for partition
in partitions:
228 energies = energiesALL[gain]
229 for index
in range(0, len(energies) + 1):
230 toEnergy = energies[index]
if index < len(energies)
else 2 * energies[index - 1]
231 fromEnergy = energies[index - 1]
if index > 0
else -1000
232 name =
'Cell_ene_' + partition +
'_' + gain +
'_slice_' +
str(index)
233 title =
'Partition ' + partition +
': ' + gain +
' Tile Cell Energy'
234 title +=
' in energy range [' +
str(fromEnergy) +
' .. ' +
str(toEnergy) +
') MeV;Energy [MeV]'
235 cellEnergyGroup.defineHistogram(name, title = title, path = partition, type =
'TH1F',
236 xbins = 100, xmin = fromEnergy, xmax = toEnergy)
238 if (partition ==
'LBA')
or (partition ==
'LBC'):
239 for samp
in range(0,len(samples_LB)):
240 name =
'Cell_ene_' + partition +
'_' + samples_LB[samp] +
'_' + gain +
'_slice_' +
str(index)
241 title =
'Partition ' + partition +
', sampling ' + samples_LB[samp] +
': ' + gain +
' Tile Cell Energy'
242 title +=
' in energy range [' +
str(fromEnergy) +
' .. ' +
str(toEnergy) +
') MeV;Energy [MeV]'
243 cellEnergyGroup.defineHistogram(name, title = title, path = partition, type =
'TH1F',
244 xbins = 100, xmin = fromEnergy, xmax = toEnergy)
246 for samp
in range(0,len(samples_EB)):
247 name =
'Cell_ene_' + partition +
'_' + samples_EB[samp] +
'_' + gain +
'_slice_' +
str(index)
248 title =
'Partition ' + partition +
', sampling ' + samples_EB[samp] +
': ' + gain +
' Tile Cell Energy'
249 title +=
' in energy range [' +
str(fromEnergy) +
' .. ' +
str(toEnergy) +
') MeV;Energy [MeV]'
250 cellEnergyGroup.defineHistogram(name, title = title, path = partition, type =
'TH1F',
251 xbins = 100, xmin = fromEnergy, xmax = toEnergy)
256 from TileCalibBlobObjs.Classes
import TileCalibUtils
as Tile
261 channelTime1DGroup = helper.addGroup(tileJetMonAlg,
'TileJetChanTime1D',
'Tile/Jet/ChanTime/')
263 for ros
in range(1, Tile.MAX_ROS):
264 for module
in range(0, Tile.MAX_DRAWER):
265 for channel
in range(0, Tile.MAX_CHAN):
266 moduleName = Tile.getDrawerString(ros, module)
267 title =
'Time in ' + moduleName +
' channel ' +
str(channel) +
';time [ns];N'
268 name = moduleName +
'_ch_' +
str(channel) +
'_1d'
270 channelTime1DGroup.defineHistogram(name, title = title, path = path, type =
'TH1F',
271 xbins = 600, xmin = -30.0, xmax = 30.0)
275 if DoEnergyDiffHistograms:
278 energyDiffGroup = helper.addGroup(tileJetMonAlg,
'TileJetEnergyDiff',
'Tile/Jet/EnergyDiff/')
280 for ros
in range(1, Tile.MAX_ROS):
281 for module
in range(0, Tile.MAX_DRAWER):
282 for channel
in range(0, Tile.MAX_CHAN):
285 moduleName = Tile.getDrawerString(ros, module)
286 title =
'Tile Cell Energy difference in ' + moduleName +
' channel ' +
str(channel) +
' ' + gain
287 title +=
';#frac{ene1 - ene2}{ene1 + ene2}'
288 name = moduleName +
'_enediff_' + gain +
'_ch1_' +
str(channel)
290 energyDiffGroup.defineHistogram(name, title = title, path = path, type =
'TH1F',
291 xbins = 100, xmin = -1.0, xmax = 1.0)
295 accumalator = helper.result()
296 result.merge(accumalator)
299 if __name__==
'__main__':
302 from AthenaCommon.Logging
import log
307 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
308 from AthenaConfiguration.TestDefaults
import defaultTestFiles
310 flags.Input.Files = defaultTestFiles.ESD
311 flags.Output.HISTFileName =
'TileJetMonitorOutput.root'
312 flags.DQ.useTrigger =
False
313 flags.DQ.enableLumiAccess =
False
314 flags.Exec.MaxEvents = 3
319 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
320 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
325 Do1DHistograms =
True,
326 DoEnergyDiffHistograms =
True)
327 cfg.merge(tileJetMonitorAccumulator)
331 cfg.store(
open(
'TileJetMonitorAlgorithm.pkl',
'wb') )
337 sys.exit(
not sc.isSuccess())