Skip to content

Commit

Permalink
Merge branch 'LSP' of https://github.com/Rosie-Hasan/acts into LSP
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosie-Hasan committed Oct 16, 2023
2 parents 0d58b7f + a4ee7ed commit 73bde57
Show file tree
Hide file tree
Showing 5 changed files with 270 additions and 19 deletions.
2 changes: 0 additions & 2 deletions Core/include/Acts/Seeding/GNN_Geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,6 @@ template <typename space_point_t> class TrigFTF_GNN_Geometry {

std::unique_ptr<Acts::FasTrackConnector> m_fastrack;

std::unique_ptr<Acts::FasTrackConnector> m_fastrack;

int m_nEtaBins;
};

Expand Down
9 changes: 1 addition & 8 deletions Examples/Algorithms/TrackFinding/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@ add_library(
src/HoughTransformSeeder.cpp
src/TrackParamsEstimationAlgorithm.cpp
src/SeedingFTFAlgorithm.cpp
)
add_library(ActsExamplesTrackFinding SHARED src /
AmbiguityResolutionAlgorithm.cpp src / SeedingAlgorithm.cpp src /
SeedingOrthogonalAlgorithm.cpp src / SpacePointMaker.cpp src /
TrackFindingAlgorithm.cpp src /
TrackFindingAlgorithmFunction.cpp src /
HoughTransformSeeder.cpp src /
TrackParamsEstimationAlgorithm.cpp src / SeedingFTFAlgorithm.cpp)
)

