LDMX Software
recon::TriggerProcessor Class Reference

Provides a trigger decision for recon using a TriggerResult object. More...

#include <TriggerProcessor.h>

Public Member Functions

 TriggerProcessor (const std::string &name, framework::Process &process)
 Class constructor.
 
virtual ~TriggerProcessor ()
 Class destructor.
 
void configure (framework::config::Parameters &parameters) override
 Configure the processor using the given user specified parameters.
 
void produce (framework::Event &event) override
 Run the trigger algorithm and create a TriggerResult object to contain info about the trigger decision such as pass/fail, number of saved variables, etc.
 
- Public Member Functions inherited from framework::Producer
 Producer (const std::string &name, Process &process)
 Class constructor.
 
virtual void process (Event &event) final
 Processing an event for a Producer is calling produce.
 
- Public Member Functions inherited from framework::EventProcessor
 DECLARE_FACTORY (EventProcessor, EventProcessor *, const std::string &, Process &)
 declare that we have a factory for this class
 
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()=default
 Class destructor.
 
virtual void beforeNewRun (ldmx::RunHeader &run_header)
 Callback for Producers to add parameters to the run header before conditions are initialized.
 
virtual void onNewRun (const ldmx::RunHeader &run_header)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
virtual void onFileOpen (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a event input ROOT file is closed.
 
virtual void onProcessStart ()
 Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.
 
virtual void onProcessEnd ()
 Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.
 
template<class T >
const T & getCondition (const std::string &condition_name)
 Access a conditions object for the current event.
 
TDirectory * getHistoDirectory ()
 Access/create a directory in the histogram file for this event processor to create histograms and analysis tuples.
 
void setStorageHint (framework::StorageControl::Hint hint)
 Mark the current event as having the given storage control hint from this module_.
 
void setStorageHint (framework::StorageControl::Hint hint, const std::string &purposeString)
 Mark the current event as having the given storage control hint from this module and the given purpose string.
 
int getLogFrequency () const
 Get the current logging frequency from the process.
 
int getRunNumber () const
 Get the run number from the process.
 
std::string getName () const
 Get the processor name.
 
void createHistograms (const std::vector< framework::config::Parameters > &histos)
 Internal function which is used to create histograms passed from the python configuration @parma histos vector of Parameters that configure histograms to create.
 

Private Attributes

std::vector< double > layer_e_sum_cuts_
 The energy sum to make cut on.
 
double beam_energy_
 The Beam energy [MeV].
 
int mode_ {0}
 The trigger mode to run in.
 
int start_layer_ {0}
 The first layer of layer sum.
 
int end_layer_ {0}
 The endpoint layer of layer sum.
 
TString algo_name_
 The name of the trigger algorithm used.
 
std::string input_coll_
 The name of the input collection (the Ecal hits_).
 
std::string input_pass_
 The pass name of the input (the Ecal hits_).
 
std::string output_coll_
 The name of the output collection (the trigger decision).
 

Additional Inherited Members

- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramPool histograms_
 helper object for making and filling histograms
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger the_log_
 The logger for this EventProcessor.
 

Detailed Description

Provides a trigger decision for recon using a TriggerResult object.

Note
TriggerProcessor takes in a set of parameters to be used in defining the trigger algorithm. An event is passed to the processor and the relevant algorithms are then run on the event (ECAL layer sum). A trigger decision is executed and the decision along with the algorithm name and relevant variables are stored in a TriggerResult object which is added to the collection.

Definition at line 32 of file TriggerProcessor.h.

Constructor & Destructor Documentation

◆ TriggerProcessor()

recon::TriggerProcessor::TriggerProcessor ( const std::string & name,
framework::Process & process )
inline

Class constructor.

Definition at line 37 of file TriggerProcessor.h.

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.

◆ ~TriggerProcessor()

virtual recon::TriggerProcessor::~TriggerProcessor ( )
inlinevirtual

Class destructor.

Definition at line 43 of file TriggerProcessor.h.

43{}

Member Function Documentation

◆ configure()

void recon::TriggerProcessor::configure ( framework::config::Parameters & parameters)
overridevirtual

Configure the processor using the given user specified parameters.

Parameters
parametersSet of parameters used to configure this processor.

Reimplemented from framework::EventProcessor.

Definition at line 8 of file TriggerProcessor.cxx.

8 {
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}
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
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].
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).
std::string input_pass_
The pass name of the input (the Ecal hits_).

