LDMX Software
ldmx::EcalGeometry Class Reference

Translation between real-space positions and cell IDs within the ECal. More...

#include <EcalGeometry.h>

Public Member Functions

virtual ~EcalGeometry ()=default
 Class destructor.
 
EcalID getID (double x, double y, double z, bool fallible=false) const
 Get a cell's ID number from its position.
 
EcalID getID (double x, double y, int layer_id, bool fallible=false) const
 Get a cell's ID from its x,y global position and layer number.
 
EcalID getID (double x, double y, int layer_id, int module_id, bool fallible=false) const
 Get a cell's ID from its x,y global position and layer/module numbers as deduced from GDML copy numbers.
 
std::tuple< double, double, double > getPosition (EcalID id) const
 Get a cell's position from its ID number.
 
std::pair< double, double > getPositionInModule (int cell_id) const
 Get a cell's position within a module.
 
double getZPosition (int layer) const
 Get the z-coordinate given the layer id.
 
double getEcalFrontZ () const
 Get the z-coordinate of the Ecal face.
 
int getNumLayers () const
 Get the number of layers in the Ecal Geometry.
 
int getNumModulesPerLayer () const
 Get the number of modules in the Ecal flower.
 
int getNumCellsPerModule () const
 Get the number of cells in each module of the Ecal Geometry.
 
std::vector< EcalIDgetNN (EcalID id) const
 Get the Nearest Neighbors of the input ID.
 
bool isNN (EcalID centroid, EcalID probe) const
 Check if the probe id is one of the nearest neightbors of the centroid id.
 
std::vector< EcalIDgetNNN (EcalID id) const
 Get the Next-to-Nearest Neighbors of the input ID.
 
bool isNNN (EcalID centroid, EcalID probe) const
 Check if the probe id is one of the next-to-nearest neightbors of the centroid id.
 
double getModuleMinR () const
 Get the center-to-flat radius of the module hexagons.
 
double getModuleMaxR () const
 Get the center-to-corner radius of the module hexagons.
 
double getCellMinR () const
 Get the center-to-flat radius of the cell hexagons.
 
double getCellMaxR () const
 Get the center-to-corner radius of the cell hexagons.
 
TH2Poly * getCellPolyMap () const
 Get a reference to the TH2Poly used for Cell IDs.
 
- 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 Member Functions

static EcalGeometrydebugMake (const framework::config::Parameters &p)
 

Static Public Attributes

static constexpr const char * CONDITIONS_OBJECT_NAME {"EcalGeometry"}
 

Private Member Functions

 EcalGeometry (const framework::config::Parameters &ps)
 Class constructor, for use only by the provider.
 
void buildLayerMap ()
 Constructs the positions of the layers in world coordinates.
 
void buildModuleMap ()
 Constructs the positions of the seven modules (moduleID) relative to the ecal center.
 
void buildCellMap ()
 Constructs the flat-bottomed hexagonal grid (cellID) of corner-down hexagonal cells.
 
void buildCellModuleMap ()
 Constructs the positions of all the cells in a layer relative to the ecal center.
 
void buildNeighborMaps ()
 Construts NNMap and NNNMap.
 
double distanceToEdge (EcalID id) const
 Distance to module edge, and whether cell is on edge of module.
 
bool isEdgeCell (EcalID cellModuleID) const
 Check if input cell is on the edge of a module.
 
bool isInside (double normX, double normY) const
 Determines if point (x,y), already normed to max hexagon radius, lies within a hexagon.
 

Private Attributes

double gap_
 Gap between module flat sides [mm].
 
double cell_r_min_ {0}
 Center-to-Flat Radius of cell hexagon [mm].
 
double module_r_min_ {0}
 Center-to-Flat Radius of module hexagon [mm].
 
double cell_r_max_ {0}
 Center-to-Corner Radius of cell hexagon [mm].
 
double module_r_max_ {0}
 Center-to-Corner Radius of module hexagon [mm].
 
bool corners_side_up_
 indicator of geometry orientation if true, flower shape's corners side (ie: side with two modules) is at the top
 
double layer_shift_x_
 shift of layers in the x-direction [mm]
 
double layer_shift_y_
 shift of layers in the y-direction [mm]
 
bool layer_shift_odd_
 shift odd layers
 
bool layer_shift_odd_bilayer_
 shift odd bi layers
 
double si_thickness_
 Thickness of the Si sensitive layer [mm].
 
double n_cell_r_height_ {0}
 Number of cell center-to-corner radii (one side of the cell) from the bottom to the top of the module.
 
double ecal_front_z_ {0}
 Front of ECal relative to world geometry [mm].
 
std::vector< double > layer_z_positions_
 The layer Z postions are with respect to the front of the ECal [mm].
 
std::map< int, std::tuple< double, double, double > > layer_pos_xy_
 Position of layer centers in world coordinates (uses layer ID as key)
 
std::map< int, std::pair< double, double > > module_pos_xy_
 Postion of module centers relative to the center of the layer in world coordinates.
 
std::map< int, std::pair< double, double > > cell_pos_in_module_
 Position of cell centers relative to center of module in p,q space.
 
std::map< EcalID, std::pair< double, double > > cell_pos_in_layer_
 Position of cell centers relative to center of layer in world coordinates.
 
std::map< EcalID, std::tuple< double, double, double > > cell_global_pos_
 Position of cell centers relative to world geometry.
 
std::map< EcalID, std::vector< EcalID > > nn_map_
 Map of cell ID to neighboring cells.
 
std::map< EcalID, std::vector< EcalID > > nnn_map_
 Map of cell ID to neighbors of neighbor cells.
 
TH2Poly cell_id_in_module_
 Honeycomb Binning from ROOT.
 

Friends

class ecal::EcalGeometryProvider
 

Detailed Description

Translation between real-space positions and cell IDs within the ECal.

This is the object that does the extra geometry not implemented in the gdml. In order to save time during the simulation, the individual cells in the readout hexagons are not constructed individually in Geant4. This means we have to have a translation between position and cell ID which is accomplished by this class.

Moreover, downstream processors sometimes need access to the cell position when they only know the cell ID. This class can also do this conversion.

ORIENTATION ASSUMPTIONS:

  • modules and cells have opposite orientation. i.e. if modules are corner-side down, then cells are flat-side down.

SOME GEOMETRY:

  • hexagons have two radii:
    • r (half of flat-to-flat width) and R (half of corner-to-corner width).
    • r = (sqrt(3)/2)R and s = R, where s is the length of an edge.
  • for seven ecal modules oriented flat-side-down, maximum x and y extents are:
    • deltaY = 6r' + 2g = 3sqrt(3)R' + 2g
    • deltaX = 4R' + s' + 2g/cos(30 deg) = 5R' + 4g/sqrt(3)
    • where g is uniform gap width between modules, and primed variables correspond to modules.

Since the whole hexagon flower has changed orientation since previous versions of the detector (which we wish to still support), I am defining an extra set of axes with respect to the flower itself. Below I have drawn the ECal hexagon i flower and defined two axes: p (through the "pointy sides") and q (through the "flat sides"). In some versions of the ECal flower, p == x and q == y while in others p == -y and q == x.

     ^
     | q axis
    __
 __/1 \__
