ATLAS Offline Software
LArNoisyROMonAlg.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 #
4 
5 def LArNoisyROMonConfig(flags, inKey="",
6  NoisyFEBDefStr="(>30 chan with Q>4000)",
7  NoisyHVlineDefStr="",
8  MNBTightFEBDefStr="",
9  MNBTight_PsVetoFEBDefStr="",
10  MNBLooseFEBDefStr=""):
11 
12  from AthenaMonitoring import AthMonitorCfgHelper
13  helper = AthMonitorCfgHelper(flags,'LArNoisyROMonAlgCfg')
14 
15  from AthenaConfiguration.ComponentFactory import CompFactory
16  NoisyFEBDefStr="(>"+str(flags.LAr.NoisyRO.BadChanPerFEB)+" chan with Q>"+str(flags.LAr.NoisyRO.CellQuality)+")"
17  NoisyHVlineDefStr="(>"+str(flags.LAr.NoisyRO.BadHVCut)+" HVlines with >"+str(flags.LAr.NoisyRO.BadHVlineFrac)+" channels with Q>"+str(flags.LAr.NoisyRO.CellQuality)+")"
18 
19  MNBTightFEBDefStr="(>"+str(flags.LAr.NoisyRO.MNBTightCut)+" chan with Q>"+str(flags.LAr.NoisyRO.CellQuality)+")"
20  MNBTight_PsVetoFEBDefStr="(>"+str(flags.LAr.NoisyRO.MNBTight_PsVetoCut[0])+" chan with Q>"+str(flags.LAr.NoisyRO.CellQuality)+") + PS veto (<"+str(flags.LAr.NoisyRO.MNBTight_PsVetoCut[1])+" channels)"
21  MNBLooseFEBDefStr="(>"+str(flags.LAr.NoisyRO.MNBLooseCut)+" chan with Q>"+str(flags.LAr.NoisyRO.CellQuality)+")"
22 
23  return LArNoisyROMonConfigCore(helper,CompFactory.LArNoisyROMonAlg, flags, inKey, NoisyFEBDefStr, NoisyHVlineDefStr, MNBTightFEBDefStr, MNBTight_PsVetoFEBDefStr, MNBLooseFEBDefStr)
24 
25 
26 def LArNoisyROMonConfigCore(helper,algoinstance,flags,
27  inKey="",
28  NoisyFEBDefStr="(>30 chan with Q>4000)",
29  NoisyHVlineDefStr="",
30  MNBTightFEBDefStr="",
31  MNBTight_PsVetoFEBDefStr="",
32  MNBLooseFEBDefStr=""):
33 
34  # first configure known bad FEBs
35  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
37  from LArBadChannelTool.LArBadFebsConfig import LArKnownBadFebCfg, LArKnownMNBFebCfg
38  cfg.merge(LArKnownBadFebCfg(flags))
39  cfg.merge(LArKnownMNBFebCfg(flags))
40 
41  larNoisyROMonAlg = helper.addAlgorithm(algoinstance,'larNoisyROMonAlg')
42 
43  NoisyROMonGroupName="LArNoisyROMonGroup"
44 
45  from LArMonitoring.GlobalVariables import lArDQGlobals
46 
47  larNoisyROMonAlg.NoisyROGroupName=NoisyROMonGroupName
48  larNoisyROMonAlg.SubDetNames=lArDQGlobals.SubDet[0:2]
49  larNoisyROMonAlg.PartitionNames=lArDQGlobals.Partitions[0:4]
50 
51  larNoisyROMonAlg.storeLooseMNBFEBs=True
52  if inKey != "":
53  larNoisyROMonAlg.inputKey=inKey
54 
55  # variable for testing on ESD
56  try:
57  LArNoisyROMonForceTrigger
58  except NameError:
59  LArNoisyROMonForceTrigger = False
60 
61  EFNoiseBurstTriggersList=[
62  "HLT_larnoiseburst_L1XE60",
63  "HLT_larnoiseburst_L1XE70",
64  "HLT_larnoiseburst_L1XE80",
65  "HLT_larnoiseburst_L1J100",
66  "HLT_larnoiseburst_L1J40_XE60",
67  "HLT_larnoiseburst_L1J40_XE50",
68  "HLT_larpsall_L1J12_FIRSTEMPTY",
69  "HLT_larpsall_L1J30_FIRSTEMPTY",
70  "HLT_larpsallem_L1EM7_FIRSTEMPTY"
71  ]
72  L1NoiseBurstTriggersList = [
73  "L1_J75",
74  "L1_J100",
75  "L1_J40_XE50",
76  "L1_J40_XE60",
77  "L1_J10_EMPTY",
78  "L1_J30_EMPTY",
79  "L1_EM7_FIRSTEMPTY",
80  "L1_J12_FIRSTEMPTY",
81  "L1_J30_FIRSTEMPTY",
82  "L1_XE60",
83  "L1_XE70",
84  "L1_XE80"
85  ]
86 
87  if flags.DQ.useTrigger or LArNoisyROMonForceTrigger:
88  larNoisyROMonAlg.doTrigger = True
89  larNoisyROMonAlg.EFNoiseBurstTriggers = EFNoiseBurstTriggersList
90  larNoisyROMonAlg.L1NoiseBurstTriggers = L1NoiseBurstTriggersList
91  else:
92  larNoisyROMonAlg.doTrigger = False
93  larNoisyROMonAlg.EFNoiseBurstTriggers = []
94  larNoisyROMonAlg.L1NoiseBurstTriggers = []
95 
96  noisyROGroup = helper.addGroup(
97  larNoisyROMonAlg,
98  NoisyROMonGroupName,
99  '/LAr/NoisyRO/'
100  )
101 
102 
103  larNoisyRO_hist_path='Summary/'
104 
105  # first trees
106  noisyROGroup.defineTree('time,time_ns,algo;LArNoise',path=larNoisyRO_hist_path,
107  treedef='time/i:time_ns/i:algo/b')
108 
109  noisyROGroup.defineTree('candidate_MNB_time,candidate_MNB_time_ns,n_candidate_MNBTight_FEB,n_candidate_MNBTight_PsVeto_FEB,n_candidate_MNBLoose_FEB,v_candidate_MNBTightFEB,v_candidate_MNBTight_PsVetoFEB,v_candidate_MNBLooseFEB;CandidateMNBFebs',path=larNoisyRO_hist_path,
110  treedef='candidate_MNB_time/i:candidate_MNB_time_ns/i:n_candidate_MNBTight_FEB/i:n_candidate_MNBTight_PsVeto_FEB/i:n_candidate_MNBLoose_FEB/i:v_candidate_MNBTightFEB/vector<int>:v_candidate_MNBTight_PsVetoFEB/vector<int>:v_candidate_MNBLooseFEB/vector<int>')
111 
112  #then global histo
113  noisyROGroup.defineHistogram('n_noisyFEBs;NoisyFEB',
114  title='Number of noisy FEB '+ NoisyFEBDefStr + ' per event;# of noisy FEB',
115  type='TH1I',
116  path=larNoisyRO_hist_path,
117  xbins=lArDQGlobals.noisyFEB_Bins,xmin=lArDQGlobals.noisyFEB_Min,xmax=lArDQGlobals.noisyFEB_Max)
118  noisyROGroup.defineHistogram('n_noisyHVlines;NoisyHVlines',
119  title='Number of noisy HVlines '+ NoisyHVlineDefStr + ' per event;# of noisy HVlines',
120  type='TH1I',
121  path=larNoisyRO_hist_path,
122  xbins=lArDQGlobals.noisyFEB_Bins,xmin=lArDQGlobals.noisyFEB_Min,xmax=lArDQGlobals.noisyFEB_Max)
123  noisyROGroup.defineHistogram('LBN;LBN',type='TH1I',
124  title='Event counter per LB',
125  path=larNoisyRO_hist_path,
126  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max)
127 
128  for subdet in range(0,2):
129  hist_path='/LAr/NoisyRO/'+lArDQGlobals.SubDet[subdet]+'/'
130  slot_low = lArDQGlobals.FEB_Slot[lArDQGlobals.Partitions[subdet*2]][0] - 0.5
131  slot_up = lArDQGlobals.FEB_Slot[lArDQGlobals.Partitions[subdet*2]][1] + 0.5
132  slot_n = int(slot_up - slot_low)
133  ft_low = lArDQGlobals.FEB_Feedthrough[lArDQGlobals.Partitions[subdet*2]][0] - 0.5
134  ft_up = lArDQGlobals.FEB_Feedthrough[lArDQGlobals.Partitions[subdet*2]][1] + 0.5
135  ft_n = int(ft_up - ft_low)
136 
137  darray = helper.addArray([lArDQGlobals.Partitions[2*subdet:2*subdet+2]],larNoisyROMonAlg,lArDQGlobals.SubDet[subdet],topPath='/')
138 
139  # Known bad FEBS
140  darray.defineHistogram('slotBad,FTBad;KnownBadFEB', title='Known Bad FEBs {0} ; Slot ; FT',
141  type='TH2I', path=hist_path,
142  xbins=slot_n,xmin=slot_low,xmax=slot_up,
143  ybins=ft_n, ymin=ft_low, ymax=ft_up,
144  merge='identical')
145 
146  darray.defineHistogram('slotMNB,FTMNB;MNBKnownFEB', title='Known MNB FEBs {0} ; Slot ; FT',
147  type='TH2I', path=hist_path,
148  xbins=slot_n,xmin=slot_low,xmax=slot_up,
149  ybins=ft_n, ymin=ft_low, ymax=ft_up,
150  merge='identical')
151 
152  # 2D plots of noisy FEBs with various cuts
153  darray.defineHistogram('slotNoisy,FTNoisy;NoisyFEBPerEvt', title='Yield of events with {0} FEB noisy -'+NoisyFEBDefStr+' (only vetoed events) ; Slot ; FT',
154  type='TH2I', path=hist_path,
155  xbins=slot_n,xmin=slot_low,xmax=slot_up,
156  ybins=ft_n, ymin=ft_low, ymax=ft_up)
157 
158  darray.defineHistogram('slotTight,FTTight;MNBTightFEBPerEvt', title='Yield of events with {0} FEB noisy -'+MNBTightFEBDefStr+' (only vetoed events) ; Slot ; FT',
159  type='TH2I', path=hist_path,
160  xbins=slot_n,xmin=slot_low,xmax=slot_up,
161  ybins=ft_n, ymin=ft_low, ymax=ft_up)
162 
163  darray.defineHistogram('slotTightCan,FTTightCan;CandidateMNBTightFEBPerEvt', title='Yield of events with {0} FEB noisy -'+MNBTightFEBDefStr+' (only vetoed events) ; Slot ; FT',
164  type='TH2I', path=hist_path,
165  xbins=slot_n,xmin=slot_low,xmax=slot_up,
166  ybins=ft_n, ymin=ft_low, ymax=ft_up)
167 
168  darray.defineHistogram('slot_PsVetoTight,FT_PsVetoTight;MNBTight_PsVetoFEBPerEvt', title='Yield of events with {0} FEB noisy -'+MNBTight_PsVetoFEBDefStr+' (only vetoed events) ; Slot ; FT',
169  type='TH2I', path=hist_path,
170  xbins=slot_n,xmin=slot_low,xmax=slot_up,
171  ybins=ft_n, ymin=ft_low, ymax=ft_up)
172 
173  darray.defineHistogram('slot_PsVetoTightCan,FT_PsVetoTightCan;CandidateMNBTight_PsVetoFEBPerEvt', title='Yield of events with {0} FEB noisy -'+MNBTight_PsVetoFEBDefStr+' (only vetoed events) ; Slot ; FT',
174  type='TH2I', path=hist_path,
175  xbins=slot_n,xmin=slot_low,xmax=slot_up,
176  ybins=ft_n, ymin=ft_low, ymax=ft_up)
177 
178  darray.defineHistogram('slotLoose,FTLoose;MNBLooseFEBPerEvt', title='Yield of events with {0} FEB noisy -'+MNBLooseFEBDefStr+' (only vetoed events) ; Slot ; FT',
179  type='TH2I', path=hist_path,
180  xbins=slot_n,xmin=slot_low,xmax=slot_up,
181  ybins=ft_n, ymin=ft_low, ymax=ft_up)
182 
183  darray.defineHistogram('slotLooseCan,FTLooseCan;CandidateMNBLooseFEBPerEvt', title='Yield of events with {0} FEB noisy -'+MNBLooseFEBDefStr+' (only vetoed events) ; Slot ; FT',
184  type='TH2I', path=hist_path,
185  xbins=slot_n,xmin=slot_low,xmax=slot_up,
186  ybins=ft_n, ymin=ft_low, ymax=ft_up)
187 
188  # 1D plots of noisy events of various type
189  darray.defineHistogram('LBStd;NoisyEvent',type='TH1I', path=hist_path,
190  title='Yield of events flagged as RNB-Standard - {0} ; Luminosity Block; Number of events',
191  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max)
192 
193  darray.defineHistogram('LBSat;SaturatedNoisyEvent',type='TH1I', path=hist_path,
194  title='Yield of events flagged as RNB-Saturated - {0} ; Luminosity Block',
195  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max)
196 
197  darray.defineHistogram('LBMNBTight;MNBTightEvent',type='TH1I', path=hist_path,
198  title='Yield of events flagged as MNB-Tight - {0} ; Luminosity Block',
199  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max)
200 
201  darray.defineHistogram('LBMNBTight_PsVeto;MNBTight_PsVetoEvent',type='TH1I', path=hist_path,
202  title='Yield of events flagged as MNB-Tight_PsVeto - {0} ; Luminosity Block',
203  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max)
204 
205  darray.defineHistogram('LBMNBLoose;MNBLooseEvent',type='TH1I', path=hist_path,
206  title='Yield of events flagged as MNB-Loose - {0} ; Luminosity Block',
207  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max)
208 
209  # 1D plots of events still noisy after EventVeto
210  darray.defineHistogram('LBStd_Veto;NoisyEvent_TimeVeto',type='TH1I', path=hist_path,
211  title='Yield of events flagged as RNB-Standard not vetoed by time window - {0} ; Luminosity Block',
212  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max)
213 
214  darray.defineHistogram('LBSat_Veto;SaturatedNoisyEvent_TimeVeto',type='TH1I', path=hist_path,
215  title='Yield of events flagged as RNB-Saturated not vetoed by time window - {0} ; Luminosity Block',
216  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max)
217 
218  darray.defineHistogram('LBMNBTight_Veto;MNBTightEvent_TimeVeto',type='TH1I', path=hist_path,
219  title='Yield of events flagged as MNB-Tight not vetoed by time window - {0} ; Luminosity Block',
220  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max)
221 
222  darray.defineHistogram('LBMNBTight_PsVeto_Veto;MNBTight_PsVetoEvent_TimeVeto',type='TH1I', path=hist_path,
223  title='Yield of events flagged as MNB-Tight_PsVeto not vetoed by time window - {0} ; Luminosity Block',
224  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max)
225 
226  darray.defineHistogram('LBMNBLoose_Veto;MNBLooseEvent_TimeVeto',type='TH1I', path=hist_path,
227  title='Yield of events flagged as MNB-Loose not vetoed by time window - {0} ; Luminosity Block',
228  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max)
229 
230  # Trigger histos
231  if larNoisyROMonAlg.doTrigger:
232  siz=len(larNoisyROMonAlg.EFNoiseBurstTriggers)
233  darray.defineHistogram('Triggers;NoisyEventTrigger',type='TH1I', path=hist_path,
234  title='Trigger fired for RNB flagged events - {0} ; Special trigger fired',
235  xbins=siz+1,xmin=0.5,xmax=siz+1.5,
236  xlabels=larNoisyROMonAlg.EFNoiseBurstTriggers.append("NONE"))
237 
238  l1siz=len(larNoisyROMonAlg.L1NoiseBurstTriggers)
239  darray.defineHistogram('L1Triggers;NoisyEventL1Term',type='TH1I', path=hist_path,
240  title='L1 term fired for RNB flagged events - {0} ; Special trigger fired',
241  xbins=l1siz+1,xmin=0.5,xmax=l1siz+1.5,
242  xlabels=larNoisyROMonAlg.L1NoiseBurstTriggers.append("NONE"))
243  for subdet in range(0,4):
244  darray1 = helper.addArray([lArDQGlobals.Partitions[2*subdet:2*subdet+2]],larNoisyROMonAlg,lArDQGlobals.SubDet[subdet],topPath='/')
245 
246  darray1.defineHistogram('LBHV;HVlineNoisyEvent',type='TH1I', path=hist_path,
247  title='Yield of events flagged by HVlines flag - {0} ; Luminosity Block; Number of events',
248  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max)
249 
250  darray1.defineHistogram('LBHV_Veto;HVlineNoisyEvent_TimeVeto',type='TH1I', path=hist_path,
251  title='Yield of events flagged by HVlines flag not vetoed by time window - {0} ; Luminosity Block',
252  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max)
253 
254 
255  cfg.merge(helper.result())
256  return cfg
257 
258 
259 if __name__=='__main__':
260 
261  # Setup logs
262  from AthenaCommon.Constants import INFO
263 
264  # Set the Athena configuration flags
265  from AthenaConfiguration.AllConfigFlags import initConfigFlags
266  flags = initConfigFlags()
267  from LArMonitoring.LArMonConfigFlags import addLArMonFlags
268  flags.addFlagsCategory("LArMon", addLArMonFlags)
269 
270  nightly = '/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/Tier0ChainTests/q431/21.0/v1/'
271  file = 'myESD.pool.root'
272 
273  flags.Input.Files = [nightly+file]
274  flags.Input.isMC = False
275  flags.DQ.useTrigger = True
276 
277  flags.Output.HISTFileName = 'LArNoisyROMonitoringOutput.root'
278 
279  flags.Exec.OutputLevel=INFO
280  flags.lock()
281 
282  # Initialize configuration object, add accumulator, merge, and run.
283  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
284  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
285  cfg = MainServicesCfg(flags)
286  cfg.merge(PoolReadCfg(flags))
287 
288  # try NoisyRO algo
289  #first geometry
290  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
291  from TileGeoModel.TileGMConfig import TileGMCfg
292  cfg.merge(LArGMCfg(flags))
293  cfg.merge(TileGMCfg(flags))
294  from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
295  cfg.merge(LArOnOffIdMappingCfg(flags))
296  from LArCalibUtils.LArHVScaleConfig import LArHVScaleCfg
297  cfg.merge(LArHVScaleCfg(flags))
298  # then NoisyROSummary creator
299  from LArCellRec.LArNoisyROSummaryConfig import LArNoisyROSummaryCfg
300  noisyROSumm = LArNoisyROSummaryCfg(flags)
301  noisyROSumm.getEventAlgo("LArNoisyROAlg").OutputKey="LArNoisyROSummary_recomputed"
302  cfg.merge(noisyROSumm)
303  # then monitoring algo
304  noisemon=LArNoisyROMonConfig(flags, inKey="LArNoisyROSummary_recomputed")
305  cfg.merge(noisemon)
306 
307  flags.dump()
308 
309  cfg.run(20) #use cfg.run() to run on all events
python.LArBadFebsConfig.LArKnownMNBFebCfg
def LArKnownMNBFebCfg(configFlags, tag=None)
Definition: LArBadFebsConfig.py:25
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
LArNoisyROMonAlg.LArNoisyROMonConfig
def LArNoisyROMonConfig(flags, inKey="", NoisyFEBDefStr="(>30 chan with Q>4000)", NoisyHVlineDefStr="", MNBTightFEBDefStr="", MNBTight_PsVetoFEBDefStr="", MNBLooseFEBDefStr="")
Definition: LArNoisyROMonAlg.py:5
LArNoisyROMonAlg.LArNoisyROMonConfigCore
def LArNoisyROMonConfigCore(helper, algoinstance, flags, inKey="", NoisyFEBDefStr="(>30 chan with Q>4000)", NoisyHVlineDefStr="", MNBTightFEBDefStr="", MNBTight_PsVetoFEBDefStr="", MNBLooseFEBDefStr="")
Definition: LArNoisyROMonAlg.py:26
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
Constants
some useful constants -------------------------------------------------—
python.LArBadFebsConfig.LArKnownBadFebCfg
def LArKnownBadFebCfg(configFlags, tag=None)
Definition: LArBadFebsConfig.py:11
LArCablingConfig.LArOnOffIdMappingCfg
def LArOnOffIdMappingCfg(configFlags)
Definition: LArCablingConfig.py:62
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
LArNoisyROSummaryConfig.LArNoisyROSummaryCfg
def LArNoisyROSummaryCfg(configFlags, **kwargs)
Definition: LArNoisyROSummaryConfig.py:8
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
str
Definition: BTagTrackIpAccessor.cxx:11
python.LArHVScaleConfig.LArHVScaleCfg
def LArHVScaleCfg(configFlags)
Definition: LArHVScaleConfig.py:8
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
TileGMConfig.TileGMCfg
def TileGMCfg(flags)
Definition: TileGMConfig.py:7