ATLAS Offline Software
TileSamplingFractionConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 
3 """Define methods to construct configured Tile sampling fraction conditions algorithm"""
4 
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 from AthenaConfiguration.Enums import LHCPeriod, BeamType
8 
9 def TileSamplingFractionCondAlgCfg(flags, **kwargs):
10  """Return component accumulator with configured Tile sampling fraction conditions algorithm
11 
12  Arguments:
13  flags -- Athena configuration flags
14  Keyword arguments:
15  Source -- source of Tile SamplingFraction conditions (COOL, FILE). Defaults to COOL.
16  TileSamplingFraction -- name of Tile sampling fraction conditions object. Defaults to TileSamplingFraction.
17  """
18 
19  acc = ComponentAccumulator()
20 
21  source = kwargs.get('Source', 'COOL')
22  samplingFraction = kwargs.get('TileSamplingFraction', 'TileSamplingFraction')
23 
24  name = samplingFraction + 'CondAlg'
25 
26  if source == 'COOL':
27  # Connect COOL Tile conditions proxies to the algorithm (default)
28 
29  samplingFractionFolder = '/TILE/OFL02/CALIB/SFR'
30 
31  TileCondProxyCoolFlt = CompFactory.getComp("TileCondProxyCool<TileCalibDrawerFlt>")
32  samplingFractionProxy = TileCondProxyCoolFlt('TileCondProxyCool_SamplingFraction', Source = samplingFractionFolder)
33 
34  samplingFractionTag = None # Tag connected to global conditions tag is used by default
35  from SimulationConfig.SimEnums import LArParameterization
36  if flags.Beam.Type is BeamType.TestBeam:
37  # fixed sampling fraction for Geant4 10.6 for all run numbers
38  samplingFractionTag = 'TileOfl02CalibSfr-SIM-06'
39  elif flags.GeoModel.Run >= LHCPeriod.Run4 or flags.Sim.ISF.Simulator.usesFastCaloSim() or flags.Sim.LArParameterization is LArParameterization.FastCaloSim:
40  samplingFractionTag = 'TileOfl02CalibSfr-SIM-07'
41 
42  from IOVDbSvc.IOVDbSvcConfig import addFolders
43  acc.merge( addFolders(flags, samplingFractionFolder + f'<key>{samplingFractionFolder}</key>',
44  detDb='TILE_OFL', className='CondAttrListCollection', tag=samplingFractionTag, db='OFLP200') )
45 
46  elif source == 'FILE':
47  # Connect FILE Tile conditions proxies to the algorithm
48  TileCondProxyFileFlt = CompFactory.getComp("TileCondProxyFile<TileCalibDrawerFlt>")
49  samplingFractionProxy = TileCondProxyFileFlt('TileCondProxyFile_SamplingFraction', Source = 'TileDefault.sfr')
50  else:
51  raise(Exception("Invalid source: %s" % source))
52 
53  G4Version = flags.Sim.G4Version
54  G4VersionMajor, G4VersionMinor = G4Version.split(".")[1:3]
55  G4V = int(G4VersionMajor) * 100 + int(G4VersionMinor)
56 
57  TileSamplingFractionCondAlg = CompFactory.getComp("TileSamplingFractionCondAlg")
58  samplingFractionCondAlg = TileSamplingFractionCondAlg( name = name, G4Version = G4V,
59  ConditionsProxy = samplingFractionProxy,
60  TileCondData = samplingFraction)
61 
62  acc.addCondAlgo(samplingFractionCondAlg)
63 
64  return acc
65 
66 
67 
68 if __name__ == "__main__":
69 
70  from AthenaConfiguration.AllConfigFlags import initConfigFlags
71  from AthenaConfiguration.TestDefaults import defaultTestFiles
72  from AthenaCommon.Logging import log
73  from AthenaCommon.Constants import DEBUG
74 
75  # Test setup
76  log.setLevel(DEBUG)
77 
78  flags = initConfigFlags()
79  flags.Input.Files = defaultTestFiles.HITS_RUN2
80  flags.lock()
81 
83 
84  acc.merge( TileSamplingFractionCondAlgCfg(flags) )
85 
86  acc.printConfig(withDetails = True, summariseProps = True)
87  print(acc.getService('IOVDbSvc'))
88  acc.store( open('TileSamplingFraction.pkl','wb') )
89 
90  print('All OK')
91 
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
TileSamplingFractionCondAlg
Definition: TileSamplingFractionCondAlg.h:16
python.TileSamplingFractionConfig.TileSamplingFractionCondAlgCfg
def TileSamplingFractionCondAlgCfg(flags, **kwargs)
Definition: TileSamplingFractionConfig.py:9
TileCondProxyCool
The tool to get Tile conditions data from DB.
Definition: TileCondProxyCool.h:25
TileCondProxyFile
The tool to get Tile conditions data from file.
Definition: TileCondProxyFile.h:28
Constants
some useful constants -------------------------------------------------—
python.IOVDbSvcConfig.addFolders
def addFolders(flags, folderStrings, detDb=None, className=None, extensible=False, tag=None, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:86
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
Trk::open
@ open
Definition: BinningType.h:40
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19