xsuite_collider
This class is used to build a Xsuite collider from a madx sequence and optics.
XsuiteCollider
XsuiteCollider is a class designed to handle the configuration and manipulation of a collider using the Xsuite library. It provides methods to load, configure, and tune the collider, as well as to perform luminosity leveling and beam-beam interaction setup.
Attributes:
| Name | Type | Description |
|---|---|---|
path_collider_file_for_configuration_as_input |
str
|
Path to the collider file to load. |
config_beambeam |
dict
|
Configuration for beam-beam interactions. |
config_knobs_and_tuning |
dict
|
Configuration for knobs and tuning. |
config_lumi_leveling |
dict
|
Configuration for luminosity leveling. |
config_lumi_leveling_ip1_5 |
dict or None
|
Configuration for luminosity leveling at IP1 and IP5. |
config_collider |
dict
|
Configuration for the collider. |
ver_hllhc_optics |
float
|
Version of the HL-LHC optics. |
ver_lhc_run |
float
|
Version of the LHC run. |
ions |
bool
|
Flag indicating if ions are used. |
_dict_orbit_correction |
dict or None
|
Dictionary for orbit correction. |
_crab |
bool or None
|
Flag indicating if crab cavities are used. |
save_output_collider |
bool
|
Flag indicating if the final collider should be saved. |
path_collider_file_for_tracking_as_output |
str
|
Path to save the final collider. |
Methods:
| Name | Description |
|---|---|
dict_orbit_correction |
Property to get the dictionary for orbit correction. |
load_collider |
Loads the collider from a file. |
install_beam_beam_wrapper |
Installs beam-beam lenses in the collider. |
set_knobs |
Sets the knobs for the collider. |
match_tune_and_chroma |
Matches the tune and chromaticity of the collider. |
set_filling_and_bunch_tracked |
Sets the filling scheme and tracks the bunch. |
compute_collision_from_scheme |
Computes the number of collisions from the filling scheme. |
crab |
Property to get the crab cavities status. |
level_all_by_separation |
Levels all IPs by separation. |
level_ip1_5_by_bunch_intensity |
Levels IP1 and IP5 by bunch intensity. |
level_ip2_8_by_separation |
Levels IP2 and IP8 by separation. |
add_linear_coupling |
Adds linear coupling to the collider. |
assert_tune_chroma_coupling |
Asserts the tune, chromaticity, and coupling of the collider. |
configure_beam_beam |
Configures the beam-beam interactions. |
record_final_luminosity |
Records the final luminosity of the collider. |
write_collider_to_disk |
Writes the collider configuration to disk. |
update_configuration_knob |
Updates a specific knob in the collider. |
return_fingerprint |
Returns a fingerprint of the collider's configuration. |
Source code in study_da/generate/master_classes/xsuite_collider.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 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 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 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 383 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 478 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 584 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 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 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 847 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 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 | |
crab: bool
property
This method checks the configuration settings for the presence and value of the
"on_crab1" knob. If the knob is present and its value is non-zero, it sets the
_crab attribute to True, indicating that crab cavities are active. Otherwise,
it sets _crab to False.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if crab cavities are active, False otherwise. |
dict_orbit_correction: dict
property
Generates and returns a dictionary containing orbit correction parameters.
This method checks if the orbit correction dictionary has already been generated. If not, it determines the appropriate set of orbit correction parameters based on the version of HLLHC optics or LHC run provided.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary containing orbit correction parameters. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If both |
ValueError
|
If no optics specific tools are available for the provided configuration. |
__init__(configuration, path_collider_file_for_configuration_as_input, ver_hllhc_optics, ver_lhc_run, ions)
Initialize the XsuiteCollider class with the given configuration and parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
configuration
|
dict
|
A dictionary containing various configuration settings. - config_beambeam (dict): Configuration for beam-beam interactions. - config_knobs_and_tuning (dict): Configuration for knobs and tuning. - config_lumi_leveling (dict): Configuration for luminosity leveling. - save_output_collider (bool): Flag to save the final collider to disk. - path_collider_file_for_tracking_as_output (str): Path to save the final collider. - config_lumi_leveling_ip1_5 (optional): Configuration for luminosity leveling at IP1 and IP5. |
required |
path_collider_file_for_configuration_as_input
|
str
|
Path to the collider file. |
required |
ver_hllhc_optics
|
float
|
Version of the HL-LHC optics. |
required |
ver_lhc_run
|
float
|
Version of the LHC run. |
required |
ions
|
bool
|
Flag indicating if ions are used. |
required |
Source code in study_da/generate/master_classes/xsuite_collider.py
add_linear_coupling(collider)
Adds linear coupling to the collider based on the version of the LHC run or HL-LHC optics.
This method adjusts the collider variables to introduce linear coupling. The specific adjustments depend on the version of the LHC run or HL-LHC optics being used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collider
|
Multiline
|
The collider object to which linear coupling will be added. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the version of the optics or run is unknown. |
Notes
- For LHC Run 3.0, the
cmrs.b1_sqandcmrs.b2_sqvariables are adjusted. - For HL-LHC optics versions 1.6, 1.5, 1.4, and 1.3, the
c_minus_re_b1andc_minus_re_b2variables are adjusted.
Source code in study_da/generate/master_classes/xsuite_collider.py
assert_tune_chroma_coupling(collider)
Asserts that the tune, chromaticity, and linear coupling of the collider match the expected values specified in the configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collider
|
Multiline
|
The collider object containing the lines to be checked. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If any of the tune, chromaticity, or linear coupling values do not match the expected values within the specified tolerances. |
Notes
The function checks the following parameters for each line ("lhcb1" and "lhcb2"): - Horizontal tune (qx) - Vertical tune (qy) - Horizontal chromaticity (dqx) - Vertical chromaticity (dqy) - Linear coupling (c_minus)
The expected values are retrieved from the self.config_knobs_and_tuning dictionary.
Source code in study_da/generate/master_classes/xsuite_collider.py
compute_collision_from_scheme()
This method reads a filling scheme from a JSON file specified in the configuration, converts the filling scheme into boolean arrays for two beams, and calculates the number of collisions at IP1 & IP5, IP2, and IP8 by performing convolutions on the arrays.
Returns:
| Type | Description |
|---|---|
tuple[int, int, int]
|
tuple[int, int, int]: A tuple containing the number of collisions at IP1 & IP5, IP2, and IP8 respectively. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the filling scheme file is not in JSON format. |
AssertionError
|
If the length of the beam arrays is not 3564. |
Source code in study_da/generate/master_classes/xsuite_collider.py
configure_beam_beam(collider)
Configures the beam-beam interactions for the collider.
This method sets up the beam-beam interactions by configuring the number of particles per bunch, the horizontal emittance (nemitt_x), and the vertical emittance (nemitt_y) based on the provided configuration. Additionally, it configures the filling scheme mask and bunch numbers if a filling pattern is specified in the configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collider
|
Multiline
|
The collider object to configure. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in study_da/generate/master_classes/xsuite_collider.py
install_beam_beam_wrapper(collider)
This method installs beam-beam interactions in the collider with the specified parameters. The beam-beam lenses are initially inactive and not configured.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collider
|
Multiline
|
The collider object where the beam-beam interactions will be installed. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in study_da/generate/master_classes/xsuite_collider.py
level_all_by_separation(n_collisions_ip1_and_5, n_collisions_ip2, n_collisions_ip8, collider)
This method updates the number of colliding bunches for IP1, IP2, IP5, and IP8 in the configuration file and performs luminosity leveling using the provided collider object. It also updates the separation knobs for the collider based on the new configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_collisions_ip1_and_5
|
int
|
Number of collisions at interaction points 1 and 5. |
required |
n_collisions_ip2
|
int
|
Number of collisions at interaction point 2. |
required |
n_collisions_ip8
|
int
|
Number of collisions at interaction point 8. |
required |
collider
|
Multiline
|
The collider object to be used for luminosity leveling. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in study_da/generate/master_classes/xsuite_collider.py
level_ip1_5_by_bunch_intensity(collider, n_collisions_ip1_and_5)
This method modifies the bunch intensity to achieve the desired luminosity levels in IP 1 and 5. It updates the configuration with the new intensity values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collider
|
Multiline
|
The collider object containing the beam and lattice configuration. |
required |
n_collisions_ip1_and_5
|
int
|
The number of collisions in IP 1 and 5. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in study_da/generate/master_classes/xsuite_collider.py
level_ip2_8_by_separation(n_collisions_ip2, n_collisions_ip8, collider)
This method updates the number of colliding bunches for IP2 and IP8 in the configuration file, performs luminosity leveling for the specified collider, and updates the separation knobs for both interaction points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_collisions_ip2
|
int
|
The number of collisions at interaction point 2 (IP2). |
required |
n_collisions_ip8
|
int
|
The number of collisions at interaction point 8 (IP8). |
required |
collider
|
Multiline
|
The collider object for which the luminosity leveling is to be performed. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in study_da/generate/master_classes/xsuite_collider.py
load_collider()
Load a collider configuration from a file.
If the file path ends with ".zip", the file is uncompressed locally and the collider configuration is loaded from the uncompressed file. Otherwise, the collider configuration is loaded directly from the file.
Returns:
| Type | Description |
|---|---|
Multiline
|
xt.Multiline: The loaded collider configuration. |
Source code in study_da/generate/master_classes/xsuite_collider.py
match_tune_and_chroma(collider, match_linear_coupling_to_zero=True)
This method adjusts the tune and chromaticity of the specified collider lines ("lhcb1" and "lhcb2") to the target values defined in the configuration. It also optionally matches the linear coupling to zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collider
|
Multiline
|
The collider object containing the lines to be tuned. |
required |
match_linear_coupling_to_zero
|
bool
|
If True, linear coupling will be matched to zero. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in study_da/generate/master_classes/xsuite_collider.py
record_beta_functions(collider)
Records the beta functions at the IPs in the collider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collider
|
Multiline
|
The collider object to record the beta functions. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in study_da/generate/master_classes/xsuite_collider.py
record_final_luminosity(collider, l_n_collisions)
Records the final luminosity and pile-up for specified interaction points (IPs) in the collider, both with and without beam-beam effects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collider
|
(xt.Multiline): The collider object configured. |
required | |
l_n_collisions
|
list[int]
|
A list containing the number of colliding bunches for each IP. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in study_da/generate/master_classes/xsuite_collider.py
return_fingerprint(collider, line_name='lhcb1')
staticmethod
Generate a detailed fingerprint of the specified collider line. Useful to compare two colliders.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collider
|
Multiline
|
The collider object containing the line data. |
required |
line_name
|
str
|
The name of the line to analyze within the collider. Default to "lhcb1". |
'lhcb1'
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A formatted string containing detailed information about the collider line, including: - Installed element types - Tunes and chromaticity - Synchrotron tune and slip factor - Twiss parameters and phases at interaction points (IPs) - Dispersion and crab dispersion at IPs - Amplitude detuning coefficients - Non-linear chromaticity - Tunes and momentum compaction vs delta |
Source code in study_da/generate/master_classes/xsuite_collider.py
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 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 | |
set_filling_and_bunch_tracked(ask_worst_bunch=False)
Sets the filling scheme and determines the bunch to be tracked for beam-beam interactions.
This method performs the following steps:
1. Retrieves the filling scheme path from the configuration.
2. Checks if the filling scheme path needs to be obtained from the template schemes.
3. Loads and verifies the filling scheme, potentially converting it if necessary.
4. Updates the configuration with the correct filling scheme path.
5. Determines the number of long-range encounters to consider.
6. If the bunch number for beam 1 is not provided, it identifies the bunch with the largest
number of long-range interactions.
- If ask_worst_bunch is True, prompts the user to confirm or provide a bunch number.
- Otherwise, automatically selects the worst bunch.
7. If the bunch number for beam 2 is not provided, it automatically selects the worst bunch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ask_worst_bunch
|
bool
|
If True, prompts the user to confirm or provide the bunch number for beam 1. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in study_da/generate/master_classes/xsuite_collider.py
set_knobs(collider)
Set all knobs for the collider, including crossing angles, dispersion correction, RF, crab cavities, experimental magnets, etc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collider
|
Multiline
|
The collider object to which the knob settings will be applied. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in study_da/generate/master_classes/xsuite_collider.py
update_configuration_knob(collider, dictionnary, knob_name)
staticmethod
Updates the given dictionary with the final value of a specified knob from the collider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collider
|
Multiline
|
The collider object containing various variables. |
required |
dictionnary
|
dict
|
The dictionary to be updated with the knob's final value. |
required |
knob_name
|
str
|
The name of the knob whose value is to be retrieved and stored. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in study_da/generate/master_classes/xsuite_collider.py
write_collider_to_disk(collider, full_configuration)
Writes the collider object to disk in JSON format if the save_output_collider flag is set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collider
|
Collider
|
The collider object to be saved. |
required |
full_configuration
|
dict
|
The full configuration dictionary to be deep-copied into the collider's metadata. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |