ATLAS Offline Software
Loading...
Searching...
No Matches
RunGeantinoMaterialTrackProduction.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 track creation
5"""
6
7
8from AthenaCommon.Logging import log
9from AthenaConfiguration.AllConfigFlags import initConfigFlags
10from AthenaConfiguration.MainServicesConfig import MainServicesCfg
11
12
14 # Argument parsing
15 from argparse import ArgumentParser
16 parser = ArgumentParser("RunGeantinoMaterialTrackProduction.py")
17 parser.add_argument("--detectors", nargs="+",
18 default=['ITkPixel', 'ITkStrip', 'Bpipe'],
19 help="Specify the list of detectors")
20 parser.add_argument("--localgeo", default=False, action="store_true",
21 help="Use local geometry Xml files")
22 parser.add_argument("--storeHITS", help="Store the G4 hits",
23 default = False, action = "store_true")
24 parser.add_argument("--geoModelSqLiteFile", default = "", help="Read geometry from sqlite file")
25 parser.add_argument("-S", "--verboseStoreGate", default=False,
26 action="store_true",
27 help="Dump the StoreGate(s) each event iteration")
28 parser.add_argument("--maxEvents",default=-1, type = int,
29 help="The number of events to run. 0 skips execution")
30 parser.add_argument("--skipEvents",default=0, type=int,
31 help="The number of events to skip")
32 parser.add_argument("--threads", default=1, type=int, help="The number of threads to run")
33 from AthenaConfiguration.TestDefaults import defaultGeometryTags, defaultConditionsTags
34 parser.add_argument("--geometrytag",default=defaultGeometryTags.RUN4, type=str,
35 help="The geometry tag to use")
36 parser.add_argument("--conditionstag",default=defaultConditionsTags.RUN4_MC, type=str,
37 help="The conditions tag to use")
38 parser.add_argument("--inputevntfile",
39 default=["/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/PhaseIIUpgrade/EVNT/mc15_14TeV.singlegeantino_E10GeV_etaFlatnp0_6.5M.evgen.EVNT.pool.root"],
40 nargs="+",
41 help="The input EVNT file to use")
42 parser.add_argument("--outputhitsfile",default="myHITS.pool.root", type=str,
43 help="The output HITS filename")
44 parser.add_argument("--outputfile",default="material-tracks.root", type=str,
45 help="The output Geantino filename")
46 return parser
47
48if __name__ == "__main__":
49 args = setupArgParser().parse_args()
50 # Some info about the job
51 print("----RunGeantinoMaterialTrackProduction for ITk geometry----")
52 print()
53 print("Using Geometry Tag: "+args.geometrytag)
54 if args.localgeo:
55 print("...overridden by local Geometry Xml files")
56 if(args.geoModelSqLiteFile):
57 print("... overridden by Geometry Sqlite file: "+args.geoModelSqLiteFile)
58 print("Input EVNT Files ")
59 for f in args.inputevntfile:
60 print (f" --- {f}")
61
62 print("Running with: {}".format(", ".join(args.detectors)))
63 print()
64
65 # Configure
66 flags = initConfigFlags()
67 if args.localgeo:
68 flags.ITk.Geometry.AllLocal = True
69
70 flags.Input.Files = args.inputevntfile
71 flags.Output.HITSFileName = args.outputhitsfile
72 flags.Concurrency.NumThreads = args.threads
73 flags.Concurrency.NumConcurrentEvents = args.threads
74 flags.Exec.MaxEvents = args.maxEvents
75 flags.Exec.SkipEvents = args.skipEvents
76 flags.Scheduler.CheckDependencies = True
77 flags.Scheduler.ShowDataDeps = True
78 flags.Scheduler.ShowDataFlow = True
79 flags.Scheduler.ShowControlFlow = True
80 flags.Scheduler.EnableVerboseViews = True
81 flags.Scheduler.AutoLoadUnmetDependencies = True
82 from SimulationConfig.SimEnums import SimulationFlavour
83 flags.Sim.ISF.Simulator = SimulationFlavour.AtlasG4
84
85
86 flags.GeoModel.AtlasVersion = args.geometrytag
87 flags.IOVDb.GlobalTag = args.conditionstag
88 flags.GeoModel.Align.Dynamic = False
89
90 from AthenaConfiguration.DetectorConfigFlags import getEnabledDetectors, setupDetectorFlags
91 from AthenaConfiguration.AutoConfigFlags import getDefaultDetectors
92
93
94 if args.geoModelSqLiteFile:
95 flags.GeoModel.SQLiteDB = True
96 flags.GeoModel.SQLiteDBFullPath = args.geoModelSqLiteFile
97 from MuonConfig.MuonConfigUtils import configureCondTag
98 configureCondTag(flags)
99 if "toroid" in args.detectors:
100 flags.Detector.GeometryMDT = False
101 flags.Detector.GeometryRPC = False
102 flags.Detector.GeometryTGC = False
103 flags.Detector.GeometrysTGC = False
104 flags.Detector.GeometryMM = False
105 flags.Detector.GeometryBpipe = False
106 flags.Detector.SpecialGeometryToroid = True
107 else:
108 detectors = args.detectors
109 detectors.append('Bpipe') # always run with beam pipe
110 setupDetectorFlags(flags, detectors, toggle_geometry=True)
111
112 flags.Acts.TrackingGeometry.UseBlueprint = True
113
114 from AthenaConfiguration.Enums import ProductionStep
115 flags.Common.ProductionStep = ProductionStep.Simulation
116
117 log.debug('Lock config flags now.')
118 flags.lock()
119 print (" ***\n ".join(getEnabledDetectors(flags)))
120
121 print(flags.dump(evaluate=True))
122
123 # Construct our accumulator to run
124 acc = MainServicesCfg(flags)
125
126 if args.verboseStoreGate:
127 acc.getService("StoreGateSvc").Dump = True
128
129 log.debug('Dumping of ConfigFlags now.')
130 flags.dump()
131
132 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
133 acc.merge(PoolReadCfg(flags))
134
135 # add BeamEffectsAlg
136 from BeamEffects.BeamEffectsAlgConfig import BeamEffectsAlgCfg
137 acc.merge(BeamEffectsAlgCfg(flags))
138
139 beamcond = acc.getCondAlgo("BeamSpotCondAlg")
140
141 beamcond.useDB=False
142 beamcond.posX=0.0
143 beamcond.posY=0.0
144 beamcond.posZ=0.0
145 beamcond.sigmaX=0.0
146 beamcond.sigmaY=0.0
147 beamcond.sigmaZ=0.0
148 beamcond.tiltX=0.0
149 beamcond.tiltY=0.0
150
151
152 from ActsConfig.ActsMaterialConfig import MaterialTrackRecorderUserActionSvcCfg
153 from G4AtlasAlg.G4AtlasAlgConfig import G4AtlasAlgCfg
154 acc.merge(G4AtlasAlgCfg(flags, "ITkG4AtlasAlg",
155 ExtraOutputs=[("ActsTrk::RecordedMaterialTrackCollection","StoreGateSvc+OutputMaterialTracks")],
156 UserActionSvc = acc.getPrimaryAndMerge(MaterialTrackRecorderUserActionSvcCfg(flags))))
157 if args.storeHITS:
158 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
159 from SimuJobTransforms.SimOutputConfig import getStreamHITS_ItemList
160 acc.merge(OutputStreamCfg(flags,"HITS", ItemList=getStreamHITS_ItemList(flags),
161 disableEventTag=True, AcceptAlgs=['ITkG4AtlasAlg']) )
162
163
164 from ActsConfig.ActsMaterialConfig import MaterialTrackWriterCfg
165 acc.merge(MaterialTrackWriterCfg(flags, useTrackingGeometry= False, FileName=args.outputfile))
166
167 from MuonConfig.MuonConfigUtils import executeTest
168 executeTest(acc)
if(pathvar)
void print(char *figname, TCanvas *c1)