ATLAS Offline Software
LArNoiseCorrelationMonAlg.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 #
5  '''Function to configures some algorithms in the monitoring system.'''
6 
7  # The following class will make a sequence, configure algorithms, and link
8  # them to GenericMonitoringTools
9 
10  from AthenaMonitoring.AthMonitorCfgHelper import AthMonitorCfgHelper
11  helper = AthMonitorCfgHelper(flags,'LArNoiseCorrelationMonAlgCfg')
12 
13  from AthenaConfiguration.ComponentFactory import CompFactory
14  return LArNoiseCorrelationMonConfigCore(helper, CompFactory.LArNoiseCorrelationMonAlg,flags)
15 
16 def LArNoiseCorrelationMonConfigCore(helper, algoinstance,flags):
17 
18 
19  from LArMonitoring.GlobalVariables import lArDQGlobals
20 
21  larNoiseCorrelMonAlg = helper.addAlgorithm(algoinstance,'larNoiseCorrelMonAlg')
22 
23  #set custom list of FEBs to be monitored (if you want one): each FEB should be passed as a string of the form "BarrelAft01slot10"
24 
25  try:
26  customFEBStoMonitor = flags.LArMon.customFEBsToMonitor
27  except AttributeError:
28  customFEBStoMonitor = ["endcapAft19slot12","endcapAft19slot09","endcapAft20slot09"]
29 
30 
31  #correct custom FEBs for upper-lower cases or single-digit ft and slot numbers (e.g. 3 instead of 03)
32  from ROOT import LArStrHelper
33  larStrHelp=LArStrHelper()
34  customFEBStoMonitor=[larStrHelp.fixFEBname(nm) for nm in customFEBStoMonitor]
35 
36 
37  # adding BadChan masker private tool
38  larNoiseCorrelMonAlg.ProblemsToMask=["deadReadout","deadPhys","short","almostDead","highNoiseHG","highNoiseMG","highNoiseLG","sporadicBurstNoise"]
39  larNoiseCorrelMonAlg.IgnoreBadChannels=True
40  larNoiseCorrelMonAlg.TriggerChain = "HLT_noalg_zb_L1ZB, HLT_noalg_zb_L1RD1_EMPTY, HLT_noalg_cosmiccalo_L1RD1_EMPTY" #turn off for calibration run
41  try:
42  larNoiseCorrelMonAlg.IsCalibrationRun = flags.LArMon.calibRun
43  except AttributeError:
44  larNoiseCorrelMonAlg.IsCalibrationRun = False
45  try:
46  larNoiseCorrelMonAlg.LArDigitContainerKey = flags.LArMon.LArDigitKey
47  except AttributeError:
48  larNoiseCorrelMonAlg.LArDigitContainerKey = 'FREE'
49 
50  #deal with custom febs to monitor (if any)
51  if len(customFEBStoMonitor)==0:
52  #we do not want to plot everything if online
53  if flags.DQ.Environment == 'online':
54  from AthenaCommon.Logging import logging
55  larNoiseCorrelMonAlg.PlotsOFF=True
56  msg=logging.getLogger("LArNoiseCorrelationMonAlg")
57  msg.warning("customFEBStoMonitors empty, and we are online, no plot will be produced")
58  msg.warning(customFEBStoMonitor)
59  pass
60  febsToMonitorBarrelA=lArDQGlobals.febsBarrelA
61  febsToMonitorEndcapA=lArDQGlobals.febsEndcapA
62  febsToMonitorBarrelC=lArDQGlobals.febsBarrelC
63  febsToMonitorEndcapC=lArDQGlobals.febsEndcapC
64  larNoiseCorrelMonAlg.FEBlist=febsToMonitorBarrelA+febsToMonitorBarrelC+febsToMonitorEndcapA+febsToMonitorEndcapC
65  else:
66  setCustomFEBS=set(customFEBStoMonitor)
67  febsToMonitorBarrelA=sorted(setCustomFEBS.intersection(lArDQGlobals.febsBarrelA))
68  febsToMonitorEndcapA=sorted(setCustomFEBS.intersection(lArDQGlobals.febsEndcapA))
69  febsToMonitorBarrelC=sorted(setCustomFEBS.intersection(lArDQGlobals.febsBarrelC))
70  febsToMonitorEndcapC=sorted(setCustomFEBS.intersection(lArDQGlobals.febsEndcapC))
71 
72  if len(febsToMonitorBarrelA)==0 and len(febsToMonitorEndcapA)==0 and len(febsToMonitorBarrelC)==0 and len(febsToMonitorEndcapC)==0:
73  from AthenaCommon.Logging import logging
74  msg=logging.getLogger("LArNoiseCorrelationMonAlg")
75  msg.warning("None of the following FEBs were recognised, no plot will be produced")
76  msg.warning(customFEBStoMonitor)
77  larNoiseCorrelMonAlg.PlotsOFF=True #lets protect ourselves against poor writing
78  larNoiseCorrelMonAlg.FEBlist=lArDQGlobals.febsBarrelA+lArDQGlobals.febsEndcapA+lArDQGlobals.febsBarrelC+lArDQGlobals.febsEndcapC #to avoid having it empty, would it crash otherwise?
79  else:
80  #pass to algorithm
81 # customFEBStoMonitor_forAlgo=[[lArDQGlobals.dictBarrelEndcap[i[0]],lArDQGlobals.dictSides[i[1]],int(i[2]),int(i[3])] for i in customFEBStoMonitor]
82  # larNoiseCorrelMonAlg.FEBsToMonitor=customFEBStoMonitor_forAlgo
83  larNoiseCorrelMonAlg.FEBlist=febsToMonitorBarrelA+febsToMonitorBarrelC+febsToMonitorEndcapA+febsToMonitorEndcapC
84  pass
85  pass
86 
87  if larNoiseCorrelMonAlg.PlotsOFF: # do not have plots, returning
88  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
90  cfg.merge(helper.result())
91  return cfg
92 
93  #prepare the monitoring group
94  grpName="NoiseCorr"
95  larNoiseCorrelMonAlg.NoiseCorrGroupName=grpName
96  correlArray = helper.addArray([larNoiseCorrelMonAlg.FEBlist],larNoiseCorrelMonAlg,grpName,'/LAr/','run')
97 # correlArray = helper.addArray([lArDQGlobals.BarrelEndcap,lArDQGlobals.Sides,lArDQGlobals.Feedthrough_RangeMax,lArDQGlobals.Slot_RangeMax],larNoiseCorrelMonAlg,"NoiseCorrRAW",'/LAr/','run')
98 
99  hist_path='NoiseCorrelation/'
100 
101  average_plot_name="RAW_NoiseCorr_average"
102  average_var_and_name="chanMeanX,chanMean;"+average_plot_name
103  correlArray.defineHistogram(average_var_and_name,
104  title=average_plot_name,
105  type='TProfile',
106  path=hist_path+'BarrelA',
107  xbins=lArDQGlobals.FEB_N_channels,xmin=lArDQGlobals.FEB_channels_Min,xmax=lArDQGlobals.FEB_channels_Max,
108  pattern=febsToMonitorBarrelA)
109 
110  correlArray.defineHistogram(average_var_and_name,
111  title=average_plot_name,
112  type='TProfile',
113  path=hist_path+'EndcapA',
114  xbins=lArDQGlobals.FEB_N_channels,xmin=lArDQGlobals.FEB_channels_Min,xmax=lArDQGlobals.FEB_channels_Max,
115  pattern=febsToMonitorEndcapA)
116 
117 
118  correlArray.defineHistogram(average_var_and_name,
119  title=average_plot_name,
120  type='TProfile',
121  path=hist_path+'BarrelC',
122  xbins=lArDQGlobals.FEB_N_channels,xmin=lArDQGlobals.FEB_channels_Min,xmax=lArDQGlobals.FEB_channels_Max,
123  pattern=febsToMonitorBarrelC)
124 
125  correlArray.defineHistogram(average_var_and_name,
126  title=average_plot_name,
127  type='TProfile',
128  path=hist_path+'EndcapC',
129  xbins=lArDQGlobals.FEB_N_channels,xmin=lArDQGlobals.FEB_channels_Min,xmax=lArDQGlobals.FEB_channels_Max,
130  pattern=febsToMonitorEndcapC)
131 
132 
133  partialSum_plot_name="RAW_NoiseCorr_partialSum"
134  partialSum_var_and_name="chanPartSumX,chanPartSumY;"+partialSum_plot_name
135 
136  correlArray.defineHistogram(partialSum_var_and_name,
137  title=partialSum_plot_name,
138  type='TH2F',
139  weight='chanPartSum',
140  path=hist_path+'BarrelA',
141  xbins=lArDQGlobals.FEB_N_channels,xmin=lArDQGlobals.FEB_channels_Min,xmax=lArDQGlobals.FEB_channels_Max,
142  ybins=lArDQGlobals.FEB_N_channels,ymin=lArDQGlobals.FEB_channels_Min,ymax=lArDQGlobals.FEB_channels_Max,
143  pattern=febsToMonitorBarrelA)
144 
145  correlArray.defineHistogram(partialSum_var_and_name,
146  title=partialSum_plot_name,
147  type='TH2F',
148  weight='chanPartSum',
149  path=hist_path+'EndcapA',
150  xbins=lArDQGlobals.FEB_N_channels,xmin=lArDQGlobals.FEB_channels_Min,xmax=lArDQGlobals.FEB_channels_Max,
151  ybins=lArDQGlobals.FEB_N_channels,ymin=lArDQGlobals.FEB_channels_Min,ymax=lArDQGlobals.FEB_channels_Max,
152  pattern=febsToMonitorEndcapA)
153 
154 
155  correlArray.defineHistogram(partialSum_var_and_name,
156  title=partialSum_plot_name,
157  type='TH2F',
158  weight='chanPartSum',
159  path=hist_path+'BarrelC',
160  xbins=lArDQGlobals.FEB_N_channels,xmin=lArDQGlobals.FEB_channels_Min,xmax=lArDQGlobals.FEB_channels_Max,
161  ybins=lArDQGlobals.FEB_N_channels,ymin=lArDQGlobals.FEB_channels_Min,ymax=lArDQGlobals.FEB_channels_Max,
162  pattern=febsToMonitorBarrelC)
163 
164  correlArray.defineHistogram(partialSum_var_and_name,
165  title=partialSum_plot_name,
166  type='TH2F',
167  weight='chanPartSum',
168  path=hist_path+'EndcapC',
169  xbins=lArDQGlobals.FEB_N_channels,xmin=lArDQGlobals.FEB_channels_Min,xmax=lArDQGlobals.FEB_channels_Max,
170  ybins=lArDQGlobals.FEB_N_channels,ymin=lArDQGlobals.FEB_channels_Min,ymax=lArDQGlobals.FEB_channels_Max,
171  pattern=febsToMonitorEndcapC)
172 
173 
174  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
176  cfg.merge(helper.result())
177  return cfg
178 
179 
180 if __name__=='__main__':
181 
182  from AthenaConfiguration.AllConfigFlags import initConfigFlags
183  flags = initConfigFlags()
184 
185  from AthenaCommon.Logging import log
186  from AthenaCommon.Constants import DEBUG
187  log.setLevel(DEBUG)
188 
189  from LArMonitoring.LArMonConfigFlags import addLArMonFlags
190  flags.addFlagsCategory("LArMon", addLArMonFlags)
191 
192  from AthenaConfiguration.TestDefaults import defaultTestFiles
193  flags.Input.Files = defaultTestFiles.RAW_RUN2
194 
195  flags.Output.HISTFileName = 'LArNoiseCorrMonOutput.root'
196  flags.DQ.enableLumiAccess = False
197  flags.DQ.useTrigger = False
198  flags.lock()
199 
200  from CaloRec.CaloRecoConfig import CaloRecoCfg
201  cfg=CaloRecoCfg(flags)
202 
203  from LArCellRec.LArNoisyROSummaryConfig import LArNoisyROSummaryCfg
204  cfg.merge(LArNoisyROSummaryCfg(flags))
205 
206  # from LArMonitoring.LArNoiseCorrelationMonAlg import LArNoiseCorrelationMonConfig
208 
209  cfg.merge(aff_acc)
210 
211  log.setLevel(DEBUG)
212  flags.dump()
213  f=open("LArNoiseCorrelationMon.pkl","wb")
214  cfg.store(f)
215  f.close()
216 
217 # cfg.run(100)
python.CaloRecoConfig.CaloRecoCfg
def CaloRecoCfg(flags, clustersname=None)
Definition: CaloRecoConfig.py:9
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
LArStrHelper
Helper class to manipulate strings for LArOnlineID names.
Definition: LArStrHelper.h:24
Constants
some useful constants -------------------------------------------------—
LArNoiseCorrelationMonAlg.LArNoiseCorrelationMonConfig
def LArNoiseCorrelationMonConfig(flags)
Definition: LArNoiseCorrelationMonAlg.py:4
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
LArNoiseCorrelationMonAlg.LArNoiseCorrelationMonConfigCore
def LArNoiseCorrelationMonConfigCore(helper, algoinstance, flags)
Definition: LArNoiseCorrelationMonAlg.py:16
Trk::open
@ open
Definition: BinningType.h:40
LArNoisyROSummaryConfig.LArNoisyROSummaryCfg
def LArNoisyROSummaryCfg(configFlags, **kwargs)
Definition: LArNoisyROSummaryConfig.py:8
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19