LDMX Software
trigger::EcalTPSelector Class Reference

Public Member Functions

 EcalTPSelector (const std::string &name, framework::Process &process)
 
virtual void configure (framework::config::Parameters &ps)
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
virtual void produce (framework::Event &event)
 Process the event and put new data products into it.
 
void decodeTP (ldmx::HgcrocTrigDigi tp, double &x, double &y, double &z, double &e)
 
- 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::string tp_coll_name_
 
std::string pass_coll_name_
 
std::string tp_coll_passname_
 
std::string tp_coll_event_passname_
 
unsigned int max_central_t_ps_ {12}
 
unsigned int max_outer_t_ps_ {8}
 

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
 
NtupleManager & ntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger the_log_
 The logger for this EventProcessor.
 

Detailed Description

Definition at line 22 of file EcalTPSelector.h.

Constructor & Destructor Documentation

◆ EcalTPSelector()

trigger::EcalTPSelector::EcalTPSelector ( const std::string & name,
framework::Process & process )
inline

Definition at line 24 of file EcalTPSelector.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.

Member Function Documentation

◆ configure()

void trigger::EcalTPSelector::configure ( framework::config::Parameters & parameters)
virtual

Callback for the EventProcessor to configure itself from the given set of parameters.

The parameters a processor has access to are the member variables of the python class in the sequence that has class_name equal to the EventProcessor class name.

For an example, look at MyProcessor.

Parameters
parametersParameters for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 10 of file EcalTPSelector.cxx.

10 {
11 tp_coll_name_ = ps.get<std::string>("tp_coll_name");
12 pass_coll_name_ = ps.get<std::string>("pass_coll_name");
13 tp_coll_passname_ = ps.get<std::string>("tp_coll_pass_name");
14 tp_coll_event_passname_ = ps.get<std::string>("tp_coll_event_passname");
15}

References framework::config::Parameters::get().

◆ decodeTP()

void trigger::EcalTPSelector::decodeTP ( ldmx::HgcrocTrigDigi tp,
double & x,
double & y,
double & z,
double & e )

Definition at line 143 of file EcalTPSelector.cxx.

144 {
145 ldmx::EcalTriggerID tid(tp.getId());
146 const ecal::EcalTriggerGeometry& geom =
148 ecal::EcalTriggerGeometry::CONDITIONS_OBJECT_NAME);
149 // const auto center_ecalID = geom.centerInTriggerCell(tid);
150 // const ldmx::EcalGeometry& hexReadout = getCondition<ldmx::EcalGeometry>(
151 // ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME);
152 // hexReadout.getCellAbsolutePosition(center_ecalID,x,y,z);
153 std::tie(x, y, z) = geom.globalPosition(tid);
154 // e = primitiveToEnergy(tp.linearPrimitive(), tid.layer());
155 EcalTpToE cvt;
156 e = cvt.calc(tp.linearPrimitive(), tid.layer());
157}
defines the relationship between precision cells and trigger cells and provides geometry information ...
std::tuple< double, double, double > globalPosition(ldmx::EcalTriggerID triggerCell) const
Returns the center of the given trigger cell in world coordinates.
const T & getCondition(const std::string &condition_name)
Access a conditions object for the current event.
Extension of DetectorID providing access to ECal trigger cell information.
uint32_t linearPrimitive() const
Get the linearized value of the trigger primitive.
uint32_t getId() const
Get the id of the digi.

◆ produce()

void trigger::EcalTPSelector::produce ( framework::Event & event)
virtual

Process the event and put new data products into it.

Parameters
eventThe Event to process.

Implements framework::Producer.

Definition at line 17 of file EcalTPSelector.cxx.

