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