target_include_directories(
ActsExamplesTrackFinding PUBLIC
Expand Down
96 changes: 96 additions & 0 deletions Examples/Python/python/acts/examples/reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,22 @@ def addSeeding(
geoSelectionConfigFile,
fastrack_inputConfigFile,

)
elif seedingAlgorithm == SeedingAlgorithm.FTF:
logger.info("Using FTF seeding")
#output of algs changed, only one output now
seeds = addFTFSeeding(
s,
spacePoints,
seedFinderConfigArg,
seedFinderOptionsArg,
seedFilterConfigArg,
trackingGeometry,
logLevel,
layerMappingConfigFile,
geoSelectionConfigFile,
fastrack_inputConfigFile,

)
else:
logger.fatal("unknown seedingAlgorithm %s", seedingAlgorithm)
Expand Down Expand Up @@ -889,6 +905,86 @@ def addFTFSeeding(
sequence.addAlgorithm(seedingAlg)
return seedingAlg.config.outputSeeds

def addFTFSeeding(
sequence: acts.examples.Sequencer,
spacePoints: str,
seedFinderConfigArg: SeedFinderConfigArg,
seedFinderOptionsArg: SeedFinderOptionsArg,
seedFilterConfigArg: SeedFilterConfigArg,
trackingGeometry: acts.TrackingGeometry,
logLevel: acts.logging.Level = None,
layerMappingConfigFile: Union[Path, str] = None,
geoSelectionConfigFile: Union[Path, str] = None,
fastrack_inputConfigFile: Union[Path, str] = None,

):
"""FTF seeding
"""

logLevel = acts.examples.defaultLogging(sequence, logLevel)()
layerMappingFile=str(layerMappingConfigFile) #turn path into string
fastrack_inputFile = str(fastrack_inputConfigFile)
seedFinderConfig = acts.SeedFinderFTFConfig(
**acts.examples.defaultKWArgs(
sigmaScattering=seedFinderConfigArg.sigmaScattering,
maxSeedsPerSpM=seedFinderConfigArg.maxSeedsPerSpM,
minPt=seedFinderConfigArg.minPt,
fastrack_input_file = fastrack_inputFile,
m_useClusterWidth = False,
),
)
seedFinderOptions = acts.SeedFinderOptions(
**acts.examples.defaultKWArgs(
beamPos=acts.Vector2(0.0, 0.0)
if seedFinderOptionsArg.beamPos == (None, None)
else acts.Vector2(
seedFinderOptionsArg.beamPos[0], seedFinderOptionsArg.beamPos[1]
),
bFieldInZ=seedFinderOptionsArg.bFieldInZ,
)
)
seedFilterConfig = acts.SeedFilterConfig(
**acts.examples.defaultKWArgs(
maxSeedsPerSpM=seedFinderConfig.maxSeedsPerSpM,
deltaRMin=(
seedFinderConfigArg.deltaR[0]
if seedFilterConfigArg.deltaRMin is None
else seedFilterConfigArg.deltaRMin
),
impactWeightFactor=seedFilterConfigArg.impactWeightFactor,
zOriginWeightFactor=seedFilterConfigArg.zOriginWeightFactor,
compatSeedWeight=seedFilterConfigArg.compatSeedWeight,
compatSeedLimit=seedFilterConfigArg.compatSeedLimit,
numSeedIncrement=seedFilterConfigArg.numSeedIncrement,
seedWeightIncrement=seedFilterConfigArg.seedWeightIncrement,
seedConfirmation=seedFilterConfigArg.seedConfirmation,
#curvatureSortingInFilter=seedFilterConfigArg.curvatureSortingInFilter,
maxSeedsPerSpMConf=seedFilterConfigArg.maxSeedsPerSpMConf,
maxQualitySeedsPerSpMConf=seedFilterConfigArg.maxQualitySeedsPerSpMConf,
useDeltaRorTopRadius=seedFilterConfigArg.useDeltaRorTopRadius,
)
)

seedingAlg = acts.examples.SeedingFTFAlgorithm(
level=logLevel,
inputSpacePoints=[spacePoints],
outputSeeds="seeds",
seedFilterConfig=seedFilterConfig,
seedFinderConfig=seedFinderConfig,
seedFinderOptions=seedFinderOptions,
layerMappingFile=layerMappingFile,
geometrySelection = acts.examples.readJsonGeometryList(
str(geoSelectionConfigFile)
),
inputSourceLinks = "sourcelinks" ,
trackingGeometry = trackingGeometry,
fill_module_csv = False,

)

sequence.addAlgorithm(seedingAlg)
return seedingAlg.config.outputSeeds


def addSeedPerformanceWriters(
sequence: acts.examples.Sequencer,
Expand Down
61 changes: 52 additions & 9 deletions Examples/Scripts/Python/full_chain_itk.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,38 @@
VertexFinder,
)

ttbar_pu200 = False u = acts.UnitConstants geo_dir = pathlib.Path("acts-itk") outputDir = pathlib.Path.cwd() / "itk_output"
#acts.examples.dump_args_calls( \
locals()) #show acts.examples python binding calls
ttbar_pu200 = False
u = acts.UnitConstants
geo_dir = pathlib.Path("acts-itk")
outputDir = pathlib.Path.cwd() / "itk_output"
# acts.examples.dump_args_calls(locals()) # show acts.examples python binding calls

detector, trackingGeometry, decorators = acts.examples.itk.buildITkGeometry(geo_dir) field = acts.examples.MagneticFieldMapXyz(str(geo_dir / "bfield/ATLAS-BField-xyz.root")) rnd = acts.examples.RandomNumbers(seed = 42)
detector, trackingGeometry, decorators = acts.examples.itk.buildITkGeometry(geo_dir)
field = acts.examples.MagneticFieldMapXyz(str(geo_dir / "bfield/ATLAS-BField-xyz.root"))
rnd = acts.examples.RandomNumbers(seed=42)

s = acts.examples.Sequencer(events = 100, numThreads = - 1, outputDir = str(outputDir))
s = acts.examples.Sequencer(events=100, numThreads=-1, outputDir=str(outputDir))

if not ttbar_pu200:addParticleGun(s, MomentumConfig(1.0 * u.GeV, 10.0 * u.GeV, transverse = True), EtaConfig(- 4.0, 4.0, uniform = True), ParticleConfig(2, acts.PdgParticle.eMuon, randomizeCharge = True), rnd = rnd, ) else :addPythia8(s, hardProcess =["Top:qqbar2ttbar=on"], npileup = 200, vtxGen = acts.examples.GaussianVertexGenerator(stddev = acts.Vector4(0.0125 * u.mm, 0.0125 * u.mm, 55.5 * u.mm, 5.0 * u.ns), mean = acts.Vector4(0, 0, 0, 0), ), rnd = rnd, outputDirRoot = outputDir, )
if not ttbar_pu200:
addParticleGun(
s,
MomentumConfig(1.0 * u.GeV, 10.0 * u.GeV, transverse=True),
EtaConfig(-4.0, 4.0, uniform=True),
ParticleConfig(2, acts.PdgParticle.eMuon, randomizeCharge=True),
rnd=rnd,
)
else:
addPythia8(
s,
hardProcess=["Top:qqbar2ttbar=on"],
npileup=200,
vtxGen=acts.examples.GaussianVertexGenerator(
stddev=acts.Vector4(0.0125 * u.mm, 0.0125 * u.mm, 55.5 * u.mm, 5.0 * u.ns),
mean=acts.Vector4(0, 0, 0, 0),
),
rnd=rnd,
outputDirRoot=outputDir,
)

addFatras(
s,
Expand All @@ -49,9 +72,29 @@
outputDirRoot=outputDir,
)

addDigitization(s, trackingGeometry, field, digiConfigFile = geo_dir / "itk-hgtd/itk-smearing-config.json", #change this file to make it do digitization outputDirRoot = outputDir, rnd = rnd, )
addDigitization(
s,
trackingGeometry,
field,
digiConfigFile=geo_dir / "itk-hgtd/itk-smearing-config.json",
outputDirRoot=outputDir,
rnd=rnd,
)

addSeeding(s, trackingGeometry, field, TruthSeedRanges(pt =(1.0 * u.GeV, None), eta =(- 4.0, 4.0), nHits =(9, None)) if ttbar_pu200 else TruthSeedRanges(), seedingAlgorithm = SeedingAlgorithm.FTF, * acts.examples.itk.itkSeedingAlgConfig(acts.examples.itk.InputSpacePointsType.PixelSpacePoints), geoSelectionConfigFile = geo_dir / "itk-hgtd/geoSelection-ITk.json", layerMappingConfigFile = geo_dir / "itk-hgtd/ACTS_FTF_mapinput.csv", fastrack_inputConfigFile = geo_dir / "itk-hgtd/binTables_ITK_RUN4.txt", outputDirRoot = outputDir, )
addSeeding(
s,
trackingGeometry,
field,
TruthSeedRanges(pt=(1.0 * u.GeV, None), eta=(-4.0, 4.0), nHits=(9, None))
if ttbar_pu200
else TruthSeedRanges(),
seedingAlgorithm=SeedingAlgorithm.Default,
*acts.examples.itk.itkSeedingAlgConfig(
acts.examples.itk.InputSpacePointsType.PixelSpacePoints
),
geoSelectionConfigFile=geo_dir / "itk-hgtd/geoSelection-ITk.json",
outputDirRoot=outputDir,
)

addCKFTracks(
s,
Expand All @@ -78,4 +121,4 @@
outputDirRoot=outputDir,
)

s.run()
s.run()
121 changes: 121 additions & 0 deletions Examples/Scripts/Python/full_chain_itk_FTF.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#!/usr/bin/env python3
import pathlib, acts, acts.examples, acts.examples.itk
from acts.examples.simulation import (
addParticleGun,
MomentumConfig,
EtaConfig,
ParticleConfig,
addPythia8,
addFatras,
ParticleSelectorConfig,
addDigitization,
)
from acts.examples.reconstruction import (
addSeeding,
SeedingAlgorithm,
TruthSeedRanges,
addCKFTracks,
CKFPerformanceConfig,
TrackSelectorRanges,
addAmbiguityResolution,
AmbiguityResolutionConfig,
addVertexFitting,
VertexFinder,
)

ttbar_pu200 = False
u = acts.UnitConstants
geo_dir = pathlib.Path("acts-itk")
outputDir = pathlib.Path.cwd() / "itk_output"
# acts.examples.dump_args_calls(locals()) # show acts.examples python binding calls

detector, trackingGeometry, decorators = acts.examples.itk.buildITkGeometry(geo_dir)
field = acts.examples.MagneticFieldMapXyz(str(geo_dir / "bfield/ATLAS-BField-xyz.root"))
rnd = acts.examples.RandomNumbers(seed=42)

s = acts.examples.Sequencer(events=100, numThreads=1, outputDir=str(outputDir))

if not ttbar_pu200:
addParticleGun(
s,
MomentumConfig(1.0 * u.GeV, 10.0 * u.GeV, transverse=True),
EtaConfig(-4.0, 4.0, uniform=True),
ParticleConfig(2, acts.PdgParticle.eMuon, randomizeCharge=True),
rnd=rnd,
)
else:
addPythia8(
s,
hardProcess=["Top:qqbar2ttbar=on"],
npileup=200,
vtxGen=acts.examples.GaussianVertexGenerator(
stddev=acts.Vector4(0.0125 * u.mm, 0.0125 * u.mm, 55.5 * u.mm, 5.0 * u.ns),
mean=acts.Vector4(0, 0, 0, 0),
),
rnd=rnd,
outputDirRoot=outputDir,
)

addFatras(
s,
trackingGeometry,
field,
rnd=rnd,
preSelectParticles=ParticleSelectorConfig(
eta=(-4.0, 4.0), pt=(150 * u.MeV, None), removeNeutral=True
)
if ttbar_pu200
else ParticleSelectorConfig(),
outputDirRoot=outputDir,
)

addDigitization(
s,
trackingGeometry,
field,
digiConfigFile=geo_dir / "itk-hgtd/itk-smearing-config.json", #change this file to make it do digitization
outputDirRoot=outputDir,
rnd=rnd,
)

addSeeding(
s,
trackingGeometry,
field,
TruthSeedRanges(pt=(1.0 * u.GeV, None), eta=(-4.0, 4.0), nHits=(9, None))
if ttbar_pu200
else TruthSeedRanges(),
seedingAlgorithm=SeedingAlgorithm.FTF,
*acts.examples.itk.itkSeedingAlgConfig(
acts.examples.itk.InputSpacePointsType.PixelSpacePoints
),
geoSelectionConfigFile=geo_dir / "itk-hgtd/geoSelection-ITk.json",
layerMappingConfigFile = geo_dir / "itk-hgtd/ACTS_FTF_mapinput.csv",
fastrack_inputConfigFile = geo_dir / "itk-hgtd/binTables_ITK_RUN4.txt",
outputDirRoot=outputDir,
)

# addCKFTracks(
# s,
# trackingGeometry,
# field,
# CKFPerformanceConfig(ptMin=1.0 * u.GeV if ttbar_pu200 else 0.0, nMeasurementsMin=6),
# TrackSelectorRanges(pt=(1.0 * u.GeV, None), absEta=(None, 4.0)),
# outputDirRoot=outputDir,
# )

# addAmbiguityResolution(
# s,
# AmbiguityResolutionConfig(maximumSharedHits=3),
# CKFPerformanceConfig(ptMin=1.0 * u.GeV if ttbar_pu200 else 0.0, nMeasurementsMin=6),
# outputDirRoot=outputDir,
# )

# addVertexFitting(
# s,
# field,
# vertexFinder=VertexFinder.Iterative,
# outputDirRoot=outputDir,
# )

s.run()

0 comments on commit 73bde57

Please sign in to comment.