Jpp 21.0.0
the software that should make you happy
Loading...
Searching...
No Matches
test_reconstruction_tools.cc
Go to the documentation of this file.
1#include <cassert>
2#include <cstddef>
3#include <memory>
4#include <vector>
5#include <string>
6
11
12#include "TFile.h"
13#include "TTree.h"
14
15void add_rec_trk(Evt &evt, int id, int rec_type, const std::vector<int> rec_stages, double lik, int status = 0)
16{
17 Trk trk;
18 trk.id = id;
19 trk.rec_type = rec_type;
20 trk.rec_stages = rec_stages;
21 trk.lik = lik;
22 trk.status = status;
23 evt.trks.emplace_back(trk);
24 return;
25}
26
35
44
53
55{
56 auto evt = get_evt_jpptrks();
57 assert(evt.trks.size() == 3); // Initial set of tracks
58 auto best = get_best_reconstructed_jppmuon(evt);
59 assert(best.id == 3);
60}
61
63{
64 auto evt = get_evt_jppshowers();
65 assert(evt.trks.size() == 3); // Initial set of tracks
66 auto best = get_best_reconstructed_jppshower(evt);
67 assert(best.id == 3);
68}
69
71{
72 auto evt = get_evt_aashowers();
73 assert(evt.trks.size() == 3); // Initial set of tracks
74 auto best = get_best_reconstructed_aashower(evt);
75 assert(best.id == 3);
76}
77
78int get_n_matched(const char *filename)
79{
80 setup_from_meta_file(filename);
81 std::unique_ptr<TFile> in_file(TFile::Open(filename));
82 assert(in_file != nullptr);
83 Evt *evt = nullptr;
84 auto *tree = in_file->Get<TTree>("E");
85 assert(tree != nullptr);
86 tree->SetBranchAddress("Evt", &evt);
87 int n_matched = 0;
88 for (Long64_t ientry = 0, nentries = tree->GetEntries(); ientry < nentries; ++ientry)
89 {
90 tree->GetEntry(ientry);
92 {
93 n_matched++;
94 }
95 }
96 return n_matched;
97}
98
100{
101 std::string dirname = "../km3net_testdata/km3net_testdata/data/";
102 // Test old file
103 std::string filename = dirname + "offline/mcv6.gsg_nue-CCHEDIS_1e4-1e6GeV.sirene.jte.jchain.aanet.1.root";
104 auto n_matched = get_n_matched(filename.c_str());
105 std::cout << "n_matched old file: " << n_matched << std::endl;
106 assert(n_matched == 31);
107
108 // Test new file
109 filename = dirname + "offline/KM3NeT_00000049_00011291.mc.gsg_neutrinos.km3sim_sirene_merged.jterbr.jppmuon_jppshower_static.offline.v9.2.sample.root";
110 n_matched = get_n_matched(filename.c_str());
111 std::cout << "n_matched new file: " << n_matched << std::endl;
112 assert(n_matched == 30);
113}
114
115int main()
116{
121 return 0;
122}
static const int JPP_RECONSTRUCTION_TYPE
ile KM3NeT Data Definitions v3.6.5 https://git.km3net.de/common/km3net-dataformat
static const int AASHOWERFITDIRECTIONENERGYFIT
static const int AANET_RECONSTRUCTION_TYPE
aanet reconstruction type
void setup_from_meta_file(const char *filename)
Setup information from file containing metadata.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
std::vector< Trk > trks
list of reconstructed tracks (can be several because of prefits,showers, etc).
Definition Evt.hh:39
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition Trk.hh:15
int status
MC or reconstruction status code, see km3net-dataformat/definitions/trkmembers.csv for values.
Definition Trk.hh:28
int id
track identifier
Definition Trk.hh:16
std::vector< int > rec_stages
list of identifiers of successful fitting stages resulting in this track
Definition Trk.hh:26
int rec_type
identifier of the fitting algorithm/chain/strategy, see km3net-dataformat/definitions/reconstruction....
Definition Trk.hh:25
double lik
likelihood or lambda value (for aafit, lambda)
Definition Trk.hh:23
Evt get_evt_aashowers()
void test_rec_jppshowers()
void add_rec_trk(Evt &evt, int id, int rec_type, const std::vector< int > rec_stages, double lik, int status=0)
void test_from_file()
Evt get_evt_jpptrks()
void test_rec_jpptrks()
Evt get_evt_jppshowers()
int get_n_matched(const char *filename)
void test_rec_aashowers()
Auxiliary methods for selection of reconstructed tracks.
const Trk & get_best_reconstructed_jppshower(const Evt &evt)
Get best reconstructed shower.
const Trk & get_best_reconstructed_jppmuon(const Evt &evt)
Get best reconstructed muon.
const Trk & get_best_reconstructed_aashower(const Evt &evt)
Get best reconstructed aashower.
bool has_reconstructed_jppmuon(const Evt &evt)
Test whether given event has a track with muon reconstruction.