LDMX Software
TriggerProcessor.cxx
1
3
4#include "DetDescr/EcalID.h"
5
6namespace recon {
7
9 layer_e_sum_cuts_ = parameters.get<std::vector<double>>("thresholds");
10 beam_energy_ = parameters.get<double>("beamEnergy");
11 mode_ = parameters.get<int>("mode");
12 start_layer_ = parameters.get<int>("start_layer");
13 end_layer_ = parameters.get<int>("end_layer");
14 input_coll_ = parameters.get<std::string>("input_collection");
15 input_pass_ = parameters.get<std::string>("input_pass");
16 output_coll_ = parameters.get<std::string>("trigger_collection");
17
18 if (mode_ == 0) {
19 algo_name_ = "LayerSumTrig";
20 } else if (mode_ == 1) {
21 algo_name_ = "CenterTower";
22 }
23}
24
27 const std::vector<ldmx::EcalHit> ecal_rec_hits =
28 event.getCollection<ldmx::EcalHit>(input_coll_, input_pass_);
29
30 // number of electrons in this event
31 const int n_electrons{event.getElectronCount()};
32
48 double layer_e_sum_cut{0.};
49 if (n_electrons <= 0)
50 layer_e_sum_cut = 0.; // always fail if no electrons
51 else if (n_electrons <= layer_e_sum_cuts_.size())
52 layer_e_sum_cut = layer_e_sum_cuts_.at(n_electrons - 1);
53 else
54 layer_e_sum_cut =
55 layer_e_sum_cuts_.at(0) + (n_electrons - 1) * beam_energy_;
56
57 ldmx_log(info) << "Got trigger energy cut " << layer_e_sum_cut << " for "
58 << n_electrons << " electrons counted in the event.";
59
60 std::vector<double> layer_digi_e(100, 0.0); // big empty vector..
61
63 for (const ldmx::EcalHit& hit : ecal_rec_hits) {
64 ldmx::EcalID id(hit.getID());
65 if (id.layer() < layer_digi_e.size()) { // just to be safe...
66 if (mode_ == 0) { // Sum over all cells in a given layer_
67 layer_digi_e[id.layer()] += hit.getEnergy();
68 } else if (mode_ == 1) { // Sum over cells in central tower only
69 // std::pair<float, float> xyPos =
70 // hit->getCellCentroidXYPair(hit->getID()); float cellRadius =
71 // sqrt(pow(xyPos.first, 2) + pow(xyPos.second, 2)); if (cellRadius <
72 // MAGICNUMBERHERE) {
73 // layerDigiE[hit->getLayer()] += hit->getEnergy();
74 //}
75 }
76 }
77 }
78
79 float layer_sum = 0;
80 bool pass = false;
81
82 for (int i_l = start_layer_; i_l < end_layer_; ++i_l) {
83 layer_sum += layer_digi_e[i_l];
84 }
85
86 pass = (layer_sum <= layer_e_sum_cut);
87 ldmx_log(info) << "Got trigger energy sum " << layer_sum
88 << "; and decision is pass = " << pass;
89
91 result.set(algo_name_, pass, 4);
92 result.setAlgoVar(0, layer_sum);
93 result.setAlgoVar(1, layer_e_sum_cut);
95 result.setAlgoVar(3, n_electrons);
96
97 event.add(output_coll_, result);
98
99 // mark the event
100 if (pass)
102 else
104}
105} // namespace recon
106
Class that defines an ECal detector ID with a cell number.
#define DECLARE_PRODUCER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Class that provides a trigger decision for recon using a TriggerResult object.
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:42
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
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 trigger decision for recon using a TriggerResult object.
std::vector< double > layer_e_sum_cuts_
The energy sum to make cut on.
std::string input_coll_
The name of the input collection (the Ecal hits_).
TString algo_name_
The name of the trigger algorithm used.
int start_layer_
The first layer of layer sum.
double beam_energy_
The Beam energy [MeV].
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 end_layer_
The endpoint layer of layer sum.
std::string output_coll_
The name of the output collection (the trigger decision).
void produce(framework::Event &event) override
Run the trigger algorithm and create a TriggerResult object to contain info about the trigger decisio...
std::string input_pass_
The pass name of the input (the Ecal hits_).
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