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