|
| 1 | +#include "JetReconstruction.h" |
| 2 | +#include "julia_init.h" |
| 3 | +#include <assert.h> |
| 4 | +#include <stdio.h> |
| 5 | +#include <stdlib.h> |
| 6 | +#include <time.h> |
| 7 | + |
| 8 | +void printPseudoJet(const jetreconstruction_PseudoJet *jet) { |
| 9 | + assert(jet != NULL); |
| 10 | + printf("PseudoJet(%f %f %f %f %ld %f %f %f %f)\n", jet->px, jet->py, jet->pz, |
| 11 | + jet->E, jet->_cluster_hist_index, jet->_pt2, jet->_inv_pt2, jet->_rap, |
| 12 | + jet->_phi); |
| 13 | +} |
| 14 | + |
| 15 | +void printHistoryElement(const jetreconstruction_HistoryElement *history) { |
| 16 | + assert(history != NULL); |
| 17 | + printf("HistoryElement(%ld %ld %ld %ld %lf %lf)\n", history->parent1, |
| 18 | + history->parent2, history->child, history->jetp_index, history->dij, |
| 19 | + history->max_dij_so_far); |
| 20 | +} |
| 21 | + |
| 22 | +void printClusterSequence(const jetreconstruction_ClusterSequence *sequence) { |
| 23 | + printf("Cluster Sequence Information:\n" |
| 24 | + "Algorithm: %d\n" |
| 25 | + "Power: %f\n" |
| 26 | + "R parameter: %f\n" |
| 27 | + "Strategy: %d\n" |
| 28 | + "Initial number of jets: %ld\n" |
| 29 | + "Total event energy (Qtot): %f\n", |
| 30 | + sequence->algorithm, sequence->power, sequence->R, sequence->strategy, |
| 31 | + sequence->n_initial_jets, sequence->Qtot); |
| 32 | + printf("Number of jets: %zu\n", sequence->jets_length); |
| 33 | + if (sequence->jets != NULL) { |
| 34 | + for (size_t i = 0; i < sequence->jets_length; i++) { |
| 35 | + printPseudoJet(sequence->jets + i); |
| 36 | + } |
| 37 | + } |
| 38 | + printf("History length: %zu\n", sequence->history_length); |
| 39 | + if (sequence->history != NULL) { |
| 40 | + for (size_t i = 0; i < sequence->history_length; i++) { |
| 41 | + printHistoryElement(sequence->history + i); |
| 42 | + } |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +void printJetsResult(const jetreconstruction_JetsResult *results) { |
| 47 | + assert(results != NULL); |
| 48 | + for (size_t i = 0; i < results->length; ++i) { |
| 49 | + printPseudoJet(results->data + i); |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +int main(int argc, char *argv[]) { |
| 54 | + clock_t start_time = clock(); |
| 55 | + init_julia(argc, argv); |
| 56 | + size_t len = 2; |
| 57 | + jetreconstruction_PseudoJet particles[2]; |
| 58 | + jetreconstruction_PseudoJet_init(&particles[0], 0.0, 1.0, 2.0, 3.0); |
| 59 | + jetreconstruction_PseudoJet_init(&particles[1], 1.0, 2.0, 3.0, 4.0); |
| 60 | + |
| 61 | + jetreconstruction_JetAlgorithm algorithm = JETRECONSTRUCTION_JETALGORITHM_CA; |
| 62 | + double R = 3.0; |
| 63 | + jetreconstruction_RecoStrategy strategy = JETRECONSTRUCTION_RECOSTRATEGY_BEST; |
| 64 | + |
| 65 | + jetreconstruction_ClusterSequence cluster_seq; |
| 66 | + jetreconstruction_jet_reconstruct(particles, len, algorithm, R, strategy, |
| 67 | + &cluster_seq); |
| 68 | + |
| 69 | + printClusterSequence(&cluster_seq); |
| 70 | + jetreconstruction_JetsResult result; |
| 71 | + jetreconstruction_exclusive_jets_njets(&cluster_seq, 2, &result); |
| 72 | + printJetsResult(&result); |
| 73 | + |
| 74 | + jetreconstruction_JetsResult_free_members(&result); |
| 75 | + jetreconstruction_ClusterSequence_free_members(&cluster_seq); |
| 76 | + shutdown_julia(0); |
| 77 | + |
| 78 | + clock_t end_time = clock(); |
| 79 | + double time_spent = (double)(end_time - start_time) / CLOCKS_PER_SEC; |
| 80 | + printf("Execution time: %f seconds\n", time_spent); |
| 81 | + return 0; |
| 82 | +} |
0 commit comments