avery/
event.rs

1use std::collections::{BTreeMap, HashMap};
2
3use particle_id::ParticleID;
4use petgraph::prelude::DiGraph;
5
6/// Scattering event
7#[derive(Clone, Debug, Default)]
8pub struct Event {
9    /// Event id
10    pub id: Option<i32>,
11    /// Global information about the current event sample
12    pub sample_info: SampleInfo,
13    /// Event weights
14    pub weights: Vec<WeightInfo>,
15    /// Scale settings
16    pub scales: Scales,
17    /// Value of the QCD coupling α_s
18    pub alpha_s: Option<f64>,
19    /// Value of the QED coupling α
20    pub alpha: Option<f64>,
21    /// ID of the process this event belongs to
22    pub process_id: Option<i32>,
23    /// Particles involved in the scattering
24    pub particles: Vec<Particle>,
25    /// Optional event information
26    pub info: String,
27    /// Optional additional structured information
28    pub attr: HashMap<String, String>,
29    /// Multiparton interaction
30    pub mpi: Option<i32>,
31    pub random_states: Vec<i32>,
32    /// Information for heavy ion collisions
33    pub heavy_ion_info: Option<HeavyIonInfo>,
34    /// Event topology
35    ///
36    /// Edge weights correspond to the index in the `particles` vector.
37    pub topology: DiGraph<Vertex, usize>,
38    /// STRIPPER-XML reweighting information
39    pub reweights: Vec<Reweight>,
40}
41
42/// Global information about an event sample
43#[derive(Clone, Debug, Default, PartialEq)]
44pub struct SampleInfo {
45    /// Generators used to produce the sample
46    pub generators: Vec<String>,
47    /// Number of events
48    pub nevents: Option<usize>,
49    /// Collider beam information
50    pub beam: [Beam; 2],
51    /// Parton Distribution Functions used
52    pub pdf: [Option<i32>; 2],
53    /// Cross sections for the various subprocesses
54    pub cross_sections: Vec<CrossSection>,
55    /// Subprocess IDs
56    pub process_ids: Vec<i32>,
57    /// How to interprete the event weights
58    pub weight_type: Option<i32>,
59    /// Optional run information
60    pub info: String,
61    /// Optional additional structured information
62    pub attr: HashMap<String, String>,
63}
64
65/// Event weight information
66#[derive(Clone, Debug, Default, PartialEq, PartialOrd)]
67pub struct WeightInfo {
68    /// The weight itself
69    pub weight: Option<f64>,
70    /// Weight name
71    pub name: Option<String>,
72    /// Factor multiplying the central renormalisation scale
73    pub mu_r_factor: Option<f64>,
74    /// Factor multiplying the central factorisation scale
75    pub mu_f_factor: Option<f64>,
76    /// PDF id
77    pub pdf: Option<i32>,
78    /// PDF id for second beam, if different from first beam
79    pub pdf2: Option<i32>,
80}
81
82// Scales associated with event
83#[derive(Clone, Debug, Default, PartialEq, PartialOrd)]
84pub struct Scales {
85    /// The renormalisation scale
86    pub mu_r: Option<f64>,
87    /// The factorisation scale
88    pub mu_f: Option<f64>,
89    /// The suggested parton shower starting scale
90    pub mu_ps: Option<f64>,
91}
92
93/// A particle
94#[derive(Clone, Debug, Default, PartialEq, PartialOrd)]
95pub struct Particle {
96    /// Particle type
97    pub id: Option<ParticleID>,
98    /// Four-momentum
99    pub p: Option<[f64; 4]>,
100    /// Mass
101    pub m: Option<f64>,
102    /// Status
103    pub status: Option<Status>,
104    /// Spin angle
105    pub spin: Option<f64>,
106    /// Colour flow (LHEF)
107    pub col: Option<[i32; 2]>,
108    /// Colour flow (HepMC)
109    pub flows: BTreeMap<i32, i32>,
110    /// Lifetime
111    pub lifetime: Option<f64>,
112    /// θ polarisation angle
113    pub theta: Option<f64>,
114    /// φ polarisation angle
115    pub phi: Option<f64>,
116}
117
118/// Beam information
119#[derive(Copy, Clone, Debug, Default, PartialEq, PartialOrd)]
120pub struct Beam {
121    /// Particle type
122    pub id: Option<ParticleID>,
123    /// Energy in GeV
124    pub energy: Option<f64>,
125}
126
127#[derive(Clone, Debug, Default, PartialEq, PartialOrd)]
128pub struct CrossSection {
129    /// Mean value for the cross section
130    pub mean: f64,
131    /// Cross section errors
132    pub err: Option<f64>,
133}
134
135#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)]
136pub enum Status {
137    /// Incoming particle
138    Incoming,
139    /// Outgoing particle
140    Outgoing,
141    /// Intermediate space-like propagator defining an x and Q^2 which should be preserved
142    IntermediateSpacelike,
143    /// Intermediate resonance, mass should be preserved
144    IntermediateResonance,
145    /// Intermediate resonance, for documentation only
146    IntermediateDoc,
147    /// Incoming beam particles at time t = −∞
148    IncomingBeam,
149    /// Unknown
150    Unknown(i32),
151}
152
153#[derive(Clone, Debug, Default, PartialEq, PartialOrd)]
154pub struct Vertex {
155    pub status: Option<i32>,
156    pub x: Option<f64>,
157    pub y: Option<f64>,
158    pub z: Option<f64>,
159    pub t: Option<f64>,
160    pub weights: Vec<f64>,
161}
162
163/// Information for heavy ion collisions
164#[derive(Debug, PartialEq, PartialOrd, Default, Copy, Clone)]
165pub struct HeavyIonInfo {
166    pub ncoll_hard: Option<i32>,
167    pub npart_proj: Option<i32>,
168    pub npart_targ: Option<i32>,
169    pub ncoll: Option<i32>,
170    pub spectator_neutrons: Option<i32>,
171    pub spectator_protons: Option<i32>,
172    pub n_nwounded_collisions: Option<i32>,
173    pub nwounded_n_collisions: Option<i32>,
174    pub nwounded_nwounded_collisions: Option<i32>,
175    pub impact_parameter: Option<f64>,
176    pub event_plane_angle: Option<f64>,
177    pub eccentricity: Option<f64>,
178    pub sigma_inel_nn: Option<f64>,
179}
180
181/// STRIPPER-XML reweighting information
182#[derive(Clone, Debug, PartialEq, PartialOrd)]
183pub struct Reweight {
184    pub channel: u32,
185    pub x1: f64,
186    pub x2: f64,
187    pub log_coeff: Vec<f64>,
188}