LDMX Software
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
ecal::EcalTriggerGeometry Class Reference

defines the relationship between precision cells and trigger cells and provides geometry information for trigger cells More...

#include <EcalTriggerGeometry.h>

Public Member Functions

 EcalTriggerGeometry (int symmetry, const ldmx::EcalGeometry *ecalGeom=0)
 
std::vector< ldmx::EcalIDcontentsOfTriggerCell (ldmx::EcalTriggerID triggerCell) const
 Returns the set of precision (full-granularity/DAQ) cells which are associated with the given trigger cell.
 
ldmx::EcalID centerInTriggerCell (ldmx::EcalTriggerID triggerCell) const
 Returns the set of precision (full-granularity/DAQ) cell which is the center of the given trigger cell.
 
ldmx::EcalTriggerID belongsTo (ldmx::EcalID precisionCell) const
 Returns which trigger cell this precision cell is associated with, or a null id if there is no such association.
 
std::tuple< double, double, double > globalPosition (ldmx::EcalTriggerID triggerCell) const
 Returns the center of the given trigger cell in world coordinates.
 
std::pair< double, double > localPosition (ldmx::EcalTriggerID triggerCell) const
 Returns the local (within module) center of the given trigger cell.
 
- Public Member Functions inherited from framework::ConditionsObject
 ConditionsObject (const std::string &name)
 Class constructor.
 
virtual ~ConditionsObject ()
 Destructor.
 
std::string getName () const
 Get the name of this object.
 

Static Public Attributes

static constexpr const char * CONDITIONS_OBJECT_NAME {"EcalTriggerGeometry"}
 

Private Attributes

int symmetry_
 Identifies what symmetries apply in this case, such as all layers being identical, or all even and odd planes being identical and whether all modules on the same plane are identical.
 
const ldmx::EcalGeometryecalGeometry_
 Reference to the Ecal geometry used for trigger geometry information.
 
std::map< ldmx::EcalID, ldmx::EcalTriggerIDprecision2trigger_
 Map of precision cells to trigger cells, under symmetry assumptions.
 
std::map< ldmx::EcalTriggerID, std::vector< ldmx::EcalID > > trigger2precision_
 Map of trigger cells to precision cells, under symmetry assumptions.
 

Detailed Description

defines the relationship between precision cells and trigger cells and provides geometry information for trigger cells

Definition at line 31 of file EcalTriggerGeometry.h.

Constructor & Destructor Documentation

◆ EcalTriggerGeometry()

ecal::EcalTriggerGeometry::EcalTriggerGeometry ( int  symmetry,
const ldmx::EcalGeometry ecalGeom = 0 
)

lower left-sector

upper-left sector

Definition at line 15 of file EcalTriggerGeometry.cxx.

17 : ConditionsObject(CONDITIONS_OBJECT_NAME),
18 symmetry_{symmetry},
19 ecalGeometry_{ecalGeom} {
20 if ((symmetry_ & MODULES_MASK) == INPLANE_IDENTICAL) {
21 // first set is the same regardless of alignment...
22 int tcell = 0;
24 for (int v = 1; v <= 10; v += 3) {
25 for (int u = 1; u <= 10; u += 3) {
26 ldmx::EcalTriggerID tid(0, 0, tcell);
27 std::vector<ldmx::EcalID> pids;
28 for (int du = -1; du <= 1; du++) {
29 for (int dv = -1; dv <= 1; dv++) {
30 ldmx::EcalID pid(0, 0, u + du, v + dv);
31 precision2trigger_[pid] = tid;
32 pids.push_back(pid);
33 }
34 }
35 trigger2precision_[tid] = pids;
36 tcell++;
37 }
38 }
40 for (int v = 13; v <= 22; v += 3) {
41 for (int u = v - 10; u <= v; u += 3) {
42 ldmx::EcalTriggerID tid(0, 0, tcell);
43 std::vector<ldmx::EcalID> pids;
44 for (int dv = -1; dv <= 1; dv++) {
45 for (int du = -1; du <= 1; du++) {
46 // changes directions here
47 ldmx::EcalID pid(0, 0, u + du + dv, v + dv);
48 precision2trigger_[pid] = tid;
49 pids.push_back(pid);
50 }
51 }
52 trigger2precision_[tid] = pids;
53 tcell++;
54 }
55 }
56 // right side
57 for (int v = 2; v <= 22; v += 3) {
58 int irow = (v - 2) / 3;
59 for (int icol = 0; icol <= std::min(irow, 3); icol++) {
60 if (irow - icol >= 4) continue;
61 ldmx::EcalTriggerID tid(0, 0, tcell);
62 std::vector<ldmx::EcalID> pids;
63 int u = 13 + 3 * icol;
64 for (int dv = -1; dv <= 1; dv++) {
65 for (int du = -1; du <= 1; du++) {
66 ldmx::EcalID pid(0, 0, u + du, v + du + dv);
67 precision2trigger_[pid] = tid;
68 pids.push_back(pid);
69 }
70 }
71 trigger2precision_[tid] = pids;
72 tcell++;
73 }
74 }
75
76 } else {
77 // raise an exception...
78 }
79}
const ldmx::EcalGeometry * ecalGeometry_
Reference to the Ecal geometry used for trigger geometry information.
int symmetry_
Identifies what symmetries apply in this case, such as all layers being identical,...
std::map< ldmx::EcalTriggerID, std::vector< ldmx::EcalID > > trigger2precision_
Map of trigger cells to precision cells, under symmetry assumptions.
std::map< ldmx::EcalID, ldmx::EcalTriggerID > precision2trigger_
Map of precision cells to trigger cells, under symmetry assumptions.
ConditionsObject(const std::string &name)
Class constructor.
Extension of DetectorID providing access to ECal layers and cell numbers in a hex grid.
Definition EcalID.h:20
Extension of DetectorID providing access to ECal trigger cell information.

