33 * SPDX-License-Identifier: MIT
44 */
55
6+ /**
7+ * @file JetReconstruction.h
8+ * @brief Header file for the C-bindings of JetReconstruction.jl.
9+ *
10+ * This file contains the definitions of data structures and functions used in
11+ * JetReconstruction.jl. The library provides functionality for efficient jet
12+ * reconstruction.
13+ */
14+
615#include <stddef.h>
716
817/*Special states in a history.*/
18+
19+ /**Special history state: Invalid child for this jet, meaning it did not
20+ * recombine further */
921#define JETRECONSTRUCTION_INVALID -3
22+ /**Special history state: Original cluster so it has no parent */
1023#define JETRECONSTRUCTION_NONEXISTENTPARENT -2
24+ /**Special history state: Cluster recombined with beam" */
1125#define JETRECONSTRUCTION_BEAMJET -1
1226
13- /*
14- Enumeration representing different jet algorithms used in
15- the JetReconstruction module.
16- */
27+ /**
28+ * @enum jetreconstruction_JetAlgorithm
29+ * @brief Enumeration representing different jet algorithms used in
30+ * the JetReconstruction.
31+ */
1732typedef enum {
18- JETRECONSTRUCTION_JETALGORITHM_ANTIKT = 0 , /* The Anti-Kt algorithm. */
19- JETRECONSTRUCTION_JETALGORITHM_CA = 1 , /* The Cambridge/Aachen algorithm. */
20- JETRECONSTRUCTION_JETALGORITHM_KT = 2 , /* The Inclusive-Kt algorithm. */
33+ JETRECONSTRUCTION_JETALGORITHM_ANTIKT = 0 , /**< The Anti-Kt algorithm. */
34+ JETRECONSTRUCTION_JETALGORITHM_CA = 1 , /**< The Cambridge/Aachen algorithm. */
35+ JETRECONSTRUCTION_JETALGORITHM_KT = 2 , /**< The Inclusive-Kt algorithm. */
2136 JETRECONSTRUCTION_JETALGORITHM_GENKT =
22- 3 , /* The Generalised Kt algorithm (with arbitrary power). */
37+ 3 , /**< The Generalised Kt algorithm (with arbitrary power). */
2338 JETRECONSTRUCTION_JETALGORITHM_EEKT =
24- 4 , /* The Generalised e+e- kt algorithm. */
39+ 4 , /**< The Generalised e+e- kt algorithm. */
2540 JETRECONSTRUCTION_JETALGORITHM_DURHAM =
26- 5 /* The e+e- kt algorithm, aka Durham. */
41+ 5 /**< The e+e- kt algorithm, aka Durham. */
2742} jetreconstruction_JetAlgorithm ;
2843
29- /*
30- Scoped enumeration (using EnumX) representing the different strategies for jet
31- reconstruction.
32- */
44+ /**
45+ * @enum jetreconstruction_RecoStrategy
46+ * @brief Enumeration representing the different strategies for jet
47+ * reconstruction.
48+ */
3349typedef enum {
34- JETRECONSTRUCTION_RECOSTRATEGY_BEST = 0 , /* The best strategy. */
35- JETRECONSTRUCTION_RECOSTRATEGY_N2PLAIN = 1 , /* The plain N2 strategy. */
36- JETRECONSTRUCTION_RECOSTRATEGY_N2TILTED = 2 /* The tiled N2 strategy. */
50+ JETRECONSTRUCTION_RECOSTRATEGY_BEST = 0 , /**< The best strategy. */
51+ JETRECONSTRUCTION_RECOSTRATEGY_N2PLAIN = 1 , /**< The plain N2 strategy. */
52+ JETRECONSTRUCTION_RECOSTRATEGY_N2TILTED = 2 /**< The tiled N2 strategy. */
3753} jetreconstruction_RecoStrategy ;
3854
39- /* The `PseudoJet` struct represents a pseudojet, a four-momentum object used in
40- jet reconstruction algorithms. Additional information for the link back into the
41- history of the clustering is stored in the `_cluster_hist_index` field. There is
42- caching of the more expensive calculations for rapidity and azimuthal angle.*/
55+ /**
56+ * @struct jetreconstruction_PseudoJet
57+ * @brief A struct representing a pseudojet, a four-momentum object used in
58+ * jet reconstruction algorithms. Additional information for the link back into
59+ * the history of the clustering is stored in the _cluster_hist_index field.
60+ * There is caching of the more expensive calculations for rapidity and
61+ * azimuthal angle.
62+ */
4363typedef struct {
44- double px ; /* The x-component of the momentum. */
45- double py ; /* The y-component of the momentum. */
46- double pz ; /* The z-component of the momentum. */
47- double E ; /* The energy component of the momentum. */
48- long _cluster_hist_index ; /* The index of the cluster history. */
49- double _pt2 ; /* The squared transverse momentum. */
50- double _inv_pt2 ; /* The inverse squared transverse momentum. */
51- double _rap ; /* The rapidity. */
52- double _phi ; /* The azimuthal angle. */
64+ double px ; /**< The x-component of the momentum. */
65+ double py ; /**< The y-component of the momentum. */
66+ double pz ; /**< The z-component of the momentum. */
67+ double E ; /**< The energy component of the momentum. */
68+ long _cluster_hist_index ; /**< The index of the cluster history. */
69+ double _pt2 ; /**< The squared transverse momentum. */
70+ double _inv_pt2 ; /**< The inverse squared transverse momentum. */
71+ double _rap ; /**< The rapidity. */
72+ double _phi ; /**< The azimuthal angle. */
5373} jetreconstruction_PseudoJet ;
5474
75+ /**
76+ * @brief Initializes a jetreconstruction_PseudoJet object with given momentum.
77+ *
78+ * @param[in] ptr Pointer to the jetreconstruction_PseudoJet object to be
79+ * initialized.
80+ * @param[in] px The x-component of the momentum.
81+ * @param[in] py The y-component of the momentum.
82+ * @param[in] pz The z-component of the momentum.
83+ * @param[in] E The energy component of the momentum.
84+ * @return An integer status code indicating the success or failure.
85+ */
5586int jetreconstruction_PseudoJet_init (jetreconstruction_PseudoJet * ptr ,
5687 double px , double py , double pz , double E );
57- /*
58- A struct holding a record of jet mergers and finalisations
59- */
88+
89+ /**
90+ * @struct jetreconstruction_HistoryElement
91+ * @brief A struct holding a record of jet mergers and finalisations.
92+ */
6093typedef struct {
61- long parent1 ; /* Index in history where first parent of this jet was
62- created (NonexistentParent if this jet is an original
63- particle) */
64- long parent2 ; /* Index in history where second parent of this jet was
65- created (NonexistentParent if this jet is an original
66- particle); BeamJet if this history entry just labels the
67- fact that the jet has recombined with the beam */
68- long child ; /* Index in history where the current jet is recombined with
69- another jet to form its child. It is Invalid
70- if this jet does not further recombine. */
71- long jetp_index ; /* Index in the jets vector where we will find the
94+ long parent1 ; /**< Index in history where first parent of this jet was
95+ created (@ref JETRECONSTRUCTION_NONEXISTENTPARENT if this jet is
96+ an original particle) */
97+ long parent2 ; /**< Index in history where second parent of this jet was
98+ created (@ref JETRECONSTRUCTION_NONEXISTENTPARENT if this jet is
99+ an original particle); @ref JETRECONSTRUCTION_BEAMJET if this
100+ history entry just labels the fact that the jet has
101+ recombined with the beam */
102+ long child ; /**< Index in history where the current jet is recombined with
103+ another jet to form its child. It is Invalid
104+ if this jet does not further recombine. */
105+ long jetp_index ; /**< Index in the jets vector where we will find the
72106 PseudoJet object corresponding to this jet (i.e. the
73107 jet created at this entry of the history). NB: if this
74108 element of the history corresponds to a beam
75- recombination, then `jetp_index=Invalid`. */
76- double dij ; /* The distance corresponding to the recombination at this
77- stage of the clustering. */
78- double max_dij_so_far ; /* The largest recombination distance seen so far
109+ recombination, then @p jetp_index = @ref JETRECONSTRUCTION_INVALID.
110+ */
111+ double dij ; /**< The distance corresponding to the recombination at this
112+ stage of the clustering. */
113+ double max_dij_so_far ; /**< The largest recombination distance seen so far
79114 in the clustering history */
80115} jetreconstruction_HistoryElement ;
81116
82- /*
83- A struct holding the full history of a jet clustering sequence, including the
84- final jets.
85- */
117+ /**
118+ * @struct jetreconstruction_ClusterSequence
119+ * @brief A struct holding the full history of a jet clustering sequence,
120+ * including the final jets.
121+ */
86122typedef struct {
87123 jetreconstruction_JetAlgorithm
88- algorithm ; /* The algorithm used for clustering. */
89- double power ; /* The power value used for the clustering algorithm (note that
90- this value is always stored as a Float64 to be
91- type stable) */
92- double R ; /* The R parameter used for the clustering algorithm. */
124+ algorithm ; /**< The algorithm used for clustering. */
125+ double power ; /**< The power value used for the clustering algorithm */
126+ double R ; /**< The R parameter used for the clustering algorithm. */
93127 jetreconstruction_RecoStrategy
94- strategy ; /* The strategy used for clustering. */
128+ strategy ; /**< The strategy used for clustering. */
95129 jetreconstruction_PseudoJet
96- * jets ; /* The actual jets in the cluster sequence, which are of type `T
97- <: FourMomentum` . */
98- size_t jets_length ; /* Length of jets. */
99- long n_initial_jets ; /* The initial number of particles used for exclusive
130+ * jets ; /**< A pointer to an array of jetreconstruction_PseudoJet
131+ containing the actual jets in the cluster sequence . */
132+ size_t jets_length ; /**< The length of @ref jets array . */
133+ long n_initial_jets ; /**< The initial number of particles used for exclusive
100134 jets. */
101135 jetreconstruction_HistoryElement
102- * history ; /* The branching history of the cluster sequence. Each
103- stage in the history indicates where to look in the
104- jets vector to get the physical PseudoJet. */
105- size_t history_length ; /* Length of history. */
106- double Qtot ; /* The total energy of the event. */
136+ * history ; /**< A pointer to an array of jetreconstruction_HistoryElement
137+ containing the branching history of the cluster sequence.
138+ Each stage in the history indicates where to look in the jets
139+ vector to get the physical PseudoJet. */
140+ size_t history_length ; /**< The length of @ref history array. */
141+ double Qtot ; /**< The total energy of the event. */
107142} jetreconstruction_ClusterSequence ;
108143
144+ /** @private */
109145void jetreconstruction_ClusterSequence_free_members_ (
110146 jetreconstruction_ClusterSequence * ptr );
147+
148+ /**
149+ * @brief Frees the members of a jetreconstruction_ClusterSequence structure.
150+ *
151+ * This function releases any resources held by the members of the given
152+ * jetreconstruction_ClusterSequence structure.
153+ *
154+ * @param[in,out] ptr Pointer to the jetreconstruction_ClusterSequence
155+ * structure.
156+ */
111157static inline void jetreconstruction_ClusterSequence_free_members (
112158 jetreconstruction_ClusterSequence * ptr ) {
113159 jetreconstruction_ClusterSequence_free_members_ (ptr );
@@ -117,34 +163,128 @@ static inline void jetreconstruction_ClusterSequence_free_members(
117163 ptr -> history_length = 0 ;
118164}
119165
166+ /**
167+ * @brief Reconstructs jets from a collection of particles using a specified
168+ * algorithm and strategy.
169+ *
170+ * This function reconstructs jets from a collection of particles using a
171+ * specified algorithm and strategy.
172+ *
173+ * @note The memory allocated for members of @p result must be freed using
174+ * the @ref jetreconstruction_ClusterSequence_free_members function after the
175+ * @p result is no longer needed to prevent memory leaks.
176+ *
177+ * @param[in] particles Pointer to an array of pseudojet objects used for jet
178+ * reconstruction.
179+ * @param[in] particles_length The length of @p particles array.
180+ * @param[in] algorithm The algorithm to use for jet reconstruction.
181+ * @param[in] R The jet radius parameter.
182+ * @param[in] strategy The jet reconstruction strategy to use.
183+ * @param[out] result A pointer to which a cluster sequence containing the
184+ * reconstructed jets and the merging history will be stored.
185+ * @return An integer status code indicating the success or failure.
186+ */
120187int jetreconstruction_jet_reconstruct (
121188 const jetreconstruction_PseudoJet * particles , size_t particles_length ,
122189 jetreconstruction_JetAlgorithm algorithm , double R ,
123190 jetreconstruction_RecoStrategy strategy ,
124191 jetreconstruction_ClusterSequence * result );
125192
193+ /**
194+ * @struct jetreconstruction_JetsResult
195+ * @brief A structure to hold the inclusive or exclusive jets.
196+ */
126197typedef struct {
127- jetreconstruction_PseudoJet * data ;
128- size_t length ;
198+ jetreconstruction_PseudoJet * data ; /**< Pointer to an array of jetreconstruction_PseudoJet. */
199+ size_t length ; /**< The length of the @ref data array. */
129200} jetreconstruction_JetsResult ;
130201
202+ /** @private */
131203void jetreconstruction_JetsResult_free_members_ (
132204 jetreconstruction_JetsResult * ptr );
205+
206+ /**
207+ * @brief Frees the members of a jetreconstruction_JetsResult structure.
208+ *
209+ * This function releases any resources held by the members of the given
210+ * jetreconstruction_JetsResult structure.
211+ *
212+ * @param[in,out] ptr A pointer to the jetreconstruction_JetsResult structure.
213+ */
133214static inline void
134215jetreconstruction_JetsResult_free_members (jetreconstruction_JetsResult * ptr ) {
135216 jetreconstruction_JetsResult_free_members_ (ptr );
136217 ptr -> data = NULL ;
137218 ptr -> length = 0 ;
138219}
139220
221+ /**
222+ * @brief Return all exclusive jets of a jetreconstruction_ClusterSequence with
223+ * a cut on the maximum distance parameter.
224+ *
225+ * This function computes the exclusive jets from a given
226+ * jetreconstruction_ClusterSequence with a cut on the maximum distance
227+ * parameter.
228+ *
229+ * @note The memory allocated for members of @p result must be freed using
230+ * the @ref jetreconstruction_JetsResult_free_members function after the
231+ * @p result is no longer needed to prevent memory leaks.
232+ *
233+ * @param[in] clustersequence A pointer to the jetreconstruction_ClusterSequence
234+ * object containing the clustering history and jets.
235+ * @param[in] dcut The distance parameter used to define the exclusive jets.
236+ * @param[out] result A pointer to the jetreconstruction_JetsResult object where
237+ * the resulting jets will be stored.
238+ * @return An integer status code indicating the success or failure.
239+ */
140240int jetreconstruction_exclusive_jets_dcut (
141241 const jetreconstruction_ClusterSequence * clustersequence , double dcut ,
142242 jetreconstruction_JetsResult * result );
143243
244+ /**
245+ * @brief Return all exclusive jets of a jetreconstruction_ClusterSequence with
246+ * a specific number of jets.
247+ *
248+ * This function computes a specific number of exclusive jets from a given
249+ * jetreconstruction_ClusterSequence.
250+ *
251+ * @note The memory allocated for members of @p result must be freed using
252+ * the @ref jetreconstruction_JetsResult_free_members function after the
253+ * @p result is no longer needed to prevent memory leaks.
254+ *
255+ * @param[in] clustersequence A pointer to the jetreconstruction_ClusterSequence
256+ * object containing the clustering history and jets.
257+ * @param[in] njets The number of exclusive jets to be calculated.
258+ * @param[out] result A pointer to the jetreconstruction_JetsResult object where
259+ * the resulting jets will be stored.
260+ * @return An integer status code indicating the success or failure.
261+ */
144262int jetreconstruction_exclusive_jets_njets (
145263 const jetreconstruction_ClusterSequence * clustersequence , size_t njets ,
146264 jetreconstruction_JetsResult * result );
147265
266+ /**
267+ * @brief Return all inclusive jets of a jetreconstruction_ClusterSequence with
268+ * pt > @p ptmin.
269+ *
270+ * This function computes the inclusive jets from a given
271+ * jetreconstruction_ClusterSequence. It iterates over the clustering history
272+ * and checks the transverse momentum of each parent jet. If the transverse
273+ * momentum is greater than or equal to @p ptmin, the jet is added to results
274+ * structure.
275+ *
276+ * @note The memory allocated for members of @p result must be freed using
277+ * the @ref jetreconstruction_JetsResult_free_members function after the
278+ * @p result is no longer needed to prevent memory leaks.
279+ *
280+ * @param[in] clustersequence A pointer to the jetreconstruction_ClusterSequence
281+ * object containing the clustering history and jets.
282+ * @param[in] ptmin The minimum transverse momentum (pt) threshold for the
283+ * inclusive jets.
284+ * @param[out] result A pointer to the jetreconstruction_JetsResult object where
285+ * the resulting jets will be stored.
286+ * @return An integer status code indicating the success or failure.
287+ */
148288int jetreconstruction_inclusive_jets (
149289 const jetreconstruction_ClusterSequence * clustersequence , double ptmin ,
150290 jetreconstruction_JetsResult * result );
0 commit comments