def configureDigitization( trackingGeometry: acts.TrackingGeometry, field: acts.MagneticFieldProvider, outputDir: Path, particlesInput: Optional[Path] = None, outputRoot: bool = True, outputCsv: bool = True, s: Optional[acts.examples.Sequencer] = None, ) -> acts.examples.Sequencer: from particle_gun import addParticleGun, EtaConfig, PhiConfig, ParticleConfig from fatras import addFatras s = s or acts.examples.Sequencer( events=100, numThreads=-1, logLevel=acts.logging.INFO ) rnd = acts.examples.RandomNumbers(seed=42) if particlesInput is None: s = addParticleGun( s, EtaConfig(-2.0, 2.0), ParticleConfig(4, acts.PdgParticle.eMuon, True), PhiConfig(0.0, 360.0 * u.degree), multiplicity=2, rnd=rnd, ) else: # Read input from input collection (e.g. Pythia8 output) evGen = acts.examples.RootParticleReader( level=s.config.logLevel, particleCollection="particles_input", filePath=str(particlesInput), orderedEvents=False, ) s.addReader(evGen) outputDir = Path(outputDir) s = addFatras( s, trackingGeometry, field, rnd=rnd, ) s = addDigitization( s, trackingGeometry, field, digiConfigFile=Path(__file__).resolve().parent.parent.parent.parent / "Examples/Algorithms/Digitization/share/default-smearing-config-generic.json", outputDirCsv=outputDir / "csv" if outputCsv else None, outputDirRoot=outputDir if outputRoot else None, rnd=rnd, ) return s
def runFatras(trackingGeometry, field, outputDir, s: acts.examples.Sequencer = None): from particle_gun import addParticleGun, EtaConfig s = s or acts.examples.Sequencer(events=100, numThreads=-1) s.config.logLevel = acts.logging.INFO rnd = acts.examples.RandomNumbers() s = addParticleGun( s, EtaConfig(-2.0, 2.0), rnd=rnd, ) outputDir = Path(outputDir) return addFatras( s, trackingGeometry, field, outputDirCsv=outputDir / "csv", outputDirRoot=outputDir, rnd=rnd, )
def runCKFTracks( trackingGeometry, decorators, geometrySelection: Path, digiConfigFile: Path, field, outputDir: Path, truthSmearedSeeded=False, truthEstimatedSeeded=False, outputCsv=True, inputParticlePath: Optional[Path] = None, s=None, ): from particle_gun import addParticleGun, EtaConfig, PhiConfig, ParticleConfig from fatras import addFatras from digitization import addDigitization from seeding import ( addSeeding, TruthSeedRanges, ParticleSmearingSigmas, SeedfinderConfigArg, SeedingAlgorithm, TrackParamsEstimationConfig, ) s = s or acts.examples.Sequencer( events=100, numThreads=-1, logLevel=acts.logging.INFO) for d in decorators: s.addContextDecorator(d) rnd = acts.examples.RandomNumbers(seed=42) outputDir = Path(outputDir) if inputParticlePath is None: s = addParticleGun( s, EtaConfig(-2.0, 2.0), ParticleConfig(4, acts.PdgParticle.eMuon, True), PhiConfig(0.0, 360.0 * u.degree), multiplicity=2, rnd=rnd, ) else: acts.logging.getLogger("CKFExample").info("Reading particles from %s", inputParticlePath.resolve()) assert inputParticlePath.exists() s.addReader( RootParticleReader( level=acts.logging.INFO, filePath=str(inputParticlePath.resolve()), particleCollection="particles_input", orderedEvents=False, )) s = addFatras( s, trackingGeometry, field, rnd=rnd, ) s = addDigitization( s, trackingGeometry, field, digiConfigFile=digiConfigFile, rnd=rnd, ) s = addSeeding( s, trackingGeometry, field, TruthSeedRanges(pt=(500.0 * u.MeV, None), nHits=(9, None)), ParticleSmearingSigmas( pRel=0.01), # only used by SeedingAlgorithm.TruthSmeared SeedfinderConfigArg( r=(None, 200 * u.mm), # rMin=default, 33mm deltaR=(1 * u.mm, 60 * u.mm), collisionRegion=(-250 * u.mm, 250 * u.mm), z=(-2000 * u.mm, 2000 * u.mm), maxSeedsPerSpM=1, sigmaScattering=50, radLengthPerSeed=0.1, minPt=500 * u.MeV, bFieldInZ=1.99724 * u.T, impactMax=3 * u.mm, ), TrackParamsEstimationConfig(deltaR=(10.0 * u.mm, None)), seedingAlgorithm=SeedingAlgorithm.TruthSmeared if truthSmearedSeeded else SeedingAlgorithm.TruthEstimated if truthEstimatedSeeded else SeedingAlgorithm.Default, geoSelectionConfigFile=geometrySelection, outputDirRoot=outputDir, rnd=rnd, # only used by SeedingAlgorithm.TruthSmeared ) s = addCKFTracks( s, trackingGeometry, field, CKFPerformanceConfig(ptMin=400.0 * u.MeV, nMeasurementsMin=6), outputDirRoot=outputDir, outputDirCsv=outputDir / "csv" if outputCsv else None, ) return s
def runSeeding( trackingGeometry, field, outputDir, s=None, seedingAlgorithm=SeedingAlgorithm.Default, ): from particle_gun import addParticleGun, EtaConfig, PhiConfig, ParticleConfig from fatras import addFatras from digitization import addDigitization s = s or acts.examples.Sequencer( events=100, numThreads=-1, logLevel=acts.logging.INFO) rnd = acts.examples.RandomNumbers(seed=42) outputDir = Path(outputDir) s = addParticleGun( s, EtaConfig(-2.0, 2.0), ParticleConfig(4, acts.PdgParticle.eMuon, True), PhiConfig(0.0, 360.0 * u.degree), multiplicity=2, outputDirCsv=outputDir / "csv", outputDirRoot=outputDir, rnd=rnd, ) s = addFatras( s, trackingGeometry, field, outputDirCsv=outputDir / "csv", outputDirRoot=outputDir, rnd=rnd, preselectParticles=False, ) srcdir = Path(__file__).resolve().parent.parent.parent.parent s = addDigitization( s, trackingGeometry, field, digiConfigFile=srcdir / "Examples/Algorithms/Digitization/share/default-smearing-config-generic.json", rnd=rnd, ) s = addSeeding( s, trackingGeometry, field, TruthSeedRanges(pt=(1.0 * u.GeV, None), eta=(-2.5, 2.5), nHits=(9, None)), ParticleSmearingSigmas( pRel=0.01), # only used by SeedingAlgorithm.TruthSmeared SeedfinderConfigArg( r=(None, 200 * u.mm), # rMin=default, 33mm deltaR=(1 * u.mm, 60 * u.mm), collisionRegion=(-250 * u.mm, 250 * u.mm), z=(-2000 * u.mm, 2000 * u.mm), maxSeedsPerSpM=1, sigmaScattering=50, radLengthPerSeed=0.1, minPt=500 * u.MeV, bFieldInZ=1.99724 * u.T, impactMax=3 * u.mm, ), acts.logging.VERBOSE, seedingAlgorithm=seedingAlgorithm, geoSelectionConfigFile=srcdir / "Examples/Algorithms/TrackFinding/share/geoSelection-genericDetector.json", inputParticles= "particles_final", # use this to reproduce the original root_file_hashes.txt - remove to fix outputDirRoot=outputDir, ) return s
detector, trackingGeometry, decorators = itk.buildITkGeometry(geo_dir) field = acts.ConstantBField(acts.Vector3(0.0, 0.0, 2.0 * u.T)) rnd = acts.examples.RandomNumbers(seed=42) from particle_gun import addParticleGun, MomentumConfig, EtaConfig, ParticleConfig from fatras import addFatras from digitization import addDigitization from seeding import addSeeding, SeedingAlgorithm, TruthSeedRanges from ckf_tracks import addCKFTracks s = acts.examples.Sequencer(events=100, numThreads=-1) s = addParticleGun( s, MomentumConfig(1.0 * u.GeV, 10.0 * u.GeV, True), EtaConfig(-4.0, 4.0, True), ParticleConfig(1, acts.PdgParticle.eMuon, True), rnd=rnd, ) s = addFatras( s, trackingGeometry, field, outputDirRoot=outputDir, rnd=rnd, ) s = addDigitization( s, trackingGeometry, field, digiConfigFile=geo_dir / "atlas/itk-hgtd/itk-smearing-config.json",
def runGsfTracks( trackingGeometry, decorators, geometrySelection: Path, digiConfigFile: Path, field, outputDir: Path, truthSmearedSeeded=False, truthEstimatedSeeded=False, outputCsv=True, inputParticlePath: Optional[Path] = None, s=None, ): from particle_gun import addParticleGun, EtaConfig, PhiConfig, ParticleConfig from fatras import addFatras from digitization import addDigitization from seeding import addSeeding, SeedingAlgorithm s = s or acts.examples.Sequencer( events=100, numThreads=-1, logLevel=acts.logging.INFO ) for d in decorators: s.addContextDecorator(d) rnd = acts.examples.RandomNumbers(seed=42) outputDir = Path(outputDir) if inputParticlePath is None: s = addParticleGun( s, EtaConfig(-2.0, 2.0), ParticleConfig(4, acts.PdgParticle.eMuon, True), PhiConfig(0.0, 360.0 * u.degree), multiplicity=2, rnd=rnd, ) else: acts.logging.getLogger("GSF Example").info( "Reading particles from %s", inputParticlePath.resolve() ) assert inputParticlePath.exists() s.addReader( RootParticleReader( level=acts.logging.INFO, filePath=str(inputParticlePath.resolve()), particleCollection="particles_input", orderedEvents=False, ) ) s = addFatras( s, trackingGeometry, field, rnd=rnd, ) s = addDigitization( s, trackingGeometry, field, digiConfigFile=digiConfigFile, rnd=rnd, ) s = addSeeding( s, trackingGeometry, field, seedingAlgorithm=SeedingAlgorithm.TruthSmeared, ) truthTrkFndAlg = acts.examples.TruthTrackFinder( level=acts.logging.INFO, inputParticles="truth_seeds_selected", inputMeasurementParticlesMap="measurement_particles_map", outputProtoTracks="prototracks", ) s.addAlgorithm(truthTrkFndAlg) s = addGsfTracks(s, trackingGeometry, field) # Output s.addWriter( acts.examples.RootTrajectoryStatesWriter( level=acts.logging.INFO, inputTrajectories="gsf_trajectories", inputParticles="truth_seeds_selected", inputSimHits="simhits", inputMeasurementParticlesMap="measurement_particles_map", inputMeasurementSimHitsMap="measurement_simhits_map", filePath=str(outputDir / "trackstates_gsf.root"), ) ) s.addWriter( acts.examples.RootTrajectorySummaryWriter( level=acts.logging.INFO, inputTrajectories="gsf_trajectories", inputParticles="truth_seeds_selected", inputMeasurementParticlesMap="measurement_particles_map", filePath=str(outputDir / "tracksummary_gsf.root"), ) ) return s
def runTruthTrackingKalman( trackingGeometry: acts.TrackingGeometry, field: acts.MagneticFieldProvider, outputDir: Path, digiConfigFile: Path, directNavigation=False, reverseFilteringMomThreshold=0 * u.GeV, s: acts.examples.Sequencer = None, inputParticlePath: Optional[Path] = None, ): from particle_gun import addParticleGun, EtaConfig, PhiConfig, ParticleConfig from fatras import addFatras from digitization import addDigitization from seeding import addSeeding, SeedingAlgorithm, TruthSeedRanges s = s or acts.examples.Sequencer( events=100, numThreads=-1, logLevel=acts.logging.INFO) rnd = acts.examples.RandomNumbers() outputDir = Path(outputDir) if inputParticlePath is None: s = addParticleGun( s, EtaConfig(-2.0, 2.0), ParticleConfig(2, acts.PdgParticle.eMuon, False), multiplicity=1, rnd=rnd, outputDirRoot=outputDir, ) else: acts.logging.getLogger("Truth tracking example").info( "Reading particles from %s", inputParticlePath.resolve()) assert inputParticlePath.exists() s.addReader( RootParticleReader( level=acts.logging.INFO, filePath=str(inputParticlePath.resolve()), particleCollection="particles_input", orderedEvents=False, )) s = addFatras( s, trackingGeometry, field, rnd=rnd, ) s = addDigitization( s, trackingGeometry, field, digiConfigFile=digiConfigFile, rnd=rnd, ) s = addSeeding( s, trackingGeometry, field, seedingAlgorithm=SeedingAlgorithm.TruthSmeared, rnd=rnd, truthSeedRanges=TruthSeedRanges( pt=(500 * u.MeV, None), nHits=(9, None), ), ) s = addKalmanTracks(s, trackingGeometry, field, directNavigation, reverseFilteringMomThreshold) # Output s.addWriter( acts.examples.RootTrajectoryStatesWriter( level=acts.logging.INFO, inputTrajectories="trajectories", inputParticles="truth_seeds_selected", inputSimHits="simhits", inputMeasurementParticlesMap="measurement_particles_map", inputMeasurementSimHitsMap="measurement_simhits_map", filePath=str(outputDir / "trackstates_fitter.root"), )) s.addWriter( acts.examples.RootTrajectorySummaryWriter( level=acts.logging.INFO, inputTrajectories="trajectories", inputParticles="truth_seeds_selected", inputMeasurementParticlesMap="measurement_particles_map", filePath=str(outputDir / "tracksummary_fitter.root"), )) s.addWriter( acts.examples.TrackFinderPerformanceWriter( level=acts.logging.INFO, inputProtoTracks="sortedprototracks" if directNavigation else "prototracks", inputParticles="truth_seeds_selected", inputMeasurementParticlesMap="measurement_particles_map", filePath=str(outputDir / "performance_track_finder.root"), )) s.addWriter( acts.examples.TrackFitterPerformanceWriter( level=acts.logging.INFO, inputTrajectories="trajectories", inputParticles="truth_seeds_selected", inputMeasurementParticlesMap="measurement_particles_map", filePath=str(outputDir / "performance_track_fitter.root"), )) return s