References algo_name_, beam_energy_, end_layer_, framework::config::Parameters::get(), input_coll_, input_pass_, layer_e_sum_cuts_, mode_, output_coll_, and start_layer_.

◆ produce()

void recon::TriggerProcessor::produce ( framework::Event & event)
overridevirtual

Run the trigger algorithm and create a TriggerResult object to contain info about the trigger decision such as pass/fail, number of saved variables, etc.

param event The event to run trigger algorithm on.

Grab the Ecal hit collection for the given event

There are three scenarios:

  1. No Incoming Electrons - If the electron count is 0 or negative (undetermined), then we set the sum-energy cut to zero so the event always fails.
  2. Num Electrons Listed in Thresholds - Pull cut from list
  3. More electrons than listed - Set threshold as 'threshold_for_1e + nExtraElectrons*beamEnergy' Note that the "overflow" formula here is too naive. It should be a fct( nElectrons, 1e_thr, beamE), taking how sigma evolves with multiplicity into account. a simple scaling might suffice there too assuming energy cuts are listed as [ Ecut_1e, Ecut_2e, ... ]

Loop over all ecal hits_ in the given event

Implements framework::Producer.

Definition at line 25 of file TriggerProcessor.cxx.

25 {
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}
void setStorageHint(framework::StorageControl::Hint hint)
Mark the current event as having the given storage control hint from this module_.
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.
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

References algo_name_, beam_energy_, end_layer_, framework::HINT_SHOULD_DROP, framework::HINT_SHOULD_KEEP, input_coll_, input_pass_, layer_e_sum_cuts_, mode_, output_coll_, ldmx::TriggerResult::set(), ldmx::TriggerResult::setAlgoVar(), framework::EventProcessor::setStorageHint(), and start_layer_.

Member Data Documentation

◆ algo_name_

TString recon::TriggerProcessor::algo_name_
private

The name of the trigger algorithm used.

Definition at line 87 of file TriggerProcessor.h.

Referenced by configure(), and produce().

◆ beam_energy_

double recon::TriggerProcessor::beam_energy_
private

The Beam energy [MeV].

Definition at line 66 of file TriggerProcessor.h.

Referenced by configure(), and produce().

◆ end_layer_

int recon::TriggerProcessor::end_layer_ {0}
private

The endpoint layer of layer sum.

not inclusive - i.e. this is the last layer that is included in the layer sum.

Definition at line 84 of file TriggerProcessor.h.

84{0};

Referenced by configure(), and produce().

◆ input_coll_

std::string recon::TriggerProcessor::input_coll_
private

The name of the input collection (the Ecal hits_).

Definition at line 90 of file TriggerProcessor.h.

Referenced by configure(), and produce().

◆ input_pass_

std::string recon::TriggerProcessor::input_pass_
private

The pass name of the input (the Ecal hits_).

Definition at line 93 of file TriggerProcessor.h.

Referenced by configure(), and produce().

◆ layer_e_sum_cuts_

std::vector<double> recon::TriggerProcessor::layer_e_sum_cuts_
private

The energy sum to make cut on.

Definition at line 63 of file TriggerProcessor.h.

Referenced by configure(), and produce().

◆ mode_

int recon::TriggerProcessor::mode_ {0}
private

The trigger mode to run in.

Mode zero sums over all cells in layer_, while in mode 1 only cells in center module are summed over. (TODO)

Definition at line 73 of file TriggerProcessor.h.

73{0};

Referenced by configure(), and produce().

◆ output_coll_

std::string recon::TriggerProcessor::output_coll_
private

The name of the output collection (the trigger decision).

Definition at line 96 of file TriggerProcessor.h.

Referenced by configure(), and produce().

◆ start_layer_

int recon::TriggerProcessor::start_layer_ {0}
private

The first layer of layer sum.

Definition at line 76 of file TriggerProcessor.h.

76{0};

Referenced by configure(), and produce().


The documentation for this class was generated from the following files: