Merged
Conversation
… backwards compatibility
…lidation, including support for error handling on warnings.
…on types in command line arguments
…ues to/from the IAEA phase space format
…ple, so that alternative multithreading paradigms are supported.
Fixed redundant comment in G4PHSPSourceAction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ParticleZoo v1.1.0
Version bump: v1.0.2 -> v1.1.0
Summary
This release introduces multi-threaded parallel phase space reading, comprehensive Python bindings, additional particle filtering for CLI tools, EGS LATCH and PENELOPE ILB interpretation infrastructure, a drop-in Geant4 primary generator action, and CI/CD pipelines for Linux, macOS, and Windows. Together these represent a major feature expansion of ParticleZoo across the library, CLI tools, and ecosystem.
Major Features
1. Multi-Threaded Parallel Phase Space Readers
Two new parallel reader classes enable thread-safe, lock-free reading of phase space files by partitioning the file across independent reader instances:
HistoryBalancedParallelReader— Distributes histories evenly across threads. Ideal for use-cases where the history is the fundamental unit of work.ParticleBalancedParallelReader— Distributes particles evenly across threads (with history boundary alignment). Best for optimal load-balancing.Both readers support
peekNextParticle(),getNextParticle(),hasMoreParticles(), per-thread history/particle counters, and expose file-level metadata (total particles, original histories, represented histories).New source files:
src/parallel/HistoryBalancedParallelReader.cc,src/parallel/ParticleBalancedParallelReader.cc, and corresponding headers underinclude/particlezoo/parallel/.2. Python Bindings
A complete Python package (
particlezoo) built with pybind11 exposes the core C++ API to Python 3.8+:Particleclass with property-style access (position, momentum, energy, weight, type, etc.)PhaseSpaceFileReader/PhaseSpaceFileWriterviacreate_reader()/create_writer()factory functionsfor particle in reader:)ParticleType,IntPropertyType,FloatPropertyType,BoolPropertyTypeenumsUserOptions, andArgParserNew Makefile targets:
make install-python,make install-python-dev,make uninstall-python.Python examples in
examples/python:read_phase_space.py,write_phase_space.py.3. Additional Particle Filtering in PHSPConvert
PHSPConvert has been significantly expanded from a basic format converter to a full-featured particle filter/converter. All new filtering options:
--photonsOnly,--electronsOnly,--filterByPDG <code>--minEnergy,--maxEnergy(in MeV)--minX/maxX,--minY/maxY,--minZ/maxZ(in cm)--minRadius,--maxRadius(XY plane, in cm)--primariesOnly,--excludePrimaries,--generations <min> <max>--preserveConstants(now a bool argument, defaults to true)--errorOnWarning(return non-zero exit code on warnings)The internal architecture was refactored from inline parsing into a structured
AppConfigclass with centralized validation and a standaloneapplyFilters()function. Errors and warnings are now tracked separately, and the error/warning distinction was corrected (mismatched particle counts are now warnings, not errors).4. PHSPImage Enhancements
PHSPImage was significantly refactored for readability and extended with new capabilities:
--score count|energy|xDir|yDir|zDir(replaces--energyWeightedfor broader fluence analysis)--primariesOnly,--excludePrimaries,--generations--EGS-latch-filterbitmask support--errorOnWarningAppConfig5. Geant4 Integration Example
A complete, ready-to-use
G4VUserPrimaryGeneratorActionimplementation for reading phase space files in Geant4 simulations:ParticleBalancedParallelReaderfor multi-threaded Geant4 runsFiles:
examples/geant4/G4PHSPSourceAction.hh,examples/geant4/G4PHSPSourceAction.cc.Library API Additions
Particle Class
getPDGCode()— Convenience method returning the PDG identification code for the particle typeisPrimary()— Returns true if the particle hasGENERATION == 1setGeneration(int)— Sets theGENERATIONinteger propertydoublearguments, internally converts tofloatIntPropertyType::GENERATION— New standard integer property type for particle generation tracking (1 = primary, 2+ = secondary)BoolPropertyType::IS_SECONDARY_PARTICLE— Deprecated in favor ofIntPropertyType::GENERATIONPhaseSpaceFileReader
peekNextParticle()— Reads the next particle without advancing the file positiongetNumberOfRepresentedHistories()— Virtual method for the count of histories that actually produced particles (distinct from "original" histories which include empty ones)peekParticleManually()— Override point for formats with custom I/O (implemented for ROOT)PhaseSpaceFileWriter
--flipX,--flipY,--flipZ— New CLI commands to negate directional cosines on writeByteBuffer
peekBytes(len)— Returns astd::spanof the nextlenbytes without advancing the read offsetPDGParticleCodes
getAllParticleTypes()— Returns the complete list of(name, ParticleType)pairs (used by Python bindings)EGS LATCH & PENELOPE ILB Infrastructure
New header:
include/particlezoo/egs/EGSLATCH.hEGSLATCHOPTIONenum (options 1, 2, 3 per EGS documentation)ApplyLATCHToParticle()— Decodes LATCH bits into particle properties (multi-crosser, generation)ExtractLATCHFromParticle()— Constructs a LATCH value from particle propertiesDoesParticlePassLATCHFilter()— Bitmask-based LATCH filtering--EGS-latch-optionand--EGS-latch-filterCLI commandsNew header:
include/particlezoo/penelope/ILBArray.hApplyILB[1-5]ToParticle()/ExtractILB[1-5]FromParticle()— Individual ILB accessor/mutator functionsApplyILBArrayToParticle()/ExtractILBArrayFromParticle()— Batch operations for the 5-element ILB arrayAll reader/writers that support these values now use these centralized routines instead of ad-hoc inline logic, ensuring consistency when converting between formats.
Argument Parsing (
argParse.h)UserOptionspromoted to a class (from ausingalias) with typed extraction methods:extractPositional(),extractStringOption(),extractIntOption(),extractUIntOption(),extractFloatOption(),extractBoolOption()CLI_UINTargument type — New unsigned integer argument supportCLIValuevariant — Now includesunsigned intstd::string_viewoverloads forPrintUsage()andParseArgs()UserOptionsinitializer list constructor — For backwards compatibility with v1.0 APIBuild System & CI
CI/CD Pipeline (
.github/workflows/c-cpp.yml)New GitHub Actions workflow testing on all three platforms:
Windows Build Script (
build.bat)root-config, include path extraction, warning suppression for ROOT headers, proper/linkprefix stripping for ROOT library flags--no-rootflag: Disable ROOT even if available-arch x64)Makefile
-Wno-deprecated-declarationsadded to both release and debug flags (forIS_SECONDARY_PARTICLEdeprecation)Other
.gitattributesupdated to export-ignore GitHub workflows and additional directories.gitignoreupdated for Python artifacts, build outputs, and test filesDocumentation
python/README.md)docs/scripts/gen_python_api.py)Breaking Changes
BoolPropertyType::IS_SECONDARY_PARTICLEis now deprecated (compiles with a warning). UseIntPropertyType::GENERATIONinstead.UserOptionsis now a class (inheriting fromstd::unordered_map) rather than a type alias — existing code using it as a map should still compile.maxParticlesCLI argument type changed fromCLI_INTtoCLI_UINTin PHSPConvert, PHSPCombine, and PHSPImage.