ATLAS Offline Software
LArCollisionTimeMonAlg.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 #
4 
5 
7  '''Function to configures some algorithms in the monitoring system.'''
8 
9  # The following class will make a sequence, configure algorithms, and link them to GenericMonitoringTools
10 
11  from AthenaMonitoring.AthMonitorCfgHelper import AthMonitorCfgHelper
12  helper = AthMonitorCfgHelper(flags,'LArCollisionTimeMonAlgCfg')
13 
14  from LArCellRec.LArCollisionTimeConfig import LArCollisionTimeCfg
15  cfg = LArCollisionTimeCfg(flags)
16 
17  from LArClusterRec.LArClusterCollisionTimeConfig import LArClusterCollisionTimeCfg
18  cfg.merge(LArClusterCollisionTimeCfg(flags))
19 
20  larColTime_hist_path='LArCollisionTime'
21 
22  from AthenaConfiguration.ComponentFactory import CompFactory
23  LArCollisionTimeMonConfigCore(flags, helper, CompFactory.LArCollisionTimeMonAlg, larColTime_hist_path)
24 
25  larClusColTime_hist_path='LArClusterCollisionTime'
26  LArCollisionTimeMonConfigCore(flags, helper, CompFactory.LArCollisionTimeMonAlg('LArClusterCollisionTimeMonAlg'), larClusColTime_hist_path)
27  for algo in helper.monSeq.Members:
28  if algo.name == 'LArClusterCollisionTimeMonAlg':
29  algo.Key = "ClusterCollTime"
30  algo.nCells = 0
31 
32  cfg.merge(helper.result())
33  return cfg
34 
35 
36 def LArCollisionTimeMonConfigCore(flags, helper, algoinstance, larColTime_hist_path):
37  larCollTimeMonAlg = helper.addAlgorithm(algoinstance,larColTime_hist_path+'MonAlg')
38 
39  collTimeGroupName="LArCollisionTimeMonGroup"
40 
41  larCollTimeMonAlg.CollTimeGroupName=collTimeGroupName
42 
43  #set the unit
44  import AthenaCommon.SystemOfUnits as Units
45  timeUnit = Units.picosecond
46  larCollTimeMonAlg.TimeUnit = timeUnit
47 
48  collTimeGroup = helper.addGroup(
49  larCollTimeMonAlg,
50  collTimeGroupName,
51  '/LAr/',
52  'run'
53  )
54 
55  from LArMonitoring.GlobalVariables import lArDQGlobals
56 
57 
58  timeUnitName='ps'
59  if timeUnit == Units.nanosecond:
60  timeUnitName='ns'
61  pass
62 
63  collTimeGroup.defineHistogram('ecTimeDiff;LArCollTime',
64  title='LArCollisionTime - difference of avg time from ECC and ECA;<t_{C}> - <t_{A}> ('+timeUnitName+');'+('Number of events (weighted by energy/GeV) per %.2f ' % (lArDQGlobals.colTime_BinWidth/timeUnit))+timeUnitName,
65  type='TH1F',
66  path=larColTime_hist_path,
67  weight='weight',
68  xbins=lArDQGlobals.colTime_Bins,xmin=lArDQGlobals.colTime_Min/timeUnit,xmax=lArDQGlobals.colTime_Max/timeUnit)
69 
70  collTimeGroup.defineHistogram('ecTimeAvg;LArCollAvgTime',
71  title='LArCollisionAverageTime - avg time of ECC and ECA;(<t_{C}> + <t_{A}>) / 2 ('+timeUnitName+(');Number of events (weighted by energy/GeV) per %.2f ' % (lArDQGlobals.avgColTime_BinWidth/timeUnit))+timeUnitName,
72  type='TH1F',
73  path=larColTime_hist_path,
74  weight='weight',
75  xbins=lArDQGlobals.avgColTime_Bins,xmin=lArDQGlobals.avgColTime_Min/timeUnit,xmax=lArDQGlobals.avgColTime_Max/timeUnit)
76 
77 
78  collTimeGroup.defineHistogram('ecTimeDiff;LArCollTimeLumiBlock',
79  title='LArCollisionTime - difference of avg time from ECC and ECA;<t_{C}> - <t_{A}> ('+timeUnitName+(');Number of events (weighted by energy/GeV) per %.2f ' % (lArDQGlobals.colTime_BinWidth/timeUnit))+timeUnitName,
80  type='TH1F',
81  path=larColTime_hist_path,
82  weight='weight',
83  xbins=lArDQGlobals.colTime_Bins,xmin=lArDQGlobals.colTime_Min/timeUnit,xmax=lArDQGlobals.colTime_Max/timeUnit,
84  duration='lb')
85 
86 
87  collTimeGroup.defineHistogram('lumi_block_timeWindow;LArCollTimeLumiBlockTimeCut',
88  title='Events with abs(<t_{C}> - <t_{A}>) < 10 ns as a function of LB;Luminosity Block Number;Number of events per LB',
89  type='TH1F',
90  path=larColTime_hist_path,
91  opt='kAlwaysCreate',
92  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max)
93 
94 
95  collTimeGroup.defineHistogram('lumi_block_singleBeam_timeWindow;LArCollTimeLumiBlockSingleBeamTimeCut',
96  title='Events with 20 ns < abs(<t_{C}> - <t_{A}>) < 30ns as a function of LB;Luminosity Block Number;Number of events per LB',
97  type='TH1F',
98  path=larColTime_hist_path,
99  opt='kAlwaysCreate',
100  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max)
101 
102 
103  collTimeGroup.defineHistogram('lumi_block,ecTimeDiff;LArCollTime_vs_LB',
104  title='LArCollisionTime Vs Luminosity Block - difference of avg time of ECC and ECA as a function of luminosity block;Luminosity Block Number;<t_{C}> - <t_{A}> ('+timeUnitName+');Number of events (weighted by energy/GeV)',
105  type='TH2F',
106  path=larColTime_hist_path,
107  weight='weight',
108  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max,
109  ybins=lArDQGlobals.colTime_Bins,ymin=lArDQGlobals.colTime_Min/timeUnit,ymax=lArDQGlobals.colTime_Max/timeUnit)
110 
111 
112  collTimeGroup.defineHistogram('bunch_crossing_id,ecTimeDiff;LArCollTime_vs_BCID',
113  title='LArCollisionTime Vs BCID - difference of avg time of ECC and ECA as a function of BCID;Bunch Crossing Number;<t_{C}> - <t_{A}> ('+timeUnitName+');Number of events (weighted by energy/GeV)',
114  type='TH2F',
115  path=larColTime_hist_path,
116  weight='weight',
117  xbins=lArDQGlobals.BCID_Bins,xmin=lArDQGlobals.BCID_Min,xmax=lArDQGlobals.BCID_Max,
118  ybins=lArDQGlobals.colTime_Bins,ymin=lArDQGlobals.colTime_Min/timeUnit,ymax=lArDQGlobals.colTime_Max/timeUnit)
119 
120  collTimeGroup.defineHistogram('lumi_block,ecTimeAvg;LArCollAvgTime_vs_LB',
121  title='LArCollisionAvgTime Vs Luminosity Block - avg time of ECC and ECA as a function of luminosity block;Luminosity Block Number;(<t_{C}> + <t_{A}>) / 2 ('+timeUnitName+');Number of events (weighted by energy/GeV)',
122  type='TH2F',
123  path=larColTime_hist_path,
124  weight='weight',
125  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max,
126  ybins=lArDQGlobals.avgColTime_Bins,ymin=lArDQGlobals.avgColTime_Min/timeUnit,ymax=lArDQGlobals.avgColTime_Max/timeUnit)
127 
128  collTimeGroup.defineHistogram('bunch_crossing_id,ecTimeAvg;LArCollAvgTime_vs_BCID',
129  title='LArCollisionAvgTime Vs BCID - avg time of ECC and ECA as a function of BCID;Bunch Crossing Number;(<t_{C}> + <t_{A}>) / 2 ('+timeUnitName+');Number of events (weighted by energy/GeV)',
130  type='TH2F',
131  path=larColTime_hist_path,
132  weight='weight',
133  xbins=lArDQGlobals.BCID_Bins,xmin=lArDQGlobals.BCID_Min,xmax=lArDQGlobals.BCID_Max,
134  ybins=lArDQGlobals.avgColTime_Bins,ymin=lArDQGlobals.avgColTime_Min/timeUnit,ymax=lArDQGlobals.avgColTime_Max/timeUnit)
135 
136 
137  #in train monitoring, only done offline
138  if flags.Common.isOnline:
139 
140  collTimeGroupName_intrain=collTimeGroupName+"_intrain"
141  collTimeGroup_intrain = helper.addGroup(
142  larCollTimeMonAlg,
143  collTimeGroupName_intrain,
144  "/LAr/"
145  )
146  larCollTimeMonAlg.InTrain_CollTimeGroupName=collTimeGroupName_intrain #pass the group name to the algorithm, this way you let the algorithm now that this group has been defined (won't be filled otherwise)
147 
148  intrain_title=" inside the train"
149  intrain_name="_intrain"
150 
151  collTimeGroup_intrain.defineHistogram('ecTimeDiff;LArCollTime'+intrain_name,
152  title='LArCollisionTime - difference of avg time from ECC and ECA'+intrain_title+';<t_{C}> - <t_{A}> ('+timeUnitName+(');Number of events (weighted by energy/GeV) per %.2f ' % (lArDQGlobals.colTime_BinWidth/timeUnit))+timeUnitName,
153  type='TH1F',
154  path=larColTime_hist_path,
155  weight='weight',
156  xbins=lArDQGlobals.colTime_Bins,xmin=lArDQGlobals.colTime_Min/timeUnit,xmax=lArDQGlobals.colTime_Max/timeUnit)
157 
158 
159  collTimeGroup_intrain.defineHistogram('ecTimeAvg;LArCollAvgTime'+intrain_name,
160  title='LArCollisionAverageTime - avg time of ECC and ECA'+intrain_title+';(<t_{C}> + <t_{A}>) / 2 ('+timeUnitName+(');Number of events (weighted by energy/GeV) per %.2f ' % (lArDQGlobals.avgColTime_BinWidth/timeUnit))+timeUnitName,
161  type='TH1F',
162  path=larColTime_hist_path,
163  weight='weight',
164  xbins=lArDQGlobals.avgColTime_Bins,xmin=lArDQGlobals.avgColTime_Min/timeUnit,xmax=lArDQGlobals.avgColTime_Max/timeUnit)
165 
166 
167  collTimeGroup_intrain.defineHistogram('ecTimeDiff;LArCollTimeLumiBlock'+intrain_name,
168  title='LArCollisionTime - difference of avg time from ECC and ECA;<t_{C}> - <t_{A}> ('+timeUnitName+')'+intrain_title+(';Number of events (weighted by energy/GeV) per %.2f ' % (lArDQGlobals.colTime_BinWidth/timeUnit))+timeUnitName,
169  type='TH1F',
170  path=larColTime_hist_path,
171  weight='weight',
172  xbins=lArDQGlobals.colTime_Bins,xmin=lArDQGlobals.colTime_Min/timeUnit,xmax=lArDQGlobals.colTime_Max/timeUnit,
173  duration='lb')
174 
175 
176 
177  collTimeGroup_intrain.defineHistogram('(lumi_block_timeWindow);LArCollTimeLumiBlockTimeCut'+intrain_name,
178  title='Events with abs(<t_{C}> - <t_{A}>) < 10ns as a function of LB'+intrain_title+';Luminosity Block Number;Number of events per LB',
179  path=larColTime_hist_path,
180  weight='weight',
181  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max)
182 
183 
184  collTimeGroup_intrain.defineHistogram('(lumi_block_singleBeam_timeWindow);LArCollTimeLumiBlockSingleBeamTimeCut'+intrain_name,
185  title='Events with 20 ns < abs(<t_{C}> - <t_{A}>) < 30ns as a function of LB'+intrain_title+';Luminosity Block Number;Number of events per LB',
186  type='TH1F',
187  path=larColTime_hist_path,
188  weight='weight',
189  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max)
190 
191 
192  collTimeGroup_intrain.defineHistogram('lumi_block,ecTimeDiff;LArCollTime_vs_LB'+intrain_name,
193  title='LArCollisionTime Vs Luminosity Block - difference of avg time of ECC and ECA as a function of luminosity block;Luminosity Block Number'+intrain_title+';<t_{C}> - <t_{A}> ('+timeUnitName+');Number of events (weighted by energy/GeV)',
194  type='TH2F',
195  path=larColTime_hist_path,
196  weight='weight',
197  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max,
198  ybins=lArDQGlobals.colTime_Bins,ymin=lArDQGlobals.colTime_Min/timeUnit,ymax=lArDQGlobals.colTime_Max/timeUnit)
199 
200 
201  collTimeGroup_intrain.defineHistogram('bunch_crossing_id,ecTimeDiff;LArCollTime_vs_BCID'+intrain_name,
202  title='LArCollisionTime Vs BCID - difference of avg time of ECC and ECA as a function of BCID'+intrain_title+';Bunch Crossing Number;<t_{C}> - <t_{A}> ('+timeUnitName+');Number of events (weighted by energy/GeV)',
203  type='TH2F',
204  path=larColTime_hist_path,
205  weight='weight',
206  xbins=lArDQGlobals.BCID_Bins,xmin=lArDQGlobals.BCID_Min,xmax=lArDQGlobals.BCID_Max,
207  ybins=lArDQGlobals.colTime_Bins,ymin=lArDQGlobals.colTime_Min/timeUnit,ymax=lArDQGlobals.colTime_Max/timeUnit)
208 
209  collTimeGroup_intrain.defineHistogram('lumi_block,ecTimeAvg;LArCollAvgTime_vs_LB'+intrain_name,
210  title='LArCollisionAvgTime Vs Luminosity Block - avg time of ECC and ECA as a function of luminosity block'+intrain_title+';Luminosity Block Number;(<t_{C}> + <t_{A}>) / 2 ('+timeUnitName+');Number of events (weighted by energy/GeV)',
211  type='TH2F',
212  path=larColTime_hist_path,
213  weight='weight',
214  xbins=lArDQGlobals.LB_Bins,xmin=lArDQGlobals.LB_Min,xmax=lArDQGlobals.LB_Max,
215  ybins=lArDQGlobals.avgColTime_Bins,ymin=lArDQGlobals.avgColTime_Min/timeUnit,ymax=lArDQGlobals.avgColTime_Max/timeUnit)
216 
217  collTimeGroup_intrain.defineHistogram('bunch_crossing_id,ecTimeAvg;LArCollAvgTime_vs_BCID'+intrain_name,
218  title='LArCollisionAvgTime Vs BCID - avg time of ECC and ECA as a function of BCID'+intrain_title+';Bunch Crossing Number;(<t_{C}> + <t_{A}>) / 2 ('+timeUnitName+');Number of events (weighted by energy/GeV)',
219  type='TH2F',
220  path=larColTime_hist_path,
221  weight='weight',
222  xbins=lArDQGlobals.BCID_Bins,xmin=lArDQGlobals.BCID_Min,xmax=lArDQGlobals.BCID_Max,
223  ybins=lArDQGlobals.avgColTime_Bins,ymin=lArDQGlobals.avgColTime_Min/timeUnit,ymax=lArDQGlobals.avgColTime_Max/timeUnit)
224 
225  pass #end of if isOnline
226 
227 
228 if __name__=='__main__':
229 
230  # Setup logs
231  from AthenaCommon.Constants import DEBUG
232  from AthenaCommon.Logging import log
233  log.setLevel(DEBUG)
234 
235  # Set the Athena configuration flags
236  from AthenaConfiguration.AllConfigFlags import initConfigFlags
237  from AthenaConfiguration.TestDefaults import defaultTestFiles
238  flags = initConfigFlags()
239  from LArMonitoring.LArMonConfigFlags import addLArMonFlags
240  flags.addFlagsCategory("LArMon", addLArMonFlags)
241  flags.Input.Files = defaultTestFiles.RAW_RUN2
242  flags.DQ.enableLumiAccess = False #copied from LArRecoFromRaw
243  flags.DQ.useTrigger = False #copied from LArRecoFromRaw
244  flags.Output.HISTFileName = 'LArCollTimeMonitoringOutput.root'
245  flags.lock()
246 
247 
248  from CaloRec.CaloRecoConfig import CaloRecoCfg
249  cfg=CaloRecoCfg(flags)
250 
251  from LumiBlockComps.BunchCrossingCondAlgConfig import BunchCrossingCondAlgCfg
252  cfg.merge(BunchCrossingCondAlgCfg(flags))
253 
254  import AthenaCommon.SystemOfUnits as Units
256  collmon.getEventAlgo("LArCollisionTimeMonAlg").timeDiffCut=5.0*Units.nanosecond
257  collmon.getEventAlgo("LArCollisionTimeMonAlg").nCells=1
258  collmon.getEventAlgo("LArCollisionTimeMonAlg").TrainFrontDistance=int(30*Units.nanosecond)
259  collmon.getEventAlgo("LArClusterCollisionTimeMonAlg").nCells=0
260  collmon.getEventAlgo("LArClusterCollisionTimeMonAlg").TrainFrontDistance=int(30*Units.nanosecond)
261  cfg.merge(collmon)
262 
263  flags.dump()
264  with open("CollTimeMonMaker.pkl", "wb") as f:
265  cfg.store(f)
SystemOfUnits
python.CaloRecoConfig.CaloRecoCfg
def CaloRecoCfg(flags, clustersname=None)
Definition: CaloRecoConfig.py:9
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.BunchCrossingCondAlgConfig.BunchCrossingCondAlgCfg
def BunchCrossingCondAlgCfg(flags)
Definition: BunchCrossingCondAlgConfig.py:8
Constants
some useful constants -------------------------------------------------—
LArClusterCollisionTimeConfig.LArClusterCollisionTimeCfg
def LArClusterCollisionTimeCfg(configFlags)
Definition: LArClusterCollisionTimeConfig.py:8
LArCollisionTimeMonAlg.LArCollisionTimeMonConfigCore
def LArCollisionTimeMonConfigCore(flags, helper, algoinstance, larColTime_hist_path)
Definition: LArCollisionTimeMonAlg.py:36
LArCollisionTimeMonAlg.LArCollisionTimeMonConfig
def LArCollisionTimeMonConfig(flags)
Definition: LArCollisionTimeMonAlg.py:6
Trk::open
@ open
Definition: BinningType.h:40
LArCollisionTimeConfig.LArCollisionTimeCfg
def LArCollisionTimeCfg(configFlags, cutIteration=False)
Definition: LArCollisionTimeConfig.py:8
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19