ATLAS Offline Software
EfexInputMonitorAlgorithm.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 #
4 
5 # note: string DQ algo parameters must have leading/trailing ' char, to distinguish from other parts of algo config
6 # these initial values were determined from run 486894 in 2024
7 # these should be reviewed at an L1Calo meeting in 2025, prior to data taking
8 # commenting out for start of 2025 - will remove this comment once new set of known anomalies established
9 knownAnomalies_hotHcal = {
10  # "KnownDead":"\"1,29;12,57;15,57;18,24;18,41;18,50;19,41;2,29;20,41;21,41;22,41;23,29;23,41;24,41;25,36;25,41;26,18;26,38;27,18;28,18;29,18;32,18;33,18;41,21;41,54;42,21;42,43;47,6;7,62;8,54;9,41;9,51;9,52;9,53;9,54;9,56\"",
11  "KnownDead":"\"1,29;13,36;18,24;18,50;2,29;23,29;25,36;26,38;30,15;32,46;36,39;41,21;41,54;42,21;42,43;47,6;7,62;8,54;9,41;9,51;9,52;9,53;9,54;9,56;26,10;27,10;28,10;29,10;30,10;31,10;32,10;33,10;18,3;19,3;20,3;21,3;22,3;23,3;24,3;25,3\"",
12  "KnownWarm":"\"26,3;27,3;28,3;29,3;30,3;31,3;32,3;33,3;34,3\"", # noisy tile drawer
13  "KnownHot":"\"15,49\"", # one hotspot in LAr HCal?
14  "KnownCold":"\"\""
15  # Below is the HI Config
16  #"KnownCold":"\"31,58\"",
17  #"KnownHot":"\"15,49;11,27;6,33;22,47;26,20;3,5;40,24\"",
18  #"KnownDead":"\"9,17;9,18;9,19;9,20;9,21;9,22;9,23;9,24;5,33;6,33;8,23;3,34;43,59;44,61;45,41;46,24\""
19 }
20 
21 knownAnomalies_coldHcal = {
22  #"KnownDead":"\"1,29;2,29;41,21;41,54;42,21;42,43;47,6;7,62;8,54;9,41;9,51;9,52;9,53;9,54;9,56\"",
23  "KnownDead":knownAnomalies_hotHcal["KnownDead"],
24  "KnownCold":"\"1,30;2,30\"",
25  "KnownHot":"\"6,33\""
26  #"KnownWarm":"\"5,33\"" # one slightly-frequent coldspot
27 }
28 knownAnomalies_hotEcal = {
29  "KnownHot":"\"2,15;2,16;2,47;2,48;2,55;2,56;47,35;47,36;48,35;48,36;47,47;47,48;48,47;48,48;4,5;13,48\"",
30  "KnownCold":"\"19,18;48,8;8,33;9,19;9,20;9,33;9,34\"",
31  "KnownWarm":"\"2,15;2,47;2,55;2,56;47,35;47,36;47,47;47,48;48,47;50,44\""
32  # Below is HI Config
33  # "KnownCold":"\"8,33;9,33;8,34;9,34;10,18;9,19;9,20;10,20;20,48;49,41;49,42;19,18;19,9;3,17;48,8;8,11;8,40;26,14\"",
34  # "KnownWarm":"\"22,13;22,14;23,13:23,14;22,47;22,48;23,47;23,48\"",
35  # "KnownHot":"\"4,5;13,48\"" # from HI Running
36 }
37 knownAnomalies_coldEcal = {
38  # "KnownHot":"\"1,15;2,15;47,47;48,36\"",
39  "KnownHot":"\"1,15;1,16;2,15;2,16;1,47;1,48;2,47;2,48;1,55;1,56;2,55;2,56;22,47;22,48;23,47;23,48;22,13;22,14;23,13;23,14;50,43;50,44;47,35;47,36;48,35;48,36;47,47;47,48;48,47;48,48\"",
40  "KnownCold":"\"8,33;8,34;49,41;49,42;10,20;9,34\""
41  # "KnownWarm":"\"1,47;1,48;1,49;1,55;1,56;2,16;2,47;2,48;2,55;2,56;22,14;23,14;47,35;47,36;47,48;48,35;48,47;48,48;49,51;50,43;50,44\""
42 }
43 
45  '''Function to configure LVL1 EfexInput algorithm in the monitoring system.'''
46 
47  # get the component factory - used for getting the algorithms
48  from AthenaConfiguration.ComponentFactory import CompFactory
49  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
50  result = ComponentAccumulator()
51 
52  from LArBadChannelTool.LArBadChannelConfig import LArMaskedSCCfg
53 
54  result.merge(LArMaskedSCCfg(flags))
55 
56  # use L1Calo's special MonitoringCfgHelper
57  from TrigT1CaloMonitoring.LVL1CaloMonitoringConfig import L1CaloMonitorCfgHelper
58  helper = L1CaloMonitorCfgHelper(flags,CompFactory.EfexInputMonitorAlgorithm,'EfexInputMonAlg')
59 
60  helper.defineHistogram('LBN,ErrorAndLocation;h_summary',title='EfexInput Monitoring summary;LBN;Error:TowerID',
61  path="Expert/Inputs/eFEX/detail",
62  hanConfig={"description":"TowerID format: '[E]EPPMMF', where E=eta index, P=phi index,M=module,F=fpga"},
63  fillGroup="errors",
64  type='TH2I',
65  xbins=1,xmin=0,xmax=1,
66  ybins=1,ymin=0,ymax=1,
67  opt=['kAddBinsDynamically','kAlwaysCreate'],merge="merge")
68 
69  import math
70  helper.defineHistogram('TowerEta,TowerPhi;h_errors',title='EfexInput Errors;#eta;#phi',
71  path="Expert/Inputs/eFEX",
72  hanConfig={"algorithm":"Histogram_Empty","description":"Locations of any non-zero em or hadronic status flags. Check <a href='./detail/h_summary'>detail/h_summary</a> for more detail if there are entries"},
73  fillGroup="errors",cutmask='IsMonReady',
74  type='TH2I',
75  xbins=50,xmin=-2.5,xmax=2.5,
76  ybins=64,ymin=-math.pi,ymax=math.pi)
77 
78 
79 
80 
81 
82  commonAlgConfig = {"libname":"libdqm_summaries.so",
83  "name":"L1Calo_BinsDiffFromStripMedian",
84  "PublishDetail":32}
85  hotCuts = {"ColdCut":-3.5,"WarmCut":9,"HotCut":20} # when looking at frequency of hot deposits, use these cuts
86  coldCuts = {"ColdCut":-4,"WarmCut":5,"HotCut":10} # lower thresholds for looking at negative energy deposits, as RMS is usually smaller
87 
88  commonThresholdConfig = {
89  "NWrongKnown":[0,100], # warn of any corrections that are needed for the known anomalies lists
90  "NDead":[0,2], # warn on any new dead spots, error if more than a couple
91  "NHot":[0,5], # warn on any new hot spots, error if more than a couple
92  "NCold":[0,5], # warn on any new cold spots, error if more than a couple
93  "NWarm":[30,40], # warn on more than 30 warm spots, error if more than 40
94  "NDeadStrip":[0,0], # no dead strips - exception to this will be in cold hcal, where tile cannot be negative
95  "NConsecUnlikelyStrip":[2,5], # warn if more than 2 consecutive strips deemed unlikely
96  }
97 
98  helper.defineDQAlgorithm("Efex_ecal_hot_etaPhiMapOutliers",
99  hanConfig=commonAlgConfig|hotCuts|knownAnomalies_hotEcal,
100  thresholdConfig=commonThresholdConfig
101  )
102 
103  helper.defineDQAlgorithm("Efex_hcal_hot_etaPhiMapOutliers",
104  hanConfig=commonAlgConfig|hotCuts|knownAnomalies_hotHcal,
105  thresholdConfig=commonThresholdConfig
106  )
107 
108  helper.defineDQAlgorithm("Efex_ecal_hot_etaPhiLBMapOutliers_Shifter",
109  hanConfig=commonAlgConfig|hotCuts|knownAnomalies_hotEcal|{"NBinsY":64,"LiveMode":1},
110  thresholdConfig=commonThresholdConfig
111  )
112 
113  helper.defineDQAlgorithm("Efex_hcal_hot_etaPhiLBMapOutliers_Shifter",
114  hanConfig=commonAlgConfig|hotCuts|knownAnomalies_hotHcal|{"NBinsY":64,"LiveMode":1},
115  thresholdConfig=commonThresholdConfig
116  )
117 
118  helper.defineDQAlgorithm("Efex_ecal_hot_etaPhiLBMapOutliers",
119  hanConfig=commonAlgConfig|hotCuts|knownAnomalies_hotEcal|{"NBinsY":64,"LiveMode":0},
120  thresholdConfig=commonThresholdConfig
121  )
122 
123  helper.defineDQAlgorithm("Efex_hcal_hot_etaPhiLBMapOutliers",
124  hanConfig=commonAlgConfig|hotCuts|knownAnomalies_hotHcal|{"NBinsY":64,"LiveMode":0},
125  thresholdConfig=commonThresholdConfig
126  )
127 
128  helper.defineDQAlgorithm("Efex_ecal_cold_etaPhiMapOutliers",
129  hanConfig=commonAlgConfig|coldCuts|knownAnomalies_coldEcal,
130  thresholdConfig=commonThresholdConfig
131  )
132 
133  helper.defineDQAlgorithm("Efex_hcal_cold_etaPhiMapOutliers",
134  hanConfig=commonAlgConfig|coldCuts|knownAnomalies_coldHcal,
135  thresholdConfig=commonThresholdConfig|{"NDeadStrip":[30,30]} # negatives not possible in tile (-1.5->1.5)
136  )
137 
138  for layer in ["ecal","hcal"]:
139  helper.defineHistogram(f'TowerEta,TowerPhi;h_dataTowers_{layer}_hot_EtaPhiMap',title=f'{layer.upper()} SuperCells >= 500MeV;#eta;#phi',
140  cutmask="AboveCut",
141  paths=["Expert/Inputs/eFEX/detail","Shifter/Inputs/eFEX"],
142  hanConfig={"algorithm":f"Efex_{layer}_hot_etaPhiMapOutliers","description":f"Check <a href='./detail/h_dataTowers_{layer}_hot_posVsLBN'>detail plot</a> to get timeseries for each location"},
143  fillGroup=layer,
144  type='TH2I',
145  xbins=50,xmin=-2.5,xmax=2.5,
146  ybins=64,ymin=-math.pi,ymax=math.pi,opt=['kAlwaysCreate'])
147 
148  helper.defineHistogram(f'LBN,binNumber;h_dataTowers_{layer}_hot_posVsLBN',title=f'{layer.upper()} SuperCells >= 500MeV;LB;64(x-1)+y',
149  paths=["Expert/Inputs/eFEX/detail","Shifter/Inputs/eFEX"],
150  cutmask="AboveCut",
151  hanConfig={"Expert/algorithm":f"Efex_{layer}_hot_etaPhiLBMapOutliers","Shifter/algorithm":f"Efex_{layer}_hot_etaPhiLBMapOutliers_Shifter",
152  "description":f"x and y correspond to axis bin numbers on <a href='../h_dataTowers_{layer}_hot_EtaPhiMap'/>eta-phi plot</a>. Use this plot to check if hotspot/coldspots affected whole or part of run: turn on Projection X1 to see 1D hist of individual locations"},
153  fillGroup=layer,
154  type='TH2I',
155  xbins=1,xmin=0,xmax=10,
156  ybins=64*50,ymin=0.5,ymax=64*50+0.5,
157  opt=['kAddBinsDynamically','kAlwaysCreate'],merge="merge")
158  helper.defineHistogram(f'TowerEta,TowerPhi;h_dataTowers_{layer}_cold_EtaPhiMap',title=f'{layer.upper()} SuperCells <= -500MeV;#eta;#phi',
159  cutmask="BelowCut",
160  path="Expert/Inputs/eFEX/detail",
161  hanConfig={"algorithm":f"Efex_{layer}_cold_etaPhiMapOutliers","description":f"Check <a href='./detail/h_dataTowers_{layer}_cold_posVsLBN'>detail plot</a> to get timeseries for each location"},
162  fillGroup=layer,
163  type='TH2I',
164  xbins=50,xmin=-2.5,xmax=2.5,
165  ybins=64,ymin=-math.pi,ymax=math.pi,opt=['kAlwaysCreate'])
166 
167  helper.defineHistogram(f'LBN,binNumber;h_dataTowers_{layer}_cold_posVsLBN',title=f'{layer.upper()} SuperCells <= -500MeV;LB;64(x-1)+y',
168  path="Expert/Inputs/eFEX/detail",
169  cutmask="BelowCut",
170  hanConfig={"description":f"x and y correspond to axis bin numbers on <a href='../h_dataTowers_{layer}_cold_EtaPhiMap'/>eta-phi plot</a>. Use this plot to check if hotspot/coldspots affected whole or part of run: turn on Projection X1 to see 1D hist of individual locations"},
171  fillGroup=layer,
172  type='TH2I',
173  xbins=1,xmin=0,xmax=10,
174  ybins=64*50,ymin=0.5,ymax=64*50+0.5,
175  opt=['kAddBinsDynamically','kAlwaysCreate'],merge="merge")
176 
177  helper.defineTree('LBN,Error,LBNString,EventNumber,TowerId,TowerEta,TowerPhi,TowerEmstatus,TowerHadstatus,TowerSlot,TowerCount,RefTowerCount,SlotSCID,timeSince,timeUntil;errors',
178  "lbn/I:error/string:lbnString/string:eventNumber/l:id/I:eta/F:phi/F:em_status/i:had_status/i:slot/I:count/I:ref_count/I:scid/string:timeSince/I:timeUntil/I",
179  title="errors tree;LBN;Error",fillGroup="errors")
180 
181 
182  result.merge(helper.result())
183  return result
184 
185 
186 if __name__=='__main__':
187  # set input file and config options
188  from AthenaConfiguration.AllConfigFlags import initConfigFlags
189  import glob
190 
191  inputs = glob.glob('/eos/atlas/atlastier0/rucio/data18_13TeV/physics_Main/00354311/data18_13TeV.00354311.physics_Main.recon.ESD.f1129/data18_13TeV.00354311.physics_Main.recon.ESD.f1129._lb0013._SFO-8._0001.1')
192 
193  flags = initConfigFlags()
194  flags.Input.Files = inputs
195  flags.Output.HISTFileName = 'ExampleMonitorOutput_LVL1_MC.root'
196 
197  flags.lock()
198  flags.dump() # print all the configs
199 
200  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
201  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
202  cfg = MainServicesCfg(flags)
203  cfg.merge(PoolReadCfg(flags))
204 
205  EfexInputMonitorCfg = EfexInputMonitoringConfig(flags)
206  cfg.merge(EfexInputMonitorCfg)
207 
208  # options - print all details of algorithms, very short summary
209  cfg.printConfig(withDetails=False, summariseProps = True)
210 
211  nevents=10
212  cfg.run(nevents)
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
EfexInputMonitorAlgorithm.EfexInputMonitoringConfig
def EfexInputMonitoringConfig(flags)
Definition: EfexInputMonitorAlgorithm.py:44
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:312
python.LArBadChannelConfig.LArMaskedSCCfg
def LArMaskedSCCfg(configFlags)
Definition: LArBadChannelConfig.py:63
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:71