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