17 {
18 if (!event.exists(tp_coll_name_, tp_coll_event_passname_)) return;
19 auto ecal_trig_digis{event.getObject<ldmx::HgcrocTrigDigiCollection>(
20 tp_coll_name_, tp_coll_passname_)};
21
22 std::map<int, ldmx::HgcrocTrigDigiCollection> l_digis; // left
23 std::map<int, ldmx::HgcrocTrigDigiCollection> r_digis; // right
24 std::map<int, ldmx::HgcrocTrigDigiCollection> c_digis; // center
25 std::map<int, int> l_sums; // left
26 std::map<int, int> r_sums; // right
27 std::map<int, int> c_sums; // center
28 for (const auto& trig_digi : ecal_trig_digis) {
29 ldmx::EcalTriggerID tid(trig_digi.getId());
30 int module = tid.module();
31 int layer = tid.layer();
32 if (module > 3) {
33 auto ptr = l_digis.find(layer);
34 if (ptr == l_digis.end()) {
35 l_digis[layer] = {trig_digi};
36 l_sums[layer] = trig_digi.linearPrimitive();
37 } else {
38 l_digis[layer].push_back(trig_digi);
39 l_sums[layer] += trig_digi.linearPrimitive();
40 }
41 } else if (module > 0) {
42 auto ptr = r_digis.find(layer);
43 if (ptr == r_digis.end()) {
44 r_digis[layer] = {trig_digi};
45 r_sums[layer] = trig_digi.linearPrimitive();
46 } else {
47 r_digis[layer].push_back(trig_digi);
48 r_sums[layer] += trig_digi.linearPrimitive();
49 }
50 } else {
51 auto ptr = c_digis.find(layer);
52 if (ptr == c_digis.end()) {
53 c_digis[layer] = {trig_digi};
54 c_sums[layer] = trig_digi.linearPrimitive();
55 } else {
56 c_digis[layer].push_back(trig_digi);
57 c_sums[layer] += trig_digi.linearPrimitive();
58 }
59 }
60 }
61
62 // Enforce truncation.
63 // For outer modules, the energy sort is not possible
64 // Instead, sort by ID to be deterministic.
65 ldmx::HgcrocTrigDigiCollection pass_t_ps;
66 pass_t_ps.reserve(ecal_trig_digis.size());
67 for (auto& pair : l_digis) {
68 auto& digis = pair.second;
69 if (digis.size() > max_outer_t_ps_) {
70 std::sort(digis.begin(), digis.end(),
72 return a.getId() > b.getId();
73 });
74 digis.resize(max_central_t_ps_);
75 }
76 pass_t_ps.insert(pass_t_ps.end(), digis.begin(), digis.end());
77 }
78 for (auto& pair : r_digis) {
79 auto& digis = pair.second;
80 if (digis.size() > max_outer_t_ps_) {
81 std::sort(digis.begin(), digis.end(),
83 return a.getId() > b.getId();
84 });
85 digis.resize(max_central_t_ps_);
86 }
87 pass_t_ps.insert(pass_t_ps.end(), digis.begin(), digis.end());
88 }
89 // center digis, can sort by energy
90 for (auto& pair : c_digis) {
91 auto& digis = pair.second;
92 if (digis.size() > max_central_t_ps_) {
93 std::sort(digis.begin(), digis.end(),
95 return a.getPrimitive() > b.getPrimitive();
96 });
97 digis.resize(max_central_t_ps_);
98 }
99 pass_t_ps.insert(pass_t_ps.end(), digis.begin(), digis.end());
100 }
101
102 // collections to record (corrected to MeV)
103 std::vector<TrigCaloHit> pass_trig_hits;
104 for (const auto& tp : pass_t_ps) {
105 double x, y, z, e;
106 decodeTP(tp, x, y, z, e);
107 pass_trig_hits.emplace_back(x, y, z, e);
108
109 ldmx::EcalTriggerID tid(tp.getId());
110 pass_trig_hits.back().setLayer(tid.layer());
111 pass_trig_hits.back().setModule(tid.module());
112 }
113
114 TrigEnergySumCollection pass_trig_sums;
115 EcalTpToE cvt;
116 for (auto& pair : l_sums) {
117 double e = cvt.calc(pair.second, pair.first);
118 // TrigEnergySum s(pair.first, 4, e);
119 pass_trig_sums.emplace_back(pair.first, 4, e);
120 }
121 for (auto& pair : r_sums) {
122 double e = cvt.calc(pair.second, pair.first);
123 // TrigEnergySum s(pair.first, 1, e);
124 pass_trig_sums.emplace_back(pair.first, 1, e);
125 }
126 for (auto& pair : c_sums) {
127 double e = cvt.calc(pair.second, pair.first);
128 // TrigEnergySum s(pair.first, 0, e);
129 pass_trig_sums.emplace_back(pair.first, 0, e);
130 }
131
132 event.add(pass_coll_name_ + "Hits", pass_trig_hits);
133 event.add(pass_coll_name_ + "Sums", pass_trig_sums);
134}
bool exists(const std::string &name, const std::string &passName, bool unique=true) const
Check for the existence of an object or collection with the given name and pass name in the event.
Definition Event.cxx:107
Contains the trigger output for a single trigger hgcroc channel.

References framework::Event::exists(), ldmx::EcalTriggerID::layer(), and ldmx::EcalTriggerID::module().

Member Data Documentation

◆ max_central_t_ps_

unsigned int trigger::EcalTPSelector::max_central_t_ps_ {12}
private

Definition at line 46 of file EcalTPSelector.h.

46{12};

◆ max_outer_t_ps_

unsigned int trigger::EcalTPSelector::max_outer_t_ps_ {8}
private

Definition at line 47 of file EcalTPSelector.h.

47{8};

◆ pass_coll_name_

std::string trigger::EcalTPSelector::pass_coll_name_
private

Definition at line 40 of file EcalTPSelector.h.

◆ tp_coll_event_passname_

std::string trigger::EcalTPSelector::tp_coll_event_passname_
private

Definition at line 44 of file EcalTPSelector.h.

◆ tp_coll_name_

std::string trigger::EcalTPSelector::tp_coll_name_
private

Definition at line 38 of file EcalTPSelector.h.

◆ tp_coll_passname_

std::string trigger::EcalTPSelector::tp_coll_passname_
private

Definition at line 42 of file EcalTPSelector.h.


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