Jpp 21.0.1
the software that should make you happy
Loading...
Searching...
No Matches
test_reconstruction_tools.cc File Reference
#include <cassert>
#include <cstddef>
#include <memory>
#include <vector>
#include <string>
#include "km3net-dataformat/offline/Evt.hh"
#include "km3net-dataformat/offline/Trk.hh"
#include "km3net-dataformat/definitions/reconstruction.hh"
#include "km3net-dataformat/tools/reconstruction.hh"
#include "TFile.h"
#include "TTree.h"

Go to the source code of this file.

Functions

void add_rec_trk (Evt &evt, int id, int rec_type, const std::vector< int > rec_stages, double lik, int status=0)
 
Evt get_evt_jpptrks ()
 
Evt get_evt_jppshowers ()
 
Evt get_evt_aashowers ()
 
void test_rec_jpptrks ()
 
void test_rec_jppshowers ()
 
void test_rec_aashowers ()
 
int get_n_matched (const char *filename)
 
void test_from_file ()
 
int main ()
 

Function Documentation

◆ add_rec_trk()

void add_rec_trk ( Evt & evt,
int id,
int rec_type,
const std::vector< int > rec_stages,
double lik,
int status = 0 )

Definition at line 15 of file test_reconstruction_tools.cc.

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}
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

◆ get_evt_jpptrks()

Evt get_evt_jpptrks ( )

Definition at line 27 of file test_reconstruction_tools.cc.

28{
29 Evt evt;
33 return evt;
34}
static const int JPP_RECONSTRUCTION_TYPE
ile KM3NeT Data Definitions v3.6.5 https://git.km3net.de/common/km3net-dataformat
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
void add_rec_trk(Evt &evt, int id, int rec_type, const std::vector< int > rec_stages, double lik, int status=0)

◆ get_evt_jppshowers()

◆ get_evt_aashowers()

◆ test_rec_jpptrks()

void test_rec_jpptrks ( )

Definition at line 54 of file test_reconstruction_tools.cc.

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}
Evt get_evt_jpptrks()
const Trk & get_best_reconstructed_jppmuon(const Evt &evt)
Get best reconstructed muon.

◆ test_rec_jppshowers()

void test_rec_jppshowers ( )

Definition at line 62 of file test_reconstruction_tools.cc.

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}
Evt get_evt_jppshowers()
const Trk & get_best_reconstructed_jppshower(const Evt &evt)
Get best reconstructed shower.

◆ test_rec_aashowers()

void test_rec_aashowers ( )

Definition at line 70 of file test_reconstruction_tools.cc.

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}
Evt get_evt_aashowers()
const Trk & get_best_reconstructed_aashower(const Evt &evt)
Get best reconstructed aashower.

◆ get_n_matched()

int get_n_matched ( const char * filename)

Definition at line 78 of file test_reconstruction_tools.cc.

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}
void setup_from_meta_file(const char *filename)
Setup information from file containing metadata.
bool has_reconstructed_jppmuon(const Evt &evt)
Test whether given event has a track with muon reconstruction.

◆ test_from_file()

void test_from_file ( )

Definition at line 99 of file test_reconstruction_tools.cc.

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}
int get_n_matched(const char *filename)

◆ main()

int main ( )

Definition at line 115 of file test_reconstruction_tools.cc.

116{
121 return 0;
122}
void test_rec_jppshowers()
void test_from_file()
void test_rec_jpptrks()
void test_rec_aashowers()