File indexing completed on 2025-08-05 08:10:09
0001
0002
0003 import os
0004 import argparse
0005
0006 import acts
0007 from acts.examples import Sequencer, RootMaterialTrackWriter
0008 from acts.examples.odd import getOpenDataDetector
0009
0010
0011 def runMaterialValidation(
0012 trackingGeometry,
0013 decorators,
0014 field,
0015 outputDir,
0016 nevents=1000,
0017 ntracks=1000,
0018 outputName="propagation-material",
0019 s=None,
0020 ):
0021
0022 s = s or Sequencer(events=nevents, numThreads=-1)
0023
0024 for decorator in decorators:
0025 s.addContextDecorator(decorator)
0026
0027 nav = acts.Navigator(trackingGeometry=trackingGeometry)
0028
0029 stepper = acts.StraightLineStepper()
0030
0031
0032 prop = acts.examples.ConcretePropagator(acts.Propagator(stepper, nav))
0033
0034 rnd = acts.examples.RandomNumbers(seed=42)
0035
0036 alg = acts.examples.PropagationAlgorithm(
0037 propagatorImpl=prop,
0038 level=acts.logging.INFO,
0039 randomNumberSvc=rnd,
0040 ntests=ntracks,
0041 sterileLogger=True,
0042 propagationStepCollection="propagation-steps",
0043 recordMaterialInteractions=True,
0044 d0Sigma=0,
0045 z0Sigma=0,
0046 )
0047
0048 s.addAlgorithm(alg)
0049
0050 s.addWriter(
0051 RootMaterialTrackWriter(
0052 level=acts.logging.INFO,
0053 inputMaterialTracks=alg.config.propagationMaterialCollection,
0054 filePath=os.path.join(outputDir, (outputName + ".root")),
0055 storeSurface=True,
0056 storeVolume=True,
0057 )
0058 )
0059
0060 return s
0061
0062
0063 if "__main__" == __name__:
0064 p = argparse.ArgumentParser()
0065
0066 p.add_argument(
0067 "-n", "--events", type=int, default=1000, help="Number of events to process"
0068 )
0069 p.add_argument(
0070 "-t", "--tracks", type=int, default=1000, help="Number of tracks per event"
0071 )
0072 p.add_argument(
0073 "-m", "--map", type=str, default="", help="Input file for the material map"
0074 )
0075 p.add_argument("-o", "--output", type=str, default="", help="Output file name")
0076
0077 args = p.parse_args()
0078
0079 matDeco = acts.IMaterialDecorator.fromFile(args.map)
0080
0081 detector, trackingGeometry, decorators = getOpenDataDetector(mdecorator=matDeco)
0082
0083 field = acts.ConstantBField(acts.Vector3(0, 0, 0 * acts.UnitConstants.T))
0084
0085 runMaterialValidation(
0086 trackingGeometry,
0087 decorators,
0088 field,
0089 nevents=args.events,
0090 ntracks=args.tracks,
0091 outputDir=os.getcwd(),
0092 outputName=args.output,
0093 ).run()