ATLAS Offline Software
Functions
TileTBCellMonitorAlgorithm Namespace Reference

Functions

def TileTBCellMonitoringConfig (flags, timeRange=[-100, 100], fragIDs=[0x100, 0x101, 0x200, 0x201, 0x402], useDemoCabling=2018, useFELIX=False, **kwargs)
 

Function Documentation

◆ TileTBCellMonitoringConfig()

def TileTBCellMonitorAlgorithm.TileTBCellMonitoringConfig (   flags,
  timeRange = [-100, 100],
  fragIDs = [0x100, 0x101, 0x200, 0x201, 0x402],
  useDemoCabling = 2018,
  useFELIX = False,
**  kwargs 
)
Function to configure TileTBCellMonitorAlgorithm algorithm in the monitoring system.

Definition at line 12 of file TileTBCellMonitorAlgorithm.py.

12 def TileTBCellMonitoringConfig(flags, timeRange=[-100, 100], fragIDs=[0x100, 0x101, 0x200, 0x201, 0x402], useDemoCabling=2018, useFELIX=False, **kwargs):
13 
14  ''' Function to configure TileTBCellMonitorAlgorithm algorithm in the monitoring system.'''
15 
16  suffix = "Flx" if useFELIX else ""
17  basePath = 'TestBeam/' + ('Felix' if useFELIX else 'Legacy') + '/Cell'
18 
19  cellContainer = kwargs.pop('CaloCellContainer', f'AllCalo{suffix}')
20  kwargs.setdefault('ScaleFactor', 0.25 if useFELIX else 1.0)
21  kwargs.setdefault('EnergyThresholdForTime', 1 * GeV)
22 
23  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
24  result = ComponentAccumulator()
25 
26  from TileGeoModel.TileGMConfig import TileGMCfg
27  result.merge(TileGMCfg(flags))
28 
29  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
30  result.merge(LArGMCfg(flags))
31 
32  from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
33  result.merge(TileCablingSvcCfg(flags))
34 
35  from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg
36  result.merge(TileInfoLoaderCfg(flags))
37 
38  from AthenaMonitoring import AthMonitorCfgHelper
39  helper = AthMonitorCfgHelper(flags, f'TileTBCell{suffix}Monitoring')
40 
41  demoCabling = kwargs.pop('useDemoCabling', 2018)
42  from TileCalibBlobObjs.Classes import TileCalibUtils as Tile
43 
44  modules = []
45  if fragIDs:
46  for fragID in fragIDs:
47  ros = fragID >> 8
48  drawer = fragID & 0x3F
49  modules += [Tile.getDrawerString(ros, drawer)]
50  else:
51  for ros in range(1, Tile.MAX_ROS):
52  for drawer in range(0, Tile.MAX_DRAWER):
53  fragIDs += [(ros << 8) | drawer]
54  modules += [Tile.getDrawerString(ros, drawer)]
55 
56  cellMonAlgorithms = []
57  gains = ['HG', 'LG'] if flags.Tile.RunType.isBiGain() else [""]
58  from AthenaConfiguration.ComponentFactory import CompFactory
59  for gain in gains:
60  cellMonAlg = helper.addAlgorithm(CompFactory.TileTBCellMonitorAlgorithm, f'TileTBCell{suffix}{gain}MonAlg')
61  cellMonAlg.CaloCellContainer = f'{cellContainer}{gain}'
62  cellMonAlg.TriggerChain = ''
63  cellMonAlg.TileFragIDs = fragIDs
64 
65  for k, v in kwargs.items():
66  setattr(cellMonAlg, k, v)
67 
68  cellMonAlgorithms += [cellMonAlg]
69 
70  towersLB = [[tower for tower in range(0, 10)], # Sample A
71  [tower for tower in range(0, 9)], # Sample BC/B
72  [tower*2 for tower in range(0, 4)]] # Sample D
73 
74  towersEB = [[tower for tower in range(11, 16)], # Sample A
75  [tower for tower in range(9, 15)], # Sample B/C
76  [tower*2 for tower in range(4, 7)]] # Sample D
77 
78  def getCellNameFromSampleAndTower(sample, tower):
79  ''' The function to get Tile cell name from sample and tower'''
80  sampleName = {0: 'A', 1: 'B', 2: 'D'}[sample]
81  if sample == 1:
82  if tower < 8:
83  sampleName += 'C' # BC1 ... BC8 in LB
84  elif tower == 9:
85  sampleName = 'C' # C10 in EB
86  cellName = f'{sampleName}{tower + 1}' if sample < 2 else f'{sampleName}{int(tower / 2)}'
87  return cellName
88 
89  def addCellHistogramsArray(helper, modules, algorithm, name, title, path='', type='TH1D',
90  xbins=100, xmin=-100, xmax=100, ybins=None, ymin=None, ymax=None,
91  run='', xvalue='', yvalue=None, aliasPrefix='', xtitle='', ytitle=''):
92  ''' This function configures 1D or 2D histograms with monitored value per Tile module and cell '''
93 
94  cellArray = helper.addArray([modules], algorithm, name, topPath=path)
95  for postfix, tool in cellArray.Tools.items():
96  moduleName = postfix[1:]
97  partition = moduleName[:3]
98  towers = towersLB if moduleName.startswith('L') else towersEB
99  for sample in range(0, 3):
100  for tower in towers[sample]:
101  cellName = getCellNameFromSampleAndTower(sample, tower)
102  fullPath = f'{partition}/{moduleName}'
103  name = f'{xvalue}_{sample}_{tower}'
104  if yvalue:
105  name += f',{yvalue}_{sample}_{tower}'
106  name += f';{aliasPrefix}{cellName}_{moduleName}'
107  fullTitle = f'Run {run} {moduleName} {cellName}: {title};{xtitle};{ytitle}'
108  tool.defineHistogram(name, title=fullTitle, path=fullPath, type=type,
109  xbins=xbins, xmin=xmin, xmax=xmax,
110  ybins=ybins, ymin=ymin, ymax=ymax)
111  return cellArray
112 
113  from TileMonitoring.TileMonitoringCfgHelper import getCellName
114  from TileMonitoring.TileMonitoringCfgHelper import getLegacyChannelForDemonstrator
115 
116  def addChannelHistogramsArray(helper, modules, algorithm, name, title, path='', type='TH1D',
117  xbins=100, xmin=-100, xmax=100, xvalue='', xtitle='', ytitle='',
118  run='', aliasPrefix='', useDemoCabling=demoCabling):
119  ''' This function configures 1D histograms with Tile monitored value per module and channel '''
120 
121  channelArray = helper.addArray([modules], algorithm, name, topPath=path)
122  for postfix, tool in channelArray.Tools.items():
123  moduleName = postfix[1:]
124  partition = moduleName[:3]
125  module = int(moduleName[3:]) - 1
126  for channel in range(0, Tile.MAX_CHAN):
127  legacyChannel = getLegacyChannelForDemonstrator(useDemoCabling, partition, module, channel)
128  cell = getCellName(partition, legacyChannel)
129  if cell:
130  cellName = cell.replace('B', 'BC') if (partition in ['LBA','LBC'] and cell and cell[0] == 'B' and cell != 'B9') else cell
131  fullPath = f'{partition}/{moduleName}'
132  name = f'{xvalue}_{channel};{aliasPrefix}_{moduleName}_{cellName}_ch_{channel}'
133  fullTitle = f'Run {run} {moduleName} {cellName} Channel {channel}: {title};{xtitle};{ytitle}'
134  tool.defineHistogram(name, title=fullTitle, path=fullPath, type=type,
135  xbins=xbins, xmin=xmin, xmax=xmax)
136  return channelArray
137 
138  totalEnergy = min(flags.Beam.Energy / GeV, 300)
139  nEnergyBins = int(totalEnergy * 2)
140  run = str(flags.Input.RunNumbers[0])
141  nTimeBins = timeRange[1] - timeRange[0]
142 
143  for cellMonAlg in cellMonAlgorithms:
144  topPath = f'{basePath}/LG' if 'LG' in cellMonAlg.name else basePath
145 
146  # Configure histogram with TileTBCellMonAlg algorithm execution time
147  executeTimeGroup = helper.addGroup(cellMonAlg, 'TileTBCellMonExecuteTime', topPath)
148  executeTimeGroup.defineHistogram('TIME_execute', path='', type='TH1F',
149  title=f'Time for execute TileTBCell{suffix}MonAlg algorithm;time [#mus]',
150  xbins=100, xmin=0, xmax=10000)
151 
152  sampleEnergyArray = helper.addArray([modules], cellMonAlg, 'TileSampleEnergy', topPath=topPath)
153  for postfix, tool in sampleEnergyArray.Tools.items():
154  moduleName = postfix[1:]
155  partition = moduleName[:3]
156  fullPath = f'{partition}/{moduleName}'
157  titlePrefix = f'Run {run} {moduleName}:'
158 
159  tool.defineHistogram(f'energy;EnergyTotal_{moduleName}', path=fullPath, type='TH1D',
160  title=f'{titlePrefix} Total energy;Energy [pC];Entries',
161  xbins=nEnergyBins, xmin=0.0, xmax=totalEnergy)
162 
163  tool.defineHistogram(f'energyA,energyBC;EnergyTotalSampleBCVsA_{moduleName}', path=fullPath, type='TH2D',
164  title=f'{titlePrefix} Total energy in sample BC vs sample A;Sample A Energy [pC];Sample B Energy [pC]',
165  xbins=nEnergyBins, xmin=0.0, xmax=totalEnergy, ybins=nEnergyBins, ymin=0.0, ymax=totalEnergy)
166 
167  tool.defineHistogram(f'energyD;EnergyTotalSampleD_{moduleName}', path=fullPath, type='TH1D',
168  title=f'{titlePrefix} Total energy in sample D;Sample D Energy [pC];Entries',
169  xbins=nEnergyBins, xmin=0.0, xmax=totalEnergy)
170 
171  addCellHistogramsArray(helper, modules, cellMonAlg, name='TileCellEnergy', path=topPath, xvalue='energy',
172  title='Tile Cell Energy', xbins=nEnergyBins, xmin=0, xmax=totalEnergy,
173  run=run, aliasPrefix='CellEnergy', xtitle='Energy [pC]', ytitle='Entries')
174 
175  addCellHistogramsArray(helper, modules, cellMonAlg, name='TileCellEnergyDiff', path=topPath, xvalue='energyDiff',
176  title='Tile Cell Energy difference between PMTs', xbins=nEnergyBins, xmin=-totalEnergy, xmax=totalEnergy,
177  run=run, aliasPrefix='CellEnergyDiff', xtitle='Energy [pC]', ytitle='Entries')
178 
179  addCellHistogramsArray(helper, modules, cellMonAlg, name='TileCellTime', path=topPath, xvalue='time',
180  title='Tile Cell Time', xbins=nTimeBins, xmin=timeRange[0], xmax=timeRange[1],
181  run=run, aliasPrefix='CellTime', xtitle='Time [ns]', ytitle='Entries')
182 
183  addCellHistogramsArray(helper, modules, cellMonAlg, name='TileCellTimeDiff', path=topPath,
184  xvalue='timeDiff', title='Tile Cell Time difference between PMTs',
185  xbins=nTimeBins, xmin=timeRange[0], xmax=timeRange[1],
186  run=run, aliasPrefix='CellTimeDiff', xtitle='Time [ns]', ytitle='Entries')
187 
188  addCellHistogramsArray(helper, modules, cellMonAlg, name='TileCellEnergyLeftVsRightPMT', path=topPath, type='TH2D',
189  xvalue='energy1', yvalue='energy2', title='Tile Cell PMT2 vs PMT1 Energy',
190  xbins=nEnergyBins, xmin=0, xmax=totalEnergy, ybins=nEnergyBins, ymin=0, ymax=totalEnergy,
191  run=run, aliasPrefix='CellEnergyLeftVsRightPMT',
192  xtitle='Energy [pC]', ytitle='Energy [pC]')
193 
194  addCellHistogramsArray(helper, modules, cellMonAlg, name='TileCellTimeLeftVsRightPMT', path=topPath, type='TH2D',
195  xvalue='time1', yvalue='time2', title='Tile Cell PMT2 vs PMT1 Time',
196  xbins=nTimeBins, xmin=timeRange[0], xmax=timeRange[1], ybins=nTimeBins, ymin=timeRange[0], ymax=timeRange[1],
197  run=run, aliasPrefix='CellTimeLeftVsRightPMT', xtitle='Time [ns]', ytitle='Time [ns]')
198 
199  addChannelHistogramsArray(helper, modules, cellMonAlg, name='TileChannelEnergy', path=f'{topPath}/ChannelEnergy', type='TH1D',
200  xvalue='energy', title='Tile channel energy', xbins=nEnergyBins, xmin=0, xmax=totalEnergy,
201  run=run, aliasPrefix='ChannelEnergy', xtitle='Energy [pC]', ytitle='Entries')
202 
203  addChannelHistogramsArray(helper, modules, cellMonAlg, name='TileChannelTime', path=f'{topPath}/ChannelTime', type='TH1D',
204  xvalue='time', title='Tile channel time', xbins=nTimeBins, xmin=timeRange[0], xmax=timeRange[1],
205  run=run, aliasPrefix='ChannelTime', xtitle='Time [ns]', ytitle='Entries')
206 
207  accumalator = helper.result()
208  result.merge(accumalator)
209  return result
210 
211 
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
TileMonitoringCfgHelper.getLegacyChannelForDemonstrator
def getLegacyChannelForDemonstrator(useDemoCabling, partition, drawer, channel)
Definition: TileMonitoringCfgHelper.py:201
python.TileInfoLoaderConfig.TileInfoLoaderCfg
def TileInfoLoaderCfg(flags, **kwargs)
Definition: TileInfoLoaderConfig.py:12
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
TileMonitoringCfgHelper.getCellName
def getCellName(partition, channel)
Definition: TileMonitoringCfgHelper.py:29
str
Definition: BTagTrackIpAccessor.cxx:11
TileTBCellMonitorAlgorithm.TileTBCellMonitoringConfig
def TileTBCellMonitoringConfig(flags, timeRange=[-100, 100], fragIDs=[0x100, 0x101, 0x200, 0x201, 0x402], useDemoCabling=2018, useFELIX=False, **kwargs)
Definition: TileTBCellMonitorAlgorithm.py:12
python.TileCablingSvcConfig.TileCablingSvcCfg
def TileCablingSvcCfg(flags)
Definition: TileCablingSvcConfig.py:11
TileGMConfig.TileGMCfg
def TileGMCfg(flags)
Definition: TileGMConfig.py:7