ATLAS Offline Software
TileSamplingFractionConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 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
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.GeoModel.Run >= LHCPeriod.Run4 or flags.Overlay.DataOverlay or flags.Sim.ISF.Simulator.usesFastCaloSim() or flags.Sim.LArParameterization is LArParameterization.FastCaloSim:
37  samplingFractionTag = 'TileOfl02CalibSfr-SIM-07'
38 
39  from IOVDbSvc.IOVDbSvcConfig import addFolders
40  acc.merge( addFolders(flags, samplingFractionFolder + f'<key>{samplingFractionFolder}</key>',
41  detDb='TILE_OFL', className='CondAttrListCollection', tag=samplingFractionTag, db='OFLP200') )
42 
43  elif source == 'FILE':
44  # Connect FILE Tile conditions proxies to the algorithm
45  TileCondProxyFileFlt = CompFactory.getComp("TileCondProxyFile<TileCalibDrawerFlt>")
46  samplingFractionProxy = TileCondProxyFileFlt('TileCondProxyFile_SamplingFraction', Source = 'TileDefault.sfr')
47  else:
48  raise(Exception("Invalid source: %s" % source))
49 
50  G4Version = flags.Sim.G4Version
51  G4VersionMajor, G4VersionMinor = G4Version.split(".")[1:3]
52  G4V = int(G4VersionMajor) * 100 + int(G4VersionMinor)
53 
54  TileSamplingFractionCondAlg = CompFactory.getComp("TileSamplingFractionCondAlg")
55  samplingFractionCondAlg = TileSamplingFractionCondAlg( name = name, G4Version = G4V,
56  ConditionsProxy = samplingFractionProxy,
57  TileCondData = samplingFraction)
58 
59  acc.addCondAlgo(samplingFractionCondAlg)
60 
61  return acc
62 
63 
64 
65 if __name__ == "__main__":
66 
67  from AthenaConfiguration.AllConfigFlags import initConfigFlags
68  from AthenaConfiguration.TestDefaults import defaultTestFiles
69  from AthenaCommon.Logging import log
70  from AthenaCommon.Constants import DEBUG
71 
72  # Test setup
73  log.setLevel(DEBUG)
74 
75  flags = initConfigFlags()
76  flags.Input.Files = defaultTestFiles.HITS_RUN2
77  flags.lock()
78 
80 
81  acc.merge( TileSamplingFractionCondAlgCfg(flags) )
82 
83  acc.printConfig(withDetails = True, summariseProps = True)
84  print(acc.getService('IOVDbSvc'))
85  acc.store( open('TileSamplingFraction.pkl','wb') )
86 
87  print('All OK')
88 
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
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:72
Trk::open
@ open
Definition: BinningType.h:40
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28