LDMX Software
TriggerProcessor.cxx
1
3
4#include "DetDescr/EcalID.h"
5
6namespace recon {
7
9 layerESumCuts_ = parameters.getParameter<std::vector<double>>("thresholds");
10 beamEnergy_ = parameters.getParameter<double>("beamEnergy");
11 mode_ = parameters.getParameter<int>("mode");
12 startLayer_ = parameters.getParameter<int>("start_layer");
13 endLayer_ = parameters.getParameter<int>("end_layer");
14 inputColl_ = parameters.getParameter<std::string>("input_collection");
15 inputPass_ = parameters.getParameter<std::string>("input_pass");
16 outputColl_ = parameters.getParameter<std::string>("trigger_collection");
17
18 if (mode_ == 0) {
19 algoName_ = "LayerSumTrig";
20 } else if (mode_ == 1) {
21 algoName_ = "CenterTower";
22 }
23}
24
27 const std::vector<ldmx::EcalHit> ecalRecHits =
28 event.getCollection<ldmx::EcalHit>(inputColl_, inputPass_);
29
30 // number of electrons in this event
31 const int nElectrons{event.getElectronCount()};
32
48 double layerESumCut{0.};
49 if (nElectrons <= 0)
50 layerESumCut = 0.; // always fail if no electrons
51 else if (nElectrons <= layerESumCuts_.size())
52 layerESumCut = layerESumCuts_.at(nElectrons - 1);
53 else
54 layerESumCut = layerESumCuts_.at(0) + (nElectrons - 1) * beamEnergy_;
55
56 ldmx_log(debug) << "Got trigger energy cut " << layerESumCut << " for "
57 << nElectrons << " electrons counted in the event.";
58
59 std::vector<double> layerDigiE(100, 0.0); // big empty vector..
60
62 for (const ldmx::EcalHit& hit : ecalRecHits) {
63 ldmx::EcalID id(hit.getID());
64 if (id.layer() < layerDigiE.size()) { // just to be safe...
65 if (mode_ == 0) { // Sum over all cells in a given layer
66 layerDigiE[id.layer()] += hit.getEnergy();
67 } else if (mode_ == 1) { // Sum over cells in central tower only
68 // std::pair<float, float> xyPos =
69 // hit->getCellCentroidXYPair(hit->getID()); float cellRadius =
70 // sqrt(pow(xyPos.first, 2) + pow(xyPos.second, 2)); if (cellRadius <
71 // MAGICNUMBERHERE) {
72 // layerDigiE[hit->getLayer()] += hit->getEnergy();
73 //}
74 }
75 }
76 }
77
78 float layerSum = 0;
79 bool pass = false;
80
81 for (int iL = startLayer_; iL < endLayer_; ++iL) {
82 layerSum += layerDigiE[iL];
83 }
84
85 pass = (layerSum <= layerESumCut);
86 ldmx_log(debug) << "Got trigger energy sum " << layerSum
87 << "; and decision is pass = " << pass;
88
90 result.set(algoName_, pass, 4);
91 result.setAlgoVar(0, layerSum);
92 result.setAlgoVar(1, layerESumCut);
93 result.setAlgoVar(2, endLayer_ - startLayer_);
94 result.setAlgoVar(3, nElectrons);
95
96 event.add(outputColl_, result);
97
98 // mark the event
99 if (pass)
101 else
103}
104} // namespace recon
105
106DECLARE_PRODUCER_NS(recon, TriggerProcessor)
Class that defines an ECal detector ID with a cell number.
#define DECLARE_PRODUCER_NS(NS, 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:41
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:27
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89
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.
std::string inputPass_
The pass name of the input (the Ecal hits).
int startLayer_
The first layer of layer sum.
void configure(framework::config::Parameters &parameters) override
Configure the processor using the given user specified parameters.
std::string outputColl_
The name of the output collection (the trigger decision).
int mode_
The trigger mode to run in.
std::string inputColl_
The name of the input collection (the Ecal hits).
void produce(framework::Event &event) override
Run the trigger algorithm and create a TriggerResult object to contain info about the trigger decisio...
std::vector< double > layerESumCuts_
The energy sum to make cut on.
TString algoName_
The name of the trigger algorithm used.
double beamEnergy_
The Beam energy [MeV].
int endLayer_
The endpoint layer of layer sum.
constexpr StorageControl::Hint hint_shouldKeep
storage control hint alias for backwards compatibility
constexpr StorageControl::Hint hint_shouldDrop
storage control hint alias for backwards compatibility