/6 \__/2 \
\__/0 \__/ __ p axis __>
/5 \__/3 \
\__/4 \__/
   \__/

Now we can define a process for determining the cellular IDs.

  • Define a mapping of cell IDs within a module (center of module is the origin)
    • Use TH2Poly to do the Hexagon tiling in p,q space
  • Define center of modules with respect to center of layer in p,q space
    • currently this is assumed to be the same within all layers BUT will depend on geometry parameters like the gap between modules
  • Define center of layers (INCLUDING x,y position)
    • some versions of the geometry shift layers off the z axis to cover the gaps between modules
    • Will need to handle the conversion between x,y and p,q axes

THIS GRID:

  • column-to-column distance in a grid such as ours is 2r = sqrt(3)R.
  • row-to-row distance is 1.5R (easy to observe that twice that distance = 3R)

The cell radius is calculated from the total number of center-to-corner cell radii that span the module height. This count can have fractional counts to account for the fractions of cell radii at the module edges.

Definition at line 108 of file EcalGeometry.h.

Constructor & Destructor Documentation

◆ ~EcalGeometry()

virtual ldmx::EcalGeometry::~EcalGeometry ( )
virtualdefault

Class destructor.

Does nothing because the member variables clean up themselves.

◆ EcalGeometry()

ldmx::EcalGeometry::EcalGeometry ( const framework::config::Parameters & ps)
private

Class constructor, for use only by the provider.

Parameters
psParameters to configure the EcalGeometry

Definition at line 40 of file EcalGeometry.cxx.

41 : framework::ConditionsObject(EcalGeometry::CONDITIONS_OBJECT_NAME) {
42 layer_z_positions_ = ps.get<std::vector<double>>("layerZPositions");
43 ecal_front_z_ = ps.get<double>("ecalFrontZ");
44 module_r_min_ = ps.get<double>("moduleMinR");
45 gap_ = ps.get<double>("gap");
46 n_cell_r_height_ = ps.get<double>("nCellRHeight");
47 corners_side_up_ = ps.get<bool>("cornersSideUp");
48 layer_shift_x_ = ps.get<double>("layer_shift_x");
49 layer_shift_y_ = ps.get<double>("layer_shift_y");
50 layer_shift_odd_ = ps.get<bool>("layer_shift_odd");
51 layer_shift_odd_bilayer_ = ps.get<bool>("layer_shift_odd_bilayer");
52 si_thickness_ = ps.get<double>("si_thickness");
53
55 EXCEPTION_RAISE("BadConf",
56 "Cannot shift both odd sensitive layers and odd bilayers");
57 }
58
59 module_r_max_ = module_r_min_ * (2 / sqrt(3));
61 cell_r_min_ = (sqrt(3.) / 2.) * cell_r_max_;
62
63 ldmx_log(debug) << "Building module map with gap " << std::setprecision(2)
64 << gap_ << ", nCellRHeight " << n_cell_r_height_
65 << ", min/max radii of cell " << cell_r_min_ << " / "
66 << cell_r_max_ << ", and module " << module_r_min_ << " / "
68
74
75 ldmx_log(trace) << "Geometry fully constructed";
76}
Base class for all conditions objects, very simple.
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
void buildCellModuleMap()
Constructs the positions of all the cells in a layer relative to the ecal center.
double layer_shift_y_
shift of layers in the y-direction [mm]
void buildCellMap()
Constructs the flat-bottomed hexagonal grid (cellID) of corner-down hexagonal cells.
bool layer_shift_odd_
shift odd layers
double module_r_max_
Center-to-Corner Radius of module hexagon [mm].
double cell_r_min_
Center-to-Flat Radius of cell hexagon [mm].
double n_cell_r_height_
Number of cell center-to-corner radii (one side of the cell) from the bottom to the top of the module...
double layer_shift_x_
shift of layers in the x-direction [mm]
void buildModuleMap()
Constructs the positions of the seven modules (moduleID) relative to the ecal center.
std::vector< double > layer_z_positions_
The layer Z postions are with respect to the front of the ECal [mm].
double si_thickness_
Thickness of the Si sensitive layer [mm].
bool layer_shift_odd_bilayer_
shift odd bi layers
void buildLayerMap()
Constructs the positions of the layers in world coordinates.
double cell_r_max_
Center-to-Corner Radius of cell hexagon [mm].
double ecal_front_z_
Front of ECal relative to world geometry [mm].
double gap_
Gap between module flat sides [mm].
double module_r_min_
Center-to-Flat Radius of module hexagon [mm].
void buildNeighborMaps()
Construts NNMap and NNNMap.
bool corners_side_up_
indicator of geometry orientation if true, flower shape's corners side (ie: side with two modules) is...

References buildCellMap(), buildCellModuleMap(), buildLayerMap(), buildModuleMap(), buildNeighborMaps(), cell_r_max_, cell_r_min_, corners_side_up_, ecal_front_z_, gap_, framework::config::Parameters::get(), layer_shift_odd_, layer_shift_odd_bilayer_, layer_shift_x_, layer_shift_y_, layer_z_positions_, module_r_max_, module_r_min_, n_cell_r_height_, and si_thickness_.

Member Function Documentation

◆ buildCellMap()

void ldmx::EcalGeometry::buildCellMap ( )
private

Constructs the flat-bottomed hexagonal grid (cellID) of corner-down hexagonal cells.

Sets ecalMap_ with the defined bins being the ecal cells in coordinates with respect to the module center. Also sets cellPostionMap_ with the keys being the cell ID and the values being the position of the cell with respect to the module center.

Strategy

Use ROOT's TH2Poly::HoneyComb method to build a large hexagonal grid, then copy the polygons from it which overlap with the module with more than one vertex.

A vertex between three cells is placed at the origin, then the bottom left corner of the honeycomb and the number of x and y cells across the honeycomb is calculated by continuing to decrement the grid x/y point until the module center-to-flat distance is reached.

The hexagons that only have one vertex outside the module hexagon leave a small space un-covered by the tiling, so the vertices adjacent to the external vertex are projected onto the module edge.

Parameters
[in]cell_r_max_the center-to-flat cell radius
[in]cell_r_min_the center-to-corner cell radius
[in]module_r_min_the center-to-flat module radius
[in]module_r_max_the center-to-flat module radius
[out]ecalMap_TH2Poly with local cell ID to local cell position mapping
[out]cellPostionMap_map of local cell ID to cell center position relative to module

STRATEGY use ROOT HoneyComb method (build large hex grid, copy polygons that cover module)

the sneaky bit is that the center of TH2Poly::HoneyComb is the center of a cell while the center of one of our modules is the corner between three cells. This means some of the hexagons along the edges of the module will not be regular and need to stretched/squashed a bit.

REMEMBER: We are in p,q space for the cells_in_module_ map. i.e.

^ | q axis __ / \ – > p axis __/

TODO is this needed?

Definition at line 242 of file EcalGeometry.cxx.

