LDMX Software
Public Member Functions | Private Attributes | List of all members
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 beforeNewRun (ldmx::RunHeader &header)
 Handle allowing producers to modify run headers before the run begins.
 
- Public Member Functions inherited from framework::EventProcessor
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()
 Class destructor.
 
virtual void onNewRun (const ldmx::RunHeader &runHeader)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
virtual void onFileOpen (EventFile &eventFile)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &eventFile)
 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 tpCollName_
 
std::string passCollName_
 
unsigned int maxCentralTPs_ {12}
 
unsigned int maxOuterTPs_ {8}
 

Additional Inherited Members

- Static Public Member Functions inherited from framework::EventProcessor
static void declare (const std::string &classname, int classtype, EventProcessorMaker *)
 Internal function which is part of the PluginFactory machinery.
 
- Static Public Attributes inherited from framework::Producer
static const int CLASSTYPE {1}
 Constant used to track EventProcessor types by the PluginFactory.
 
- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramHelper histograms_
 Interface class for making and filling histograms.
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger theLog_
 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.

31 : framework::Producer(name, process) {}
Base class for a module which produces a data product.

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 tpCollName_ = ps.getParameter<std::string>("tpCollName");
7 passCollName_ = ps.getParameter<std::string>("passCollName");
8}

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

◆ decodeTP()

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

Definition at line 132 of file EcalTPSelector.cxx.

133 {
134 ldmx::EcalTriggerID tid(tp.getId());
135 const ecal::EcalTriggerGeometry& geom =
136 getCondition<ecal::EcalTriggerGeometry>(
137 ecal::EcalTriggerGeometry::CONDITIONS_OBJECT_NAME);
138 // const auto center_ecalID = geom.centerInTriggerCell(tid);
139 // const ldmx::EcalGeometry& hexReadout = getCondition<ldmx::EcalGeometry>(
140 // ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME);
141 // hexReadout.getCellAbsolutePosition(center_ecalID,x,y,z);
142 std::tie(x, y, z) = geom.globalPosition(tid);
143 // e = primitiveToEnergy(tp.linearPrimitive(), tid.layer());
144 ecalTpToE cvt;
145 e = cvt.calc(tp.linearPrimitive(), tid.layer());
146}
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.
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 10 of file EcalTPSelector.cxx.

10 {
11 if (!event.exists(tpCollName_)) return;
12 auto ecalTrigDigis{
13 event.getObject<ldmx::HgcrocTrigDigiCollection>(tpCollName_)};
14
15 std::map<int, ldmx::HgcrocTrigDigiCollection> lDigis; // left
16 std::map<int, ldmx::HgcrocTrigDigiCollection> rDigis; // right
17 std::map<int, ldmx::HgcrocTrigDigiCollection> cDigis; // center
18 std::map<int, int> lSums; // left
19 std::map<int, int> rSums; // right
20 std::map<int, int> cSums; // center
21 for (const auto& trigDigi : ecalTrigDigis) {
22 ldmx::EcalTriggerID tid(trigDigi.getId());
23 int module = tid.module();
24 int layer = tid.layer();
25 if (module > 3) {
26 auto ptr = lDigis.find(layer);
27 if (ptr == lDigis.end()) {
28 lDigis[layer] = {trigDigi};
29 lSums[layer] = trigDigi.linearPrimitive();
30 } else {
31 lDigis[layer].push_back(trigDigi);
32 lSums[layer] += trigDigi.linearPrimitive();
33 }
34 } else if (module > 0) {
35 auto ptr = rDigis.find(layer);
36 if (ptr == rDigis.end()) {
37 rDigis[layer] = {trigDigi};
38 rSums[layer] = trigDigi.linearPrimitive();
39 } else {
40 rDigis[layer].push_back(trigDigi);
41 rSums[layer] += trigDigi.linearPrimitive();
42 }
43 } else {
44 auto ptr = cDigis.find(layer);
45 if (ptr == cDigis.end()) {
46 cDigis[layer] = {trigDigi};
47 cSums[layer] = trigDigi.linearPrimitive();
48 } else {
49 cDigis[layer].push_back(trigDigi);
50 cSums[layer] += trigDigi.linearPrimitive();
51 }
52 }
53 }
54
55 // Enforce truncation.
56 // For outer modules, the energy sort is not possible
57 // Instead, sort by ID to be deterministic.
58 ldmx::HgcrocTrigDigiCollection passTPs;
59 passTPs.reserve(ecalTrigDigis.size());
60 for (auto& pair : lDigis) {
61 auto& digis = pair.second;
62 if (digis.size() > maxOuterTPs_) {
63 std::sort(digis.begin(), digis.end(),
65 return a.getId() > b.getId();
66 });
67 digis.resize(maxCentralTPs_);
68 }
69 passTPs.insert(passTPs.end(), digis.begin(), digis.end());
70 }
71 for (auto& pair : rDigis) {
72 auto& digis = pair.second;
73 if (digis.size() > maxOuterTPs_) {
74 std::sort(digis.begin(), digis.end(),
76 return a.getId() > b.getId();
77 });
78 digis.resize(maxCentralTPs_);
79 }
80 passTPs.insert(passTPs.end(), digis.begin(), digis.end());
81 }
82 // center digis, can sort by energy
83 for (auto& pair : cDigis) {
84 auto& digis = pair.second;
85 if (digis.size() > maxCentralTPs_) {
86 std::sort(digis.begin(), digis.end(),
88 return a.getPrimitive() > b.getPrimitive();
89 });
90 digis.resize(maxCentralTPs_);
91 }
92 passTPs.insert(passTPs.end(), digis.begin(), digis.end());
93 }
94
95 // collections to record (corrected to MeV)
96 TrigCaloHitCollection passTrigHits;
97 for (const auto& tp : passTPs) {
98 double x, y, z, e;
99 decodeTP(tp, x, y, z, e);
100 passTrigHits.emplace_back(x, y, z, e);
101 }
102
103 TrigEnergySumCollection passTrigSums;
104 ecalTpToE cvt;
105 for (auto& pair : lSums) {
106 double e = cvt.calc(pair.second, pair.first);
107 // TrigEnergySum s(pair.first, 4, e);
108 passTrigSums.emplace_back(pair.first, 4, e);
109 }
110 for (auto& pair : rSums) {
111 double e = cvt.calc(pair.second, pair.first);
112 // TrigEnergySum s(pair.first, 1, e);
113 passTrigSums.emplace_back(pair.first, 1, e);
114 }
115 for (auto& pair : cSums) {
116 double e = cvt.calc(pair.second, pair.first);
117 // TrigEnergySum s(pair.first, 0, e);
118 passTrigSums.emplace_back(pair.first, 0, e);
119 }
120
121 event.add(passCollName_ + "Hits", passTrigHits);
122 event.add(passCollName_ + "Sums", passTrigSums);
123}
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(), and ldmx::EcalTriggerID::layer().

Member Data Documentation

◆ maxCentralTPs_

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

Definition at line 48 of file EcalTPSelector.h.

48{12};

◆ maxOuterTPs_

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

Definition at line 49 of file EcalTPSelector.h.

49{8};

◆ passCollName_

std::string trigger::EcalTPSelector::passCollName_
private

Definition at line 46 of file EcalTPSelector.h.

◆ tpCollName_

std::string trigger::EcalTPSelector::tpCollName_
private

Definition at line 44 of file EcalTPSelector.h.


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