ATLAS Offline Software
LArCoherentNoisefractionAlg.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 #
4 '''@file LArCoherentNoisefractionAlg
5 @author P. Strizenec
6 @date 22-05-2021
7 @brief Adapted from LArNoiseCorrelationMonAlg by M. Spalla
8 '''
9 
10 def LArCoherentNoisefractionConfig(inputFlags, groupsToMonitor=[]):
11 
12  from AthenaMonitoring.AthMonitorCfgHelper import AthMonitorCfgHelper
13  helper = AthMonitorCfgHelper(flags,'LArCoherentNoisefractionMonAlgCfg')
14 
15  from AthenaConfiguration.ComponentFactory import CompFactory
16  return LArCoherentNoisefractionConfigCore(helper, CompFactory.LArCoherentNoisefractionMonAlg,inputFlags,groupsToMonitor)
17 
18 def LArCoherentNoisefractionConfigCore(helper, algoinstance, inputFlags, groupsToMonitor):
19  from LArMonitoring.GlobalVariables import lArDQGlobals
20 
21  larCoherentNoisefractionMonAlg = helper.addAlgorithm(algoinstance,'larCoherentNoisefractionMonAlg')
22 
23  #set all groups to monitor, if the empty list is passed
24  allGroups=["tot","top","bot","left","right","q1","q2","q3","q4","qs11","qs22","qs3","qs4"]
25  groupsNChan=[128,64,64,64,64,32,32,32,32,32,32,32,32]
26  allMonitor=[True,True,True,True,True,True,True,True,True,True,True,True,True]
27 
28  #from AthenaCommon.Constants import DEBUG
29  #larCoherentNoisefractionMonAlg.OutputLevel = DEBUG
30  try:
31  larCoherentNoisefractionMonAlg.IsCalibrationRun = inputFlags.LArMon.calibRun
32  except AttributeError:
33  larCoherentNoisefractionMonAlg.IsCalibrationRun = False
34  try:
35  larCoherentNoisefractionMonAlg.LArDigitContainerKey = inputFlags.LArMon.LArDigitKey
36  except AttributeError:
37  larCoherentNoisefractionMonAlg.LArDigitContainerKey = 'FREE'
38  larCoherentNoisefractionMonAlg.ListOfGroupNames = allGroups
39  larCoherentNoisefractionMonAlg.GroupNchan = groupsNChan
40  if len(groupsToMonitor) == 0:
41  customGroupstoMonitor = allMonitor
42  else:
43  if len(customGroupstoMonitor) != len(allMonitor):
44  from AthenaCommon.Logging import logging
45  logging.getLogger().warning("Wrong list of groups to monitor, setting all !")
46  customGroupstoMonitor = allMonitor
47  else:
48  customGroupstoMonitor = groupsToMonitor
49  larCoherentNoisefractionMonAlg.GroupsToMonitor = customGroupstoMonitor
50 
51  try:
52  customFEBStoMonitor = inputFlags.LArMon.customFEBsToMonitor
53  except AttributeError:
54  customFEBStoMonitor = ["endcapAft19slot12","endcapAft19slot09","endcapAft20slot09"]
55 
56  #correct custom FEBs for upper-lower cases or single-digit ft and slot numbers (e.g. 3 instead of 03)
57  from ROOT import LArStrHelper
58  larStrHelp=LArStrHelper()
59  customFEBStoMonitor=[larStrHelp.fixFEBname(nm) for nm in customFEBStoMonitor]
60 
61 
62  # adding BadChan masker private tool
63  larCoherentNoisefractionMonAlg.TriggerChain = "HLT_noalg_zb_L1ZB, HLT_noalg_cosmiccalo_L1RD1_EMPTY" #turn off for calibration run
64 
65 
66  setCustomFEBS=set(customFEBStoMonitor)
67  febsToMonitorBarrelA=list(setCustomFEBS.intersection(lArDQGlobals.febsBarrelA))
68  febsToMonitorEndcapA=list(setCustomFEBS.intersection(lArDQGlobals.febsEndcapA))
69  febsToMonitorBarrelC=list(setCustomFEBS.intersection(lArDQGlobals.febsBarrelC))
70  febsToMonitorEndcapC=list(setCustomFEBS.intersection(lArDQGlobals.febsEndcapC))
71 
72  if len(febsToMonitorBarrelA)==0 and len(febsToMonitorEndcapA)==0 and len(febsToMonitorBarrelC)==0 and len(febsToMonitorEndcapC)==0:
73  print("LArCoherentNoisefractionMonAlg:WARNING. None of the following FEBs were recognised, no plot will be produced")
74  print(customFEBStoMonitor)
75  larCoherentNoisefractionMonAlg.PlotsOFF=True #lets protect ourselves against poor writing
76  larCoherentNoisefractionMonAlg.PlotCustomFEBSset=False
77  larCoherentNoisefractionMonAlg.FEBlist=[]
78  else:
79  #pass to algorithm
80  larCoherentNoisefractionMonAlg.PlotCustomFEBSset=True
81  larCoherentNoisefractionMonAlg.FEBlist=febsToMonitorBarrelA+febsToMonitorBarrelC+febsToMonitorEndcapA+febsToMonitorEndcapC
82  pass
83 
84  #prepare the monitoring groups
85  for grp in range(0,len(allGroups)):
86  if not customGroupstoMonitor[grp]: continue
87 
88 
89  cnfArray = helper.addArray([larCoherentNoisefractionMonAlg.FEBlist],larCoherentNoisefractionMonAlg,allGroups[grp])
90 
91  hist_path='/LAr/CNF/'
92 
93  tot_plot_name="cnf_tot"
94  tot_var_and_name="SumDev;"+tot_plot_name
95  cnfArray.defineHistogram(tot_var_and_name,
96  title=tot_plot_name,
97  type='TH1F',
98  path=hist_path+'BarrelA',
99  xbins=lArDQGlobals.CNFN_tot, xmin=lArDQGlobals.CNFXmin_tot, xmax=lArDQGlobals.CNFXmax_tot,
100  pattern=febsToMonitorBarrelA)
101 
102  cnfArray.defineHistogram(tot_var_and_name,
103  title=tot_plot_name,
104  type='TH1F',
105  path=hist_path+'BarrelC',
106  xbins=lArDQGlobals.CNFN_tot, xmin=lArDQGlobals.CNFXmin_tot, xmax=lArDQGlobals.CNFXmax_tot,
107  pattern=febsToMonitorBarrelC)
108 
109  print(lArDQGlobals.CNFN_tot)
110  cnfArray.defineHistogram(tot_var_and_name,
111  title=tot_plot_name,
112  type='TH1F',
113  path=hist_path+'EndcapA',
114  xbins=lArDQGlobals.CNFN_tot, xmin=lArDQGlobals.CNFXmin_tot, xmax=lArDQGlobals.CNFXmax_tot,
115  pattern=febsToMonitorEndcapA)
116 
117 
118  cnfArray.defineHistogram(tot_var_and_name,
119  title=tot_plot_name,
120  type='TH1F',
121  path=hist_path+'EndcapC',
122  xbins=lArDQGlobals.CNFN_tot, xmin=lArDQGlobals.CNFXmin_tot, xmax=lArDQGlobals.CNFXmax_tot,
123  pattern=febsToMonitorEndcapC)
124 
125 
126  noncoh_plot_name="cnf_noncoh"
127  noncoh_var_and_name="Dev;"+noncoh_plot_name
128 
129  cnfArray.defineHistogram(noncoh_var_and_name,
130  title=noncoh_plot_name,
131  type='TH1F',
132  path=hist_path+'BarrelA',
133  xbins=lArDQGlobals.CNFN_ncoh, xmin=lArDQGlobals.CNFXmin_ncoh, xmax=lArDQGlobals.CNFXmax_ncoh,
134  pattern=febsToMonitorBarrelA)
135 
136  cnfArray.defineHistogram(noncoh_var_and_name,
137  title=noncoh_plot_name,
138  type='TH1F',
139  path=hist_path+'BarrelC',
140  xbins=lArDQGlobals.CNFN_ncoh, xmin=lArDQGlobals.CNFXmin_ncoh, xmax=lArDQGlobals.CNFXmax_ncoh,
141  pattern=febsToMonitorBarrelC)
142 
143  cnfArray.defineHistogram(noncoh_var_and_name,
144  title=noncoh_plot_name,
145  type='TH1F',
146  path=hist_path+'EndcapA',
147  xbins=lArDQGlobals.CNFN_ncoh, xmin=lArDQGlobals.CNFXmin_ncoh, xmax=lArDQGlobals.CNFXmax_ncoh,
148  pattern=febsToMonitorEndcapA)
149 
150  cnfArray.defineHistogram(noncoh_var_and_name,
151  title=noncoh_plot_name,
152  type='TH1F',
153  path=hist_path+'EndcapC',
154  xbins=lArDQGlobals.CNFN_ncoh, xmin=lArDQGlobals.CNFXmin_ncoh, xmax=lArDQGlobals.CNFXmax_ncoh,
155  pattern=febsToMonitorEndcapC)
156 
157 
158  print(cnfArray.toolList())
159 
160  cfg.merge(helper.result())
161  return cfg
162 
163 
164 if __name__=='__main__':
165 
166  from AthenaConfiguration.AllConfigFlags import initConfigFlags
167  from AthenaCommon.Logging import log
168  from AthenaCommon.Constants import DEBUG
169  log.setLevel(DEBUG)
170 
171  flags = initConfigFlags()
172  from LArMonitoring.LArMonConfigFlags import addLArMonFlags
173  flags.addFlagsCategory("LArMon", addLArMonFlags)
174  from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
175  addLArCalibFlags(flags)
176 
177  #from AthenaConfiguration.TestDefaults import defaultTestFiles
178 
179  flags.Input.Files = ['/eos/atlas/atlastier0/rucio/data21_calib/calibration_LArElec-Pedestal-5s-High-Emec-A-RawData/00393063/data21_calib.00393063.calibration_LArElec-Pedestal-5s-High-Emec-A-RawData.daq.RAW/data21_calib.00393063.calibration_LArElec-Pedestal-5s-High-Emec-A-RawData.daq.RAW._lb0000._SFO-1._0001.data','/eos/atlas/atlastier0/rucio/data21_calib/calibration_LArElec-Pedestal-5s-High-Emec-A-RawData/00393063/data21_calib.00393063.calibration_LArElec-Pedestal-5s-High-Emec-A-RawData.daq.RAW/data21_calib.00393063.calibration_LArElec-Pedestal-5s-High-Emec-A-RawData.daq.RAW._lb0000._SFO-2._0001.data','/eos/atlas/atlastier0/rucio/data21_calib/calibration_LArElec-Pedestal-5s-High-Emec-A-RawData/00393063/data21_calib.00393063.calibration_LArElec-Pedestal-5s-High-Emec-A-RawData.daq.RAW/data21_calib.00393063.calibration_LArElec-Pedestal-5s-High-Emec-A-RawData.daq.RAW._lb0000._SFO-3._0001.data','/eos/atlas/atlastier0/rucio/data21_calib/calibration_LArElec-Pedestal-5s-High-Emec-A-RawData/00393063/data21_calib.00393063.calibration_LArElec-Pedestal-5s-High-Emec-A-RawData.daq.RAW/data21_calib.00393063.calibration_LArElec-Pedestal-5s-High-Emec-A-RawData.daq.RAW._lb0000._SFO-4._0001.data']
180 
181  flags.LArMon.calibRun = True
182  flags.Output.HISTFileName = 'LArCNFMonOutput.root'
183  flags.DQ.enableLumiAccess = False
184  flags.DQ.useTrigger = False
185 
186  from AthenaConfiguration.Enums import BeamType
187  flags.Beam.Type = BeamType.Collisions
188  flags.lock()
189 
190  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
192  from LArByteStream.LArRawDataReadingConfig import LArRawDataReadingCfg
193  cfg.merge(LArRawDataReadingCfg(flags,LArDigitKey="HIGH",LArRawChannelKey=""))
194  # for calib digits:
195  #from LArByteStream.LArRawCalibDataReadingConfig import LArRawCalibDataReadingCfg
196  #cfg.merge(LArRawCalibDataReadingCfg(flags,gain="HIGH",doCalibDigit=True))
197  from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
198  cfg.merge(LArOnOffIdMappingCfg(flags))
199  from LArConfiguration.LArElecCalibDBConfig import LArElecCalibDBCfg
200  cfg.merge(LArElecCalibDBCfg(flags,["Pedestal"]))
201 
202  feblist=[]
203  for ft in [11,12,23,24]:
204  for slot in range(1,15):
205  if slot < 10:
206  feblist += ['EndcapAft'+str(ft)+'slot0'+str(slot)]
207  else:
208  feblist += ['EndcapAft'+str(ft)+'slot'+str(slot)]
209  aff_acc = LArCoherentNoisefractionConfig(flags,feblist)
210 
211  cfg.merge(aff_acc)
212 
213  cfg.printConfig()
214  log.setLevel(DEBUG)
215  flags.dump()
216  f=open("LArCNFMon.pkl","wb")
217  cfg.store(f)
218  f.close()
219 
220  #cfg.run(100)
python.LArElecCalibDBConfig.LArElecCalibDBCfg
def LArElecCalibDBCfg(flags, condObjs)
Definition: LArElecCalibDBConfig.py:47
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
LArStrHelper
Helper class to manipulate strings for LArOnlineID names.
Definition: LArStrHelper.h:24
LArCoherentNoisefractionAlg.LArCoherentNoisefractionConfig
def LArCoherentNoisefractionConfig(inputFlags, groupsToMonitor=[])
Definition: LArCoherentNoisefractionAlg.py:10
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
Constants
some useful constants -------------------------------------------------—
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
LArCablingConfig.LArOnOffIdMappingCfg
def LArOnOffIdMappingCfg(configFlags)
Definition: LArCablingConfig.py:62
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
python.LArRawDataReadingConfig.LArRawDataReadingCfg
def LArRawDataReadingCfg(configFlags, **kwargs)
Definition: LArRawDataReadingConfig.py:10
Trk::open
@ open
Definition: BinningType.h:40
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
LArCoherentNoisefractionAlg.LArCoherentNoisefractionConfigCore
def LArCoherentNoisefractionConfigCore(helper, algoinstance, inputFlags, groupsToMonitor)
Definition: LArCoherentNoisefractionAlg.py:18
str
Definition: BTagTrackIpAccessor.cxx:11
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
python.LArCalibConfigFlags.addLArCalibFlags
def addLArCalibFlags(flags, isSC=False)
Definition: LArCalibConfigFlags.py:3