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

Detailed Description

Definition at line 28 of file EcalTPSelector.h.

Constructor & Destructor Documentation

◆ EcalTPSelector()

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

Definition at line 30 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 className equal to the EventProcessor class name.

For an example, look at MyProcessor.

Parameters
parametersParameters for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 5 of file EcalTPSelector.cxx.

5 {
6 tp_coll_name_ = ps.get<std::string>("tpCollName");
7 pass_coll_name_ = ps.get<std::string>("passCollName");
8 tp_coll_passname_ = ps.get<std::string>("tp_coll_pass_name");
9 tp_coll_event_passname_ = ps.get<std::string>("tp_coll_event_passname");
10}

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

◆ decodeTP()

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

Definition at line 138 of file EcalTPSelector.cxx.

139 {
140 ldmx::EcalTriggerID tid(tp.getId());
141 const ecal::EcalTriggerGeometry& geom =
143 ecal::EcalTriggerGeometry::CONDITIONS_OBJECT_NAME);
144 // const auto center_ecalID = geom.centerInTriggerCell(tid);
145 // const ldmx::EcalGeometry& hexReadout = getCondition<ldmx::EcalGeometry>(
146 // ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME);
147 // hexReadout.getCellAbsolutePosition(center_ecalID,x,y,z);
148 std::tie(x, y, z) = geom.globalPosition(tid);
149 // e = primitiveToEnergy(tp.linearPrimitive(), tid.layer());
150 EcalTpToE cvt;
151 e = cvt.calc(tp.linearPrimitive(), tid.layer());
152}
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 12 of file EcalTPSelector.cxx.

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

52{12};

◆ max_outer_t_ps_

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

Definition at line 53 of file EcalTPSelector.h.

53{8};

◆ pass_coll_name_

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

Definition at line 46 of file EcalTPSelector.h.

◆ tp_coll_event_passname_

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

Definition at line 50 of file EcalTPSelector.h.

◆ tp_coll_name_

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

Definition at line 44 of file EcalTPSelector.h.

◆ tp_coll_passname_

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

Definition at line 48 of file EcalTPSelector.h.


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