LDMX Software
DeepTriggerProcessor.cxx
Go to the documentation of this file.
1
12#include <limits>
13
14#include "DetDescr/EcalID.h"
15#include "Ecal/Event/EcalHit.h"
16#include "Framework/Configure/Parameters.h"
19
20namespace recon {
21
37 public:
42 : framework::Producer(name, process) {}
43
48
54 void configure(framework::config::Parameters& parameters) override;
55
63 void produce(framework::Event& event) override;
64
65 private:
67 std::vector<double> layer_e_sum_cuts_;
68
71
77 int mode_{0};
78
81
88 int end_layer_{0};
89
91 TString algo_name_;
92
94 std::string input_coll_;
95
97 std::string input_pass_;
98
100 std::string output_coll_;
101};
102
104 framework::config::Parameters& parameters) {
105 layer_e_sum_cuts_ = parameters.get<std::vector<double>>("thresholds");
106 beam_energy_ = parameters.get<double>("beam_energy");
107 mode_ = parameters.get<int>("mode");
108 start_layer_ = parameters.get<int>("start_layer");
109 end_layer_ = parameters.get<int>("end_layer");
110 input_coll_ = parameters.get<std::string>("input_collection");
111 input_pass_ = parameters.get<std::string>("input_pass");
112 output_coll_ = parameters.get<std::string>("trigger_collection");
113
114 if (mode_ == 0) {
115 algo_name_ = "DeepLayerSumTrig";
116 } else if (mode_ == 1) {
117 algo_name_ = "DeepCenterTower";
118 }
119}
120
123 const std::vector<ldmx::EcalHit> ecal_rec_hits =
124 event.getCollection<ldmx::EcalHit>(input_coll_, input_pass_);
125
126 // number of electrons in this event
127 const int n_electrons{event.getElectronCount()};
128
144 double layer_e_sum_cut{0.};
145 if (n_electrons <= 0)
146 layer_e_sum_cut =
147 std::numeric_limits<double>::max(); // always fail if no electrons
148 else if (n_electrons <= layer_e_sum_cuts_.size())
149 layer_e_sum_cut = layer_e_sum_cuts_.at(n_electrons - 1);
150 else
151 layer_e_sum_cut =
152 layer_e_sum_cuts_.at(0) + (n_electrons - 1) * beam_energy_;
153
154 ldmx_log(info) << "Got trigger energy cut " << layer_e_sum_cut << " for "
155 << n_electrons << " electrons counted in the event.";
156
157 std::vector<double> layer_digi_e(100, 0.0); // big empty vector..
158
160 for (const ldmx::EcalHit& hit : ecal_rec_hits) {
161 ldmx::EcalID id(hit.getID());
162 if (id.layer() < layer_digi_e.size()) { // just to be safe...
163 if (mode_ == 0) { // Sum over all cells in a given layer_
164 layer_digi_e[id.layer()] += hit.getEnergy();
165 } else if (mode_ == 1) { // Sum over cells in central tower only
166 // not implemented, see TriggerProcessor
167 }
168 }
169 }
170
171 float layer_sum = 0;
172 bool pass = false;
173
174 for (int i_l = start_layer_; i_l < end_layer_; ++i_l) {
175 layer_sum += layer_digi_e[i_l];
176 }
177
178 pass = (layer_sum >= layer_e_sum_cut);
179 ldmx_log(info) << "Got trigger energy sum " << layer_sum
180 << "; and decision is pass = " << pass;
181
182 ldmx::TriggerResult result;
183 result.set(algo_name_, pass, 4);
184 result.setAlgoVar(0, layer_sum);
185 result.setAlgoVar(1, layer_e_sum_cut);
187 result.setAlgoVar(3, n_electrons);
188
189 event.add(output_coll_, result);
190
191 // mark the event
192 if (pass)
194 else
196}
197} // namespace recon
198
Class that defines an ECal detector ID with a cell number.
Base classes for all user event processing components to extend.
#define DECLARE_PRODUCER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Class that represents the trigger decision (pass/fail) for reconstruction.
void setStorageHint(framework::StorageControl::Hint hint)
Mark the current event as having the given storage control hint from this module_.
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.
Producer(const std::string &name, Process &process)
Class constructor.
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
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:75
Stores reconstructed hit information from the ECAL.
Definition EcalHit.h:19
Extension of DetectorID providing access to ECal layers and cell numbers in a hex grid.
Definition EcalID.h:20
Represents the trigger decision (pass/fail) for reconstruction.
void set(const TString &name, bool pass, int nvar)
Set name and pass of trigger.
void setAlgoVar(int element, double value)
Set an algorithm variable.
Provides a deep-layer trigger decision for recon using a TriggerResult object.
std::vector< double > layer_e_sum_cuts_
The energy sum to make cut on.
TString algo_name_
The name of the trigger algorithm used.
int end_layer_
The endpoint layer of layer sum.
std::string output_coll_
The name of the output collection (the trigger decision).
std::string input_pass_
The pass name of the input (the Ecal hits_).
void configure(framework::config::Parameters &parameters) override
Configure the processor using the given user specified parameters.
int mode_
The trigger mode to run in.
int start_layer_
The first layer of layer sum.
virtual ~DeepTriggerProcessor()
Class destructor.
void produce(framework::Event &event) override
Run the trigger algorithm and create a TriggerResult object to contain info about the trigger decisio...
double beam_energy_
The Beam energy [MeV].
std::string input_coll_
The name of the input collection (the Ecal hits_).
DeepTriggerProcessor(const std::string &name, framework::Process &process)
Class constructor.
All classes in the ldmx-sw project use this namespace.
constexpr StorageControl::Hint HINT_SHOULD_DROP
storage control hint alias for backwards compatibility
constexpr StorageControl::Hint HINT_SHOULD_KEEP
storage control hint alias for backwards compatibility