ATLAS Offline Software
RunGeantinoStepRecordingITk.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 """
4 Run geantino processing for material step creation
5 """
6 
7 from argparse import ArgumentParser
8 from AthenaCommon.Logging import log
9 from AthenaConfiguration.AllConfigFlags import initConfigFlags
10 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
11 from AthenaConfiguration.ComponentFactory import CompFactory
12 
13 # Argument parsing
14 parser = ArgumentParser("RunGeantinoStepRecordingITk.py")
15 parser.add_argument("detectors", metavar="detectors", type=str, nargs="*",
16  help="Specify the list of detectors")
17 parser.add_argument("--simulate", default=True, action="store_true",
18  help="Run Simulation")
19 parser.add_argument("--localgeo", default=False, action="store_true",
20  help="Use local geometry Xml files")
21 parser.add_argument("-V", "--verboseAccumulators", default=False,
22  action="store_true",
23  help="Print full details of the AlgSequence")
24 parser.add_argument("-S", "--verboseStoreGate", default=False,
25  action="store_true",
26  help="Dump the StoreGate(s) each event iteration")
27 parser.add_argument("--maxEvents",default=10, type=int,
28  help="The number of events to run. 0 skips execution")
29 parser.add_argument("--skipEvents",default=0, type=int,
30  help="The number of events to skip")
31 parser.add_argument("--geometrytag",default="ATLAS-P2-RUN4-03-00-00", type=str,
32  help="The geometry tag to use")
33 parser.add_argument("--inputevntfile",
34  default="/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/PhaseIIUpgrade/EVNT/mc15_14TeV.singlegeantino_E10GeV_etaFlatnp0_6.5M.evgen.EVNT.pool.root",
35  help="The input EVNT file to use")
36 parser.add_argument("--outputhitsfile",default="myHITS.pool.root", type=str,
37  help="The output HITS filename")
38 args = parser.parse_args()
39 
40 
41 # Some info about the job
42 print("----GeantinoStepRecording for ITk geometry----")
43 print()
44 print("Using Geometry Tag: "+args.geometrytag)
45 if args.localgeo:
46  print("...overridden by local Geometry Xml files")
47 print("Input EVNT File:"+args.inputevntfile)
48 if not args.detectors:
49  print("Running complete detector")
50 else:
51  print("Running with: {}".format(", ".join(args.detectors)))
52 print()
53 
54 # Configure
55 flags = initConfigFlags()
56 if args.localgeo:
57  flags.ITk.Geometry.AllLocal = True
58 
59 flags.Input.Files = [args.inputevntfile]
60 flags.Output.HITSFileName = args.outputhitsfile
61 
62 flags.GeoModel.AtlasVersion = args.geometrytag
63 flags.IOVDb.GlobalTag = "OFLCOND-SIM-00-00-00"
64 flags.GeoModel.Align.Dynamic = False
65 
66 flags.Exec.SkipEvents = args.skipEvents
67 
68 from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
69 detectors = args.detectors if 'detectors' in args and args.detectors else ['ITkPixel', 'ITkStrip', 'HGTD']
70 detectors.append('Bpipe') # always run with beam pipe
71 setupDetectorFlags(flags, detectors, toggle_geometry=True)
72 
73 log.debug('Lock config flags now.')
74 flags.lock()
75 
76 # Construct our accumulator to run
77 acc = MainServicesCfg(flags)
78 
79 
80 if args.verboseAccumulators:
81  acc.printConfig(withDetails=True)
82 if args.verboseStoreGate:
83  acc.getService("StoreGateSvc").Dump = True
84 
85 log.debug('Dumping of ConfigFlags now.')
86 flags.dump()
87 
88 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
89 acc.merge(PoolReadCfg(flags))
90 
91 # add BeamEffectsAlg
92 from BeamEffects.BeamEffectsAlgConfig import BeamEffectsAlgCfg
93 acc.merge(BeamEffectsAlgCfg(flags))
94 
95 beamcond = acc.getCondAlgo("BeamSpotCondAlg")
96 
97 beamcond.useDB=False
98 beamcond.posX=0.0
99 beamcond.posY=0.0
100 beamcond.posZ=0.0
101 beamcond.sigmaX=0.0
102 beamcond.sigmaY=0.0
103 beamcond.sigmaZ=0.0
104 beamcond.tiltX=0.0
105 beamcond.tiltY=0.0
106 
107 kwargs = {}
108 
109 svcName = "G4UA::MaterialStepRecorderUserActionSvc"
110 from TrkG4UserActions.TrkG4UserActionsConfig import MaterialStepRecorderUserActionSvcCfg
111 acc.merge(MaterialStepRecorderUserActionSvcCfg(flags,svcName,**kwargs))
112 kwargs.update(UserActionSvc=svcName)
113 
114 if args.simulate:
115  from G4AtlasAlg.G4AtlasAlgConfig import G4AtlasAlgCfg
116  acc.merge(G4AtlasAlgCfg(flags, "ITkG4AtlasAlg", **kwargs))
117  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
118  from SimuJobTransforms.SimOutputConfig import getStreamHITS_ItemList
119  acc.merge( OutputStreamCfg(flags,"HITS", ItemList=getStreamHITS_ItemList(flags), disableEventTag=True, AcceptAlgs=['ITkG4AtlasAlg']) )
120 
121 
122 AthenaOutputStream=CompFactory.AthenaOutputStream
123 AthenaOutputStreamTool=CompFactory.AthenaOutputStreamTool
124 writingTool = AthenaOutputStreamTool( "MaterialStepCollectionStreamTool" )
125 
126 outputStream = AthenaOutputStream(name = "MaterialStepCollectionStream",
127  WritingTool = writingTool,
128  ItemList=['EventInfo#*', 'Trk::MaterialStepCollection#*'],
129  MetadataItemList = [ "EventStreamInfo#MaterialStepCollectionStream", "IOVMetaDataContainer#*" ],
130  OutputFile = "MaterialStepCollection.root")
131 
132 StoreGateSvc=CompFactory.StoreGateSvc
133 acc.addService(StoreGateSvc("MetaDataStore"))
134 outputStream.MetadataStore = acc.getService("MetaDataStore")
135 
136 MakeEventStreamInfo=CompFactory.MakeEventStreamInfo
137 streamInfoTool = MakeEventStreamInfo( "MaterialStepCollectionStream_MakeEventStreamInfo" )
138 streamInfoTool.Key = "MaterialStepCollectionStream"
139 streamInfoTool.EventInfoKey = "EventInfo"
140 outputStream.HelperTools.append(streamInfoTool)
141 
142 acc.addEventAlgo(outputStream)
143 
144 acc.printConfig(withDetails = True, summariseProps = True)
145 
146 acc.run(maxEvents=args.maxEvents)
147 
G4AtlasAlgConfig.G4AtlasAlgCfg
def G4AtlasAlgCfg(flags, name="G4AtlasAlg", **kwargs)
Definition: G4AtlasAlgConfig.py:12
vtune_athena.format
format
Definition: vtune_athena.py:14
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:12
BeamEffectsAlgConfig.BeamEffectsAlgCfg
def BeamEffectsAlgCfg(flags, name="BeamEffectsAlg", **kwargs)
Definition: BeamEffectsAlgConfig.py:101
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:256
MakeEventStreamInfo
This class provides an algorithm to make the EventStreamInfo object and update it.
Definition: MakeEventStreamInfo.h:27
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.DetectorConfigFlags.setupDetectorFlags
def setupDetectorFlags(flags, custom_list=None, use_metadata=False, toggle_geometry=False, validate_only=False, keep_beampipe=False)
Definition: DetectorConfigFlags.py:286
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
AthenaOutputStream
algorithm that marks for write data objects in SG
Definition: AthenaOutputStream.h:58
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
AthenaOutputStreamTool
This is the implementation of IAthenaOutputStreamTool.
Definition: AthenaOutputStreamTool.h:31
python.FilterHit_Skeleton.getStreamHITS_ItemList
def getStreamHITS_ItemList(flags)
Definition: FilterHit_Skeleton.py:12
python.TrkG4UserActionsConfig.MaterialStepRecorderUserActionSvcCfg
def MaterialStepRecorderUserActionSvcCfg(configFlags, name="G4UA::MaterialStepRecorderUserActionSvc", **kwargs)
Definition: TrkG4UserActionsConfig.py:13