Fennel API¶
Fennel ¶
Main interface for light yield calculations using the Aachen parametrization.
This class provides methods for calculating Cherenkov light yields from various particle types (tracks, electromagnetic cascades, hadronic cascades) in transparent media.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
userconfig
|
dict or str or Path
|
User configuration as either a dictionary or path to YAML file. If None, uses the default configuration from config module. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
_particles |
Dict[int, Particle]
|
Dictionary mapping PDG IDs to Particle objects |
_track |
Track
|
Track light yield calculator |
_em_cascade |
EM_Cascade
|
Electromagnetic cascade light yield calculator |
_hadron_cascade |
Hadron_Cascade
|
Hadronic cascade light yield calculator |
_photon |
Photon
|
Photon propagation calculator |
_dg |
Definitions_Generator
|
Generator for storing calculation definitions |
Examples:
Basic usage with default configuration:
>>> from fennel import Fennel
>>> fennel = Fennel()
>>> energy = 100.0 # GeV
>>> wavelengths = np.linspace(300, 600, 100) # nm
>>> dcounts, angles = fennel.track_yields(energy, wavelengths=wavelengths)
>>> fennel.close()
Using custom configuration:
>>> from fennel import Fennel, config
>>> config["general"]["random state seed"] = 42
>>> config["general"]["jax"] = False
>>> fennel = Fennel()
>>> dcounts, _, _, _ = fennel.em_yields(energy=1000.0, particle=11)
>>> fennel.close()
Loading configuration from file:
Notes
- Always call
close()when finished to properly cleanup and save logs - Enable JAX for GPU acceleration of calculations
- Set random seed for reproducible results
Initialize the Fennel light yield calculator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
userconfig
|
dict or str or Path
|
User configuration. Can be: - dict: Configuration dictionary to merge with defaults - str or Path: Path to YAML configuration file - None: Use default configuration |
None
|
Raises:
| Type | Description |
|---|---|
ImportError
|
If JAX is enabled in config but not installed |
FileNotFoundError
|
If configuration file path doesn't exist |
Source code in fennel/fennel.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
auto_yields ¶
auto_yields(energy, particle: int, interaction='total', wavelengths=config['advanced']['wavelengths'], angle_grid=config['advanced']['angles'], n=config['mediums'][config['scenario']['medium']]['refractive index'], z_grid=config['advanced']['z grid'], function=False)
Auto fetcher function for a given particle and energy. This will fetch/evaluate the functions corresponding to the given particle. Some of the output will be none depending on the constructed object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
energy
|
float
|
The energy(ies) of the particle in GeV |
required |
particle
|
int
|
The pdg id of the particle of interest |
required |
wavelengths
|
array
|
Optional: The desired wavelengths |
config['advanced']['wavelengths']
|
interaction
|
str
|
Optional: The interaction which should produce the light. This is used during track construction. |
'total'
|
angle_grid
|
array
|
Optional: The desired angles in degress |
config['advanced']['angles']
|
n
|
float
|
Optional: The refractive index of the medium. |
config['mediums'][config['scenario']['medium']]['refractive index']
|
z_grid
|
array
|
Optional: The grid in cm for the long. distributions. Used when modeling cascades. |
config['advanced']['z grid']
|
function
|
bool
|
Optional: returns the functional form instead of the evaluation |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
differential_counts |
function / float / array
|
dN/dlambda The differential photon counts per track length (in cm). The shape of the array is (len(wavelengths), len(deltaL)). |
differential_counts_sample |
float / array
|
A sample of the differential counts distribution. Same shape as the differential counts |
em_fraction_mean |
float / array
|
The fraction of em particles |
em_fraction_sample |
float / array
|
A sample of the em_fraction |
long_profile |
function / float / array
|
The distribution along the shower axis for cm |
angles |
function / float / array
|
The angular distribution in degrees |
Source code in fennel/fennel.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
calculate ¶
calculate(energy: float, particle: Optional[int] = None, particle_type: Optional[str] = None, interaction: str = 'total') -> Union[TrackYieldResult, EMYieldResult, HadronYieldResult]
Universal calculation method that auto-detects particle type.
This is the most flexible method - you can specify either a PDG ID or a particle type name, and it will call the appropriate calculation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
energy
|
float
|
Particle/cascade energy in GeV |
required |
particle
|
int
|
PDG ID of the particle. If provided, type is auto-detected. |
None
|
particle_type
|
str
|
Particle type: 'muon'/'track', 'electron'/'em', 'pion'/'hadron' Only used if particle PDG ID is not provided. |
None
|
interaction
|
str
|
For tracks: energy loss mechanism |
'total'
|
Returns:
| Type | Description |
|---|---|
TrackYieldResult, EMYieldResult, or HadronYieldResult
|
Appropriate result container based on particle type |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither particle nor particle_type is specified, or if both are specified and conflict. |
Examples:
>>> fennel = Fennel()
>>> # Auto-detect from PDG ID
>>> result = fennel.calculate(100.0, particle=11) # electron
>>> result = fennel.calculate(100.0, particle=211) # pion
>>>
>>> # Specify by name (uses default PDG for that type)
>>> result = fennel.calculate(100.0, particle_type='muon')
>>> result = fennel.calculate(100.0, particle_type='electron')
Source code in fennel/fennel.py
1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 | |
close ¶
Clean up and finalize the Fennel session.
Saves the configuration to file (if logging is enabled) and closes all logging handlers. Always call this method when finished with calculations to ensure proper cleanup.
Examples:
Notes
This method will: - Dump the current configuration to the location specified in config - Display a farewell message in the logs - Shut down all logging handlers
Source code in fennel/fennel.py
definitions ¶
Write the definitions file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
None
|
|
required |
Returns:
| Type | Description |
|---|---|
None
|
|
em_yields ¶
em_yields(energy: float, particle: int, wavelengths: Optional[ndarray] = None, angle_grid: Optional[ndarray] = None, n: Optional[float] = None, z_grid: Optional[ndarray] = None, function: bool = False) -> Union[Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray], Tuple[Callable, Callable, Callable, Callable]]
Calculate Cherenkov light yields from electromagnetic cascades.
Computes photon yields from electromagnetic showers initiated by electrons, positrons, or photons. Returns the spectral distribution, longitudinal profile, and angular distribution of emitted light.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
energy
|
float
|
Initial particle energy in GeV. Must be positive. |
required |
particle
|
int
|
PDG ID of the particle: - 11: electron (e-) - -11: positron (e+) - 22: photon (γ) |
required |
wavelengths
|
ndarray
|
Wavelengths for spectral calculation in nm. If None, uses config["advanced"]["wavelengths"]. Shape: (n_wavelengths,) |
None
|
angle_grid
|
ndarray
|
Emission angles in degrees. If None, uses config["advanced"]["angles"]. Shape: (n_angles,) |
None
|
n
|
float
|
Refractive index of the medium. If None, uses value from config. Must be > 1 for Cherenkov emission. |
None
|
z_grid
|
ndarray
|
Distance grid for longitudinal profile in cm. If None, uses config["advanced"]["z grid"]. Shape: (n_distances,) |
None
|
function
|
bool
|
If True, returns callable functions. Default is False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
differential_counts |
ndarray or Callable
|
Differential photon counts dN/dλ per cascade. Shape: (n_wavelengths,) if function=False |
differential_counts_sample |
ndarray or Callable
|
Sampled version of differential counts for stochastic modeling. Same shape as differential_counts. |
long_profile |
ndarray or Callable
|
Longitudinal shower development profile. Shape: (n_distances,) if function=False |
angles |
ndarray or Callable
|
Angular distribution of emitted Cherenkov light. Shape: (n_angles,) if function=False |
Examples:
Calculate light yield from 1 TeV electron:
>>> fennel = Fennel()
>>> energy = 1000.0 # GeV
>>> wavelengths = np.linspace(300, 600, 100)
>>> dcounts, dcounts_sample, long_prof, angles = fennel.em_yields(
... energy, particle=11, wavelengths=wavelengths
... )
>>> total_photons = integrate_trapezoid(dcounts, wavelengths)
Compare electron and positron yields:
>>> e_minus = fennel.em_yields(100.0, particle=11)
>>> e_plus = fennel.em_yields(100.0, particle=-11)
Get functional form:
Notes
- Electromagnetic cascades develop through pair production and bremsstrahlung
- The longitudinal profile shows shower development along the cascade axis
- Electrons and positrons produce nearly identical yields
- Photons initiate cascades through pair production
Source code in fennel/fennel.py
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
em_yields_v2 ¶
em_yields_v2(energy: float, particle: int, wavelengths: Optional[ndarray] = None, angle_grid: Optional[ndarray] = None, n: Optional[float] = None, z_grid: Optional[ndarray] = None, function: bool = False) -> EMYieldResult
Calculate EM cascade light yields with enhanced API (v2.0).
This is an improved version of em_yields() that returns a structured result container and includes comprehensive input validation with helpful error messages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
energy
|
float
|
Cascade energy in GeV. Must be positive. |
required |
particle
|
int
|
PDG ID: 11 (e-), -11 (e+), 22 (γ) |
required |
wavelengths
|
ndarray
|
Wavelength grid in nm. If None, uses config default. |
None
|
angle_grid
|
ndarray
|
Angular grid in radians. If None, uses config default. |
None
|
n
|
float
|
Refractive index. If None, uses config medium value. |
None
|
z_grid
|
ndarray
|
Longitudinal distance grid. If None, uses config default. |
None
|
function
|
bool
|
If True, returns callables instead of evaluated arrays. |
False
|
Returns:
| Type | Description |
|---|---|
EMYieldResult
|
Container with dcounts, dcounts_sample, longitudinal_profile, angles, energy, and particle attributes. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If any input parameter is invalid, with helpful error message. |
Examples:
>>> fennel = Fennel()
>>> result = fennel.em_yields_v2(1000.0, particle=11)
>>> print(result)
EMYieldResult(energy=1000.0 GeV, particle=electron, mode=array)
>>> print(f"Particle: {result.particle_name}")
Particle: electron
See Also
em_yields : Original API method (still supported) quick_cascade : Simplified interface with minimal parameters
Source code in fennel/fennel.py
768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 | |
hadron_yields ¶
hadron_yields(energy: float, particle: int, wavelengths: Optional[ndarray] = None, angle_grid: Optional[ndarray] = None, n: Optional[float] = None, z_grid: Optional[ndarray] = None, function: bool = False) -> Union[Tuple[np.ndarray, np.ndarray, float, float, np.ndarray, np.ndarray], Tuple[Callable, Callable, Callable, Callable, Callable, Callable]]
Calculate Cherenkov light yields from hadronic cascades.
Computes photon yields from hadronic showers initiated by pions, kaons, protons, or neutrons. Returns spectral and spatial distributions along with the electromagnetic fraction of the cascade.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
energy
|
float
|
Initial hadron energy in GeV. Must be positive. |
required |
particle
|
int
|
PDG ID of the hadron: - 211: π+ (positive pion) - -211: π- (negative pion) - 130: K_L0 (long-lived neutral kaon) - 2212: p (proton) - -2212: p̄ (antiproton) - 2112: n (neutron) |
required |
wavelengths
|
ndarray
|
Wavelengths for spectral calculation in nm. If None, uses config["advanced"]["wavelengths"]. Shape: (n_wavelengths,) |
None
|
angle_grid
|
ndarray
|
Emission angles in degrees. If None, uses config["advanced"]["angles"]. Shape: (n_angles,) |
None
|
n
|
float
|
Refractive index of the medium. If None, uses value from config. Must be > 1 for Cherenkov emission. |
None
|
z_grid
|
ndarray
|
Distance grid for longitudinal profile in cm. If None, uses config["advanced"]["z grid"]. Shape: (n_distances,) |
None
|
function
|
bool
|
If True, returns callable functions. Default is False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
differential_counts |
ndarray or Callable
|
Differential photon counts dN/dλ per cascade. Shape: (n_wavelengths,) if function=False |
differential_counts_sample |
ndarray or Callable
|
Sampled version for stochastic modeling. Same shape as differential_counts. |
em_fraction_mean |
float or Callable
|
Mean electromagnetic fraction of the cascade. Typically 0.5-0.9 depending on energy and particle type. |
em_fraction_sample |
float or Callable
|
Sampled electromagnetic fraction for stochastic modeling. |
long_profile |
ndarray or Callable
|
Longitudinal shower development profile. Shape: (n_distances,) if function=False |
angles |
ndarray or Callable
|
Angular distribution of emitted Cherenkov light. Shape: (n_angles,) if function=False |
Examples:
Calculate yield from 100 GeV positive pion:
>>> fennel = Fennel()
>>> energy = 100.0 # GeV
>>> dcounts, dcounts_s, em_frac, em_frac_s, long_prof, angles = ... fennel.hadron_yields(energy, particle=211)
>>> print(f"EM fraction: {em_frac:.2f}")
EM fraction: 0.74
Compare different hadrons:
>>> pion_yields = fennel.hadron_yields(1000.0, particle=211)
>>> proton_yields = fennel.hadron_yields(1000.0, particle=2212)
>>> kaon_yields = fennel.hadron_yields(1000.0, particle=130)
Notes
- Hadronic cascades have both electromagnetic and hadronic components
- The EM fraction increases with energy
- Protons tend to have lower EM fractions than pions at same energy
- The longitudinal profile is typically longer than EM cascades
- Particle/antiparticle pairs may have slightly different yields
Source code in fennel/fennel.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 | |
hadron_yields_v2 ¶
hadron_yields_v2(energy: float, particle: int, wavelengths: Optional[ndarray] = None, angle_grid: Optional[ndarray] = None, n: Optional[float] = None, z_grid: Optional[ndarray] = None, function: bool = False) -> HadronYieldResult
Calculate hadron cascade light yields with enhanced API (v2.0).
This is an improved version of hadron_yields() that returns a structured result container and includes comprehensive input validation with helpful error messages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
energy
|
float
|
Hadron energy in GeV. Must be positive. |
required |
particle
|
int
|
PDG ID: 211 (π+), -211 (π-), 130 (K_L), 2212 (p), 2112 (n) |
required |
wavelengths
|
ndarray
|
Wavelength grid in nm. If None, uses config default. |
None
|
angle_grid
|
ndarray
|
Angular grid in radians. If None, uses config default. |
None
|
n
|
float
|
Refractive index. If None, uses config medium value. |
None
|
z_grid
|
ndarray
|
Longitudinal distance grid. If None, uses config default. |
None
|
function
|
bool
|
If True, returns callables instead of evaluated arrays. |
False
|
Returns:
| Type | Description |
|---|---|
HadronYieldResult
|
Container with dcounts, dcounts_sample, em_fraction, em_fraction_sample, longitudinal_profile, angles, energy, and particle attributes. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If any input parameter is invalid, with helpful error message. |
Examples:
>>> fennel = Fennel()
>>> result = fennel.hadron_yields_v2(1000.0, particle=211)
>>> print(result)
HadronYieldResult(energy=1000.0 GeV, particle=π+, em_frac=0.74, mode=array)
>>> print(f"EM fraction: {result.em_fraction:.1%}")
EM fraction: 74.0%
See Also
hadron_yields : Original API method (still supported) quick_cascade : Simplified interface with minimal parameters
Source code in fennel/fennel.py
848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 | |
hidden_function ¶
Yaha! You found me!
Source code in fennel/fennel.py
pars2csv ¶
Write the parameters to a csv file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
None
|
|
required |
Returns:
| Type | Description |
|---|---|
None
|
|
quick_cascade ¶
Quick cascade calculation with minimal parameters.
Automatically detects whether the particle is EM or hadronic and calls the appropriate method. Uses sensible defaults from configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
energy
|
float
|
Cascade energy in GeV |
required |
particle
|
int
|
PDG ID of the particle |
required |
Returns:
| Type | Description |
|---|---|
EMYieldResult or HadronYieldResult
|
Appropriate result container based on particle type |
Examples:
>>> fennel = Fennel()
>>> electron_result = fennel.quick_cascade(1000.0, particle=11)
>>> pion_result = fennel.quick_cascade(1000.0, particle=211)
Source code in fennel/fennel.py
quick_track ¶
Quick track calculation with minimal parameters.
Uses sensible defaults for wavelengths, angles, and refractive index from configuration. Perfect for quick calculations or when you don't need to customize the grids.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
energy
|
float
|
Particle energy in GeV |
required |
interaction
|
str
|
Energy loss mechanism |
'total'
|
Returns:
| Type | Description |
|---|---|
TrackYieldResult
|
Result container with default grids |
Examples:
>>> fennel = Fennel()
>>> result = fennel.quick_track(100.0)
>>> result = fennel.quick_track(100.0, interaction='brems')
Source code in fennel/fennel.py
track_yields ¶
track_yields(energy: float, wavelengths: Optional[ndarray] = None, angle_grid: Optional[ndarray] = None, n: Optional[float] = None, interaction: str = 'total', function: bool = False) -> Union[Tuple[np.ndarray, np.ndarray], Tuple[Callable, Callable]]
Calculate Cherenkov light yields from charged particle tracks (muons).
Computes the differential photon counts as a function of wavelength and the angular distribution of emitted Cherenkov light for a charged particle track (currently muons only).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
energy
|
float
|
Particle energy in GeV. Must be positive. |
required |
wavelengths
|
ndarray
|
Wavelengths at which to calculate yields in nm. If None, uses config["advanced"]["wavelengths"]. Shape: (n_wavelengths,) |
None
|
angle_grid
|
ndarray
|
Emission angles in degrees for angular distribution. If None, uses config["advanced"]["angles"]. Shape: (n_angles,) |
None
|
n
|
float
|
Refractive index of the medium. If None, uses value from config for current medium. Must be > 1 for Cherenkov emission. |
None
|
interaction
|
(total, ionization, brems, pair, nuclear)
|
Energy loss mechanism to consider: - 'total': All interactions combined (default) - 'ionization': Ionization losses only - 'brems': Bremsstrahlung only - 'pair': Pair production only - 'nuclear': Nuclear interactions only |
'total'
|
function
|
bool
|
If True, returns callable functions instead of evaluated arrays. In JAX mode, these functions only accept scalar inputs. Default is False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
differential_counts |
ndarray or Callable
|
If function=False: Array of differential photon counts dN/dλ per cm of track length. Shape: (n_wavelengths,) If function=True: Callable with signature (energy, wavelength) -> float |
angles |
ndarray or Callable
|
If function=False: Angular distribution of emitted light. Shape: (n_angles,) If function=True: Callable with signature (angle, n, energy) -> float |
Examples:
Calculate light yield for 100 GeV muon:
>>> fennel = Fennel()
>>> wavelengths = np.linspace(300, 600, 100)
>>> energy = 100.0 # GeV
>>> dcounts, angles = fennel.track_yields(energy, wavelengths=wavelengths)
>>> total_photons_per_cm = integrate_trapezoid(dcounts, wavelengths)
Get functional form for later evaluation:
>>> dcounts_func, angles_func = fennel.track_yields(
... energy, function=True
... )
>>> yield_at_400nm = dcounts_func(energy, 400.0)
Calculate only bremsstrahlung contribution:
Notes
- Currently only supports muons (PDG ID 13, -13)
- In JAX mode with function=True, returned functions are JIT-compiled
- The angular distribution is normalized to integrate to 1
- Wavelengths should be in the optical/UV range (typically 300-600 nm)
Source code in fennel/fennel.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 | |
track_yields_v2 ¶
track_yields_v2(energy: float, wavelengths: Optional[ndarray] = None, angle_grid: Optional[ndarray] = None, n: Optional[float] = None, interaction: str = 'total', function: bool = False) -> TrackYieldResult
Calculate track light yields with enhanced API (v2.0).
This is an improved version of track_yields() that returns a structured result container and includes comprehensive input validation with helpful error messages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
energy
|
float
|
Particle energy in GeV. Must be positive. |
required |
wavelengths
|
ndarray
|
Wavelength grid in nm. If None, uses config default. |
None
|
angle_grid
|
ndarray
|
Angular grid in radians. If None, uses config default. |
None
|
n
|
float
|
Refractive index. If None, uses config medium value. |
None
|
interaction
|
str
|
Energy loss mechanism: 'total', 'brems', 'pair', 'compton', etc. |
'total'
|
function
|
bool
|
If True, returns callables instead of evaluated arrays. |
False
|
Returns:
| Type | Description |
|---|---|
TrackYieldResult
|
Container with dcounts, angles, energy, and interaction attributes. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If any input parameter is invalid, with helpful error message. |
Examples:
>>> fennel = Fennel()
>>> result = fennel.track_yields_v2(100.0)
>>> print(result)
TrackYieldResult(energy=100.0 GeV, interaction='total', mode=array)
>>> total_photons = integrate_trapezoid(result.dcounts, wavelengths)
See Also
track_yields : Original API method (still supported) quick_track : Simplified interface with minimal parameters