242 {
262 TH2Poly gridMap;
263
264 // make hexagonal grid [boundary is rectangle] larger than the module
265 double gridMinP = 0., gridMinQ = 0.; // start at the origin
266 int numPCells = 0, numQCells = 0;
267
268 // first x-cell is only a half
269 gridMinP -= cell_r_min_;
270 numPCells++;
271 while (gridMinP > -1 * module_r_max_) {
272 gridMinP -= 2 * cell_r_min_; // decrement x by cell center-to-flat diameter
273 numPCells++;
274 }
275 while (gridMinQ > -1 * module_r_min_) {
276 // decrement y by cell center-to-corner radius
277 // alternate between a full corner-to-corner diameter
278 // and a side of a cell (center-to-corner radius)
279 if (numQCells % 2 == 0)
280 gridMinQ -= 1 * cell_r_max_;
281 else
282 gridMinQ -= 2 * cell_r_max_;
283 numQCells++;
284 }
285 // only counted one half of the cells
286 numPCells *= 2;
287 numQCells *= 2;
288
289 gridMap.Honeycomb(gridMinP, gridMinQ, cell_r_max_, numPCells, numQCells);
290
291 ldmx_log(trace) << std::setprecision(2)
292 << "Building buildCellMap with cell rmin: " << cell_r_min_
293 << " cell rmax: " << cell_r_max_ << " (gridMinP,gridMinQ) = ("
294 << gridMinP << "," << gridMinQ << ")"
295 << " (numPCells,numQCells) = (" << numPCells << ","
296 << numQCells << ")";
297
298 // copy cells lying within module boundaries to a module grid
299 TListIter next(gridMap.GetBins()); // a TH2Poly is a TList of TH2PolyBin
300 TH2PolyBin* polyBin = 0;
301 TGraph* poly = 0; // a polygon returned by TH2Poly is a TGraph
302 // cells_in_module_ IDs go from 0 to N-1, not equal to original grid cell ID
303 int cell_id = 0;
304 while ((polyBin = (TH2PolyBin*)next())) {
305 // these bins are coming from the honeycomb
306 // grid so we assume that they are regular
307 // hexagons i.e. has 6 vertices
308 poly = (TGraph*)polyBin->GetPolygon();
309
310 // decide whether to copy polygon to new map.
311 // use all vertices in case of cut-off edge polygons.
312 int numVerticesInside = 0;
313 double vertex_p[6], vertex_q[6]; // vertices of the cell
314 bool isinside[6]; // which vertices are inside
315 ldmx_log(trace) << " Cell vertices";
316 for (unsigned i = 0; i < 6; i++) {
317 poly->GetPoint(i, vertex_p[i], vertex_q[i]);
318 ldmx_log(trace) << " vtx # " << i;
319 ldmx_log(trace) << " vtx p,q " << vertex_p[i] << " " << vertex_q[i];
320
321 isinside[i] =
322 isInside(vertex_p[i] / module_r_max_, vertex_q[i] / module_r_max_);
323 if (isinside[i]) numVerticesInside++;
324 }
325
326 if (numVerticesInside > 1) {
327 // Include this cell if more than one of its vertices is inside the module
328 // hexagon
329 double actual_p[8], actual_q[8];
330 int num_vertices{0};
331 if (numVerticesInside < 6) {
332 // This cell is stradling the edge of the module
333 // and is NOT cleanly cut by module edge
334
335 ldmx_log(trace) << " Polygon " << cell_id
336 << " has vertices poking out of module hexagon.";
337
338 // loop through vertices
339 for (int i = 0; i < 6; i++) {
340 int up = i == 5 ? 0 : i + 1;
341 int dn = i == 0 ? 5 : i - 1;
342 if (isinside[i] and (not isinside[up] or not isinside[dn])) {
343 // this vertex is inside the module hexagon and is adjacent to a
344 // vertex outside
345 // ==> project this vertex onto the nearest edge of the module
346 // hexagon
347
348 // determine which side of hexagon we should project onto
349 double edge_origin_p, edge_origin_q;
350 double edge_dest_p, edge_dest_q;
351 if (vertex_p[i] < -module_r_max_ / 2.) {
352 // sloped edge on negative-x side
353 edge_origin_p = -1. * module_r_max_;
354 edge_origin_q = 0.;
355 edge_dest_p = -0.5 * module_r_max_;
356 edge_dest_q = module_r_min_;
357 } else if (vertex_p[i] > module_r_max_ / 2.) {
358 // sloped edge on positive-x side
359 edge_origin_p = 0.5 * module_r_max_;
360 edge_origin_q = module_r_min_;
361 edge_dest_p = module_r_max_;
362 edge_dest_q = 0.;
363 } else {
364 // flat edge at top
365 edge_origin_p = 0.5 * module_r_max_;
366 edge_origin_q = module_r_min_;
367 edge_dest_p = -0.5 * module_r_max_;
368 edge_dest_q = module_r_min_;
369 }
370 // flip to bottom half if below x-axis
371 if (vertex_q[i] < 0) {
372 edge_dest_q *= -1;
373 edge_origin_q *= -1;
374 }
375
376 // get edge slope vector
377 double edge_slope_p = edge_dest_p - edge_origin_p;
378 double edge_slope_q = edge_dest_q - edge_origin_q;
379
380 ldmx_log(trace)
381 << "Vertex " << i
382 << " is inside and adjacent to a vertex outside the module.";
383 ldmx_log(trace) << "Working on edge with slope (" << edge_slope_p
384 << "," << edge_slope_q << ")" << " and origin ("
385 << edge_origin_p << "," << edge_origin_q << ")";
386
387 // project vertices adjacent to the vertex outside the module onto
388 // the module edge
389 double projection_factor =
390 ((vertex_p[i] - edge_origin_p) * edge_slope_p +
391 (vertex_q[i] - edge_origin_q) * edge_slope_q) /
392 (edge_slope_p * edge_slope_p + edge_slope_q * edge_slope_q);
393
394 double proj_p = edge_origin_p + projection_factor * edge_slope_p;
395 double proj_q = edge_origin_q + projection_factor * edge_slope_q;
396
397 if (not isinside[up]) {
398 // the next point is outside
399 actual_p[num_vertices] = vertex_p[i];
400 actual_q[num_vertices] = vertex_q[i];
401 actual_p[num_vertices + 1] = proj_p;
402 actual_q[num_vertices + 1] = proj_q;
403 } else {
404 // the previous point was outside
405 actual_p[num_vertices] = proj_p;
406 actual_q[num_vertices] = proj_q;
407 actual_p[num_vertices + 1] = vertex_p[i];
408 actual_q[num_vertices + 1] = vertex_q[i];
409 }
410 num_vertices += 2;
411
412 ldmx_log(trace) << "New Vertex " << i << " : (" << vertex_p[i]
413 << "," << vertex_q[i] << ")";
414
415 } else {
416 actual_p[num_vertices] = vertex_p[i];
417 actual_q[num_vertices] = vertex_q[i];
418 num_vertices++;
419 } // should we project or not
420 } // loop through vertices
421 } else {
422 // all 6 inside, just copy the vertices over
423 num_vertices = 6;
424 for (int i = 0; i < 6; i++) {
425 actual_p[i] = vertex_p[i];
426 actual_q[i] = vertex_q[i];
427 }
428 } // if numVerticesInside is less than 5
429
430 // TH2Poly needs to have its own copy of the polygon TGraph
431 // otherwise, we get a seg fault when EcalGeometry is destructed
432 // because the polygon that was copied over from gridMap is deleted at
433 // the end of this function
434 cell_id_in_module_.AddBin(num_vertices, actual_p, actual_q);
435
439 double p = (polyBin->GetXMax() + polyBin->GetXMin()) / 2.;
440 double q = (polyBin->GetYMax() + polyBin->GetYMin()) / 2.;
441
442 ldmx_log(trace) << " Copying poly with ID " << polyBin->GetBinNumber()
443 << " and (p,q) (" << std::setprecision(2) << p << "," << q
444 << ")";
445 // save cell location as center of ENTIRE hexagon
446 cell_pos_in_module_[cell_id] = std::pair<double, double>(p, q);
447 ++cell_id; // incrememnt cell ID
448 } // if num vertices inside is > 1
449 } // loop over larger grid spanning module hexagon
450 return;
451}
std::map< int, std::pair< double, double > > cell_pos_in_module_
Position of cell centers relative to center of module in p,q space.
bool isInside(double normX, double normY) const
Determines if point (x,y), already normed to max hexagon radius, lies within a hexagon.
TH2Poly cell_id_in_module_
Honeycomb Binning from ROOT.

