LDMX Software
TriggerProcessor.cxx
1
3
4#include "DetDescr/EcalID.h"
5#include "Ecal/Event/EcalHit.h"
7
8namespace recon {
9
11 layer_e_sum_cuts_ = parameters.get<std::vector<double>>("thresholds");
12 beam_energy_ = parameters.get<double>("beam_energy");
13 mode_ = parameters.get<int>("mode");
14 start_layer_ = parameters.get<int>("start_layer");
15 end_layer_ = parameters.get<int>("end_layer");
16 input_coll_ = parameters.get<std::string>("input_collection");
17 input_pass_ = parameters.get<std::string>("input_pass");
18 output_coll_ = parameters.get<std::string>("trigger_collection");
19
20 if (mode_ == 0) {
21 algo_name_ = "LayerSumTrig";
22 } else if (mode_ == 1) {
23 algo_name_ = "CenterTower";
24 }
25}
26
29 const std::vector<ldmx::EcalHit> ecal_rec_hits =
30 event.getCollection<ldmx::EcalHit>(input_coll_, input_pass_);
31
32 // number of electrons in this event
33 const int n_electrons{event.getElectronCount()};
34
50 double layer_e_sum_cut{0.};
51 if (n_electrons <= 0)
52 layer_e_sum_cut = 0.; // always fail if no electrons
53 else if (n_electrons <= layer_e_sum_cuts_.size())
54 layer_e_sum_cut = layer_e_sum_cuts_.at(n_electrons - 1);
55 else
56 layer_e_sum_cut =
57 layer_e_sum_cuts_.at(0) + (n_electrons - 1) * beam_energy_;
58
59 ldmx_log(info) << "Got trigger energy cut " << layer_e_sum_cut << " for "
60 << n_electrons << " electrons counted in the event.";
61
62 std::vector<double> layer_digi_e(100, 0.0); // big empty vector..
63
65 for (const ldmx::EcalHit& hit : ecal_rec_hits) {
66 ldmx::EcalID id(hit.getID());
67 if (id.layer() < layer_digi_e.size()) { // just to be safe...
68 if (mode_ == 0) { // Sum over all cells in a given layer_
69 layer_digi_e[id.layer()] += hit.getEnergy();
70 } else if (mode_ == 1) { // Sum over cells in central tower only
71 // std::pair<float, float> xyPos =
72 // hit->getCellCentroidXYPair(hit->getID()); float cellRadius =
73 // sqrt(pow(xyPos.first, 2) + pow(xyPos.second, 2)); if (cellRadius <
74 // MAGICNUMBERHERE) {
75 // layerDigiE[hit->getLayer()] += hit->getEnergy();
76 //}
77 }
78 }
79 }
80
81 float layer_sum = 0;
82 bool pass = false;
83
84 for (int i_l = start_layer_; i_l < end_layer_; ++i_l) {
85 layer_sum += layer_digi_e[i_l];
86 }
87
88 pass = (layer_sum <= layer_e_sum_cut);
89 ldmx_log(info) << "Got trigger energy sum " << layer_sum
90 << "; and decision is pass = " << pass;
91
93 result.set(algo_name_, pass, 4);
94 result.setAlgoVar(0, layer_sum);
95 result.setAlgoVar(1, layer_e_sum_cut);
97 result.setAlgoVar(3, n_electrons);
98
99 event.add(output_coll_, result);
100
101 // mark the event
102 if (pass)
104 else
106}
107} // namespace recon
108
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.
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 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 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