LDMX Software
TrigClusterNNProducer.h
Go to the documentation of this file.
1
8#ifndef TRIGGER_TRIGCLUSTERNNPRODUCER_H
9#define TRIGGER_TRIGCLUSTERNNPRODUCER_H
10
11#include <cstddef>
12#include <memory>
13#include <string>
14#include <vector>
15
16// LDMX
17#include "Framework/Configure/Parameters.h"
19#include "Tools/ONNXRuntime.h"
20#include "Trigger/Event/TrigCaloCluster.h"
21#include "Trigger/Event/TrigEnergySum.h"
22
23namespace trigger {
24
41 public:
42 TrigClusterNNProducer(const std::string& name, framework::Process& process);
43 virtual ~TrigClusterNNProducer() = default;
45 void produce(framework::Event& event) override;
46 void onProcessEnd() override;
47
57 static void fillInputs(const TrigCaloClusterCollection& clusters,
58 const TrigEnergySumCollection& ecal_sums,
59 const TrigEnergySumCollection& hcal_sums,
60 std::vector<float>& inputs);
61
62 static constexpr std::size_t MAX_CLUSTERS = 3;
63 static constexpr std::size_t N_FEATURES = 9;
64 static constexpr std::size_t N_CLASSES = 9;
65
67 static constexpr std::size_t FEAT_X = 0;
68 static constexpr std::size_t FEAT_Y = 1;
69 static constexpr std::size_t FEAT_Z = 2;
70 static constexpr std::size_t FEAT_E = 3;
71 static constexpr std::size_t FEAT_DEPTH = 4;
72 static constexpr std::size_t FEAT_N_TP = 5;
73 static constexpr std::size_t FEAT_N_CLUSTERS = 6;
74 static constexpr std::size_t FEAT_ECAL_SUM_E = 7;
75 static constexpr std::size_t FEAT_HCAL_SUM_ADC = 8;
76 static_assert(FEAT_HCAL_SUM_ADC + 1 == N_FEATURES);
77
79 static constexpr std::size_t BKG_CLASS = 0;
80
81 private:
82 std::string cluster_coll_name_;
83 std::string ecal_sum_coll_name_;
84 std::string hcal_sum_coll_name_;
86 std::string input_pass_;
87 std::string score_coll_name_;
88
90 ldmx::ort::FloatArrays data_;
91 std::unique_ptr<ldmx::ort::ONNXRuntime> rt_;
92
93 int nevents_{0};
94 double processing_time_{0.};
95 double inference_time_{0.};
96};
97
98} // namespace trigger
99
100#endif // TRIGGER_TRIGCLUSTERNNPRODUCER_H
Base classes for all user event processing components to extend.
Implements an event buffer system for storing event data.
Definition Event.h:40
Class which represents the process under execution.
Definition Process.h:34
Base class for a module which produces a data product.
virtual void process(Event &event) final
Processing an event for a Producer is calling produce.
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:26
Scores each event with the ECal trigger MLP and stores the output.
void onProcessEnd() override
Callback for the EventProcessor to take any necessary action when the processing of events finishes,...
static void fillInputs(const TrigCaloClusterCollection &clusters, const TrigEnergySumCollection &ecal_sums, const TrigEnergySumCollection &hcal_sums, std::vector< float > &inputs)
Fill flattened (MAX_CLUSTERS, N_FEATURES) model input, (index = slot * N_FEATURES + feature).
void configure(framework::config::Parameters &ps) override
Callback for the EventProcessor to configure itself from the given set of parameters.
void produce(framework::Event &event) override
Process the event and put new data products into it.
static constexpr std::size_t BKG_CLASS
class index of the single-electron background in the model output
static constexpr std::size_t FEAT_X
feature index within one cluster slot of the model input
ldmx::ort::FloatArrays data_
model input buffer, reused every event
std::string input_pass_
pass name shared by all three input collections