References cell_id_in_module_, cell_pos_in_module_, cell_r_max_, cell_r_min_, isInside(), module_r_max_, and module_r_min_.

Referenced by EcalGeometry().

◆ buildCellModuleMap()

void ldmx::EcalGeometry::buildCellModuleMap ( )
private

Constructs the positions of all the cells in a layer relative to the ecal center.

This uses the modulePostionMap_ and cellPositionMap_ to calculate the center of all cells relative to the ecal center.

Parameters
[in]modulePositionMap_map of module IDs to module centers relative to ecal
[in]cellPositionMap_map of cell IDs to cell centers relative to module
[out]

construct map of cell centers relative to layer center

construct map of global cell centers relative to target center

Definition at line 453 of file EcalGeometry.cxx.

453 {
454 ldmx_log(trace) << "Building cellModule position map";
456 for (auto const& [module_id, module_xy] : module_pos_xy_) {
457 for (auto const& [cell_id, cell_pq] : cell_pos_in_module_) {
458 double cell_x{cell_pq.first}, cell_y{cell_pq.second};
459 // convert from (p,q) to (x,y) space
460 // when the corners are not up, x = p and y = q
461 // so no transformation needs to be done
462 if (corners_side_up_) unrotate(cell_x, cell_y);
463
464 // calculate cell's pq relative to entire layer center
465 auto cell_rel_to_layer =
466 std::make_pair(module_xy.first + cell_x, module_xy.second + cell_y);
467
468 // now add the layer-center values to get the global position
469 // of the cell
470 cell_pos_in_layer_[EcalID(0, module_id, cell_id)] = cell_rel_to_layer;
471 }
472 }
473
475 for (auto const& [layer_id, layer_xyz] : layer_pos_xy_) {
476 for (auto const& [flat_id, rel_to_layer] : cell_pos_in_layer_) {
477 // now add the layer-center values to get the global position
478 // of the cell
479 cell_global_pos_[EcalID(layer_id, flat_id.module(), flat_id.cell())] =
480 std::make_tuple(rel_to_layer.first + std::get<0>(layer_xyz),
481 rel_to_layer.second + std::get<1>(layer_xyz),
482 std::get<2>(layer_xyz));
483 }
484 }
485
486 ldmx_log(trace) << "Cell module map contains " << cell_global_pos_.size()
487 << " entries. ";
488 return;
489}
std::map< EcalID, std::tuple< double, double, double > > cell_global_pos_
Position of cell centers relative to world geometry.
std::map< int, std::pair< double, double > > module_pos_xy_
Postion of module centers relative to the center of the layer in world coordinates.
std::map< int, std::tuple< double, double, double > > layer_pos_xy_
Position of layer centers in world coordinates (uses layer ID as key)
std::map< EcalID, std::pair< double, double > > cell_pos_in_layer_
Position of cell centers relative to center of layer in world coordinates.

References cell_global_pos_, cell_pos_in_layer_, cell_pos_in_module_, corners_side_up_, layer_pos_xy_, and module_pos_xy_.

Referenced by EcalGeometry().

◆ buildLayerMap()

void ldmx::EcalGeometry::buildLayerMap ( )
private

Constructs the positions of the layers in world coordinates.

Definition at line 185 of file EcalGeometry.cxx.

185 {
186 ldmx_log(debug) << "Building layer map with " << layer_z_positions_.size()
187 << " layers";
189 if (layer_shift_odd_) {
190 ldmx_log(debug) << "Shifting odd layers by (x,y) = (" << layer_shift_x_
191 << ", " << layer_shift_y_ << ") mm";
192 } else {
193 ldmx_log(debug) << "Shifting odd bilayers by (x,y) = (" << layer_shift_x_
194 << ", " << layer_shift_y_ << ") mm";
195 }
196 }
197
198 for (std::size_t i_layer{0}; i_layer < layer_z_positions_.size(); ++i_layer) {
199 // default is centered on z-axis
200 double x{0}, y{0}, z{ecal_front_z_ + layer_z_positions_.at(i_layer)};
201 if (layer_shift_odd_ and (i_layer % 2 == 1)) {
202 x += layer_shift_x_;
203 y += layer_shift_y_;
204 } else if (layer_shift_odd_bilayer_ and ((i_layer / 2) % 2 == 1)) {
205 x += layer_shift_x_;
206 y += layer_shift_y_;
207 }
208 ldmx_log(trace) << " Layer " << i_layer << " has center at (" << x
209 << ", " << y << ", " << z << ") mm";
210
211 layer_pos_xy_[i_layer] = std::make_tuple(x, y, z);
212 }
213}

References ecal_front_z_, layer_pos_xy_, layer_shift_odd_, layer_shift_odd_bilayer_, layer_shift_x_, layer_shift_y_, and layer_z_positions_.

Referenced by EcalGeometry().

◆ buildModuleMap()

void ldmx::EcalGeometry::buildModuleMap ( )
private

Constructs the positions of the seven modules (moduleID) relative to the ecal center.

Sets modulePositionMap_ using the module IDs for keys and the centers of the module hexagons for values.

