Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
physmon_vertexing.py
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file physmon_vertexing.py
1 #!/usr/bin/env python3
2 import tempfile
3 from pathlib import Path
4 import shutil
5 import datetime
6 
7 import acts
8 from acts.examples.simulation import (
9  addParticleGun,
10  MomentumConfig,
11  EtaConfig,
12  PhiConfig,
13  ParticleConfig,
14  addFatras,
15  addDigitization,
16 )
17 
18 from acts.examples.reconstruction import (
19  addSeeding,
20  SeedFinderConfigArg,
21  SeedFinderOptionsArg,
22  SeedingAlgorithm,
23  addCKFTracks,
24  addAmbiguityResolution,
25  AmbiguityResolutionConfig,
26  addVertexFitting,
27  VertexFinder,
28  TrackSelectorConfig,
29 )
30 
31 from physmon_common import makeSetup
32 
33 u = acts.UnitConstants
34 
35 setup = makeSetup()
36 
37 
38 def run_vertexing(fitter, mu, events):
39  with tempfile.TemporaryDirectory() as temp:
41  events=events,
42  numThreads=-1,
43  logLevel=acts.logging.INFO,
45  Path(__file__).parent.parent / "fpe_masks.yml"
46  ),
47  )
48 
49  tp = Path(temp)
50 
51  for d in setup.decorators:
52  s.addContextDecorator(d)
53 
54  rnd = acts.examples.RandomNumbers(seed=42)
55 
57  s,
58  MomentumConfig(1.0 * u.GeV, 10.0 * u.GeV, transverse=True),
59  EtaConfig(-3.0, 3.0),
60  PhiConfig(0.0, 360.0 * u.degree),
61  ParticleConfig(4, acts.PdgParticle.eMuon, randomizeCharge=True),
62  vtxGen=acts.examples.GaussianVertexGenerator(
63  mean=acts.Vector4(0, 0, 0, 0),
64  stddev=acts.Vector4(
65  0.0125 * u.mm, 0.0125 * u.mm, 55.5 * u.mm, 1.0 * u.ns
66  ),
67  ),
68  multiplicity=mu,
69  rnd=rnd,
70  )
71 
72  addFatras(
73  s,
74  setup.trackingGeometry,
75  setup.field,
76  enableInteractions=True,
77  rnd=rnd,
78  )
79 
81  s,
82  setup.trackingGeometry,
83  setup.field,
84  digiConfigFile=setup.digiConfig,
85  rnd=rnd,
86  )
87 
88  addSeeding(
89  s,
90  setup.trackingGeometry,
91  setup.field,
93  r=(33 * u.mm, 200 * u.mm),
94  deltaR=(1 * u.mm, 60 * u.mm),
95  collisionRegion=(-250 * u.mm, 250 * u.mm),
96  z=(-2000 * u.mm, 2000 * u.mm),
97  maxSeedsPerSpM=1,
98  sigmaScattering=5,
99  radLengthPerSeed=0.1,
100  minPt=500 * u.MeV,
101  impactMax=3 * u.mm,
102  ),
103  SeedFinderOptionsArg(bFieldInZ=2 * u.T),
104  seedingAlgorithm=SeedingAlgorithm.Default,
105  geoSelectionConfigFile=setup.geoSel,
106  )
107 
108  addCKFTracks(
109  s,
110  setup.trackingGeometry,
111  setup.field,
113  loc0=(-4.0 * u.mm, 4.0 * u.mm),
114  pt=(500 * u.MeV, None),
115  nMeasurementsMin=6,
116  ),
117  )
118 
120  s,
121  AmbiguityResolutionConfig(maximumSharedHits=3),
122  )
123 
125  s,
126  setup.field,
127  vertexFinder=fitter,
128  outputDirRoot=tp,
129  )
130 
131  s.run()
132 
133  del s
134 
135  perf_file = tp / f"performance_vertexing.root"
136  assert perf_file.exists(), "Performance file not found"
137  shutil.copy(
138  perf_file,
139  setup.outdir / f"performance_vertexing_{fitter.name}_mu{mu}.root",
140  )
141 
142 
143 for fitter in (VertexFinder.Iterative, VertexFinder.AMVF):
144  for mu in (1, 10, 25, 50, 75, 100, 125, 150, 175, 200):
145  start = datetime.datetime.now()
146 
147  events = 5
148  run_vertexing(fitter, mu, events)
149 
150  delta = datetime.datetime.now() - start
151 
152  duration = delta.total_seconds() / events
153 
154  (
155  setup.outdir / f"performance_vertexing_{fitter.name}_mu{mu}_time.txt"
156  ).write_text(str(duration))