cres/
lib.rs

1//! `cres` is a crate for cell resampling, introduced in
2//!
3//! Unbiased Elimination of Negative Weights in Monte Carlo Samples\
4//! J. Andersen, A. Maier\
5//! [arXiv:2109.07851](https://arxiv.org/abs/2109.07851)
6//!
7//! Efficient negative-weight elimination in large high-multiplicity Monte Carlo event samples\
8//! Jeppe R. Andersen, Andreas Maier, Daniel MaƮtre\
9//! [arXiv:2303.15246](https://arxiv.org/abs/2303.15246)
10//!
11//! # How to use
12//!
13//! Probably the best way to get started is to look at the examples, starting with
14//! `examples/minimal.rs`.
15//!
16//! ## Most relevant modules
17//!
18//! - [prelude] exports a list of the most relevant classes and objects
19//! - [cres] contains the main class and lists the steps that are performed
20//! - [io] event input and output (from and to files)
21//! - [event] for the internal event format
22//! - [distance] for user-defined distance functions
23//! - [seeds] and [resampler] for the resampling
24//!
25#![warn(missing_docs)]
26
27#[cfg(target_family = "unix")]
28#[cfg(feature = "capi")]
29pub mod c_api;
30/// Definition of event cells
31pub mod cell;
32/// Callbacks used upon cell construction and when writing out events
33pub mod cell_collector;
34/// Jet clustering helpers
35pub mod cluster;
36/// Output compression
37pub mod compression;
38pub mod cres;
39/// Distance functions
40pub mod distance;
41/// Scattering event class
42pub mod event;
43/// Supported event file formats
44pub mod formats;
45/// Four-vector class
46pub mod four_vector;
47/// HepMC2 interface
48pub mod hepmc2;
49/// Event input/output
50pub mod io;
51/// LesHouches Event File interface
52#[cfg(feature = "lhef")]
53pub mod lhef;
54/// Nearest neighbour search algorithms
55pub mod neighbour_search;
56/// BlackHat ntuple interface
57#[cfg(feature = "ntuple")]
58pub mod ntuple;
59/// Phase-space partitions
60pub mod partition;
61/// Most important exports
62pub mod prelude;
63/// Progress bar
64pub mod progress_bar;
65/// Cell resampling
66pub mod resampler;
67/// Cell seed selection
68pub mod seeds;
69/// STRIPPER XML interface
70#[cfg(feature = "stripper-xml")]
71pub mod stripper_xml;
72/// Common traits
73pub mod traits;
74/// Unweighting
75pub mod unweight;
76/// Vantage-point tree
77pub mod vptree;
78
79mod parsing;
80mod util;
81
82const fn parse_version(s: &str) -> u32 {
83    match u32::from_str_radix(s, 10) {
84        Ok(int) => int,
85        Err(_) => panic!("Failed to parse version number"),
86    }
87}
88
89/// cres version
90pub const VERSION: &str = env!("CARGO_PKG_VERSION");
91/// Major version number
92pub const VERSION_MAJOR: u32 = parse_version(env!("CARGO_PKG_VERSION_MAJOR"));
93/// Minor version number
94pub const VERSION_MINOR: u32 = parse_version(env!("CARGO_PKG_VERSION_MINOR"));
95/// Patch version number
96pub const VERSION_PATCH: u32 = parse_version(env!("CARGO_PKG_VERSION_PATCH"));
97/// Hash of the compiled git commit
98pub const GIT_REV: Option<&str> = option_env!("VERGEN_GIT_SHA");
99/// git branch during compilation
100pub const GIT_BRANCH: Option<&str> = option_env!("VERGEN_GIT_BRANCH");
101
102/// Features enabled during compilation
103pub const FEATURES: [&str; NFEATURES] = [
104    #[cfg(feature = "lhef")]
105    "lhef",
106    #[cfg(feature = "multiweight")]
107    "multiweight",
108    #[cfg(feature = "ntuple")]
109    "ntuple",
110    #[cfg(feature = "stripper-xml")]
111    "stripper-xml",
112    #[cfg(feature = "capi")]
113    "capi",
114];
115
116const NFEATURES: usize = {
117    #[allow(unused_mut)]
118    let mut nfeatures = 0;
119    #[cfg(feature = "lhef")]
120    {
121        nfeatures += 1;
122    }
123    #[cfg(feature = "multiweight")]
124    {
125        nfeatures += 1;
126    }
127    #[cfg(feature = "ntuple")]
128    {
129        nfeatures += 1;
130    }
131    #[cfg(feature = "stripper-xml")]
132    {
133        nfeatures += 1;
134    }
135    #[cfg(feature = "capi")]
136    {
137        nfeatures += 1;
138    }
139    nfeatures
140};
141
142pub use noisy_float::prelude::{n64, N64, Float};
143pub use particle_id::*;