References precision2trigger_, symmetry_, and trigger2precision_.

Member Function Documentation

◆ belongsTo()

ldmx::EcalTriggerID ecal::EcalTriggerGeometry::belongsTo ( ldmx::EcalID  precisionCell) const

Returns which trigger cell this precision cell is associated with, or a null id if there is no such association.

Definition at line 115 of file EcalTriggerGeometry.cxx.

116 {
117 ldmx::EcalID effId;
118 if ((symmetry_ & MODULES_MASK) == INPLANE_IDENTICAL) {
119 effId = ldmx::EcalID(0, 0, precisionCell.cell());
120 }
121 auto ptr = precision2trigger_.find(effId);
122 if (ptr == precision2trigger_.end()) {
123 return ldmx::EcalTriggerID(0, 0, 0); // not ideal
124 } else {
125 return ldmx::EcalTriggerID(precisionCell.layer(), precisionCell.module(),
126 ptr->second.triggercell());
127 }
128}
int cell() const
Get the value of the cell field from the ID.
Definition EcalID.h:111
int module() const
Get the value of the module field from the ID.
Definition EcalID.h:87
int layer() const
Get the value of the layer field from the ID.
Definition EcalID.h:99

References ldmx::EcalID::cell(), ldmx::EcalID::layer(), ldmx::EcalID::module(), precision2trigger_, and symmetry_.

Referenced by ecal::EcalTrigPrimDigiProducer::produce().

◆ centerInTriggerCell()

ldmx::EcalID ecal::EcalTriggerGeometry::centerInTriggerCell ( ldmx::EcalTriggerID  triggerCell) const

Returns the set of precision (full-granularity/DAQ) cell which is the center of the given trigger cell.

Definition at line 98 of file EcalTriggerGeometry.cxx.

99 {
101 if ((symmetry_ & MODULES_MASK) == INPLANE_IDENTICAL) {
102 effId = ldmx::EcalTriggerID(0, 0, triggerCell.triggercell());
103 }
104 auto ptr = trigger2precision_.find(effId);
105 if (ptr == trigger2precision_.end()) {
106 std::stringstream ss;
107 ss << "Unable to find trigger cell " << triggerCell;
108 EXCEPTION_RAISE("EcalGeometryException", ss.str());
109 }
110
111 return ldmx::EcalID(triggerCell.layer(), triggerCell.module(),
112 ptr->second[4].cell());
113}
int layer() const
Get the value of the layer field from the ID.
int module() const
Get the value of the module field from the ID.
int triggercell() const
Get the value of the trigger cell field from the ID.

References ldmx::EcalTriggerID::layer(), ldmx::EcalTriggerID::module(), symmetry_, trigger2precision_, and ldmx::EcalTriggerID::triggercell().

Referenced by globalPosition(), and localPosition().

◆ contentsOfTriggerCell()

std::vector< ldmx::EcalID > ecal::EcalTriggerGeometry::contentsOfTriggerCell ( ldmx::EcalTriggerID  triggerCell) const

Returns the set of precision (full-granularity/DAQ) cells which are associated with the given trigger cell.

Definition at line 81 of file EcalTriggerGeometry.cxx.

