ATLAS Offline Software
JfexInputMonitorAlgorithm.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 #
5  '''Function to configure LVL1 JfexInput algorithm in the monitoring system.'''
6 
7  # get the component factory - used for getting the algorithms
8  from AthenaConfiguration.ComponentFactory import CompFactory
9  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
10  from AthenaConfiguration.Enums import Format
11  result = ComponentAccumulator()
12 
13  # use L1Calo's special MonitoringCfgHelper
14  from TrigT1CaloMonitoring.LVL1CaloMonitoringConfig import L1CaloMonitorCfgHelper
15  helper = L1CaloMonitorCfgHelper(flags,CompFactory.JfexInputMonitorAlgorithm,'JfexInputMonAlg')
16 
17 
18  #Algorithms needed for the monitoring
19  if flags.Input.Format==Format.BS:
20 
21  #Decorator for the DataTowers
22  from L1CaloFEXAlgos.L1CaloFEXAlgosConfig import L1CalojFEXDecoratorCfg
23  result.merge(L1CalojFEXDecoratorCfg(flags,ExtraInfo = False))
24 
25  #jfex emulated input: EmulatedTowers
26  from L1CaloFEXAlgos.FexEmulatedTowersConfig import jFexEmulatedTowersCfg
27  result.merge(jFexEmulatedTowersCfg(flags))
28 
29 
30  # get any algorithms
31  JfexInputMonAlg = helper.alg
32 
33  # add any steering
34  groupName = 'JfexInputMonitor' # the monitoring group name is also used for the package name
35  JfexInputMonAlg.Grouphist = groupName
36 
37  #mainDir = 'L1Calo'
38  trigPath = 'Developer/JfexInput/'
39  Calosource_names = ["Barrel","Tile","EMEC","HEC","FCAL1","FCAL2","FCAL3"]
40  FPGA_names = ["U1","U2","U4","U3"]
41 
42  from math import pi
43 
44  x_phi = []
45  for i in range(67):
46  phi = (-pi- pi/32) + pi/32*i
47  x_phi.append(phi)
48  x_phi = sorted(x_phi)
49 
50  phi_bins = {
51  'xbins': x_phi
52  }
53 
54  eta_phi_bins = {
55  'xbins': 100, 'xmin': -5, 'xmax': 5,
56  'ybins': x_phi
57  }
58 
59  helper.defineHistogram('genLocation,genType;h_jFEX_Errors', path="Developer/JfexInput", type='TH2I',
60  fillGroup=groupName+"Gen",
61  title='jFEX generic monitoring for shifters;Location;Type',
62  xbins=4, xmin=0, xmax=4, xlabels=["Sim_DataTowers","Sim_EmulatedTowers","Input_Mismatch","Input_Invalids"],
63  ybins=4, ymin=0, ymax=4, ylabels=["TOB", "global TOB", "EM layer", "HAD layer" ],
64  opt=['kCanRebin'])
65 
66  #JfexInputMonAlg.jFEXMonTool = myGenericGroup
67 
68  helper.defineHistogram('EventType,Decision;h_summary',title='JfexInput Monitoring summary;Event Type;Decision',
69  fillGroup=groupName,
70  type='TH2I',path=trigPath,
71  xbins=1,xmin=0,xmax=1,xlabels=["Normal"],
72  ybins=1,ymin=0,ymax=1,ylabels=["AllOk"],
73  opt=['kCanRebin'],merge="merge")
74 
75 
76  decorGroup = groupName+"_decorated"
77  decorAllGroup = groupName+"_decorated_all"
78  emulatedGroup = groupName+"_emulated"
79 
80  for i in range(7):
81  fillGroup = groupName+"_details_"+str(i)
82 
83  if(i == 1):
84  helper.defineHistogram('DataEt_Tile,EmulatedEt_Tile;h_SumSCell_vs_Data_'+Calosource_names[i], title='Data Et vs Tile Et ('+ Calosource_names[i]+'); Data Et [GeV]; Tile Et [GeV]',
85  fillGroup=fillGroup,
86  type='TH2F',path=trigPath+"expert/", xbins=200,xmin=0,xmax=100,ybins=200,ymin=0,ymax=100)
87 
88  else:
89  helper.defineHistogram('DataEt,EmulatedEt;h_SumSCell_vs_Data_'+Calosource_names[i], title='Data vs SCell Sum Et ('+ Calosource_names[i]+'); Data Et [MeV]; SCell Sum Et [MeV]',
90  fillGroup=fillGroup,
91  type='TH2F',path=trigPath+"expert/", xbins=160,xmin=-2000,xmax=2000,ybins=160,ymin=-2000,ymax=2000)
92 
93 
94 
95  helper.defineHistogram('region,type;h_DataErrors', title='jFEX Data mismatches per region; Region; Type',
96  type='TH2F',path=trigPath, xbins=7,xmin=0,xmax=7,ybins=2,ymin=0,ymax=2,xlabels=Calosource_names,ylabels=["Invalid codes","Data mismatch"])
97 
98  helper.defineHistogram('TowerEtaInvalid,TowerPhiInvalid;h_2Dmap_InvalidCodes', title='jFex DataTower Invalid Et codes (4095); #eta; #phi',
99  type='TH2F',path=trigPath, **eta_phi_bins)
100 
101  helper.defineHistogram('TowerEtaEmpty,TowerPhiEmpty;h_2Dmap_EmptyCodes', title='jFex DataTower Empty Et codes (0); #eta; #phi',
102  type='TH2F',path=trigPath, **eta_phi_bins)
103 
104  helper.defineHistogram('TowerEta,TowerPhi;h_2Dmap_MismatchedEts', title='jFex DataTower mismatches (no invalid codes); #eta; #phi',
105  fillGroup=decorGroup,
106  type='TH2F',path=trigPath, **eta_phi_bins)
107 
108  helper.defineHistogram('DataEt,SCellSum;h_SumSCell_vs_Data_Mismatched', title='Data vs SCell Sum Et (unmatching); Data Et [MeV]; SCell Sum Et [MeV]',
109  fillGroup=decorGroup,
110  type='TH2F',path=trigPath, xbins=160,xmin=-2000,xmax=2000,ybins=160,ymin=-2000,ymax=2000)
111 
112  helper.defineHistogram('DataEt,SCellSum;h_SumSCell_vs_Data_all', title='Data vs SCell Sum Et (all Towers); Data Et [MeV]; SCell Sum Et [MeV]',
113  fillGroup=decorAllGroup,
114  type='TH2F',path=trigPath, xbins=160,xmin=-2000,xmax=2000,ybins=160,ymin=-2000,ymax=2000)
115 
116  helper.defineHistogram('DataEt,frac_SCellSum;h_frac_SumSCell_vs_Data', title='Data vs (Et_{SCell}-Et_{Data})/Et_{Data} (no invalid codes); Data Et [MeV]; (Et_{SCell}-Et_{Data})/Et_{Data}',
117  fillGroup=decorGroup,
118  type='TH2F',path=trigPath, xbins=160,xmin=-2000,xmax=2000,ybins=100,ymin=-20,ymax=20)
119 
120  helper.defineHistogram('TowerEta,TowerPhi;h_2Dmap_DataVsEmulated', title='Input Data vs Emulated data; #eta; #phi',
121  fillGroup=emulatedGroup,
122  type='TH2F',path=trigPath, **eta_phi_bins)
123  helper.defineHistogram('TowerEtaDeco,TowerPhiDeco;h_2Dmap_EmulatedVsDecorated', title='Emulated vs Decorated data; #eta; #phi',
124  fillGroup=emulatedGroup,
125  type='TH2F',path=trigPath, **eta_phi_bins)
126 
127  # histograms of jFex tower variables (content of the container)
128  helper.defineHistogram('NJfexTowers;h_nJfexTowers', title='Number of jFex towers',
129  fillGroup=groupName,type='TH1I', path=trigPath+"Content/", xbins=2000,xmin=0,xmax=20000)
130 
131  helper.defineHistogram('TowerEta;h_TowerEta', title='jFex Tower Eta',
132  fillGroup=groupName,type='TH1F', path=trigPath+"Content/", xbins=100,xmin=-5.0,xmax=5.0)
133 
134  helper.defineHistogram('TowerPhi;h_TowerPhi', title='jFex Tower Phi',
135  fillGroup=groupName,type='TH1F', path=trigPath+"Content/", **phi_bins)
136 
137  helper.defineHistogram('TowerEta,TowerPhi;h_TowerEtaPhiMap', title='jFex Tower Eta vs Phi',
138  fillGroup=groupName,type='TH2F',path=trigPath+"Content/", **eta_phi_bins)
139 
140  helper.defineHistogram('TowerGlobalEta;h_TowerGlobalEta', title='jFex Tower Global Eta',
141  fillGroup=groupName,type='TH1I', path=trigPath+"Content/", xbins=100,xmin=-50,xmax=50)
142 
143  helper.defineHistogram('TowerGlobalPhi;h_TowerGlobalPhi', title='jFex Tower Global Phi',
144  fillGroup=groupName,type='TH1F', path=trigPath+"Content/", xbins=67,xmin=-1,xmax=65)
145 
146  helper.defineHistogram('TowerGlobalEta,TowerGlobalPhi;h_TowerGlobalEtaPhiMap', title='jFex Tower Global Eta vs Phi',
147  fillGroup=groupName,type='TH2I',path=trigPath+"Content/", xbins=100,xmin=-50,xmax=50,ybins=67,ymin=-1,ymax=65)
148 
149  helper.defineHistogram('TowerModule;h_TowerModule', title='jFex Tower Module Number',
150  fillGroup=groupName,type='TH1I', path=trigPath+"Content/", xbins=6,xmin=0,xmax=6)
151 
152  helper.defineHistogram('TowerFpga;h_TowerFpga', title='jFex Tower FPGA Number',
153  fillGroup=groupName,type='TH1I', path=trigPath+"Content/", xbins=4,xmin=0,xmax=4,xlabels=FPGA_names)
154 
155  helper.defineHistogram('TowerChannel;h_TowerChannel', title='jFex Tower Channel Number',
156  fillGroup=groupName,type='TH1I', path=trigPath+"Content/", xbins=60,xmin=0,xmax=60)
157 
158  helper.defineHistogram('TowerDataID;h_TowerDataID', title='jFex Tower Data ID',
159  fillGroup=groupName,type='TH1I', path=trigPath+"Content/", xbins=16,xmin=0,xmax=16)
160 
161  helper.defineHistogram('TowerSimulationID;h_TowerSimulationID', title='jFex Tower Simulation ID',
162  fillGroup=groupName,type='TH1F', path=trigPath+"Content/", xbins=1000,xmin=0,xmax=1500000.0)
163 
164  helper.defineHistogram('TowerCalosource;h_TowerCalosource', title='jFex Tower Calo Source',
165  fillGroup=groupName,type='TH1I', path=trigPath+"Content/", xbins=7,xmin=0,xmax=7,xlabels=Calosource_names)
166 
167  helper.defineHistogram('TowerEtcount_barrel;h_TowerEtcount_barrel', title='jFex Tower Et Barrel',
168  fillGroup=groupName,type='TH1I', path=trigPath+"Content/", xbins=4096,xmin=0,xmax=4096)
169 
170  helper.defineHistogram('TowerEtcount_tile;h_TowerEtcount_tile', title='jFex Tower Et Tile',
171  fillGroup=groupName,type='TH1I', path=trigPath+"Content/", xbins=4096,xmin=0,xmax=4096)
172 
173  helper.defineHistogram('TowerEtcount_emec;h_TowerEtcount_emec', title='jFex Tower Et EMEC',
174  fillGroup=groupName,type='TH1I', path=trigPath+"Content/", xbins=4096,xmin=0,xmax=4096)
175 
176  helper.defineHistogram('TowerEtcount_hec;h_TowerEtcount_hec', title='jFex Tower Et HEC',
177  fillGroup=groupName,type='TH1I', path=trigPath+"Content/", xbins=4096,xmin=0,xmax=4096)
178 
179  helper.defineHistogram('TowerEtcount_fcal1;h_TowerEtcount_fcal1', title='jFex Tower Et FCAL1',
180  fillGroup=groupName,type='TH1I', path=trigPath+"Content/", xbins=4096,xmin=0,xmax=4096)
181 
182  helper.defineHistogram('TowerEtcount_fcal2;h_TowerEtcount_fcal2', title='jFex Tower Et FCAL2',
183  fillGroup=groupName,type='TH1I', path=trigPath+"Content/", xbins=4096,xmin=0,xmax=4096)
184 
185  helper.defineHistogram('TowerEtcount_fcal3;h_TowerEtcount_fcal3', title='jFex Tower Et FCAL3',
186  fillGroup=groupName,type='TH1I', path=trigPath+"Content/", xbins=4096,xmin=0,xmax=4096)
187 
188  helper.defineHistogram('TowerSaturationflag;h_TowerSaturationflag', title='jFex Tower Saturation FLag',
189  fillGroup=groupName,type='TH1I', path=trigPath+"Content/", xbins=2,xmin=0,xmax=2)
190 
191 
192  acc = helper.result()
193  result.merge(acc)
194  return result
195 
196 if __name__=='__main__':
197  # set input file and config options
198  from AthenaConfiguration.AllConfigFlags import initConfigFlags
199  import glob
200 
201  import argparse
202  parser = argparse.ArgumentParser(prog='python -m TrigT1CaloMonitoring.JfexInputMonitoringAlgorithm',
203  description="""Used to run jFEX Monitoring\n\n
204  Example: python -m TrigT1CaloMonitoring.JfexInputMonitoringAlgorithm --filesInput file.root.\n
205  Overwrite inputs using standard athena opts --filesInput, evtMax etc. see athena --help""")
206  parser.add_argument('--evtMax',type=int,default=-1,help="number of events")
207  parser.add_argument('--filesInput',nargs='+',help="input files",required=True)
208  parser.add_argument('--skipEvents',type=int,default=0,help="number of events to skip")
209  args = parser.parse_args()
210 
211 
212  flags = initConfigFlags()
213  flags.Input.Files = [file for x in args.filesInput for file in glob.glob(x)]
214  flags.Output.HISTFileName = 'jFexInputData_Monitoring.root'
215 
216  flags.Exec.MaxEvents = args.evtMax
217  flags.Exec.SkipEvents = args.skipEvents
218 
219  flags.lock()
220  flags.dump() # print all the configs
221 
222  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
223  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
224  cfg = MainServicesCfg(flags)
225  cfg.merge(PoolReadCfg(flags))
226 
227  JfexInputMonitorCfg = JfexInputMonitoringConfig(flags)
228  cfg.merge(JfexInputMonitorCfg)
229  cfg.run()
L1CaloFEXAlgosConfig.L1CalojFEXDecoratorCfg
def L1CalojFEXDecoratorCfg(flags, name="jFexTower2SCellDecorator", jTowersReadKey="L1_jFexDataTowers", ExtraInfo=False, SCMasking=True)
Definition: L1CaloFEXAlgosConfig.py:12
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:256
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
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.
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:569
FexEmulatedTowersConfig.jFexEmulatedTowersCfg
def jFexEmulatedTowersCfg(flags, name="jFexEmulatedTowerMaker", writeKey="L1_jFexEmulatedTowers")
Definition: FexEmulatedTowersConfig.py:9
str
Definition: BTagTrackIpAccessor.cxx:11
JfexInputMonitorAlgorithm.JfexInputMonitoringConfig
def JfexInputMonitoringConfig(flags)
Definition: JfexInputMonitorAlgorithm.py:4
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69