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-2024 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")
31parser.add_argument("--geometrytag",default="ATLAS-P2-RUN4-03-00-00", type=str,
32 help="The geometry tag to use")
33parser.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")
36parser.add_argument("--outputhitsfile",default="myHITS.pool.root", type=str,
37 help="The output HITS filename")
38args = parser.parse_args()
39
40
41# Some info about the job
42print("----GeantinoStepRecording for ITk geometry----")
43print()
44print("Using Geometry Tag: "+args.geometrytag)
45if args.localgeo:
46 print("...overridden by local Geometry Xml files")
47print("Input EVNT File:"+args.inputevntfile)
48if not args.detectors:
49 print("Running complete detector")
50else:
51 print("Running with: {}".format(", ".join(args.detectors)))
52print()
53
54# Configure
55flags = initConfigFlags()
56if args.localgeo:
57 flags.ITk.Geometry.AllLocal = True
58
59flags.Input.Files = [args.inputevntfile]
60flags.Output.HITSFileName = args.outputhitsfile
61
62flags.GeoModel.AtlasVersion = args.geometrytag
63flags.IOVDb.GlobalTag = "OFLCOND-SIM-00-00-00"
64flags.GeoModel.Align.Dynamic = False
65
66flags.Exec.SkipEvents = args.skipEvents
67
68from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
69detectors = args.detectors if 'detectors' in args and args.detectors else ['ITkPixel', 'ITkStrip', 'HGTD']
70detectors.append('Bpipe') # always run with beam pipe
71setupDetectorFlags(flags, detectors, toggle_geometry=True)
72
73log.debug('Lock config flags now.')
74flags.lock()
75
76# Construct our accumulator to run
77acc = MainServicesCfg(flags)
78
79
80if args.verboseAccumulators:
81 acc.printConfig(withDetails=True)
82if args.verboseStoreGate:
83 acc.getService("StoreGateSvc").Dump = True
84
85log.debug('Dumping of ConfigFlags now.')
86flags.dump()
87
88from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
89acc.merge(PoolReadCfg(flags))
90
91# add BeamEffectsAlg
92from BeamEffects.BeamEffectsAlgConfig import BeamEffectsAlgCfg
93acc.merge(BeamEffectsAlgCfg(flags))
94
95beamcond = acc.getCondAlgo("BeamSpotCondAlg")
96
97beamcond.useDB=False
98beamcond.posX=0.0
99beamcond.posY=0.0
100beamcond.posZ=0.0
101beamcond.sigmaX=0.0
102beamcond.sigmaY=0.0
103beamcond.sigmaZ=0.0
104beamcond.tiltX=0.0
105beamcond.tiltY=0.0
106
107kwargs = {}
108svcName = "G4UA::MaterialStepRecorderUserActionSvc"
109from TrkG4UserActions.TrkG4UserActionsConfig import MaterialStepRecorderUserActionSvcCfg
110userAction = acc.getPrimaryAndMerge(MaterialStepRecorderUserActionSvcCfg(flags,svcName,**kwargs))
111kwargs.update(UserActionSvc=userAction)
112
113if args.simulate:
114 from G4AtlasAlg.G4AtlasAlgConfig import G4AtlasAlgCfg
115 acc.merge(G4AtlasAlgCfg(flags, "ITkG4AtlasAlg", **kwargs))
116 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
117 from SimuJobTransforms.SimOutputConfig import getStreamHITS_ItemList
118 acc.merge( OutputStreamCfg(flags,"HITS", ItemList=getStreamHITS_ItemList(flags), disableEventTag=True, AcceptAlgs=['ITkG4AtlasAlg']) )
119
120from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
121acc.merge(EventInfoCnvAlgCfg(flags))
122
123AthenaOutputStream=CompFactory.AthenaOutputStream
124AthenaOutputStreamTool=CompFactory.AthenaOutputStreamTool
125writingTool = AthenaOutputStreamTool( "MaterialStepCollectionStreamTool" )
126
127outputStream = AthenaOutputStream(name = "MaterialStepCollectionStream",
128 WritingTool = writingTool,
129 ItemList=['EventInfo#*', 'Trk::MaterialStepCollection#*'],
130 MetadataItemList = [ "EventStreamInfo#MaterialStepCollectionStream", "IOVMetaDataContainer#*" ],
131 OutputFile = "MaterialStepCollection.root")
132
133StoreGateSvc=CompFactory.StoreGateSvc
134acc.addService(StoreGateSvc("MetaDataStore"))
135outputStream.MetadataStore = acc.getService("MetaDataStore")
136
137MakeEventStreamInfo=CompFactory.MakeEventStreamInfo
138streamInfoTool = MakeEventStreamInfo( "MaterialStepCollectionStream_MakeEventStreamInfo" )
139streamInfoTool.Key = "MaterialStepCollectionStream"
140streamInfoTool.EventInfoKey = "EventInfo"
141outputStream.HelperTools.append(streamInfoTool)
142
143acc.addEventAlgo(outputStream)
144
145acc.printConfig(withDetails = True, summariseProps = True)
146
147acc.run(maxEvents=args.maxEvents)
148
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.