ATLAS Offline Software
TileCablingSvcConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 """Define method to construct configured Tile cabling service"""
4 
5 from AthenaConfiguration.AccumulatorCache import AccumulatorCache
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 from AthenaConfiguration.Enums import LHCPeriod
8 
9 
10 @AccumulatorCache
11 def TileCablingSvcCfg(flags):
12  """Return component accumulator with configured Tile cabling service
13 
14  Arguments:
15  flags -- Athena configuration flags
16  """
17 
18  from AthenaCommon.Logging import logging
19  msg = logging.getLogger('TileCablingSvc')
20 
21  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
22  acc = ComponentAccumulator()
23 
24  from TileGeoModel.TileGMConfig import TileGMCfg
25  acc.merge( TileGMCfg(flags) )
26 
27  tileCablingSvc = CompFactory.TileCablingSvc()
28 
29  geometry = flags.GeoModel.AtlasVersion
30 
31  if not flags.Common.isOnline:
32  runNumber = flags.Input.RunNumbers[0]
33  if flags.Input.OverrideRunNumber > 0:
34  from AthenaKernel.EventIdOverrideConfig import getMinMaxRunNumbers
35  runNumber = getMinMaxRunNumbers(flags)[0]
36  if flags.GeoModel.Run is LHCPeriod.Run1:
37  if runNumber > 219651:
38  # Choose RUN2 cabling for old geometry tags starting from 26-MAR-2013
39  tileCablingSvc.CablingType = 4
40  msg.warning("Forcing RUN2 cabling for run %s with geometry %s", runNumber, geometry)
41 
42  elif flags.GeoModel.Run is LHCPeriod.Run2:
43  if (flags.Input.isMC and runNumber >= 310000) or runNumber >= 343000 or runNumber < 1:
44  # Choose RUN2a cabling for R2 geometry tags starting from 31-Jan-2018
45  tileCablingSvc.CablingType = 5
46  msg.info("Forcing RUN2a (2018) cabling for run %s with geometry %s", runNumber, geometry)
47 
48  else:
49  tileCablingSvc.CablingType = 4
50  msg.info("Forcing RUN2 (2014-2017) cabling for run %s with geometry %s", runNumber, geometry)
51  elif flags.GeoModel.Run is LHCPeriod.Run3:
52  tileCablingSvc.CablingType = 6
53  msg.info("Forcing RUN3 cabling for run %s with geometry %s", flags.GeoModel.Run.value, geometry)
54  else: #Running online or simulating running online: either way, do not access run number
55  if flags.GeoModel.Run is LHCPeriod.Run1:
56  tileCablingSvc.CablingType = 4
57  msg.warning("Forcing RUN2 (2014-2017) cabling for unknown run number and geometry %s", geometry)
58  if flags.GeoModel.Run is LHCPeriod.Run2:
59  tileCablingSvc.CablingType = 5
60  msg.info("Forcing RUN2a (2018) cabling for online run with geometry %s", geometry)
61  elif flags.GeoModel.Run is LHCPeriod.Run3:
62  tileCablingSvc.CablingType = 6
63  msg.info("Forcing RUN3 cabling for online run with geometry %s", geometry)
64  elif flags.GeoModel.Run is LHCPeriod.Run4:
65  tileCablingSvc.CablingType = 6
66  msg.warning("Forcing RUN3 cabling beyond Run3 for online run with geometry %s", geometry)
67  else:
68  msg.error("Tile Cabling version not set for %s", geometry)
69 
70  acc.addService(tileCablingSvc, primary = True)
71 
72  return acc
73 
74 
75 if __name__ == "__main__":
76 
77  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
78  from AthenaConfiguration.AllConfigFlags import initConfigFlags
79  from AthenaConfiguration.TestDefaults import defaultTestFiles
80  from AthenaCommon.Logging import log
81  from AthenaCommon.Constants import DEBUG
82 
83  # Test setup
84  log.setLevel(DEBUG)
85 
86  flags = initConfigFlags()
87  flags.Input.Files = defaultTestFiles.RAW_RUN2
88  flags.lock()
89 
91  acc.merge( TileCablingSvcCfg(flags) )
92 
93  acc.printConfig(withDetails = True, summariseProps = True)
94  print(acc.getService('TileCablingSvc'))
95  acc.store( open('TileCablingSvc.pkl','wb') )
96 
97  print('All OK')
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
Constants
some useful constants -------------------------------------------------—
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
Trk::open
@ open
Definition: BinningType.h:40
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.EventIdOverrideConfig.getMinMaxRunNumbers
def getMinMaxRunNumbers(flags)
Definition: EventIdOverrideConfig.py:101
python.TileCablingSvcConfig.TileCablingSvcCfg
def TileCablingSvcCfg(flags)
Definition: TileCablingSvcConfig.py:11
TileGMConfig.TileGMCfg
def TileGMCfg(flags)
Definition: TileGMConfig.py:7