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
74log.debug('Lock config flags now.')
75flags.lock()
76
77# Construct our accumulator to run
78acc = MainServicesCfg(flags)
79
80
81if args.verboseAccumulators:
82 acc.printConfig(withDetails=True)
83if args.verboseStoreGate:
84 acc.getService("StoreGateSvc").Dump = True
85
86log.debug('Dumping of ConfigFlags now.')
87flags.dump()
88
89from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
90acc.merge(PoolReadCfg(flags))
91
92# add BeamEffectsAlg
93from BeamEffects.BeamEffectsAlgConfig import BeamEffectsAlgCfg
94acc.merge(BeamEffectsAlgCfg(flags))
95
96beamcond = acc.getCondAlgo("BeamSpotCondAlg")
97
98beamcond.useDB=False
99beamcond.posX=0.0
100beamcond.posY=0.0
101beamcond.posZ=0.0
102beamcond.sigmaX=0.0
103beamcond.sigmaY=0.0
104beamcond.sigmaZ=0.0
105beamcond.tiltX=0.0
106beamcond.tiltY=0.0
107
108kwargs = {}
109svcName = "G4UA::MaterialStepRecorderUserActionSvc"
110from TrkG4UserActions.TrkG4UserActionsConfig import MaterialStepRecorderUserActionSvcCfg
111userAction = acc.getPrimaryAndMerge(MaterialStepRecorderUserActionSvcCfg(flags,svcName,**kwargs))
112kwargs.update(UserActionSvc=userAction)
113
114if 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
121from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
122acc.merge(EventInfoCnvAlgCfg(flags))
123
124AthenaOutputStream=CompFactory.AthenaOutputStream
125AthenaOutputStreamTool=CompFactory.AthenaOutputStreamTool
126writingTool = AthenaOutputStreamTool( "MaterialStepCollectionStreamTool",
127 TopLevelContainerName = "",
128 SubLevelBranchName = "<type>/<key>" )
129
130outputStream = AthenaOutputStream(name = "MaterialStepCollectionStream",
131 WritingTool = writingTool,
132 ItemList=['EventInfo#*', 'Trk::MaterialStepCollection#*'],
133 MetadataItemList = [ "EventStreamInfo#MaterialStepCollectionStream", "IOVMetaDataContainer#*" ],
134 OutputFile = "MaterialStepCollection.root")
135
136StoreGateSvc=CompFactory.StoreGateSvc
137acc.addService(StoreGateSvc("MetaDataStore"))
138outputStream.MetadataStore = acc.getService("MetaDataStore")
139
140MakeEventStreamInfo=CompFactory.MakeEventStreamInfo
141streamInfoTool = MakeEventStreamInfo( "MaterialStepCollectionStream_MakeEventStreamInfo" )
142streamInfoTool.Key = "MaterialStepCollectionStream"
143streamInfoTool.EventInfoKey = "EventInfo"
144outputStream.HelperTools.append(streamInfoTool)
145
146acc.addEventAlgo(outputStream)
147
148acc.printConfig(withDetails = True, summariseProps = True)
149
150acc.run(maxEvents=args.maxEvents)
151
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.