82 {
84 std::vector<ldmx::EcalID> retval;
85 if ((symmetry_ & MODULES_MASK) == INPLANE_IDENTICAL) {
86 effId = ldmx::EcalTriggerID(0, 0, triggerCell.triggercell());
87 }
88 auto ptr = trigger2precision_.find(effId);
89 if (ptr != trigger2precision_.end()) {
90 for (auto idz : ptr->second) {
91 retval.push_back(
92 ldmx::EcalID(triggerCell.layer(), triggerCell.module(), idz.cell()));
93 }
94 }
95 return retval;
96}

References ldmx::EcalTriggerID::layer(), ldmx::EcalTriggerID::module(), symmetry_, trigger2precision_, and ldmx::EcalTriggerID::triggercell().

◆ globalPosition()

std::tuple< double, double, double > ecal::EcalTriggerGeometry::globalPosition ( ldmx::EcalTriggerID  triggerCell) const

Returns the center of the given trigger cell in world coordinates.

depends on Ecal Geometry (ldmx::EcalGeometry)

C++17's structured bindings is helpful here

auto [x,y,z] = trig_geom.globalPosition(triggerCell);
// x,y,z are the world coordinates of the center of the trigger cell

Definition at line 131 of file EcalTriggerGeometry.cxx.

132 {
133 if (!ecalGeometry_) return std::make_tuple(0, 0, 0);
134 ldmx::EcalID pid = centerInTriggerCell(triggerCell);
135 return ecalGeometry_->getPosition(pid);
136}
ldmx::EcalID centerInTriggerCell(ldmx::EcalTriggerID triggerCell) const
Returns the set of precision (full-granularity/DAQ) cell which is the center of the given trigger cel...
std::tuple< double, double, double > getPosition(EcalID id) const
Get a cell's position from its ID number.

References centerInTriggerCell(), ecalGeometry_, and ldmx::EcalGeometry::getPosition().

Referenced by trigger::TrigEcalClusterProducer::produce().

◆ localPosition()

std::pair< double, double > ecal::EcalTriggerGeometry::localPosition ( ldmx::EcalTriggerID  triggerCell) const

Returns the local (within module) center of the given trigger cell.

depends on Ecal Geometry (ldmx::EcalGeometry)

Definition at line 138 of file EcalTriggerGeometry.cxx.

139 {
140 if (!ecalGeometry_) return std::make_pair(0, 0);
141 ldmx::EcalID pid = centerInTriggerCell(triggerCell);
143}
std::pair< double, double > getPositionInModule(int cell_id) const
Get a cell's position within a module.

References ldmx::EcalID::cell(), centerInTriggerCell(), ecalGeometry_, and ldmx::EcalGeometry::getPositionInModule().

Member Data Documentation

◆ CONDITIONS_OBJECT_NAME

constexpr const char* ecal::EcalTriggerGeometry::CONDITIONS_OBJECT_NAME {"EcalTriggerGeometry"}
staticconstexpr

Definition at line 33 of file EcalTriggerGeometry.h.

33{"EcalTriggerGeometry"};

◆ ecalGeometry_

const ldmx::EcalGeometry* ecal::EcalTriggerGeometry::ecalGeometry_
private

Reference to the Ecal geometry used for trigger geometry information.

Definition at line 85 of file EcalTriggerGeometry.h.

Referenced by globalPosition(), and localPosition().

◆ precision2trigger_

std::map<ldmx::EcalID, ldmx::EcalTriggerID> ecal::EcalTriggerGeometry::precision2trigger_
private

Map of precision cells to trigger cells, under symmetry assumptions.

Definition at line 88 of file EcalTriggerGeometry.h.

Referenced by belongsTo(), and EcalTriggerGeometry().

◆ symmetry_

int ecal::EcalTriggerGeometry::symmetry_
private

Identifies what symmetries apply in this case, such as all layers being identical, or all even and odd planes being identical and whether all modules on the same plane are identical.

Definition at line 83 of file EcalTriggerGeometry.h.

Referenced by belongsTo(), centerInTriggerCell(), contentsOfTriggerCell(), and EcalTriggerGeometry().

◆ trigger2precision_

std::map<ldmx::EcalTriggerID, std::vector<ldmx::EcalID> > ecal::EcalTriggerGeometry::trigger2precision_
private

Map of trigger cells to precision cells, under symmetry assumptions.

Definition at line 91 of file EcalTriggerGeometry.h.

Referenced by centerInTriggerCell(), contentsOfTriggerCell(), and EcalTriggerGeometry().


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