ATLAS Offline Software
LArEMSamplingFractionConfig.py
Go to the documentation of this file.
1 #!/usr/bin/env athena.py
2 
3 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 #
5 # This CA configuration script replaces the previously used legacy script for simulating sampling fractions
6 #
7 
8 import sys
9 
10 from AthenaConfiguration.AllConfigFlags import initConfigFlags
11 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
12 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
13 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
14 from AthenaConfiguration.ComponentFactory import CompFactory
15 
16 
17 # Adding algorithm
18 def LarEMSamplingFractionCfg(flags, name="LarEMSamplingFraction", **kwargs):
19  acc = ComponentAccumulator()
20 
21  acc.addService(CompFactory.THistSvc(name="THistSvc", Output=[ f"{name} DATAFILE='{flags.Output.HISTFileName}' OPT='RECREATE'" ]))
22 
23  kwargs.setdefault('HistPath', f"/{name}/")
24  kwargs.setdefault('DoCells', 0)
25 
26  kwargs.setdefault('CalibrationHitContainerNames', [
27  "LArCalibrationHitInactive",
28  "LArCalibrationHitActive",
29  "TileCalibHitInactiveCell",
30  "TileCalibHitActiveCell",
31  ] )
32 
33  acc.addEventAlgo(CompFactory.LarEMSamplingFraction(name, **kwargs))
34 
35  return acc
36 
37 
38 # Setting flags
39 flags = initConfigFlags()
40 flags.IOVDb.GlobalTag = 'OFLCOND-MC16-SDR-16'
41 flags.Input.Files = ['test.root']
42 flags.Output.HISTFileName = 'LArEM_SF.root'
43 flags.Exec.MaxEvents = -1
44 flags.fillFromArgs()
45 flags.dump()
46 flags.lock()
47 
48 # Main CA and basic services
49 acc = MainServicesCfg(flags)
50 acc.merge(LarEMSamplingFractionCfg(flags))
51 acc.merge(PoolReadCfg(flags))
52 
53 # Finalize
54 acc.run()
55 
56 sys.exit( acc.run().isFailure() )
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
LArEMSamplingFractionConfig.LarEMSamplingFractionCfg
def LarEMSamplingFractionCfg(flags, name="LarEMSamplingFraction", **kwargs)
Definition: LArEMSamplingFractionConfig.py:18