ATLAS Offline Software
ISF_FastCaloSimServicesTestHelpers.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 """FastCaloSimServices test helpers
3 
4 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5 """
6 
7 from argparse import ArgumentParser
8 from AthenaConfiguration.Enums import ProductionStep
9 from AthenaConfiguration.ComponentFactory import CompFactory
10 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
11 
12 
13 def TestMessageSvcCfg(flags):
14  """MessageSvc for FCSServices"""
15  MessageSvc = CompFactory.MessageSvc
16  acc = ComponentAccumulator()
17  acc.addService(MessageSvc(setError=["HepMcParticleLink"]))
18  return acc
19 
20 
22  """FCSServices test argument parser"""
23  parser = ArgumentParser()
24  parser.add_argument("-n", "--maxEvents", default=3, type=int,
25  help="The number of events to run. 0 skips execution")
26  parser.add_argument("-t", "--threads", default=1, type=int,
27  help="The number of concurrent threads to run. 0 uses serial Athena.")
28  parser.add_argument("-V", "--verboseAccumulators", default=False, action="store_true",
29  help="Print full details of the AlgSequence for each accumulator")
30  parser.add_argument("-S", "--verboseStoreGate", default=False, action="store_true",
31  help="Dump the StoreGate(s) each event iteration")
32  parser.add_argument("-o", "--output", default='', type=str,
33  help="Output RDO file")
34  parser.add_argument("-s", "--outputSig", default='', type=str,
35  help="Output RDO_SGNL file")
36  return parser
37 
38 
39 def defaultTestFlags(configFlags, args):
40  """Fill default FCSServices flags for testing"""
41 
42  from AthenaConfiguration.TestDefaults import defaultGeometryTags, defaultTestFiles
43  configFlags.Input.RunNumbers = [284500]
44  configFlags.Input.OverrideRunNumber = True
45  configFlags.Input.LumiBlockNumbers = [1]
46  configFlags.Input.Files = defaultTestFiles.EVNT # ["root://eosuser.cern.ch///eos/atlas/atlascerngroupdisk/proj-simul/OutputSamples/rel21/mc16_13TeV.photon.E65536.eta20_25.EVNT.merged.pool.root"]
47  configFlags.Output.HITSFileName = "myHITSnew.pool.root"
48  configFlags.Common.ProductionStep = ProductionStep.Simulation
49 
50  # Sim configFlags
51  from SimulationConfig.SimEnums import BeamPipeSimMode, CalibrationRun, LArParameterization, SimulationFlavour, TruthStrategy
52  configFlags.Sim.TruthStrategy = TruthStrategy.MC15aPlus
53  configFlags.Sim.PhysicsList = "FTFP_BERT_ATL"
54  configFlags.Sim.CalibrationRun = CalibrationRun.Off
55  configFlags.Sim.RecordStepInfo = False
56  configFlags.Sim.BeamPipeSimMode = BeamPipeSimMode.FastSim
57  configFlags.Sim.ISFRun = True
58  configFlags.Sim.ISF.Simulator = SimulationFlavour.ATLFAST3MT
59  configFlags.Sim.FastCalo.ParamsInputFilename = "FastCaloSim/MC23/TFCSparam_AF3_MC23_Sep23.root"
60  configFlags.Sim.FastCalo.CaloCellsName = "AllCalo"
61 
62  configFlags.IOVDb.GlobalTag = "OFLCOND-MC16-SDR-14"
63  configFlags.GeoModel.Align.Dynamic = False
64  configFlags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
65 
66  detectors = ['Bpipe', 'BCM', 'Pixel', 'SCT', 'TRT', 'LAr', 'Tile', 'MBTS', 'CSC', 'MDT', 'RPC', 'TGC']
67  # Setup detector flags
68  from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
69  setupDetectorFlags(configFlags, detectors, toggle_geometry=True)
70 
71  # Frozen showers OFF = 0
72  configFlags.Sim.LArParameterization = LArParameterization.NoFrozenShowers
73 
74  if args.output:
75  if args.output == 'None':
76  configFlags.Output.RDOFileName = ''
77  else:
78  configFlags.Output.RDOFileName = args.output
79 
80  if args.outputSig:
81  configFlags.Output.RDO_SGNLFileName = args.outputSig
82 
83 
84 def postprocessAndLockFlags(configFlags, args):
85  """Postprocess and lock config flags for FCSServices"""
86  # Flags relating to multithreaded execution
87  configFlags.Concurrency.NumThreads = args.threads
88  if args.threads > 0:
89  configFlags.Scheduler.ShowDataDeps = True
90  configFlags.Scheduler.ShowDataFlow = True
91  configFlags.Scheduler.ShowControlFlow = True
92  configFlags.Concurrency.NumConcurrentEvents = args.threads
93 
94  configFlags.lock()
95 
96 
97 def printAndRun(accessor, configFlags, args):
98  """Common debugging and execution for FCSServices tests"""
99  # Dump config
100  if args.verboseAccumulators:
101  accessor.printConfig(withDetails=True)
102  if args.verboseStoreGate:
103  accessor.getService("StoreGateSvc").Dump = True
104  configFlags.dump()
105 
106  # Dump config summary
107  accessor.printConfig(withDetails=False)
108 
109  # Execute and finish
110  sc = accessor.run(maxEvents=args.maxEvents)
111 
112 
113  # Success should be 0
114  return not sc.isSuccess()
ISF_FastCaloSimServicesTestHelpers.TestMessageSvcCfg
def TestMessageSvcCfg(flags)
Definition: ISF_FastCaloSimServicesTestHelpers.py:13
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
ISF_FastCaloSimServicesTestHelpers.printAndRun
def printAndRun(accessor, configFlags, args)
Definition: ISF_FastCaloSimServicesTestHelpers.py:97
jobOptions.MessageSvc
MessageSvc
Definition: jobOptions.crmc.py:63
python.DetectorConfigFlags.setupDetectorFlags
def setupDetectorFlags(flags, custom_list=None, use_metadata=False, toggle_geometry=False, validate_only=False, keep_beampipe=False)
Definition: DetectorConfigFlags.py:292
ISF_FastCaloSimServicesTestHelpers.postprocessAndLockFlags
def postprocessAndLockFlags(configFlags, args)
Definition: ISF_FastCaloSimServicesTestHelpers.py:84
ISF_FastCaloSimServicesTestHelpers.CommonTestArgumentParser
def CommonTestArgumentParser()
Definition: ISF_FastCaloSimServicesTestHelpers.py:21
ISF_FastCaloSimServicesTestHelpers.defaultTestFlags
def defaultTestFlags(configFlags, args)
Definition: ISF_FastCaloSimServicesTestHelpers.py:39