ATLAS Offline Software
TileTBAANtupleConfig.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 #
5 '''
6 @file TileTBAANtupleConfig.py
7 @brief Python configuration of TileTBAANtuple algorithm for the Run III
8 '''
9 
10 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
11 from AthenaConfiguration.ComponentFactory import CompFactory
12 from TileConfiguration.TileConfigFlags import TileRunType
13 
14 import sys
15 
16 
17 def getTileTBperiod(run, useFELIX):
18  ''' Function to get Tile TB period.'''
19 
20  TBperiod = 2015 if (run // 100000 == 5) else 2016
21 
22  if useFELIX:
23  TBperiod = 2017
24  if run > 800000:
25  TBperiod += 2
26  if run >= 2200000:
27  TBperiod = 2022
28  elif run >= 2110000:
29  TBperiod = 2021
30 
31  return TBperiod
32 
33 
34 def TileTBAANtupleCfg(flags, outputFile='', useFELIX=None, **kwargs):
35 
36  ''' Function to configure TileTBAANtuple algorithm.'''
37 
38  acc = ComponentAccumulator()
39 
40  cisRun = flags.Tile.RunType is TileRunType.CIS
41  monoRun = flags.Tile.RunType is TileRunType.MONOCIS
42  pedestalRun = flags.Tile.RunType is TileRunType.PED
43 
44  # Units: TileRawChannelUnit::ADC (0) or TileRawChannelUnit::MegaElectronVolts (3)
45  offlineUnits = 0 if cisRun or monoRun or pedestalRun else 3
46  calibrateEnergy = (offlineUnits != 0)
47 
48  run = flags.Input.RunNumbers[0]
49 
50  if useFELIX is None:
51  useFELIX = True if run > 2310438 else False
52 
53  TBperiod = getTileTBperiod(run, useFELIX)
54 
55  kwargs.setdefault('TileDigitsContainer', 'TileDigitsCnt')
56  kwargs.setdefault('TileBeamElemContainer', 'TileBeamElemCnt')
57  kwargs.setdefault('TileRawChannelContainerFlat', "")
58  kwargs.setdefault('TileRawChannelContainerFit', 'TileRawChannelFit' if flags.Tile.doFit else "")
59  kwargs.setdefault('TileRawChannelContainerOpt', "TileRawChannelOpt2" if flags.Tile.doOpt2 else "")
60  kwargs.setdefault('TileRawChannelContainerDsp', "")
61  kwargs.setdefault('TileRawChannelContainerFitCool', 'TileRawChannelFitCool' if flags.Tile.doFitCOOL else "")
62 
63  kwargs.setdefault('TileDigitsContainerFlx', 'TileDigitsFlxCnt' if useFELIX else "")
64  kwargs.setdefault('TileRawChannelContainerFitFlx', 'TileRawChannelFlxFit' if useFELIX and flags.Tile.doFit else "")
65  kwargs.setdefault('TileRawChannelContainerOptFlx', 'TileRawChannelFlxOpt2' if useFELIX and flags.Tile.doOpt2 else "")
66 
67  kwargs.setdefault('TileHitContainer', "")
68  kwargs.setdefault('TileHitVector', "")
69  kwargs.setdefault('CaloCellContainer', 'AllCalo')
70 
71  kwargs.setdefault('TileLaserObj', "")
72 
73  kwargs.setdefault('OfflineUnits', offlineUnits)
74  kwargs.setdefault('CalibrateEnergy', calibrateEnergy)
75  kwargs.setdefault('CalibMode', pedestalRun or cisRun)
76  kwargs.setdefault('PMTOrder', not (cisRun or monoRun or pedestalRun))
77 
78  kwargs.setdefault('NSamples', -1)
79  kwargs.setdefault('NSamplesFelix', 16 if useFELIX else 0)
80 
81  kwargs.setdefault('TBperiod', TBperiod)
82 
83  acc = ComponentAccumulator()
84 
85  from TileGeoModel.TileGMConfig import TileGMCfg
86  acc.merge(TileGMCfg(flags))
87 
88  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
89  acc.merge(LArGMCfg(flags))
90 
91  from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
92  acc.merge( TileCablingSvcCfg(flags) )
93 
94  if 'TileCondToolEmscale' not in kwargs:
95  from TileConditions.TileEMScaleConfig import TileCondToolEmscaleCfg
96  emScaleTool = acc.popToolsAndMerge( TileCondToolEmscaleCfg(flags) )
97  kwargs['TileCondToolEmscale'] = emScaleTool
98 
99  from TileRecUtils.TileDQstatusConfig import TileDQstatusAlgCfg
100  acc.merge( TileDQstatusAlgCfg(flags) )
101 
102  if flags.Input.isMC:
103  from TileConditions.TileSamplingFractionConfig import TileSamplingFractionCondAlgCfg
104  acc.merge( TileSamplingFractionCondAlgCfg(flags) )
105  else:
106  kwargs['TileSamplingFraction'] = ""
107 
108  if not outputFile:
109  outputFile = f'tiletb_{run}.aan.root'
110  histsvc = CompFactory.THistSvc()
111  histsvc.Output += ["%s DATAFILE='%s' OPT='RECREATE'" % ('AANT', outputFile)]
112  acc.addService(histsvc)
113 
114  alg = CompFactory.TileTBAANtuple(**kwargs)
115  from TileMonitoring.TileTBBeamChambersCalibration import updateBeamChambersCalibrations
117  acc.addEventAlgo(alg, primary=True)
118 
119  return acc
120 
121 
122 if __name__ == '__main__':
123 
124  # Setup logs
125  from AthenaCommon.Logging import log
126  from AthenaCommon.Constants import INFO
127  log.setLevel(INFO)
128 
129  from AthenaConfiguration.AllConfigFlags import initConfigFlags
130  from AthenaConfiguration.TestDefaults import defaultConditionsTags, defaultGeometryTags, defaultTestFiles
131 
132  flags = initConfigFlags()
133  parser = flags.getArgumentParser()
134  parser.add_argument('--postExec', help='Code to execute after setup')
135  args, _ = parser.parse_known_args()
136 
137  flags.Exec.MaxEvents = 3
138  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
139  flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_DATA
140  flags.Tile.doFit = False
141  flags.Tile.doOpt2 = False
142  flags.Tile.RunType = TileRunType.PHY
143  flags.Input.Files = defaultTestFiles.RAW_RUN2
144 
145  flags.fillFromArgs(parser=parser)
146  flags.lock()
147 
148  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
149  cfg = MainServicesCfg(flags)
150 
151  from TileByteStream.TileByteStreamConfig import TileRawDataReadingCfg
152  cfg.merge( TileRawDataReadingCfg(flags, readMuRcv=False,
153  readDigits=True,
154  readRawChannel=True,
155  readDigitsFlx=True,
156  readBeamElem=True,
157  stateless=False) )
158 
159  cfg.merge( TileTBAANtupleCfg(flags, TileBeamElemContainer="") )
160 
161  cfg.getCondAlgo('TileHid2RESrcIDCondAlg').RODStatusProxy = None
162 
163  # =======>>> Any last things to do?
164  if args.postExec:
165  log.info('Executing postExec: %s', args.postExec)
166  exec(args.postExec)
167 
168  if args.config_only:
169  cfg.store(open('TileTBAANtuple.pkl', 'wb'))
170  else:
171  sc = cfg.run()
172  # Success should be 0
173  sys.exit(not sc.isSuccess())
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.TileSamplingFractionConfig.TileSamplingFractionCondAlgCfg
def TileSamplingFractionCondAlgCfg(flags, **kwargs)
Definition: TileSamplingFractionConfig.py:9
TileTBAANtupleConfig.TileTBAANtupleCfg
def TileTBAANtupleCfg(flags, outputFile='', useFELIX=None, **kwargs)
Definition: TileTBAANtupleConfig.py:34
TileDQstatusConfig.TileDQstatusAlgCfg
def TileDQstatusAlgCfg(flags, **kwargs)
Definition: TileDQstatusConfig.py:31
LArG4FSStartPointFilter.exec
exec
Definition: LArG4FSStartPointFilter.py:103
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Constants
some useful constants -------------------------------------------------—
TileTBBeamChambersCalibration.updateBeamChambersCalibrations
def updateBeamChambersCalibrations(alg, run)
Definition: TileTBBeamChambersCalibration.py:92
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
python.TileEMScaleConfig.TileCondToolEmscaleCfg
def TileCondToolEmscaleCfg(flags, **kwargs)
Definition: TileEMScaleConfig.py:125
Trk::open
@ open
Definition: BinningType.h:40
TileTBAANtupleConfig.getTileTBperiod
def getTileTBperiod(run, useFELIX)
Definition: TileTBAANtupleConfig.py:17
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
TileByteStreamConfig.TileRawDataReadingCfg
def TileRawDataReadingCfg(flags, readDigits=True, readRawChannel=True, readMuRcv=None, readMuRcvDigits=False, readMuRcvRawCh=False, readBeamElem=None, readLaserObj=None, readDigitsFlx=False, readL2=False, stateless=False, **kwargs)
Definition: TileByteStreamConfig.py:87
python.TileCablingSvcConfig.TileCablingSvcCfg
def TileCablingSvcCfg(flags)
Definition: TileCablingSvcConfig.py:11
TileGMConfig.TileGMCfg
def TileGMCfg(flags)
Definition: TileGMConfig.py:7