The module IDs are set in the ecal.gdml file and are replicated here.

  • 0 for center module
  • 1 on top (12 o'clock)
  • clockwise till 6 at 11 o'clock
Parameters
[in]gap_separation between module flat-sides
[in]moduler_center-to-flat module radius
[out]modulePositionMap_map of module IDs to module centers relative to ecal

Definition at line 215 of file EcalGeometry.cxx.

215 {
216 static const double C_PI = 3.14159265358979323846;
217
218 // the center module (module_id == 0) has always been (and will always be?)
219 // centered with respect to the layer position
220 module_pos_xy_[0] = std::pair<double, double>(0., 0.);
221
222 // for flat-side-up designs (v12 and earlier), the modules are numbered 1 on
223 // positive y-axis and then counter-clockwise until 6
224 //
225 // for corner-side-up designes (v13 and later), the modules are numbered 1 on
226 // positive x-axis and then counter-clockwise until 6.
227 for (unsigned id = 1; id < 7; id++) {
228 // flat-side-up
229 double x = (2. * module_r_min_ + gap_) * sin((id - 1) * (C_PI / 3.));
230 double y = (2. * module_r_min_ + gap_) * cos((id - 1) * (C_PI / 3.));
231 if (corners_side_up_) {
232 // re-calculating to make sure centers match GDML
233 x = (2. * module_r_min_ + gap_) * cos((id - 1) * (C_PI / 3.));
234 y = -(2. * module_r_min_ + gap_) * sin((id - 1) * (C_PI / 3.));
235 }
236 module_pos_xy_[id] = std::pair<double, double>(x, y);
237 ldmx_log(trace) << " Module " << id << " is centered at (x,y) = " << "("
238 << x << ", " << y << ") mm";
239 }
240}

References corners_side_up_, gap_, module_pos_xy_, and module_r_min_.

Referenced by EcalGeometry().

◆ buildNeighborMaps()

void ldmx::EcalGeometry::buildNeighborMaps ( )
private

Construts NNMap and NNNMap.

Since this only occurs once during processing, we can be wasteful. We do a nested loop over the entire cellular position map and calculate neighbors by seeing which cells are within multiples of the cellular radius of each other.

Note
We require two cells to be in the same layer in order to be nearest neighbors or next-nearest neighbors.
Parameters
[in]cellModulePostionMap_map of cells to cell centers relative to ecal
[out]NNMap_map of cell IDs to list of cell IDs that are its nearest neighbors
[out]NNNMap_map of cell IDs to list of cell IDs that are its next-to-nearest neighbors

STRATEGY

Neighbors may include from other modules. All this is precomputed. So we can be wasteful here. Gaps may be nonzero, so we simply apply an anulus requirement (r < point <= r+dr) using total x,y positions relative to the ecal center (cell+module positions). This makes the routine portable to future cell layouts. Note that the module centers already take into account a nonzero gap. The number of neighbors is not simple because: edges, and that module edges have cutoff cells. (NN) Center within [1*cell_r_min_, 3*cell_r_min_] (NNN) Center within [3*cell_r_min_, 4.5*cell_r_min_] Chosen b/c in ideal case, centers are at 2*cell_ (NN), and at 3*cell_r_max_=3.46*cell_r_min_ and 4*cell_r_min_ (NNN).

do distance calculation

Definition at line 491 of file EcalGeometry.cxx.

491 {
505 ldmx_log(trace) << "Building Nearest and Next-Nearest Neighbor maps";
506
507 nn_map_.clear();
508 nnn_map_.clear();
509 for (auto const& [center_id, center_xyz] : cell_pos_in_layer_) {
510 for (auto const& [probe_id, probe_xyz] : cell_pos_in_layer_) {
512 double dist = distance(probe_xyz, center_xyz);
513 if (dist > 1 * cell_r_min_ && dist <= 3. * cell_r_min_) {
514 nn_map_[center_id].push_back(probe_id);
515 } else if (dist > 3. * cell_r_min_ && dist <= 4.5 * cell_r_min_) {
516 nnn_map_[center_id].push_back(probe_id);
517 }
518 }
519 // Keeping this commented out until the SimIDs string method is implemented
520 // ldmx_log(debug) << " Found " << nn_map_[center_id].size() << " NN and "
521 // << nnn_map_[center_id].size() << " NNN for cell " << center_id;
522 }
523 return;
524}
std::map< EcalID, std::vector< EcalID > > nnn_map_
Map of cell ID to neighbors of neighbor cells.
std::map< EcalID, std::vector< EcalID > > nn_map_
Map of cell ID to neighboring cells.

References cell_pos_in_layer_, cell_r_min_, nn_map_, and nnn_map_.

Referenced by EcalGeometry().

◆ debugMake()

static EcalGeometry * ldmx::EcalGeometry::debugMake ( const framework::config::Parameters & p)
inlinestatic

Definition at line 347 of file EcalGeometry.h.

347 {
348 return new EcalGeometry(p);
349 }
EcalGeometry(const framework::config::Parameters &ps)
Class constructor, for use only by the provider.

◆ distanceToEdge()

double ldmx::EcalGeometry::distanceToEdge ( EcalID id) const
private

Distance to module edge, and whether cell is on edge of module.

@TODO Use getNN()/getNNN() + isEdgeCell() to expand functionality.

Parameters
[in]cellModuleIDEcalId where all we care about is module and cell
Returns
distance to edge of the module

Definition at line 526 of file EcalGeometry.cxx.

526 {
527 // https://math.stackexchange.com/questions/1210572/find-the-distance-to-the-edge-of-a-hexagon
528 std::pair<double, double> cellLocation = cell_pos_in_module_.at(id.cell());
529 double x = fabs(cellLocation.first); // bring to first quadrant
530 double y = fabs(cellLocation.second);
531 double r = sqrt(x * x + y * y);
532 double theta = (r > 1E-3) ? fabs(std::atan(y / x)) : 0;
533 if (x < module_r_max_ / 2.)
534 return (module_r_min_ -
535 y); // closest line is straight vertical to top edge
536 double dist =
537 sqrt(3.) * module_r_max_ / (std::sin(theta) + sqrt(3.) * std::cos(theta));
538 return dist;
539}

References cell_pos_in_module_, module_r_max_, and module_r_min_.

Referenced by isEdgeCell().

◆ getCellMaxR()

double ldmx::EcalGeometry::getCellMaxR ( ) const
inline

Get the center-to-corner radius of the cell hexagons.

Returns
cell max radius [mm]

Definition at line 329 of file EcalGeometry.h.

329{ return cell_r_max_; }

References cell_r_max_.

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

◆ getCellMinR()

double ldmx::EcalGeometry::getCellMinR ( ) const
inline

Get the center-to-flat radius of the cell hexagons.

Returns
cell min radius [mm]

Definition at line 322 of file EcalGeometry.h.

322{ return cell_r_min_; }

References cell_r_min_.

◆ getCellPolyMap()

TH2Poly * ldmx::EcalGeometry::getCellPolyMap ( ) const
inline

Get a reference to the TH2Poly used for Cell IDs.

Note
This is only helpful in the use case where you want to print the cell ID <-> cell position map. DO NOT USE THIS OTHERWISE.
Returns
pointer to member variable cell_id_in_module_

Definition at line 340 of file EcalGeometry.h.

340 {
341 for (auto const& [cell_id, cell_center] : cell_pos_in_module_) {
342 cell_id_in_module_.Fill(cell_center.first, cell_center.second, cell_id);
343 }
344 return &cell_id_in_module_;
345 }

References cell_id_in_module_, and cell_pos_in_module_.

◆ getEcalFrontZ()

double ldmx::EcalGeometry::getEcalFrontZ ( ) const
inline

Get the z-coordinate of the Ecal face.

Returns
z-coordinate of the Ecal face

Definition at line 215 of file EcalGeometry.h.

215{ return ecal_front_z_; }

References ecal_front_z_.

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

◆ getID() [1/3]

EcalID ldmx::EcalGeometry::getID ( double x,
double y,
double z,
bool fallible = false ) const

Get a cell's ID number from its position.

Parameters
[in]xglobal x position [mm]
[in]yglobal y position [mm]
[in]zglobal z position [mm]
[in]falliblebool to decide if the function should fail
Returns
EcalID of the cell (null-id if fallible) Example for fallible use case
auto id = geometry.getID(x, y, z, true);
if (id.null()) {
// position (x,y) is not contained within a cell in layer at z
}

Definition at line 78 of file EcalGeometry.cxx.

78 {
79 int layer_id{-1};
80 for (const auto& [lid, layer_xyz] : layer_pos_xy_) {
81 // check if the z coordinate is within the layer thickness
82 if (std::abs(std::get<2>(layer_xyz) - z) < si_thickness_) {
83 layer_id = lid;
84 break;
85 }
86 }
87 if (layer_id < 0) {
88 if (fallible) {
89 return ldmx::EcalID(0);
90 } else {
91 EXCEPTION_RAISE("BadConf", "z = " + std::to_string(z) +
92 " mm is not within any"
93 " of the configured layers.");
94 }
95 }
96 return getID(x, y, layer_id, fallible);
97}
EcalID getID(double x, double y, double z, bool fallible=false) const
Get a cell's ID number from its position.
Extension of DetectorID providing access to ECal layers and cell numbers in a hex grid.
Definition EcalID.h:20

References getID(), layer_pos_xy_, and si_thickness_.

Referenced by getID(), getID(), and ecal::EcalVetoProcessor::produce().

◆ getID() [2/3]

EcalID ldmx::EcalGeometry::getID ( double x,
double y,
int layer_id,
bool fallible = false ) const

Get a cell's ID from its x,y global position and layer number.

This is faster as long as we trust that the layer positions between GDML and the configured parameters of this class match.

Parameters
[in]xglobal x position [mm]
[in]yglobal y position [mm]
[in]layer_idinteger ID of the layer the hit is in
[in]falliblebool to decide if the function should fail
Returns
EcalID of the cell (null-id if fallible) Example for fallible use case
auto id = geometry.getID(x, y, ilayer, true);
if (id.null()) {
// position (x,y) is not contained within a cell in layer ilayer
}

Definition at line 99 of file EcalGeometry.cxx.

100 {
101 // now assume we know the layer
102 // shift to center of layer
103 // and convert to flower coordinates
104 double p{x - std::get<0>(layer_pos_xy_.at(layer_id))},
105 q{y - std::get<1>(layer_pos_xy_.at(layer_id))};
106
107 // deduce module ID
108 // there are only 7 modules so we just loop through them
109 // all and pick out the module ID that we are inside of
110
111 int module_id{-1};
112 for (auto const& [mid, module_xy] : module_pos_xy_) {
113 double probe_x{p - module_xy.first}, probe_y{q - module_xy.second};
114 if (corners_side_up_) rotate(probe_x, probe_y);
115 if (isInside(probe_x / module_r_max_, probe_y / module_r_max_)) {
116 module_id = mid;
117 break;
118 }
119 }
120
121 if (module_id < 0) {
122 if (fallible) {
123 return ldmx::EcalID(0);
124 } else {
125 EXCEPTION_RAISE(
126 "BadConf",
127 TString::Format(
128 "Coordinates relative to layer (p,q) = (%.2f, %.2f) mm "
129 "derived from world coordinates (%.2f, %.2f) mm with layer = %d "
130 "are not inside any module.",
131 p, q, x, y, layer_id)
132 .Data());
133 }
134 }
135
136 return getID(x, y, layer_id, module_id);
137}

References corners_side_up_, getID(), isInside(), layer_pos_xy_, module_pos_xy_, and module_r_max_.

◆ getID() [3/3]

EcalID ldmx::EcalGeometry::getID ( double x,
double y,
int layer_id,
int module_id,
bool fallible = false ) const

Get a cell's ID from its x,y global position and layer/module numbers as deduced from GDML copy numbers.

This is the fastest option but we need to carefully validated that the layer and module positions between the GDML and the configured parameters of this class match.

Parameters
[in]xglobal x position [mm]
[in]yglobal y position [mm]
[in]layer_idinteger ID of the layer the hit is in
[in]module_idinteger ID of the module the hit is in
[in]falliblebool to decide if the function should fail
Returns
EcalID of the cell (null-id if fallible) Example for fallible use case
auto id = geometry.getID(x, y, ilayer, imodule, true);
if (id.null()) {
// position (x,y) is not contained within a cell in layer ilayer in
module imodule
}

Definition at line 139 of file EcalGeometry.cxx.

140 {
141 // now assume we know the layer and module
142 // shift to center of layer and then center of module
143 double p{x - std::get<0>(layer_pos_xy_.at(layer_id)) -
144 module_pos_xy_.at(module_id).first},
145 q{y - std::get<1>(layer_pos_xy_.at(layer_id)) -
146 module_pos_xy_.at(module_id).second};
147
148 // need to rotate
149 if (corners_side_up_) rotate(p, q);
150
151 // deduce cell ID
152 int cell_id = cell_id_in_module_.FindBin(p, q) - 1;
153
154 if (cell_id < 0) {
155 if (fallible) {
156 return ldmx::EcalID(0);
157 } else {
158 EXCEPTION_RAISE(
159 "BadConf",
160 TString::Format(
161 "Relative cell coordinates (%.2f, %.2f) mm "
162 "derived from world coordinates (%.2f, %.2f) mm with layer = %d "
163 "and module = %d are outside module hexagon",
164 p, q, x, y, layer_id, module_id)
165 .Data());
166 }
167 }
168
169 return EcalID(layer_id, module_id, cell_id);
170}

References cell_id_in_module_, corners_side_up_, layer_pos_xy_, and module_pos_xy_.

◆ getModuleMaxR()

double ldmx::EcalGeometry::getModuleMaxR ( ) const
inline

Get the center-to-corner radius of the module hexagons.

Returns
module max radius [mm]

Definition at line 315 of file EcalGeometry.h.

315{ return module_r_max_; }

References module_r_max_.

◆ getModuleMinR()

double ldmx::EcalGeometry::getModuleMinR ( ) const
inline

Get the center-to-flat radius of the module hexagons.

Returns
module min radius [mm]

Definition at line 308 of file EcalGeometry.h.

308{ return module_r_min_; }

References module_r_min_.

◆ getNN()

std::vector< EcalID > ldmx::EcalGeometry::getNN ( EcalID id) const
inline

Get the Nearest Neighbors of the input ID.

Parameters
idid to get
Returns
list of EcalID that are the inputs nearest neighbors

Definition at line 254 of file EcalGeometry.h.

254 {
255 auto list = nn_map_.at(EcalID(0, id.module(), id.cell()));
256 for (auto& flat : list)
257 flat = EcalID(id.layer(), flat.module(), flat.cell());
258 return list;
259 }

References nn_map_.

Referenced by isNN().

◆ getNNN()

std::vector< EcalID > ldmx::EcalGeometry::getNNN ( EcalID id) const
inline

Get the Next-to-Nearest Neighbors of the input ID.

Parameters
idid to get
Returns
list of EcalID that are the inputs next-to-nearest neighbors

Definition at line 281 of file EcalGeometry.h.

281 {
282 auto list = nnn_map_.at(EcalID(0, id.module(), id.cell()));
283 for (auto& flat : list)
284 flat = EcalID(id.layer(), flat.module(), flat.cell());
285 return list;
286 }

References nnn_map_.

Referenced by isNNN().

◆ getNumCellsPerModule()

int ldmx::EcalGeometry::getNumCellsPerModule ( ) const
inline

Get the number of cells in each module of the Ecal Geometry.

Note
This assumes that all modules are the full high-density hexagons from CMS (no triangles!)

Definition at line 244 of file EcalGeometry.h.

244 {
245 return cell_id_in_module_.GetNumberOfBins();
246 }

References cell_id_in_module_.

◆ getNumLayers()

int ldmx::EcalGeometry::getNumLayers ( ) const
inline

Get the number of layers in the Ecal Geometry.

Returns
number fo layers in geometry

Definition at line 222 of file EcalGeometry.h.

222{ return layer_pos_xy_.size(); }

References layer_pos_xy_.

◆ getNumModulesPerLayer()

int ldmx::EcalGeometry::getNumModulesPerLayer ( ) const
inline

Get the number of modules in the Ecal flower.

Note
This number is hard-coded to reflect the fact that it is also hard-coded in the buildModuleMap function. If a future geometry adds more modules (perhaps "triangles" to fill in rectangular block in the HCal that the ECal is in), then buildModuleMap and this function will need to be modified.
Returns
number of modules

Definition at line 236 of file EcalGeometry.h.

236{ return 7; }

◆ getPosition()

std::tuple< double, double, double > ldmx::EcalGeometry::getPosition ( EcalID id) const

Get a cell's position from its ID number.

std::tuple is useful here because you can use C++17's pattern matching to use code like the following

auto [x,y,z] = geometry.getPosition(id);

Definition at line 172 of file EcalGeometry.cxx.

172 {
173 return cell_global_pos_.at(id);
174}

References cell_global_pos_.

Referenced by ecal::EcalTriggerGeometry::globalPosition(), ecal::EcalPnetVetoProcessor::makeInputs(), ecal::EcalVetoProcessor::produce(), and ecal::EcalWABRecProcessor::produce().

◆ getPositionInModule()

std::pair< double, double > ldmx::EcalGeometry::getPositionInModule ( int cell_id) const

Get a cell's position within a module.

Definition at line 176 of file EcalGeometry.cxx.

176 {
177 auto pq = cell_pos_in_module_.at(cell_id);
178
179 // going from (p,q) to (x,y) is a unrotate
180 if (corners_side_up_) unrotate(pq.first, pq.second);
181
182 return pq;
183}

References cell_pos_in_module_, and corners_side_up_.

Referenced by ecal::EcalTriggerGeometry::localPosition().

◆ getZPosition()

double ldmx::EcalGeometry::getZPosition ( int layer) const
inline

Get the z-coordinate given the layer id.

Parameters
[in]layerint layer id
Returns
z-coordinate of the input sensitive layer

Definition at line 207 of file EcalGeometry.h.

207 {
208 return std::get<2>(layer_pos_xy_.at(layer));
209 }

References layer_pos_xy_.

Referenced by ecal::EcalMipTrackingProcessor::produce(), and ecal::EcalVetoProcessor::produce().

◆ isEdgeCell()

bool ldmx::EcalGeometry::isEdgeCell ( EcalID cellModuleID) const
inlineprivate

Check if input cell is on the edge of a module.

See also
distanceToEdge
Parameters
[in]cellModuleIDEcalId where all we care about is module and cell return true if distance to edge is less than max cell radius

Definition at line 471 of file EcalGeometry.h.

471 {
472 return (distanceToEdge(cellModuleID) < cell_r_max_);
473 }
double distanceToEdge(EcalID id) const
Distance to module edge, and whether cell is on edge of module.

References cell_r_max_, and distanceToEdge().

◆ isInside()

bool ldmx::EcalGeometry::isInside ( double normX,
double normY ) const
private

Determines if point (x,y), already normed to max hexagon radius, lies within a hexagon.

Corners are (1,0) and (0.5,sqrt(3)/2). Uses "<", not "<=".

Note
This function is in p,q space so any rotations need to be performed before calling this function.
Parameters
[in]normXX-coordinate relative to module hexagon divided by maximum hexagon radius
[in]normYY-coordinate relative to module hexagon divided by maximum hexagon radius
Returns
true if (normX,normY) is within the hexagon centered at the origin with maximum radius 1.

Definition at line 541 of file EcalGeometry.cxx.

541 {
542 ldmx_log(trace) << std::fixed << std::setprecision(2)
543 << "Checking if normXY=(" << normX << "," << normY
544 << ") is inside.";
545 normX = fabs(normX), normY = fabs(normY);
546 double xvec = -1, yvec = -1. / sqrt(3);
547 double xref = 0.5, yref = sqrt(3) / 2.;
548 if ((normX > 1.) || (normY > yref)) {
549 ldmx_log(trace) << "They are outside quadrant.";
550 return false;
551 }
552 double dotProd = (xvec * (normX - xref) + yvec * (normY - yref));
553 ldmx_log(trace) << std::fixed << std::setprecision(2)
554 << "They are inside quadrant. Dot product (>0 is inside): "
555 << dotProd;
556 return (dotProd > 0.);
557}

Referenced by buildCellMap(), and getID().

◆ isNN()

bool ldmx::EcalGeometry::isNN ( EcalID centroid,
EcalID probe ) const
inline

Check if the probe id is one of the nearest neightbors of the centroid id.

Parameters
probeid to check if it is nearest neighbor
centroidid that is center of neighbors
Returns
true if probe ID is a nearest neighbor of the centroid

Definition at line 268 of file EcalGeometry.h.

268 {
269 for (auto& id : getNN(centroid)) {
270 if (id == probe) return true;
271 }
272 return false;
273 }
std::vector< EcalID > getNN(EcalID id) const
Get the Nearest Neighbors of the input ID.

References getNN().

◆ isNNN()

bool ldmx::EcalGeometry::isNNN ( EcalID centroid,
EcalID probe ) const
inline

Check if the probe id is one of the next-to-nearest neightbors of the centroid id.

Parameters
probeid to check if it is a next-to-nearest neighbor
centroidid that is center of neighbors
Returns
true if probe ID is a next-to-nearest neighbor of the centroid

Definition at line 296 of file EcalGeometry.h.

296 {
297 for (auto& id : getNNN(centroid)) {
298 if (id == probe) return true;
299 }
300 return false;
301 }
std::vector< EcalID > getNNN(EcalID id) const
Get the Next-to-Nearest Neighbors of the input ID.

References getNNN().

Friends And Related Symbol Documentation

◆ ecal::EcalGeometryProvider

friend class ecal::EcalGeometryProvider
friend

Definition at line 358 of file EcalGeometry.h.

Member Data Documentation

◆ cell_global_pos_

std::map<EcalID, std::tuple<double, double, double> > ldmx::EcalGeometry::cell_global_pos_
private

Position of cell centers relative to world geometry.

This is where we convert p,q (flower) space into x,y (world) space by calculating the z-location as well as including rotations and shifts when converting from p,q to x,y.

The key is the full EcalID and the value is the x,y,z tuple.

Definition at line 614 of file EcalGeometry.h.

Referenced by buildCellModuleMap(), and getPosition().

◆ cell_id_in_module_

TH2Poly ldmx::EcalGeometry::cell_id_in_module_
mutableprivate

Honeycomb Binning from ROOT.

Needs to be mutable because ROOT doesn't have good const handling

Lookup a cell ID using its position relative to the center of the module in p,q space.

Definition at line 638 of file EcalGeometry.h.

Referenced by buildCellMap(), getCellPolyMap(), getID(), and getNumCellsPerModule().

◆ cell_pos_in_layer_

std::map<EcalID, std::pair<double, double> > ldmx::EcalGeometry::cell_pos_in_layer_
private

Position of cell centers relative to center of layer in world coordinates.

Note
Layer shifts are NOT included in this map since they depend on the layer number!!

Uses EcalID with layer set to zero as key.

Definition at line 603 of file EcalGeometry.h.

Referenced by buildCellModuleMap(), and buildNeighborMaps().

◆ cell_pos_in_module_

std::map<int, std::pair<double, double> > ldmx::EcalGeometry::cell_pos_in_module_
private

Position of cell centers relative to center of module in p,q space.

use cell ID as key

Definition at line 592 of file EcalGeometry.h.

Referenced by buildCellMap(), buildCellModuleMap(), distanceToEdge(), getCellPolyMap(), and getPositionInModule().

◆ cell_r_max_

double ldmx::EcalGeometry::cell_r_max_ {0}
private

Center-to-Corner Radius of cell hexagon [mm].

Definition at line 503 of file EcalGeometry.h.

503{0};

Referenced by buildCellMap(), EcalGeometry(), getCellMaxR(), and isEdgeCell().

◆ cell_r_min_

double ldmx::EcalGeometry::cell_r_min_ {0}
private

Center-to-Flat Radius of cell hexagon [mm].

Definition at line 497 of file EcalGeometry.h.

497{0};

Referenced by buildCellMap(), buildNeighborMaps(), EcalGeometry(), and getCellMinR().

◆ CONDITIONS_OBJECT_NAME

const char* ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME {"EcalGeometry"}
staticconstexpr

Definition at line 110 of file EcalGeometry.h.

110{"EcalGeometry"};

◆ corners_side_up_

bool ldmx::EcalGeometry::corners_side_up_
private

indicator of geometry orientation if true, flower shape's corners side (ie: side with two modules) is at the top

Definition at line 513 of file EcalGeometry.h.

Referenced by buildCellModuleMap(), buildModuleMap(), EcalGeometry(), getID(), getID(), and getPositionInModule().

◆ ecal_front_z_

double ldmx::EcalGeometry::ecal_front_z_ {0}
private

Front of ECal relative to world geometry [mm].

Definition at line 566 of file EcalGeometry.h.

566{0};

Referenced by buildLayerMap(), EcalGeometry(), and getEcalFrontZ().

◆ gap_

double ldmx::EcalGeometry::gap_
private

Gap between module flat sides [mm].

Definition at line 494 of file EcalGeometry.h.

Referenced by buildModuleMap(), and EcalGeometry().

◆ layer_pos_xy_

std::map<int, std::tuple<double, double, double> > ldmx::EcalGeometry::layer_pos_xy_
private

Position of layer centers in world coordinates (uses layer ID as key)

Definition at line 576 of file EcalGeometry.h.

Referenced by buildCellModuleMap(), buildLayerMap(), getID(), getID(), getID(), getNumLayers(), and getZPosition().

◆ layer_shift_odd_

bool ldmx::EcalGeometry::layer_shift_odd_
private

shift odd layers

odd layers are the high-z layer in each bi-layer

i.e. We will shift if layer_id_ % 2 == 1

Definition at line 532 of file EcalGeometry.h.

Referenced by buildLayerMap(), and EcalGeometry().

◆ layer_shift_odd_bilayer_

bool ldmx::EcalGeometry::layer_shift_odd_bilayer_
private

shift odd bi layers

NOT IMPLEMENTED IN GDML

This shifts the bi-layer grouping of two sensitive layers together.

i.e. We will shift if (layer_id_ / 2) % 2 == 1

where it is integer division.

Definition at line 546 of file EcalGeometry.h.

Referenced by buildLayerMap(), and EcalGeometry().

◆ layer_shift_x_

double ldmx::EcalGeometry::layer_shift_x_
private

shift of layers in the x-direction [mm]

Definition at line 518 of file EcalGeometry.h.

Referenced by buildLayerMap(), and EcalGeometry().

◆ layer_shift_y_

double ldmx::EcalGeometry::layer_shift_y_
private

shift of layers in the y-direction [mm]

Definition at line 523 of file EcalGeometry.h.

Referenced by buildLayerMap(), and EcalGeometry().

◆ layer_z_positions_

std::vector<double> ldmx::EcalGeometry::layer_z_positions_
private

The layer Z postions are with respect to the front of the ECal [mm].

Definition at line 569 of file EcalGeometry.h.

Referenced by buildLayerMap(), and EcalGeometry().

◆ module_pos_xy_

std::map<int, std::pair<double, double> > ldmx::EcalGeometry::module_pos_xy_
private

Postion of module centers relative to the center of the layer in world coordinates.

(uses module ID as key)

Definition at line 584 of file EcalGeometry.h.

Referenced by buildCellModuleMap(), buildModuleMap(), getID(), and getID().

◆ module_r_max_

double ldmx::EcalGeometry::module_r_max_ {0}
private

Center-to-Corner Radius of module hexagon [mm].

Definition at line 506 of file EcalGeometry.h.

506{0};

Referenced by buildCellMap(), distanceToEdge(), EcalGeometry(), getID(), and getModuleMaxR().

◆ module_r_min_

double ldmx::EcalGeometry::module_r_min_ {0}
private

Center-to-Flat Radius of module hexagon [mm].

Definition at line 500 of file EcalGeometry.h.

500{0};

Referenced by buildCellMap(), buildModuleMap(), distanceToEdge(), EcalGeometry(), and getModuleMinR().

◆ n_cell_r_height_

double ldmx::EcalGeometry::n_cell_r_height_ {0}
private

Number of cell center-to-corner radii (one side of the cell) from the bottom to the top of the module.

Could be fractional depending on how many fractions of a radii are spanning between the center of the top/bottom cell row and the edge of the module

Definition at line 563 of file EcalGeometry.h.

563{0};

Referenced by EcalGeometry().

◆ nn_map_

std::map<EcalID, std::vector<EcalID> > ldmx::EcalGeometry::nn_map_
private

Map of cell ID to neighboring cells.

The EcalID's in this map all have layer ID set to zero.

Definition at line 621 of file EcalGeometry.h.

Referenced by buildNeighborMaps(), and getNN().

◆ nnn_map_

std::map<EcalID, std::vector<EcalID> > ldmx::EcalGeometry::nnn_map_
private

Map of cell ID to neighbors of neighbor cells.

The EcalID's in this map all have layer ID set to zero.

Definition at line 628 of file EcalGeometry.h.

Referenced by buildNeighborMaps(), and getNNN().

◆ si_thickness_

double ldmx::EcalGeometry::si_thickness_
private

Thickness of the Si sensitive layer [mm].

This is used to determine if a hit is within a layer when the z-coordinate is given.

Definition at line 554 of file EcalGeometry.h.

Referenced by EcalGeometry(), and getID().


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