DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
treelitemodel.hpp
Go to the documentation of this file.
1#ifndef TRIGGERALGS_TREELITEMODEL_HPP_
2#define TRIGGERALGS_TREELITEMODEL_HPP_
3
4#include <cstdint>
5#include <string>
6#include <vector>
7#include <memory>
8#include <cmath>
9
10#if defined(__clang__) || defined(__GNUC__)
11# define LIKELY(x) __builtin_expect(!!(x), 1)
12# define UNLIKELY(x) __builtin_expect(!!(x), 0)
13#else
14# define LIKELY(x) (x)
15# define UNLIKELY(x) (x)
16#endif
17
18namespace triggeralgs {
19
20 union Entry {
22 float fvalue;
23 int qvalue;
24 };
25
28 public:
29 TreeliteModelBase(int numTargets = 1, int maxNumClass = 1);
30 virtual ~TreeliteModelBase() = default;
31
32 int32_t get_num_target() const;
33 void get_num_class(int32_t* out) const;
34 // Different models may have different number of feature
35 // - make this function virtual and always override it
36 virtual int32_t get_num_feature() const = 0;
37
38 virtual const char* get_threshold_type() const;
39 virtual const char* get_leaf_output_type() const;
40
41 //Virtual prediction function — overridden by each concrete model
42 virtual void predict(union Entry* data, int pred_margin, float* result) const = 0;
43
44 // Common postprocessing shared by all models
45 virtual void postprocess(float* result) const;
46
47 protected:
48 static const int32_t num_class[1];
49 int32_t N_TARGET;
50 int32_t MAX_N_CLASS;
51 };
52
55 public:
57 virtual int32_t get_num_feature() const override;
58 void predict(union Entry* data, int pred_margin, float* result) const override;
59 };
60
61 // Add model later for PD-VD signal findings
62
63} // namespace triggeralgs
64#endif // TRIGGERALGS_TREELITEMODEL_HPP_
Base class: defines shared interface and utilities for all models.
virtual void predict(union Entry *data, int pred_margin, float *result) const =0
virtual void postprocess(float *result) const
void get_num_class(int32_t *out) const
TreeliteModelBase(int numTargets=1, int maxNumClass=1)
virtual const char * get_threshold_type() const
virtual const char * get_leaf_output_type() const
virtual int32_t get_num_feature() const =0
virtual ~TreeliteModelBase()=default
static const int32_t num_class[1]
Model for signal finding in PD-HD — trained on PD-HD data.
void predict(union Entry *data, int pred_margin, float *result) const override
virtual int32_t get_num_feature() const override