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