1 from pathlib
import Path
2 from typing
import Optional, Union, List
4 from collections
import namedtuple
10 u = acts.UnitConstants
12 SeedingAlgorithm = Enum(
14 "Default TruthSmeared TruthEstimated Orthogonal HoughTransform FTF",
17 TruthSeedRanges = namedtuple(
19 [
"rho",
"z",
"phi",
"eta",
"absEta",
"pt",
"nHits"],
20 defaults=[(
None,
None)] * 7,
23 ParticleSmearingSigmas = namedtuple(
24 "ParticleSmearingSigmas",
25 [
"d0",
"d0PtA",
"d0PtB",
"z0",
"z0PtA",
"z0PtB",
"t0",
"phi",
"theta",
"pRel"],
29 SeedFinderConfigArg = namedtuple(
39 "interactionPointCut",
44 "skipZMiddleBinSearch",
46 "useVariableMiddleSPRange",
49 "centralSeedConfirmationRange",
50 "forwardSeedConfirmationRange",
54 "deltaRMiddleSPRange",
60 defaults=[
None] * 19 + [(
None,
None)] * 8,
62 SeedFinderOptionsArg = namedtuple(
63 "SeedFinderOptions", [
"beamPos",
"bFieldInZ"], defaults=[(
None,
None),
None]
66 SeedFilterConfigArg = namedtuple(
70 "zOriginWeightFactor",
74 "seedWeightIncrement",
77 "maxQualitySeedsPerSpMConf",
78 "useDeltaRorTopRadius",
84 SpacePointGridConfigArg = namedtuple(
89 "phiBinDeflectionCoverage",
95 defaults=[
None] * 6 + [(
None,
None)] * 1,
98 SeedingAlgorithmConfigArg = namedtuple(
99 "SeedingAlgorithmConfig",
103 "zBinNeighborsBottom",
109 TruthEstimatedSeedingAlgorithmConfigArg = namedtuple(
114 defaults=[(
None,
None)],
117 TrackSelectorConfig = namedtuple(
118 "TrackSelectorConfig",
119 [
"loc0",
"loc1",
"time",
"eta",
"absEta",
"pt",
"phi",
"nMeasurementsMin"],
120 defaults=[(
None,
None)] * 7 + [
None],
123 CkfConfig = namedtuple(
125 [
"chi2CutOff",
"numMeasurementsCutOff",
"maxSteps"],
126 defaults=[15.0, 10,
None],
129 AmbiguityResolutionConfig = namedtuple(
130 "AmbiguityResolutionConfig",
131 [
"maximumSharedHits",
"nMeasurementsMin",
"maximumIterations"],
135 AmbiguityResolutionMLConfig = namedtuple(
136 "AmbiguityResolutionMLConfig",
137 [
"maximumSharedHits",
"nMeasurementsMin",
"maximumIterations"],
141 AmbiguityResolutionMLDBScanConfig = namedtuple(
142 "AmbiguityResolutionMLDBScanConfig",
143 [
"nMeasurementsMin",
"epsilonDBScan",
"minPointsDBScan"],
155 seedingAlgorithm=SeedingAlgorithm,
156 truthSeedRanges=TruthSeedRanges,
157 particleSmearingSigmas=ParticleSmearingSigmas,
158 seedFinderConfigArg=SeedFinderConfigArg,
159 seedFinderOptionsArg=SeedFinderOptionsArg,
160 seedFilterConfigArg=SeedFilterConfigArg,
161 spacePointGridConfigArg=SpacePointGridConfigArg,
162 seedingAlgorithmConfigArg=SeedingAlgorithmConfigArg,
163 truthEstimatedSeedingAlgorithmConfigArg=TruthEstimatedSeedingAlgorithmConfigArg,
164 logLevel=acts.logging.Level,
168 trackingGeometry: acts.TrackingGeometry,
169 field: acts.MagneticFieldProvider,
170 geoSelectionConfigFile: Optional[Union[Path, str]] =
None,
171 layerMappingConfigFile: Optional[Union[Path, str]] =
None,
172 fastrack_inputConfigFile: Optional[Union[Path, str]] =
None,
173 seedingAlgorithm: SeedingAlgorithm = SeedingAlgorithm.Default,
176 initialSigmas: Optional[list] =
None,
177 initialVarInflation: Optional[list] =
None,
183 houghTransformConfig: acts.examples.HoughTransformSeeder.Config = acts.examples.HoughTransformSeeder.Config(),
185 particleHypothesis: Optional[
186 acts.ParticleHypothesis
187 ] = acts.ParticleHypothesis.pion,
188 inputParticles: str =
"particles",
189 outputDirRoot: Optional[Union[Path, str]] =
None,
190 logLevel: Optional[acts.logging.Level] =
None,
191 rnd: Optional[acts.examples.RandomNumbers] =
None,
193 """This function steers the seeding
197 the sequencer module to which we add the Seeding steps (returned from addSeeding)
198 trackingGeometry : tracking geometry
199 field : magnetic field
200 geoSelectionConfigFile : Path|str, path, None
201 Json file for space point geometry selection. Not required for SeedingAlgorithm.TruthSmeared.
202 seedingAlgorithm : SeedingAlgorithm, Default
203 seeding algorithm to use: one of Default (no truth information used), TruthSmeared, TruthEstimated
204 truthSeedRanges : TruthSeedRanges(rho, z, phi, eta, absEta, pt, nHits)
205 TruthSeedSelector configuration. Each range is specified as a tuple of (min,max).
206 Defaults of no cuts specified in Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedSelector.hpp
207 If specified as None, don't run ParticleSmearing at all (and use addCKFTracks(selectedParticles="particles"))
208 particleSmearingSigmas : ParticleSmearingSigmas(d0, d0PtA, d0PtB, z0, z0PtA, z0PtB, t0, phi, theta, pRel)
209 ParticleSmearing configuration.
210 Defaults specified in Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSmearing.hpp
212 Sets the initial covariance matrix diagonal. This is ignored in case of TruthSmearing.
213 Defaults specified in Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackParamsEstimationAlgorithm.hpp
214 initialVarInflation : list
215 List of 6 scale factors to inflate the initial covariance matrix
216 Defaults (all 1) specified in Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSmearing.hpp
217 seedFinderConfigArg : SeedFinderConfigArg(maxSeedsPerSpM, cotThetaMax, sigmaScattering, radLengthPerSeed, minPt, impactMax, deltaPhiMax, interactionPointCut, deltaZMax, maxPtScattering, zBinEdges, zBinsCustomLooping, rRangeMiddleSP, useVariableMiddleSPRange, binSizeR, seedConfirmation, centralSeedConfirmationRange, forwardSeedConfirmationRange, deltaR, deltaRBottomSP, deltaRTopSP, deltaRMiddleSPRange, collisionRegion, r, z, zOutermostLayers)
218 Defaults specified in Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackParamsEstimationAlgorithm.hpp
219 seedFinderConfigArg : SeedFinderConfigArg(maxSeedsPerSpM, cotThetaMax, sigmaScattering, radLengthPerSeed, minPt, impactMax, deltaPhiMax, interactionPointCut, deltaZMax, maxPtScattering, zBinEdges, zBinsCustomLooping, skipZMiddleBinSearch, rRangeMiddleSP, useVariableMiddleSPRange, binSizeR, seedConfirmation, centralSeedConfirmationRange, forwardSeedConfirmationRange, deltaR, deltaRBottomSP, deltaRTopSP, deltaRMiddleSPRange, collisionRegion, r, z, zOutermostLayers)
220 SeedFinderConfig settings. deltaR, deltaRBottomSP, deltaRTopSP, deltaRMiddleSPRange, collisionRegion, r, z, zOutermostLayers are ranges specified as a tuple of (min,max). beamPos is specified as (x,y).
221 Defaults specified in Core/include/Acts/Seeding/SeedFinderConfig.hpp
222 seedFinderOptionsArg : SeedFinderOptionsArg(bFieldInZ, beamPos)
223 Defaults specified in Core/include/Acts/Seeding/SeedFinderConfig.hpp
224 seedFilterConfigArg : SeedFilterConfigArg(compatSeedWeight, compatSeedLimit, numSeedIncrement, seedWeightIncrement, seedConfirmation, maxSeedsPerSpMConf, maxQualitySeedsPerSpMConf, useDeltaRorTopRadius)
225 Defaults specified in Core/include/Acts/Seeding/SeedFilterConfig.hpp
226 spacePointGridConfigArg : SpacePointGridConfigArg(rMax, zBinEdges, phiBinDeflectionCoverage, phi, maxPhiBins, impactMax)
227 SpacePointGridConfigArg settings. phi is specified as a tuple of (min,max).
228 Defaults specified in Core/include/Acts/Seeding/SpacePointGrid.hpp
229 seedingAlgorithmConfigArg : SeedingAlgorithmConfigArg(allowSeparateRMax, zBinNeighborsTop, zBinNeighborsBottom, numPhiNeighbors)
230 Defaults specified in Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/SeedingAlgorithm.hpp
231 truthEstimatedSeedingAlgorithmConfigArg : TruthEstimatedSeedingAlgorithmConfigArg(deltaR)
232 Currently only deltaR=(min,max) range specified here.
233 particleHypothesis : Optional[acts.ParticleHypothesis]
234 The hypothesis used for track finding. Defaults to pion.
235 inputParticles : str, "particles"
236 input particles name in the WhiteBoard
237 outputDirRoot : Path|str, path, None
238 the output folder for the Root output, None triggers no output
239 logLevel : acts.logging.Level, None
240 logging level to override setting given in `s`
241 rnd : RandomNumbers, None
242 random number generator. Only used by SeedingAlgorithm.TruthSmeared.
246 logger = acts.logging.getLogger(
"addSeeding")
247 logger.setLevel(logLevel)
249 if truthSeedRanges
is not None:
250 selectedParticles =
"truth_seeds_selected"
259 selectedParticles = inputParticles
263 if seedingAlgorithm == SeedingAlgorithm.TruthSmeared:
264 logger.info(
"Using smeared truth particles for seeding")
269 particleSmearingSigmas,
277 s, trackingGeometry, geoSelectionConfigFile, logLevel
280 if seedingAlgorithm == SeedingAlgorithm.TruthEstimated:
281 logger.info(
"Using truth track finding from space points for seeding")
286 truthEstimatedSeedingAlgorithmConfigArg,
289 elif seedingAlgorithm == SeedingAlgorithm.Default:
290 logger.info(
"Using default seeding")
294 seedingAlgorithmConfigArg,
296 seedFinderOptionsArg,
298 spacePointGridConfigArg,
301 elif seedingAlgorithm == SeedingAlgorithm.Orthogonal:
302 logger.info(
"Using orthogonal seeding")
307 seedFinderOptionsArg,
311 elif seedingAlgorithm == SeedingAlgorithm.HoughTransform:
312 logger.info(
"Using Hough Transform seeding")
313 houghTransformConfig.inputSpacePoints = [spacePoints]
314 houghTransformConfig.inputMeasurements =
"measurements"
315 houghTransformConfig.inputSourceLinks =
"sourcelinks"
316 houghTransformConfig.outputProtoTracks =
"prototracks"
317 houghTransformConfig.outputSeeds =
"seeds"
318 houghTransformConfig.trackingGeometry = trackingGeometry
320 elif seedingAlgorithm == SeedingAlgorithm.FTF:
321 logger.info(
"Using FTF seeding")
327 seedFinderOptionsArg,
331 layerMappingConfigFile,
332 geoSelectionConfigFile,
333 fastrack_inputConfigFile,
336 logger.fatal(
"unknown seedingAlgorithm %s", seedingAlgorithm)
338 parEstimateAlg = acts.examples.TrackParamsEstimationAlgorithm(
341 outputTrackParameters=
"estimatedparameters",
342 trackingGeometry=trackingGeometry,
345 initialSigmas=initialSigmas,
346 initialVarInflation=initialVarInflation,
347 particleHypothesis=particleHypothesis,
350 s.addAlgorithm(parEstimateAlg)
352 prototracks =
"seed-prototracks"
354 acts.examples.SeedsToPrototracks(
357 outputProtoTracks=prototracks,
361 if outputDirRoot
is not None:
369 parEstimateAlg.config.outputTrackParameters,
379 outputParticles: str,
380 truthSeedRanges: TruthSeedRanges,
381 logLevel: acts.logging.Level =
None,
383 """adds truth particles filtering before filtering
384 For parameters description see addSeeding
386 selAlg = acts.examples.TruthSeedSelector(
388 ptMin=truthSeedRanges.pt[0],
389 ptMax=truthSeedRanges.pt[1],
390 etaMin=truthSeedRanges.eta[0],
391 etaMax=truthSeedRanges.eta[1],
392 nHitsMin=truthSeedRanges.nHits[0],
393 nHitsMax=truthSeedRanges.nHits[1],
394 rhoMin=truthSeedRanges.rho[0],
395 rhoMax=truthSeedRanges.rho[1],
396 zMin=truthSeedRanges.z[0],
397 zMax=truthSeedRanges.z[1],
398 phiMin=truthSeedRanges.phi[0],
399 phiMax=truthSeedRanges.phi[1],
400 absEtaMin=truthSeedRanges.absEta[0],
401 absEtaMax=truthSeedRanges.absEta[1],
404 inputParticles=inputParticles,
405 inputMeasurementParticlesMap=
"measurement_particles_map",
406 outputParticles=outputParticles,
408 s.addAlgorithm(selAlg)
413 rnd: Optional[acts.examples.RandomNumbers],
414 selectedParticles: str,
415 particleSmearingSigmas: ParticleSmearingSigmas,
416 initialSigmas: Optional[List[float]],
417 initialVarInflation: List[float],
418 particleHypothesis: Optional[acts.ParticleHypothesis],
419 logLevel: acts.logging.Level =
None,
421 """adds algorithm that would mimic detector response uncertainties for truth seeding
422 For parameters description see addSeeding
425 rnd = rnd
or acts.examples.RandomNumbers(seed=42)
427 ptclSmear = acts.examples.ParticleSmearing(
429 inputParticles=selectedParticles,
430 outputTrackParameters=
"estimatedparameters",
434 sigmaD0=particleSmearingSigmas.d0,
435 sigmaD0PtA=particleSmearingSigmas.d0PtA,
436 sigmaD0PtB=particleSmearingSigmas.d0PtB,
437 sigmaZ0=particleSmearingSigmas.z0,
438 sigmaZ0PtA=particleSmearingSigmas.z0PtA,
439 sigmaZ0PtB=particleSmearingSigmas.z0PtB,
440 sigmaT0=particleSmearingSigmas.t0,
441 sigmaPhi=particleSmearingSigmas.phi,
442 sigmaTheta=particleSmearingSigmas.theta,
443 sigmaPRel=particleSmearingSigmas.pRel,
444 initialSigmas=initialSigmas,
445 initialVarInflation=initialVarInflation,
446 particleHypothesis=particleHypothesis,
449 sequence.addAlgorithm(ptclSmear)
451 truthTrkFndAlg = acts.examples.TruthTrackFinder(
453 inputParticles=selectedParticles,
454 inputMeasurementParticlesMap=
"measurement_particles_map",
455 outputProtoTracks=
"truth_particle_tracks",
457 sequence.addAlgorithm(truthTrkFndAlg)
464 TruthEstimatedSeedingAlgorithmConfigArg: TruthEstimatedSeedingAlgorithmConfigArg,
465 logLevel: acts.logging.Level =
None,
467 """adds truth seeding
468 For parameters description see addSeeding
472 truthSeeding = acts.examples.TruthSeedingAlgorithm(
474 inputParticles=inputParticles,
475 inputMeasurementParticlesMap=
"measurement_particles_map",
476 inputSpacePoints=[spacePoints],
477 outputParticles=
"truth_seeded_particles",
478 outputProtoTracks=
"truth_particle_tracks",
481 deltaRMin=TruthEstimatedSeedingAlgorithmConfigArg.deltaR[0],
482 deltaRMax=TruthEstimatedSeedingAlgorithmConfigArg.deltaR[1],
485 sequence.addAlgorithm(truthSeeding)
487 return truthSeeding.config.outputSeeds
492 trackingGeometry: acts.TrackingGeometry,
493 geoSelectionConfigFile: Union[Path, str],
494 logLevel: acts.logging.Level =
None,
496 """adds space points making
497 For parameters description see addSeeding
500 spAlg = acts.examples.SpacePointMaker(
502 inputSourceLinks=
"sourcelinks",
503 inputMeasurements=
"measurements",
504 outputSpacePoints=
"spacepoints",
505 trackingGeometry=trackingGeometry,
506 geometrySelection=acts.examples.readJsonGeometryList(
507 str(geoSelectionConfigFile)
510 sequence.addAlgorithm(spAlg)
511 return spAlg.config.outputSpacePoints
517 seedingAlgorithmConfigArg: SeedingAlgorithmConfigArg,
518 seedFinderConfigArg: SeedFinderConfigArg,
519 seedFinderOptionsArg: SeedFinderOptionsArg,
520 seedFilterConfigArg: SeedFilterConfigArg,
521 spacePointGridConfigArg: SpacePointGridConfigArg,
522 logLevel: acts.logging.Level =
None,
524 """adds standard seeding
525 For parameters description see addSeeding
529 seedFinderConfig = acts.SeedFinderConfig(
531 rMin=seedFinderConfigArg.r[0],
532 rMax=seedFinderConfigArg.r[1],
533 deltaRMin=seedFinderConfigArg.deltaR[0],
534 deltaRMax=seedFinderConfigArg.deltaR[1],
536 seedFinderConfigArg.deltaR[0]
537 if seedFinderConfigArg.deltaRTopSP[0]
is None
538 else seedFinderConfigArg.deltaRTopSP[0]
541 seedFinderConfigArg.deltaR[1]
542 if seedFinderConfigArg.deltaRTopSP[1]
is None
543 else seedFinderConfigArg.deltaRTopSP[1]
546 seedFinderConfigArg.deltaR[0]
547 if seedFinderConfigArg.deltaRBottomSP[0]
is None
548 else seedFinderConfigArg.deltaRBottomSP[0]
551 seedFinderConfigArg.deltaR[1]
552 if seedFinderConfigArg.deltaRBottomSP[1]
is None
553 else seedFinderConfigArg.deltaRBottomSP[1]
555 deltaRMiddleMinSPRange=seedFinderConfigArg.deltaRMiddleSPRange[0],
556 deltaRMiddleMaxSPRange=seedFinderConfigArg.deltaRMiddleSPRange[1],
557 collisionRegionMin=seedFinderConfigArg.collisionRegion[0],
558 collisionRegionMax=seedFinderConfigArg.collisionRegion[1],
559 zMin=seedFinderConfigArg.z[0],
560 zMax=seedFinderConfigArg.z[1],
562 seedFinderConfigArg.zOutermostLayers[0]
563 if seedFinderConfigArg.zOutermostLayers[0]
is not None
564 else seedFinderConfigArg.z[0],
565 seedFinderConfigArg.zOutermostLayers[1]
566 if seedFinderConfigArg.zOutermostLayers[1]
is not None
567 else seedFinderConfigArg.z[1],
569 maxSeedsPerSpM=seedFinderConfigArg.maxSeedsPerSpM,
570 cotThetaMax=seedFinderConfigArg.cotThetaMax,
571 sigmaScattering=seedFinderConfigArg.sigmaScattering,
572 radLengthPerSeed=seedFinderConfigArg.radLengthPerSeed,
573 minPt=seedFinderConfigArg.minPt,
574 impactMax=seedFinderConfigArg.impactMax,
575 interactionPointCut=seedFinderConfigArg.interactionPointCut,
576 deltaZMax=seedFinderConfigArg.deltaZMax,
577 maxPtScattering=seedFinderConfigArg.maxPtScattering,
578 zBinEdges=seedFinderConfigArg.zBinEdges,
579 zBinsCustomLooping=seedFinderConfigArg.zBinsCustomLooping,
580 skipZMiddleBinSearch=seedFinderConfigArg.skipZMiddleBinSearch,
581 rRangeMiddleSP=seedFinderConfigArg.rRangeMiddleSP,
582 useVariableMiddleSPRange=seedFinderConfigArg.useVariableMiddleSPRange,
583 binSizeR=seedFinderConfigArg.binSizeR,
584 seedConfirmation=seedFinderConfigArg.seedConfirmation,
585 centralSeedConfirmationRange=seedFinderConfigArg.centralSeedConfirmationRange,
586 forwardSeedConfirmationRange=seedFinderConfigArg.forwardSeedConfirmationRange,
589 seedFinderOptions = acts.SeedFinderOptions(
591 beamPos=acts.Vector2(0.0, 0.0)
592 if seedFinderOptionsArg.beamPos == (
None,
None)
594 seedFinderOptionsArg.beamPos[0], seedFinderOptionsArg.beamPos[1]
596 bFieldInZ=seedFinderOptionsArg.bFieldInZ,
599 seedFilterConfig = acts.SeedFilterConfig(
601 maxSeedsPerSpM=seedFinderConfig.maxSeedsPerSpM,
603 seedFinderConfig.deltaRMin
604 if seedFilterConfigArg.deltaRMin
is None
605 else seedFilterConfigArg.deltaRMin
607 impactWeightFactor=seedFilterConfigArg.impactWeightFactor,
608 zOriginWeightFactor=seedFilterConfigArg.zOriginWeightFactor,
609 compatSeedWeight=seedFilterConfigArg.compatSeedWeight,
610 compatSeedLimit=seedFilterConfigArg.compatSeedLimit,
611 numSeedIncrement=seedFilterConfigArg.numSeedIncrement,
612 seedWeightIncrement=seedFilterConfigArg.seedWeightIncrement,
613 seedConfirmation=seedFilterConfigArg.seedConfirmation,
614 centralSeedConfirmationRange=seedFinderConfig.centralSeedConfirmationRange,
615 forwardSeedConfirmationRange=seedFinderConfig.forwardSeedConfirmationRange,
616 maxSeedsPerSpMConf=seedFilterConfigArg.maxSeedsPerSpMConf,
617 maxQualitySeedsPerSpMConf=seedFilterConfigArg.maxQualitySeedsPerSpMConf,
618 useDeltaRorTopRadius=seedFilterConfigArg.useDeltaRorTopRadius,
622 gridConfig = acts.SpacePointGridConfig(
624 minPt=seedFinderConfig.minPt,
626 seedFinderConfig.rMax
627 if spacePointGridConfigArg.rMax
is None
628 else spacePointGridConfigArg.rMax
630 zMax=seedFinderConfig.zMax,
631 zMin=seedFinderConfig.zMin,
633 seedFinderConfig.deltaRMax
634 if spacePointGridConfigArg.deltaRMax
is None
635 else spacePointGridConfigArg.deltaRMax
637 cotThetaMax=seedFinderConfig.cotThetaMax,
638 phiMin=spacePointGridConfigArg.phi[0],
639 phiMax=spacePointGridConfigArg.phi[1],
640 maxPhiBins=spacePointGridConfigArg.maxPhiBins,
641 impactMax=spacePointGridConfigArg.impactMax,
642 zBinEdges=spacePointGridConfigArg.zBinEdges,
643 phiBinDeflectionCoverage=spacePointGridConfigArg.phiBinDeflectionCoverage,
647 gridOptions = acts.SpacePointGridOptions(
649 bFieldInZ=seedFinderOptions.bFieldInZ,
653 seedingAlg = acts.examples.SeedingAlgorithm(
655 inputSpacePoints=[spacePoints],
658 allowSeparateRMax=seedingAlgorithmConfigArg.allowSeparateRMax,
659 zBinNeighborsTop=seedingAlgorithmConfigArg.zBinNeighborsTop,
660 zBinNeighborsBottom=seedingAlgorithmConfigArg.zBinNeighborsBottom,
661 numPhiNeighbors=seedingAlgorithmConfigArg.numPhiNeighbors,
663 gridConfig=gridConfig,
664 gridOptions=gridOptions,
665 seedFilterConfig=seedFilterConfig,
666 seedFinderConfig=seedFinderConfig,
667 seedFinderOptions=seedFinderOptions,
669 sequence.addAlgorithm(seedingAlg)
671 return seedingAlg.config.outputSeeds
677 seedFinderConfigArg: SeedFinderConfigArg,
678 seedFinderOptionsArg: SeedFinderOptionsArg,
679 seedFilterConfigArg: SeedFilterConfigArg,
680 logLevel: acts.logging.Level =
None,
682 """adds orthogonal seeding algorithm
683 For parameters description see addSeeding
686 seedFinderConfig = acts.SeedFinderOrthogonalConfig(
688 rMin=seedFinderConfigArg.r[0],
689 rMax=seedFinderConfigArg.r[1],
691 seedFinderConfigArg.deltaR[0]
692 if seedFinderConfigArg.deltaRTopSP[0]
is None
693 else seedFinderConfigArg.deltaRTopSP[0]
696 seedFinderConfigArg.deltaR[1]
697 if seedFinderConfigArg.deltaRTopSP[1]
is None
698 else seedFinderConfigArg.deltaRTopSP[1]
701 seedFinderConfigArg.deltaR[0]
702 if seedFinderConfigArg.deltaRBottomSP[0]
is None
703 else seedFinderConfigArg.deltaRBottomSP[0]
706 seedFinderConfigArg.deltaR[1]
707 if seedFinderConfigArg.deltaRBottomSP[1]
is None
708 else seedFinderConfigArg.deltaRBottomSP[1]
710 collisionRegionMin=seedFinderConfigArg.collisionRegion[0],
711 collisionRegionMax=seedFinderConfigArg.collisionRegion[1],
712 zMin=seedFinderConfigArg.z[0],
713 zMax=seedFinderConfigArg.z[1],
715 seedFinderConfigArg.zOutermostLayers[0]
716 if seedFinderConfigArg.zOutermostLayers[0]
is not None
717 else seedFinderConfigArg.z[0],
718 seedFinderConfigArg.zOutermostLayers[1]
719 if seedFinderConfigArg.zOutermostLayers[1]
is not None
720 else seedFinderConfigArg.z[1],
722 maxSeedsPerSpM=seedFinderConfigArg.maxSeedsPerSpM,
723 cotThetaMax=seedFinderConfigArg.cotThetaMax,
724 sigmaScattering=seedFinderConfigArg.sigmaScattering,
725 radLengthPerSeed=seedFinderConfigArg.radLengthPerSeed,
726 minPt=seedFinderConfigArg.minPt,
727 impactMax=seedFinderConfigArg.impactMax,
728 deltaPhiMax=seedFinderConfigArg.deltaPhiMax,
729 interactionPointCut=seedFinderConfigArg.interactionPointCut,
730 deltaZMax=seedFinderConfigArg.deltaZMax,
731 maxPtScattering=seedFinderConfigArg.maxPtScattering,
732 rRangeMiddleSP=seedFinderConfigArg.rRangeMiddleSP,
733 useVariableMiddleSPRange=seedFinderConfigArg.useVariableMiddleSPRange,
734 seedConfirmation=seedFinderConfigArg.seedConfirmation,
735 centralSeedConfirmationRange=seedFinderConfigArg.centralSeedConfirmationRange,
736 forwardSeedConfirmationRange=seedFinderConfigArg.forwardSeedConfirmationRange,
739 seedFinderOptions = acts.SeedFinderOptions(
741 beamPos=acts.Vector2(0.0, 0.0)
742 if seedFinderOptionsArg.beamPos == (
None,
None)
744 seedFinderOptionsArg.beamPos[0], seedFinderOptionsArg.beamPos[1]
746 bFieldInZ=seedFinderOptionsArg.bFieldInZ,
749 seedFilterConfig = acts.SeedFilterConfig(
751 maxSeedsPerSpM=seedFinderConfig.maxSeedsPerSpM,
753 seedFinderConfigArg.deltaR[0]
754 if seedFilterConfigArg.deltaRMin
is None
755 else seedFilterConfigArg.deltaRMin
757 impactWeightFactor=seedFilterConfigArg.impactWeightFactor,
758 zOriginWeightFactor=seedFilterConfigArg.zOriginWeightFactor,
759 compatSeedWeight=seedFilterConfigArg.compatSeedWeight,
760 compatSeedLimit=seedFilterConfigArg.compatSeedLimit,
761 numSeedIncrement=seedFilterConfigArg.numSeedIncrement,
762 seedWeightIncrement=seedFilterConfigArg.seedWeightIncrement,
763 seedConfirmation=seedFilterConfigArg.seedConfirmation,
764 maxSeedsPerSpMConf=seedFilterConfigArg.maxSeedsPerSpMConf,
765 maxQualitySeedsPerSpMConf=seedFilterConfigArg.maxQualitySeedsPerSpMConf,
766 useDeltaRorTopRadius=seedFilterConfigArg.useDeltaRorTopRadius,
769 seedingAlg = acts.examples.SeedingOrthogonalAlgorithm(
771 inputSpacePoints=[spacePoints],
773 seedFilterConfig=seedFilterConfig,
774 seedFinderConfig=seedFinderConfig,
775 seedFinderOptions=seedFinderOptions,
777 sequence.addAlgorithm(seedingAlg)
779 return seedingAlg.config.outputSeeds
784 config: acts.examples.HoughTransformSeeder.Config,
785 logLevel: acts.logging.Level =
None,
788 Configures HoughTransform (HT) for seeding, instead of extra proxy config objects it takes
789 directly the HT example algorithm config.
792 ht = acts.examples.HoughTransformSeeder(config=config, level=logLevel)
793 sequence.addAlgorithm(ht)
796 return ht.config.outputSeeds
802 seedFinderConfigArg: SeedFinderConfigArg,
803 seedFinderOptionsArg: SeedFinderOptionsArg,
804 seedFilterConfigArg: SeedFilterConfigArg,
805 trackingGeometry: acts.TrackingGeometry,
806 logLevel: acts.logging.Level =
None,
807 layerMappingConfigFile: Union[Path, str] =
None,
808 geoSelectionConfigFile: Union[Path, str] =
None,
809 fastrack_inputConfigFile: Union[Path, str] =
None,
814 layerMappingFile =
str(layerMappingConfigFile)
815 fastrack_inputFile =
str(fastrack_inputConfigFile)
816 seedFinderConfig = acts.SeedFinderFTFConfig(
818 sigmaScattering=seedFinderConfigArg.sigmaScattering,
819 maxSeedsPerSpM=seedFinderConfigArg.maxSeedsPerSpM,
820 minPt=seedFinderConfigArg.minPt,
821 fastrack_input_file=fastrack_inputFile,
822 m_useClusterWidth=
False,
825 seedFinderOptions = acts.SeedFinderOptions(
827 beamPos=acts.Vector2(0.0, 0.0)
828 if seedFinderOptionsArg.beamPos == (
None,
None)
830 seedFinderOptionsArg.beamPos[0], seedFinderOptionsArg.beamPos[1]
832 bFieldInZ=seedFinderOptionsArg.bFieldInZ,
835 seedFilterConfig = acts.SeedFilterConfig(
837 maxSeedsPerSpM=seedFinderConfig.maxSeedsPerSpM,
839 seedFinderConfigArg.deltaR[0]
840 if seedFilterConfigArg.deltaRMin
is None
841 else seedFilterConfigArg.deltaRMin
843 impactWeightFactor=seedFilterConfigArg.impactWeightFactor,
844 zOriginWeightFactor=seedFilterConfigArg.zOriginWeightFactor,
845 compatSeedWeight=seedFilterConfigArg.compatSeedWeight,
846 compatSeedLimit=seedFilterConfigArg.compatSeedLimit,
847 numSeedIncrement=seedFilterConfigArg.numSeedIncrement,
848 seedWeightIncrement=seedFilterConfigArg.seedWeightIncrement,
849 seedConfirmation=seedFilterConfigArg.seedConfirmation,
851 maxSeedsPerSpMConf=seedFilterConfigArg.maxSeedsPerSpMConf,
852 maxQualitySeedsPerSpMConf=seedFilterConfigArg.maxQualitySeedsPerSpMConf,
853 useDeltaRorTopRadius=seedFilterConfigArg.useDeltaRorTopRadius,
857 seedingAlg = acts.examples.SeedingFTFAlgorithm(
859 inputSpacePoints=[spacePoints],
861 seedFilterConfig=seedFilterConfig,
862 seedFinderConfig=seedFinderConfig,
863 seedFinderOptions=seedFinderOptions,
864 layerMappingFile=layerMappingFile,
865 geometrySelection=acts.examples.readJsonGeometryList(
866 str(geoSelectionConfigFile)
868 inputSourceLinks=
"sourcelinks",
869 trackingGeometry=trackingGeometry,
870 fill_module_csv=
False,
873 sequence.addAlgorithm(seedingAlg)
874 return seedingAlg.config.outputSeeds
879 outputDirRoot: Union[Path, str],
882 selectedParticles: str,
884 outputTrackParameters: str,
885 logLevel: acts.logging.Level =
None,
887 """Writes seeding related performance output"""
889 outputDirRoot = Path(outputDirRoot)
890 if not outputDirRoot.exists():
891 outputDirRoot.mkdir()
894 acts.examples.SeedingPerformanceWriter(
895 level=customLogLevel(minLevel=acts.logging.DEBUG),
897 inputParticles=selectedParticles,
898 inputMeasurementParticlesMap=
"measurement_particles_map",
899 filePath=
str(outputDirRoot /
"performance_seeding.root"),
904 acts.examples.RootTrackParameterWriter(
905 level=customLogLevel(),
906 inputTrackParameters=outputTrackParameters,
907 inputProtoTracks=prototracks,
908 inputParticles=inputParticles,
909 inputSimHits=
"simhits",
910 inputMeasurementParticlesMap=
"measurement_particles_map",
911 inputMeasurementSimHitsMap=
"measurement_simhits_map",
912 filePath=
str(outputDirRoot /
"estimatedparams.root"),
913 treeName=
"estimatedparams",
920 trackingGeometry: acts.TrackingGeometry,
921 field: acts.MagneticFieldProvider,
922 directNavigation: bool =
False,
923 reverseFilteringMomThreshold: float = 0 * u.GeV,
924 inputProtoTracks: str =
"truth_particle_tracks",
925 multipleScattering: bool =
True,
926 energyLoss: bool =
True,
927 clusters: str =
None,
928 calibrator: acts.examples.MeasurementCalibrator = acts.examples.makePassThroughCalibrator(),
929 logLevel: Optional[acts.logging.Level] =
None,
934 srfSortAlg = acts.examples.SurfaceSortingAlgorithm(
935 level=customLogLevel(),
936 inputProtoTracks=inputProtoTracks,
937 inputSimHits=
"simhits",
938 inputMeasurementSimHitsMap=
"measurement_simhits_map",
939 outputProtoTracks=
"sorted_truth_particle_tracks",
941 s.addAlgorithm(srfSortAlg)
942 inputProtoTracks = srfSortAlg.config.outputProtoTracks
945 "multipleScattering": multipleScattering,
946 "energyLoss": energyLoss,
947 "reverseFilteringMomThreshold": reverseFilteringMomThreshold,
948 "freeToBoundCorrection": acts.examples.FreeToBoundCorrection(
False),
949 "level": customLogLevel(),
952 fitAlg = acts.examples.TrackFittingAlgorithm(
953 level=customLogLevel(),
954 inputMeasurements=
"measurements",
955 inputSourceLinks=
"sourcelinks",
956 inputProtoTracks=inputProtoTracks,
957 inputInitialTrackParameters=
"estimatedparameters",
958 inputClusters=clusters
if clusters
is not None else "",
959 outputTracks=
"kfTracks",
961 fit=acts.examples.makeKalmanFitterFunction(
962 trackingGeometry, field, **kalmanOptions
964 calibrator=calibrator,
966 s.addAlgorithm(fitAlg)
967 s.addWhiteboardAlias(
"tracks", fitAlg.config.outputTracks)
969 trackConverter = acts.examples.TracksToTrajectories(
970 level=customLogLevel(),
971 inputTracks=fitAlg.config.outputTracks,
972 outputTrajectories=
"kfTrajectories",
974 s.addAlgorithm(trackConverter)
975 s.addWhiteboardAlias(
"trajectories", trackConverter.config.outputTrajectories)
982 trackingGeometry: acts.TrackingGeometry,
983 field: acts.MagneticFieldProvider,
984 inputProtoTracks: str =
"truth_particle_tracks",
985 logLevel: Optional[acts.logging.Level] =
None,
990 "betheHeitlerApprox": acts.examples.AtlasBetheHeitlerApprox.makeDefault(),
992 "abortOnError":
False,
993 "disableAllMaterialHandling":
False,
994 "finalReductionMethod": acts.examples.FinalReductionMethod.maxWeight,
995 "weightCutoff": 1.0e-4,
996 "level": customLogLevel(),
999 gsfAlg = acts.examples.TrackFittingAlgorithm(
1000 level=customLogLevel(),
1001 inputMeasurements=
"measurements",
1002 inputSourceLinks=
"sourcelinks",
1003 inputProtoTracks=inputProtoTracks,
1004 inputInitialTrackParameters=
"estimatedparameters",
1005 outputTracks=
"gsf_tracks",
1007 fit=acts.examples.makeGsfFitterFunction(trackingGeometry, field, **gsfOptions),
1008 calibrator=acts.examples.makePassThroughCalibrator(),
1010 s.addAlgorithm(gsfAlg)
1011 s.addWhiteboardAlias(
"tracks", gsfAlg.config.outputTracks)
1013 trackConverter = acts.examples.TracksToTrajectories(
1014 level=customLogLevel(),
1015 inputTracks=gsfAlg.config.outputTracks,
1016 outputTrajectories=
"gsf_trajectories",
1018 s.addAlgorithm(trackConverter)
1024 trackSelectorConfig=TrackSelectorConfig,
1025 ckfConfig=CkfConfig,
1029 trackingGeometry: acts.TrackingGeometry,
1030 field: acts.MagneticFieldProvider,
1031 trackSelectorConfig: Optional[TrackSelectorConfig] =
None,
1033 outputDirCsv: Optional[Union[Path, str]] =
None,
1034 outputDirRoot: Optional[Union[Path, str]] =
None,
1035 writeTrajectories: bool =
True,
1036 logLevel: Optional[acts.logging.Level] =
None,
1039 """This function steers the seeding
1044 the sequencer module to which we add the Seeding steps (returned from addSeeding)
1045 trackingGeometry : tracking geometry
1046 field : magnetic field
1047 outputDirCsv : Path|str, path, None
1048 the output folder for the Csv output, None triggers no output
1049 outputDirRoot : Path|str, path, None
1050 the output folder for the Root output, None triggers no output
1051 trackSelectorConfig : TrackSelectorConfig(loc0, loc1, time, eta, absEta, pt, phi, minMeasurements)
1052 TrackSelector configuration. Each range is specified as a tuple of (min,max).
1053 Defaults of no cuts specified in Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackSelector.hpp
1054 writeTrajectories : bool, True
1055 write trackstates_ckf.root and tracksummary_ckf.root ntuples? These can be quite large.
1063 trackFinder = acts.examples.TrackFindingAlgorithm(
1064 level=customLogLevel(),
1065 measurementSelectorCfg=acts.MeasurementSelector.Config(
1068 acts.GeometryIdentifier(),
1071 [ckfConfig.chi2CutOff],
1072 [ckfConfig.numMeasurementsCutOff],
1077 trackSelectorCfg=acts.TrackSelector.Config(
1079 loc0Min=trackSelectorConfig.loc0[0],
1080 loc0Max=trackSelectorConfig.loc0[1],
1081 loc1Min=trackSelectorConfig.loc1[0],
1082 loc1Max=trackSelectorConfig.loc1[1],
1083 timeMin=trackSelectorConfig.time[0],
1084 timeMax=trackSelectorConfig.time[1],
1085 phiMin=trackSelectorConfig.phi[0],
1086 phiMax=trackSelectorConfig.phi[1],
1087 etaMin=trackSelectorConfig.eta[0],
1088 etaMax=trackSelectorConfig.eta[1],
1089 absEtaMin=trackSelectorConfig.absEta[0],
1090 absEtaMax=trackSelectorConfig.absEta[1],
1091 ptMin=trackSelectorConfig.pt[0],
1092 ptMax=trackSelectorConfig.pt[1],
1093 minMeasurements=trackSelectorConfig.nMeasurementsMin,
1096 if trackSelectorConfig
is not None
1098 inputMeasurements=
"measurements",
1099 inputSourceLinks=
"sourcelinks",
1100 inputInitialTrackParameters=
"estimatedparameters",
1101 outputTracks=
"ckfTracks",
1102 findTracks=acts.examples.TrackFindingAlgorithm.makeTrackFinderFunction(
1103 trackingGeometry, field, customLogLevel()
1106 maxSteps=ckfConfig.maxSteps,
1109 s.addAlgorithm(trackFinder)
1110 s.addWhiteboardAlias(
"tracks", trackFinder.config.outputTracks)
1112 trackConverter = acts.examples.TracksToTrajectories(
1113 level=customLogLevel(),
1114 inputTracks=trackFinder.config.outputTracks,
1115 outputTrajectories=
"trajectories-from-tracks",
1117 s.addAlgorithm(trackConverter)
1118 s.addWhiteboardAlias(
"trajectories", trackConverter.config.outputTrajectories)
1123 trajectories=
"trajectories",
1124 outputDirCsv=outputDirCsv,
1125 outputDirRoot=outputDirRoot,
1126 writeStates=writeTrajectories,
1127 writeSummary=writeTrajectories,
1128 writeCKFperformance=
True,
1129 writeFinderPerformance=
False,
1130 writeFitterPerformance=
False,
1132 writeCovMat=writeCovMat,
1140 trackingGeometry: acts.TrackingGeometry,
1141 field: acts.MagneticFieldProvider,
1143 inputProtoTracks: str =
"truth_particle_tracks",
1144 multipleScattering: bool =
False,
1145 energyLoss: bool =
False,
1146 clusters: str =
None,
1147 calibrator: acts.examples.MeasurementCalibrator = acts.examples.makePassThroughCalibrator(),
1148 logLevel: Optional[acts.logging.Level] =
None,
1153 "multipleScattering": multipleScattering,
1154 "energyLoss": energyLoss,
1155 "freeToBoundCorrection": acts.examples.FreeToBoundCorrection(
False),
1156 "level": customLogLevel(),
1159 fitAlg = acts.examples.TrackFittingAlgorithm(
1160 level=customLogLevel(),
1161 inputMeasurements=
"measurements",
1162 inputSourceLinks=
"sourcelinks",
1163 inputProtoTracks=inputProtoTracks,
1164 inputInitialTrackParameters=
"estimatedparameters",
1165 inputClusters=clusters
if clusters
is not None else "",
1166 outputTracks=
"gx2fTracks",
1168 fit=acts.examples.makeGlobalChiSquareFitterFunction(
1169 trackingGeometry, field, **gx2fOptions
1171 calibrator=calibrator,
1173 s.addAlgorithm(fitAlg)
1174 s.addWhiteboardAlias(
"tracks", fitAlg.config.outputTracks)
1176 trackConverter = acts.examples.TracksToTrajectories(
1177 level=customLogLevel(),
1178 inputTracks=fitAlg.config.outputTracks,
1179 outputTrajectories=
"gx2fTrajectories",
1181 s.addAlgorithm(trackConverter)
1182 s.addWhiteboardAlias(
"trajectories", trackConverter.config.outputTrajectories)
1190 trajectories: str =
"trajectories",
1191 outputDirCsv: Optional[Union[Path, str]] =
None,
1192 outputDirRoot: Optional[Union[Path, str]] =
None,
1193 writeStates: bool =
True,
1194 writeSummary: bool =
True,
1195 writeCKFperformance: bool =
True,
1196 writeFinderPerformance: bool =
True,
1197 writeFitterPerformance: bool =
True,
1198 logLevel: Optional[acts.logging.Level] =
None,
1203 if outputDirRoot
is not None:
1204 outputDirRoot = Path(outputDirRoot)
1205 if not outputDirRoot.exists():
1206 outputDirRoot.mkdir()
1210 trackStatesWriter = acts.examples.RootTrajectoryStatesWriter(
1211 level=customLogLevel(),
1212 inputTrajectories=trajectories,
1217 inputParticles=
"particles_selected",
1218 inputSimHits=
"simhits",
1219 inputMeasurementParticlesMap=
"measurement_particles_map",
1220 inputMeasurementSimHitsMap=
"measurement_simhits_map",
1221 filePath=
str(outputDirRoot / f
"trackstates_{name}.root"),
1222 treeName=
"trackstates",
1224 s.addWriter(trackStatesWriter)
1228 trackSummaryWriter = acts.examples.RootTrajectorySummaryWriter(
1229 level=customLogLevel(),
1230 inputTrajectories=trajectories,
1235 inputParticles=
"particles_selected",
1236 inputMeasurementParticlesMap=
"measurement_particles_map",
1237 filePath=
str(outputDirRoot / f
"tracksummary_{name}.root"),
1238 treeName=
"tracksummary",
1239 writeCovMat=writeCovMat,
1241 s.addWriter(trackSummaryWriter)
1243 if writeCKFperformance:
1245 ckfPerfWriter = acts.examples.CKFPerformanceWriter(
1246 level=customLogLevel(),
1247 inputParticles=
"truth_seeds_selected",
1248 inputTrajectories=trajectories,
1249 inputMeasurementParticlesMap=
"measurement_particles_map",
1250 filePath=
str(outputDirRoot / f
"performance_{name}.root"),
1252 s.addWriter(ckfPerfWriter)
1254 if writeFinderPerformance:
1256 acts.examples.TrackFinderPerformanceWriter(
1257 level=acts.logging.INFO,
1258 inputProtoTracks=
"prototracks",
1259 inputParticles=
"truth_seeds_selected",
1260 inputMeasurementParticlesMap=
"measurement_particles_map",
1262 outputDirRoot / f
"performance_track_finder_{name}.root"
1267 if writeFitterPerformance:
1269 acts.examples.TrackFitterPerformanceWriter(
1270 level=acts.logging.INFO,
1271 inputParticles=
"truth_seeds_selected",
1272 inputTrajectories=
"trajectories",
1273 inputMeasurementParticlesMap=
"measurement_particles_map",
1275 outputDirRoot / f
"performance_track_fitter_{name}.root"
1280 if outputDirCsv
is not None:
1281 outputDirCsv = Path(outputDirCsv)
1282 if not outputDirCsv.exists():
1283 outputDirCsv.mkdir()
1286 csvMTJWriter = acts.examples.CsvMultiTrajectoryWriter(
1287 level=customLogLevel(),
1288 inputTrajectories=trajectories,
1289 inputMeasurementParticlesMap=
"measurement_particles_map",
1290 outputDir=
str(outputDirCsv),
1291 fileName=
str(f
"tracks_{name}.csv"),
1293 s.addWriter(csvMTJWriter)
1297 trackSelectorConfig=TrackSelectorConfig,
1301 trackSelectorConfig: TrackSelectorConfig,
1304 logLevel: Optional[acts.logging.Level] =
None,
1305 ) -> acts.examples.TrackSelectorAlgorithm:
1309 selectorConfig = acts.TrackSelector.Config(
1311 loc0Min=trackSelectorConfig.loc0[0],
1312 loc0Max=trackSelectorConfig.loc0[1],
1313 loc1Min=trackSelectorConfig.loc1[0],
1314 loc1Max=trackSelectorConfig.loc1[1],
1315 timeMin=trackSelectorConfig.time[0],
1316 timeMax=trackSelectorConfig.time[1],
1317 phiMin=trackSelectorConfig.phi[0],
1318 phiMax=trackSelectorConfig.phi[1],
1319 etaMin=trackSelectorConfig.eta[0],
1320 etaMax=trackSelectorConfig.eta[1],
1321 absEtaMin=trackSelectorConfig.absEta[0],
1322 absEtaMax=trackSelectorConfig.absEta[1],
1323 ptMin=trackSelectorConfig.pt[0],
1324 ptMax=trackSelectorConfig.pt[1],
1325 minMeasurements=trackSelectorConfig.nMeasurementsMin,
1329 trackSelector = acts.examples.TrackSelectorAlgorithm(
1330 level=customLogLevel(),
1331 inputTracks=inputTracks,
1332 outputTracks=outputTracks,
1333 selectorConfig=selectorConfig,
1336 s.addAlgorithm(trackSelector)
1338 return trackSelector
1341 ExaTrkXBackend = Enum(
"ExaTrkXBackend",
"Torch Onnx")
1346 trackingGeometry: acts.TrackingGeometry,
1347 geometrySelection: Union[Path, str],
1348 modelDir: Union[Path, str],
1349 outputDirRoot: Optional[Union[Path, str]] =
None,
1350 backend: Optional[ExaTrkXBackend] = ExaTrkXBackend.Torch,
1351 logLevel: Optional[acts.logging.Level] =
None,
1360 acts.examples.TruthSeedSelector(
1361 level=customLogLevel(),
1364 inputParticles=
"particles_initial",
1365 inputMeasurementParticlesMap=
"measurement_particles_map",
1366 outputParticles=
"particles_seed_selected",
1372 acts.examples.SpacePointMaker(
1373 level=customLogLevel(),
1374 inputSourceLinks=
"sourcelinks",
1375 inputMeasurements=
"measurements",
1376 outputSpacePoints=
"spacepoints",
1377 trackingGeometry=trackingGeometry,
1378 geometrySelection=acts.examples.readJsonGeometryList(
1379 str(geometrySelection)
1384 metricLearningConfig = {
1385 "level": customLogLevel(),
1392 "level": customLogLevel(),
1397 "level": customLogLevel(),
1401 if backend == ExaTrkXBackend.Torch:
1402 metricLearningConfig[
"modelPath"] =
str(modelDir /
"embed.pt")
1403 metricLearningConfig[
"numFeatures"] = 3
1404 filterConfig[
"modelPath"] =
str(modelDir /
"filter.pt")
1405 filterConfig[
"nChunks"] = 10
1406 filterConfig[
"numFeatures"] = 3
1407 gnnConfig[
"modelPath"] =
str(modelDir /
"gnn.pt")
1408 gnnConfig[
"undirected"] =
True
1409 gnnConfig[
"numFeatures"] = 3
1411 graphConstructor = acts.examples.TorchMetricLearning(**metricLearningConfig)
1413 acts.examples.TorchEdgeClassifier(**filterConfig),
1414 acts.examples.TorchEdgeClassifier(**gnnConfig),
1416 trackBuilder = acts.examples.BoostTrackBuilding(customLogLevel())
1417 elif backend == ExaTrkXBackend.Onnx:
1418 metricLearningConfig[
"modelPath"] =
str(modelDir /
"embedding.onnx")
1419 metricLearningConfig[
"spacepointFeatures"] = 3
1420 filterConfig[
"modelPath"] =
str(modelDir /
"filtering.onnx")
1421 gnnConfig[
"modelPath"] =
str(modelDir /
"gnn.onnx")
1423 graphConstructor = acts.examples.OnnxMetricLearning(**metricLearningConfig)
1425 acts.examples.OnnxEdgeClassifier(**filterConfig),
1426 acts.examples.OnnxEdgeClassifier(**gnnConfig),
1428 trackBuilder = acts.examples.CugraphTrackBuilding(customLogLevel())
1431 acts.examples.TrackFindingAlgorithmExaTrkX(
1432 level=customLogLevel(),
1433 inputSpacePoints=
"spacepoints",
1434 outputProtoTracks=
"protoTracks",
1435 graphConstructor=graphConstructor,
1436 edgeClassifiers=edgeClassifiers,
1437 trackBuilder=trackBuilder,
1442 if outputDirRoot
is not None:
1444 acts.examples.TrackFinderPerformanceWriter(
1445 level=customLogLevel(),
1446 inputProtoTracks=
"protoTracks",
1447 inputParticles=
"particles_initial",
1448 inputMeasurementParticlesMap=
"measurement_particles_map",
1449 filePath=
str(Path(outputDirRoot) /
"performance_track_finding.root"),
1457 config=AmbiguityResolutionConfig,
1462 outputDirCsv: Optional[Union[Path, str]] =
None,
1463 outputDirRoot: Optional[Union[Path, str]] =
None,
1464 writeTrajectories: bool =
True,
1465 logLevel: Optional[acts.logging.Level] =
None,
1468 from acts.examples import GreedyAmbiguityResolutionAlgorithm
1472 alg = GreedyAmbiguityResolutionAlgorithm(
1473 level=customLogLevel(),
1474 inputTracks=
"tracks",
1475 outputTracks=
"ambiTracks",
1477 maximumSharedHits=config.maximumSharedHits,
1478 nMeasurementsMin=config.nMeasurementsMin,
1479 maximumIterations=config.maximumIterations,
1484 trackConverter = acts.examples.TracksToTrajectories(
1485 level=customLogLevel(),
1486 inputTracks=alg.config.outputTracks,
1487 outputTrajectories=
"ambiTrajectories",
1489 s.addAlgorithm(trackConverter)
1490 s.addWhiteboardAlias(
"trajectories", trackConverter.config.outputTrajectories)
1495 trajectories=
"trajectories",
1496 outputDirCsv=outputDirCsv,
1497 outputDirRoot=outputDirRoot,
1498 writeStates=writeTrajectories,
1499 writeSummary=writeTrajectories,
1500 writeCKFperformance=
True,
1501 writeFinderPerformance=
False,
1502 writeFitterPerformance=
False,
1504 writeCovMat=writeCovMat,
1511 config=AmbiguityResolutionMLConfig,
1516 onnxModelFile: Optional[Union[Path, str]] =
None,
1517 outputDirCsv: Optional[Union[Path, str]] =
None,
1518 outputDirRoot: Optional[Union[Path, str]] =
None,
1519 writeTrajectories: bool =
True,
1520 logLevel: Optional[acts.logging.Level] =
None,
1523 from acts.examples import GreedyAmbiguityResolutionAlgorithm
1527 algML = AmbiguityResolutionMLAlgorithm(
1528 level=customLogLevel(),
1529 inputTracks=
"tracks",
1530 inputDuplicateNN=onnxModelFile,
1531 outputTracks=
"ambiTracksML",
1533 nMeasurementsMin=config.nMeasurementsMin,
1537 algGreedy = GreedyAmbiguityResolutionAlgorithm(
1538 level=customLogLevel(),
1539 inputTracks=algML.config.outputTracks,
1540 outputTracks=
"ambiTracksMLGreedy",
1542 maximumSharedHits=config.maximumSharedHits,
1543 nMeasurementsMin=config.nMeasurementsMin,
1544 maximumIterations=config.maximumIterations,
1548 s.addAlgorithm(algML)
1549 s.addAlgorithm(algGreedy)
1551 trackConverter = acts.examples.TracksToTrajectories(
1552 level=customLogLevel(),
1553 inputTracks=algGreedy.config.outputTracks,
1554 outputTrajectories=
"ambiTrajectories",
1556 s.addAlgorithm(trackConverter)
1557 s.addWhiteboardAlias(
"trajectories", trackConverter.config.outputTrajectories)
1562 trajectories=
"trajectories",
1563 outputDirCsv=outputDirCsv,
1564 outputDirRoot=outputDirRoot,
1565 writeStates=writeTrajectories,
1566 writeSummary=writeTrajectories,
1567 writeCKFperformance=
True,
1568 writeFinderPerformance=
False,
1569 writeFitterPerformance=
False,
1577 config=AmbiguityResolutionMLDBScanConfig,
1582 onnxModelFile: Optional[Union[Path, str]] =
None,
1583 outputDirCsv: Optional[Union[Path, str]] =
None,
1584 outputDirRoot: Optional[Union[Path, str]] =
None,
1585 writeTrajectories: bool =
True,
1586 logLevel: Optional[acts.logging.Level] =
None,
1588 from acts.examples import AmbiguityResolutionMLDBScanAlgorithm
1592 alg = AmbiguityResolutionMLDBScanAlgorithm(
1593 level=customLogLevel(),
1594 inputTracks=
"tracks",
1595 inputDuplicateNN=onnxModelFile,
1596 outputTracks=
"ambiTracksMLDBScan",
1598 nMeasurementsMin=config.nMeasurementsMin,
1599 epsilonDBScan=config.epsilonDBScan,
1600 minPointsDBScan=config.minPointsDBScan,
1605 trackConverter = acts.examples.TracksToTrajectories(
1606 level=customLogLevel(),
1607 inputTracks=alg.config.outputTracks,
1608 outputTrajectories=
"ambiTrajectories",
1610 s.addAlgorithm(trackConverter)
1611 s.addWhiteboardAlias(
"trajectories", trackConverter.config.outputTrajectories)
1615 name=
"ambiMLDBScan",
1616 trajectories=
"trajectories",
1617 outputDirCsv=outputDirCsv,
1618 outputDirRoot=outputDirRoot,
1619 writeStates=writeTrajectories,
1620 writeSummary=writeTrajectories,
1621 writeCKFperformance=
True,
1622 writeFinderPerformance=
False,
1623 writeFitterPerformance=
False,
1631 trackSelectorConfig=TrackSelectorConfig,
1636 seeder: Optional[acts.VertexSeedFinder] = acts.VertexSeedFinder.GaussianSeeder,
1637 trajectories: Optional[str] =
"trajectories",
1638 trackParameters: Optional[str] =
None,
1639 associatedParticles: Optional[str] =
None,
1640 outputProtoVertices: str =
"protovertices",
1641 outputVertices: str =
"fittedVertices",
1642 vertexFinder: VertexFinder = VertexFinder.Truth,
1643 trackSelectorConfig: Optional[TrackSelectorConfig] =
None,
1644 outputDirRoot: Optional[Union[Path, str]] =
None,
1645 logLevel: Optional[acts.logging.Level] =
None,
1647 """This function steers the vertex fitting
1652 the sequencer module to which we add the Seeding steps (returned from addVertexFitting)
1653 field : magnetic field
1654 seeder : enum member
1655 determines vertex seeder, can be acts.seeder.GaussianSeeder or acts.seeder.AdaptiveGridSeeder
1656 outputDirRoot : Path|str, path, None
1657 the output folder for the Root output, None triggers no output
1658 associatedParticles : str, "associatedTruthParticles"
1659 VertexPerformanceWriter.inputAssociatedTruthParticles
1660 vertexFinder : VertexFinder, Truth
1661 vertexFinder algorithm: one of Truth, AMVF, Iterative
1662 logLevel : acts.logging.Level, None
1663 logging level to override setting given in `s`
1667 VertexFitterAlgorithm,
1668 IterativeVertexFinderAlgorithm,
1669 AdaptiveMultiVertexFinderAlgorithm,
1670 VertexPerformanceWriter,
1673 trajectories = trajectories
if trajectories
is not None else ""
1674 trackParameters = trackParameters
if trackParameters
is not None else ""
1675 associatedParticles = associatedParticles
if associatedParticles
is not None else ""
1679 if trackSelectorConfig
is not None:
1682 trackSelectorConfig,
1683 inputTrackParameters=trackParameters,
1684 inputTrajectories=trajectories,
1685 outputTrackParameters=
"selectedTrackParametersVertexing",
1686 outputTrajectories=
"selectedTrajectoriesVertexing",
1687 logLevel=customLogLevel(),
1690 trajectories = trackSelector.config.outputTrajectories
if trajectories
else ""
1692 trackSelector.config.outputTrackParameters
if trackParameters
else ""
1695 inputParticles =
"particles_input"
1696 selectedParticles =
"particles_selected"
1698 if vertexFinder == VertexFinder.Truth:
1699 findVertices = TruthVertexFinder(
1700 level=customLogLevel(),
1701 inputParticles=selectedParticles,
1702 outputProtoVertices=outputProtoVertices,
1703 excludeSecondaries=
True,
1705 s.addAlgorithm(findVertices)
1706 fitVertices = VertexFitterAlgorithm(
1707 level=customLogLevel(),
1709 inputTrajectories=trajectories,
1710 inputTrackParameters=trackParameters,
1711 inputProtoVertices=findVertices.config.outputProtoVertices,
1712 outputVertices=outputVertices,
1714 s.addAlgorithm(fitVertices)
1715 elif vertexFinder == VertexFinder.Iterative:
1716 findVertices = IterativeVertexFinderAlgorithm(
1717 level=customLogLevel(),
1719 inputTrajectories=trajectories,
1720 inputTrackParameters=trackParameters,
1721 outputProtoVertices=outputProtoVertices,
1722 outputVertices=outputVertices,
1724 s.addAlgorithm(findVertices)
1725 elif vertexFinder == VertexFinder.AMVF:
1726 findVertices = AdaptiveMultiVertexFinderAlgorithm(
1727 level=customLogLevel(),
1730 inputTrajectories=trajectories,
1731 inputTrackParameters=trackParameters,
1732 outputProtoVertices=outputProtoVertices,
1733 outputVertices=outputVertices,
1735 s.addAlgorithm(findVertices)
1737 raise RuntimeError(
"Invalid finder argument")
1739 if outputDirRoot
is not None:
1740 outputDirRoot = Path(outputDirRoot)
1741 if not outputDirRoot.exists():
1742 outputDirRoot.mkdir()
1743 if associatedParticles == selectedParticles:
1745 "Using VertexPerformanceWriter with smeared particles is not necessarily supported. "
1746 "Please get in touch with us"
1749 VertexPerformanceWriter(
1750 level=customLogLevel(),
1751 inputAllTruthParticles=inputParticles,
1752 inputSelectedTruthParticles=selectedParticles,
1753 inputMeasurementParticlesMap=
"measurement_particles_map",
1754 inputTrajectories=trajectories,
1755 inputTrackParameters=trackParameters,
1756 inputAssociatedTruthParticles=associatedParticles,
1757 inputVertices=outputVertices,
1759 minTrackVtxMatchFraction=0.5
if associatedParticles
else 0.0,
1760 treeName=
"vertexing",
1761 filePath=
str(outputDirRoot /
"performance_vertexing.root"),
1770 outputDirRoot: Optional[Union[Path, str]] =
None,
1771 logLevel: Optional[acts.logging.Level] =
None,
1772 inputSpacePoints: Optional[str] =
"spacepoints",
1773 outputVertices: Optional[str] =
"fittedSeedVertices",
1776 SingleSeedVertexFinderAlgorithm,
1777 VertexPerformanceWriter,
1782 findSingleSeedVertex = SingleSeedVertexFinderAlgorithm(
1783 level=customLogLevel(),
1784 inputSpacepoints=inputSpacePoints,
1785 outputVertices=outputVertices,
1787 s.addAlgorithm(findSingleSeedVertex)
1789 inputParticles =
"particles_input"
1790 selectedParticles =
"particles_selected"
1792 if outputDirRoot
is not None:
1793 outputDirRoot = Path(outputDirRoot)
1794 if not outputDirRoot.exists():
1795 outputDirRoot.mkdir()
1798 VertexPerformanceWriter(
1799 level=customLogLevel(),
1800 inputAllTruthParticles=inputParticles,
1801 inputSelectedTruthParticles=selectedParticles,
1803 inputVertices=outputVertices,
1804 treeName=
"seedvertexing",
1805 filePath=
str(outputDirRoot /
"performance_seedvertexing.root"),