6 from AthenaCommon.Logging
import logging
7 from ByteStreamCnvSvc.ByteStreamConfig
import ByteStreamReadCfg
8 from AthenaConfiguration.ComponentFactory
import CompFactory
9 mlog = logging.getLogger(
'LArSuperCellMonConfig' )
12 from AthenaMonitoring.AthMonitorCfgHelper
import AthMonitorCfgHelper
13 helper = AthMonitorCfgHelper(flags,
'LArSuperCellMonAlgCfg')
15 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
18 if not flags.DQ.enableLumiAccess
and not flags.DQ.Environment ==
'online':
19 mlog.warning(
'This algo needs Lumi access, returning empty config')
22 from LArGeoAlgsNV.LArGMConfig
import LArGMCfg
24 from TileGeoModel.TileGMConfig
import TileGMCfg
27 from DetDescrCnvSvc.DetDescrCnvSvcConfig
import DetDescrCnvSvcCfg
30 if flags.Common.isOnline:
31 cfg.addCondAlgo(CompFactory.CaloSuperCellAlignCondAlg(
'CaloSuperCellAlignCondAlg'))
33 from LumiBlockComps.BunchCrossingCondAlgConfig
import BunchCrossingCondAlgCfg
36 from CaloTools.CaloNoiseCondAlgConfig
import CaloNoiseCondAlgCfg
41 from LArByteStream.LArRawSCDataReadingConfig
import LArRawSCDataReadingCfg
44 from TrigT1CaloFexPerf.EmulationConfig
import emulateSC_Cfg
47 from LArCellRec.LArRAWtoSuperCellConfig
import LArRAWtoSuperCellCfg
53 from LArCabling.LArCablingConfig
import LArOnOffIdMappingSCCfg
57 from LArConfiguration.LArElecCalibDBConfig
import LArElecCalibDBSCCfg
59 larLATOMEBuilderAlg=CompFactory.LArLATOMEBuilderAlg(
"LArLATOMEBuilderAlg")
62 runinfo=
getLArDTInfoForRun(flags.Input.RunNumbers[0], connstring=
"COOLONL_LAR/CONDBR2")
63 streamTypes=runinfo.streamTypes()
64 except Exception
as e:
65 mlog.warning(
"Could not get DT run info, using defaults !")
67 streamTypes=[
"RawADC"]
69 for i
in range(0,len(streamTypes)):
70 mlog.info(
"runinfo.streamTypes()[i]: "+
str(streamTypes[i]))
71 if streamTypes[i] ==
"RawADC":
72 larLATOMEBuilderAlg.LArDigitKey =
"SC"
73 larLATOMEBuilderAlg.isADCBas =
False
74 if streamTypes[i] ==
"ADC":
75 larLATOMEBuilderAlg.isADCBas =
True
76 larLATOMEBuilderAlg.LArDigitKey =
"SC_ADC_BAS"
78 cfg.addEventAlgo(larLATOMEBuilderAlg)
79 cfg.merge(
LArRAWtoSuperCellCfg(flags,name=
"LArRAWRecotoSuperCell",mask=mask,doReco=
True,SCIn=
"SC_ET_RECO",SCellContainerOut=
"SCell_ET_RECO") )
82 cfg.merge(
LArElecCalibDBSCCfg(flags, condObjs=[
"Ramp",
"DAC2uA",
"Pedestal",
"uA2MeV",
"MphysOverMcal",
"OFC",
"Shape",
"HVScaleCorr"]))
86 algname=
'LArSuperCellMonAlg'
87 lArCellMonAlg=CompFactory.LArSuperCellMonAlg(algname,CaloCellContainerReco=
"SCell_ET_RECO",CaloCellContainerRef=flags.Trigger.L1.L1CaloSuperCellContainerName,doSCReco=
True,CaloCellContainer=
'EmulatedSuperCells')
89 if flags.Input.isMC
is False and not flags.Common.isOnline:
90 from LumiBlockComps.LuminosityCondAlgConfig
import LuminosityCondAlgCfg
92 from LumiBlockComps.LBDurationCondAlgConfig
import LBDurationCondAlgCfg
96 from AthenaConfiguration.Enums
import BeamType
97 if flags.Beam.Type
is BeamType.Cosmics:
98 algname=algname+
'Cosmics'
101 flags.Beam.Type
is BeamType.Cosmics,
102 flags.Input.isMC, algname, RemoveMasked=mask)
104 cfg.merge(helper.result())
113 LArSuperCellMonAlg = helper.addAlgorithm(algclass, algname)
116 GroupName=
"LArSuperCellMon"
117 LArSuperCellMonAlg.MonGroupName = GroupName
119 LArSuperCellMonAlg.EnableLumi =
False
120 LArSuperCellMonAlg.CaloCellContainer =
'EmulatedSuperCells'
121 LArSuperCellMonAlg.CaloCellContainerRef = flags.Trigger.L1.L1CaloSuperCellContainerName
122 LArSuperCellMonAlg.RemoveMasked = RemoveMasked
123 LArSuperCellMonAlg.doDatabaseNoiseVsEtaPhi=
True
132 cellMonGroup = helper.addGroup(
135 '/LAr/LArSuperCellMon_NoTrigSel/'
138 cellMonGroup=
defineHistograms(cellMonGroup,LArSuperCellMonAlg.LayerNames,isHLT=
False)
139 return LArSuperCellMonAlg
143 from AthenaConfiguration.ComponentFactory
import CompFactory
144 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
145 from AthenaMonitoringKernel.GenericMonitoringTool
import GenericMonitoringTool
147 if flags.Common.isOnline:
148 cfg.addCondAlgo(CompFactory.CaloSuperCellAlignCondAlg(
'CaloSuperCellAlignCondAlg'))
151 from CaloTools.CaloNoiseCondAlgConfig
import CaloNoiseCondAlgCfg
155 from TrigT1CaloFexPerf.EmulationConfig
import emulateSC_Cfg
158 from LArCellRec.LArRAWtoSuperCellConfig
import LArRAWtoSuperCellCfg
162 from LArCabling.LArCablingConfig
import LArOnOffIdMappingSCCfg
165 SCellsToCheck=
"SCellFromBS"
166 if flags.Common.isOnline:
167 from LArByteStream.LArRawSCDataReadingConfig
import LArRawSCDataReadingCfg
170 cfg.merge(
LArRAWtoSuperCellCfg(flags,name=
"LArRAWtoSuperCellFromBS",SCellContainerOut=SCellsToCheck,mask=mask) )
172 SCellsToCheck=
"SCell"
174 lArCellMonAlg=CompFactory.LArSuperCellMonAlg(name,CaloCellContainerReco=
"",CaloCellContainerRef=
"EmulatedSCells",doSCReco=
False,CaloCellContainer=SCellsToCheck,TrigDecisionTool=
"",EnableLumi =
False, RemoveMasked = RemoveMasked)
176 if flags.Input.isMC
is False and not flags.Common.isOnline:
177 from LumiBlockComps.LuminosityCondAlgConfig
import LuminosityCondAlgCfg
179 from LumiBlockComps.LBDurationCondAlgConfig
import LBDurationCondAlgCfg
184 lArCellMonAlg.GMTools = [monTool]
185 lArCellMonAlg.MonGroupName=
'LArSuperCellMonTool'
186 lArCellMonAlg.BunchCrossingCondDataKey=
""
188 doDatabaseNoiseVsEtaPhi =
False
189 lArCellMonAlg.doDatabaseNoiseVsEtaPhi = doDatabaseNoiseVsEtaPhi
190 monTool=
defineHistograms(monTool,lArCellMonAlg.LayerNames,isHLT=
True,isDatabaseNoise=doDatabaseNoiseVsEtaPhi,isReco=
False,jumpHEC=
True)
191 cfg.addEventAlgo(lArCellMonAlg)
194 def defineHistograms(cellMonGroup,LayerNames,isHLT=False,isDatabaseNoise=True,isReco=True,jumpHEC=False):
197 from LArMonitoring.GlobalVariables
import lArDQGlobals
200 if isHLT: sc_hist_path=
'EXPERT'
203 cellMonGroup.defineHistogram(
'superCellEt;h_SuperCellEt',
204 title=
'Super Cell E_T [MeV]; MeV; # entries',
205 type=
'TH1F', path=sc_hist_path,
206 xbins = 100,xmin=0,xmax=50000)
207 cellMonGroup.defineHistogram(
'superCellEta;h_SuperCellEta',
208 title=
'Super Cell eta; #eta; # entries',
209 type=
'TH1F', path=sc_hist_path,
210 xbins = 100,xmin=-5,xmax=5)
211 cellMonGroup.defineHistogram(
'superCelltime;h_SuperCelltime',
212 title=
'Super Cell time [ns]; ns; # entries',
213 type=
'TH1F', path=sc_hist_path,
214 xbins = 100, xmin=-400,xmax=400)
215 cellMonGroup.defineHistogram(
'superCellprovenance;h_SuperCellprovenance',
216 title=
'Super Cell provenance; bitmask ; # entries',
217 type=
'TH1F', path=sc_hist_path,
218 xbins = 700, xmin=0,xmax=700)
219 cellMonGroup.defineHistogram(
'BCID,superCellEt;h_SuperCellEt_vs_BCID',
220 title=
'Super Cell ET [MeV] vs BCID ; BCID from train front; %',
221 type=
'TH2F', path=sc_hist_path,
222 xbins = 50, xmin=0,xmax=50,
223 ybins = 80, ymin=-1000,ymax=1000)
224 cellMonGroup.defineHistogram(
'BCID,superCellEtRef;h_SuperCellEtRef_vs_BCID',
225 title=
'Super Cell ET [MeV] vs BCID ; BCID from train front; %',
226 type=
'TH2F', path=sc_hist_path,
227 xbins = 50, xmin=0,xmax=50,
228 ybins = 80, ymin=-1000,ymax=1000)
230 cellMonGroup.defineHistogram(
'resolutionHET;h_SuperCellResolution',
231 title=
'Super Cell reconstruction resolution ; %; # entries',
232 type=
'TH1F', path=sc_hist_path,
233 xbins = 70, xmin=-20,xmax=120)
234 cellMonGroup.defineHistogram(
'resolutionPass;h_SuperCellResolutionPass',
235 title=
'Super Cell reconstruction resolution for BCIDed ; %; # entries',
236 type=
'TH1F', path=sc_hist_path,
237 xbins = 70, xmin=-20,xmax=120)
238 cellMonGroup.defineHistogram(
'superCellEt,resolution;h_SuperCellResolution_vs_ET',
239 title=
'Super Cell reconstruction resolution vs ET ; [MeV]; %',
240 type=
'TH2F', path=sc_hist_path,
241 xbins = 100, xmin=0,xmax=50000,
242 ybins = 70, ymin=-20,ymax=120)
243 cellMonGroup.defineHistogram(
'superCellEta,resolutionHET;h_SuperCellResolution_vs_eta',
244 title=
'Super Cell reconstruction resolution vs #eta ; #eta; %',
245 type=
'TH2F', path=sc_hist_path,
246 xbins = 100, xmin=-5,xmax=5,
247 ybins = 40, ymin=-20,ymax=20)
248 cellMonGroup.defineHistogram(
'BCID,resolution;h_SuperCellResolution_vs_BCID',
249 title=
'Super Cell reconstruction resolution vs BCID ; BCID from train front; %',
250 type=
'TH2F', path=sc_hist_path,
251 xbins = 50, xmin=0,xmax=50,
252 ybins = 80, ymin=-120,ymax=120)
254 cellMonGroup.defineHistogram(
'superCellEtRef,superCellEt;h_SuperCellEtLin',
255 title=
'Super Cell E_T Linearity; Ref SC E_T [MeV]; SC E_T [MeV]',
256 type=
'TH2F', path=sc_hist_path,
257 xbins = 100,xmin=0,xmax=50000,
258 ybins = 100,ymin=0,ymax=50000)
259 cellMonGroup.defineHistogram(
'superCellprovenanceRef,superCellprovenance;h_SuperCellprovenanceLin',
260 title=
'Super Cell provenance Linearity; Ref SC bitmask ; SC bitmask',
261 type=
'TH2F', path=sc_hist_path,
262 xbins = 17, xmin=0,xmax=680,
263 ybins = 17, ymin=0,ymax=680)
264 cellMonGroup.defineHistogram(
'BCID;h_BCID',
265 title=
'BCID from the front of the train; BCID ; # entries',
266 type=
'TH1F', path=sc_hist_path,
267 xbins = 120, xmin=0,xmax=120)
269 cellMonGroup.defineHistogram(
'superCelltimeReco;h_SuperCelltimeReco',
270 title=
'Reco Super Cell time [ns]; ns; # entries',
271 type=
'TH1F', path=sc_hist_path,
272 xbins = 100, xmin=-400,xmax=400)
273 cellMonGroup.defineHistogram(
'superCelltimeRef,superCelltimeReco;h_SuperCelltimeLin',
274 title=
'Super Cell time Linearity; Ref SC time [ns]; Reco SC time [ns]',
275 type=
'TH2F', path=sc_hist_path,
276 xbins = 100, xmin=-200,xmax=200,
277 ybins = 100, ymin=-200,ymax=200)
280 partxbins=lArDQGlobals.SuperCell_Variables[
"etaRange"][
"All"][
"All"]
281 partybins=lArDQGlobals.SuperCell_Variables[
"phiRange"][
"All"][
"All"]
282 cellMonGroup.defineHistogram(
'superCellEta,superCellPhi,superCellEtDiff;h_SuperCellCoverage_EtDiff',
283 title=
'ET Diff: #phi vs #eta;#eta;#phi',
284 type=
'TProfile2D', path=sc_hist_path,
285 xbins = partxbins, ybins = partybins)
288 sc_hist_path=
'SC_Layer/'
289 if isHLT: sc_hist_path=
'EXPERT'
290 for part
in LayerNames:
300 if ( jumpHEC
and (
"HEC" in Part)
and (
"0" not in Sampling ) ):
302 partxbins=lArDQGlobals.SuperCell_Variables[
"etaRange"][Part][Side][Sampling]
303 partybins=lArDQGlobals.SuperCell_Variables[
"phiRange"][Part][Side][Sampling]
304 cellMonGroup.defineHistogram(
'superCellEta_'+part+
',superCellPhi_'+part+
',superCellEtDiff_'+part+
';h_SuperCellCoverage_EtDiff_'+part,
305 title=
'ET Diff '+part+
': #phi vs #eta;#eta;#phi',
306 type=
'TProfile2D', path=sc_hist_path,
307 xbins = partxbins, ybins = partybins)
310 cellMonGroup.defineHistogram(
'superCellEt_'+part+
';h_SuperCellEt'+part,
311 title=
'Super Cell E_T [MeV] '+partp+
'; MeV; # entries',
312 type=
'TH1F', path=sc_hist_path,
313 xbins = 100,xmin=0,xmax=50000)
314 cellMonGroup.defineHistogram(
'superCellEta_'+part+
';h_SuperCellEta'+part,
315 title=
'Super Cell eta '+partp+
'; #eta; # entries',
316 type=
'TH1F', path=sc_hist_path,
317 xbins = 100,xmin=-5,xmax=5)
318 cellMonGroup.defineHistogram(
'superCelltime_'+part+
';h_SuperCelltime'+part,
319 title=
'Super Cell time [ns] '+partp+
'; ns; # entries',
320 type=
'TH1F', path=sc_hist_path,
321 xbins = 100, xmin=-400,xmax=400)
322 cellMonGroup.defineHistogram(
'superCellprovenance_'+part+
';h_SuperCellprovenance'+part,
323 title=
'Super Cell provenance '+partp+
'; bitmask ; # entries',
324 type=
'TH1F', path=sc_hist_path,
325 xbins = 700, xmin=0,xmax=700)
326 cellMonGroup.defineHistogram(
'BCID,superCellEt_'+part+
';h_SuperCellET_vs_BCID'+part,
327 title=
'Super Cell ET [MeV] vs BCID '+partp+
'; BCID from train front; %',
328 type=
'TH2F', path=sc_hist_path,
329 xbins = 50, xmin=0,xmax=50,
330 ybins = 100, ymin=-1000,ymax=1000)
331 cellMonGroup.defineHistogram(
'BCID,superCellEtRef_'+part+
';h_SuperCellRefET_vs_BCID'+part,
332 title=
'Super Cell ET [MeV] vs BCID '+partp+
'; BCID from train front; %',
333 type=
'TH2F', path=sc_hist_path,
334 xbins = 50, xmin=0,xmax=50,
335 ybins = 100, ymin=-1000,ymax=1000)
337 cellMonGroup.defineHistogram(
'resolutionHET_'+part+
';h_SuperCellResolution'+part,
338 title=
'Super Cell reconstruction resolution '+partp+
'; %; # entries',
339 type=
'TH1F', path=sc_hist_path,
340 xbins = 70, xmin=-20,xmax=120)
341 cellMonGroup.defineHistogram(
'resolutionPass_'+part+
';h_SuperCellResolutionPass'+part,
342 title=
'Super Cell reconstruction resolution for BCIDed '+partp+
'; %; # entries',
343 type=
'TH1F', path=sc_hist_path,
344 xbins = 70, xmin=-20,xmax=120)
345 cellMonGroup.defineHistogram(
'superCellEt_'+part+
',resolution_'+part+
';h_SuperCellResolution_vs_ET'+part,
346 title=
'Super Cell reconstruction resolution vs ET '+partp+
'; [MeV]; %',
347 type=
'TH2F', path=sc_hist_path,
348 xbins = 100, xmin=0,xmax=50000,
349 ybins = 70, ymin=-20,ymax=120)
350 cellMonGroup.defineHistogram(
'superCellEta_'+part+
',resolutionHET_'+part+
';h_SuperCellResolution_vs_eta'+part,
351 title=
'Super Cell reconstruction resolution vs #eta '+partp+
'; #eta; %',
352 type=
'TH2F', path=sc_hist_path,
353 xbins = 100, xmin=-5,xmax=5,
354 ybins = 40, ymin=-20,ymax=20)
355 cellMonGroup.defineHistogram(
'BCID,resolution_'+part+
';h_SuperCellResolution_vs_BCID'+part,
356 title=
'Super Cell reconstruction resolution vs BCID '+partp+
'; BCID from train front; %',
357 type=
'TH2F', path=sc_hist_path,
358 xbins = 50, xmin=0,xmax=50,
359 ybins = 80, ymin=-120,ymax=120)
361 cellMonGroup.defineHistogram(
'superCellEtRef_'+part+
',superCellEt_'+part+
';h_SuperCellEtLin'+part,
362 title=
'Super Cell E_T Linearity '+partp+
'; Ref SC E_T [MeV]; SC E_T [MeV]',
363 type=
'TH2F', path=sc_hist_path,
364 xbins = 100,xmin=0,xmax=50000,
365 ybins = 100,ymin=0,ymax=50000)
366 cellMonGroup.defineHistogram(
'superCelltimeRef_'+part+
',superCelltimeReco_'+part+
';h_SuperCelltimeLin'+part,
367 title=
'Super Cell time Linearity '+partp+
'; Ref SC time [ns]; Reco SC time [ns]',
368 type=
'TH2F', path=sc_hist_path,
369 xbins = 100, xmin=-200,xmax=200,
370 ybins = 100, ymin=-200,ymax=200)
371 cellMonGroup.defineHistogram(
'superCellprovenanceRef_'+part+
',superCellprovenance_'+part+
';h_SuperCellprovenanceLin'+part,
372 title=
'Super Cell provenance Linearity '+partp+
'; Ref SC bitmask ; SC bitmask',
373 type=
'TH2F', path=sc_hist_path,
374 xbins = 17, xmin=0,xmax=680,
375 ybins = 17, ymin=0,ymax=680)
377 cellMonGroup.defineHistogram(
'superCelltimeReco_'+part+
';h_SuperCelltimeReco'+part,
378 title=
'Reco Super Cell time [ns] '+partp+
'; ns; # entries',
379 type=
'TH1F', path=sc_hist_path,
380 xbins = 100, xmin=-400,xmax=400)
383 if ( isDatabaseNoise ):
384 for part
in LayerNames:
386 cellMonGroup.defineHistogram(
'cellEnergy_'+part+
';CellEnergy_'+part,
387 title=
'Cell Energy in ' +part+
';Cell Energy [MeV];Cell Events',
388 type=
'TH1F', path=sc_hist_path,
389 xbins = 100,xmin=0,xmax=50000
392 cellMonGroup.defineHistogram(
'celleta_'+part+
';NCellsActiveVsEta_'+part,
393 title=
"No. of Active Cells in #eta for "+part+
";cell #eta",
394 type=
'TH1F', path=sc_hist_path,
395 xbins = 100,xmin=-5,xmax=5
398 cellMonGroup.defineHistogram(
'cellphi_'+part+
';NCellsActiveVsPhi_'+part,
399 title=
"No. of Active Cells in #phi for "+part+
";cell #phi",
400 type=
'TH1F', path=sc_hist_path,
401 xbins = 100,xmin=-5,xmax=5
404 cellMonGroup.defineHistogram(
'celleta_'+part+
',cellphi_'+part+
';DatabaseNoiseVsEtaPhi_'+part,
405 title=
"Map of Noise Values from the Database vs (#eta,#phi) for "+part+
";cell #eta;cell #phi",
406 weight=
'cellnoisedb_'+part,
407 cutmask=
'doDatabaseNoisePlot',
408 type=
'TH2F', path=sc_hist_path,
409 xbins = 100,xmin=-5,xmax=5,
410 ybins = 100,ymin=-5,ymax=5,
411 merge=
'weightedAverage')
418 if __name__==
'__main__':
423 from AthenaConfiguration.Enums
import LHCPeriod, BunchStructureSource
424 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
425 from AthenaCommon.Logging
import log
429 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
435 flags.Input.Files = [
'/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/TrigP1Test/data24_13p6TeV.00475321.physics_EnhancedBias.merge.RAW._lb0231._SFO-11._0001.1']
437 flags.Output.HISTFileName =
'LArSuperCellMonOutput.root'
438 flags.DQ.enableLumiAccess =
True
439 flags.DQ.useTrigger =
False
440 flags.DQ.Environment =
'tier0'
442 flags.IOVDb.GlobalTag =
"CONDBR2-ES1PA-2022-07"
443 flags.Common.isOnline =
True
444 flags.GeoModel.Run=LHCPeriod.Run3
445 flags.Exec.OutputLevel=WARNING
446 flags.Beam.BunchStructureSource=BunchStructureSource.FILLPARAMS
448 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
450 flags.fillFromArgs(sys.argv[1:])
454 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
466 if not flags.DQ.Environment ==
'online':
467 from LumiBlockComps.BunchCrossingCondAlgConfig
import BunchCrossingCondAlgCfg
473 f=
open(
"LArSuperCellMon.pkl",
"wb")