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< EcalID > getNN (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< EcalID > getNNN (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 EcalGeometry * debugMake (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 101 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 49 of file EcalGeometry.cxx.

50 : framework::ConditionsObject(EcalGeometry::CONDITIONS_OBJECT_NAME) {
51 layer_z_positions_ = ps.get<std::vector<double>>("layer_z_positions");
52 ecal_front_z_ = ps.get<double>("ecal_front_z");
53 module_r_min_ = ps.get<double>("module_min_r");
54 gap_ = ps.get<double>("gap");
55 n_cell_r_height_ = ps.get<double>("n_cell_r_height");
56 corners_side_up_ = ps.get<bool>("corners_side_up");
57 layer_shift_x_ = ps.get<double>("layer_shift_x");
58 layer_shift_y_ = ps.get<double>("layer_shift_y");
59 layer_shift_odd_ = ps.get<bool>("layer_shift_odd");
60 layer_shift_odd_bilayer_ = ps.get<bool>("layer_shift_odd_bilayer");
61 si_thickness_ = ps.get<double>("si_thickness");
62
64 EXCEPTION_RAISE("BadConf",
65 "Cannot shift both odd sensitive layers and odd bilayers");
66 }
67
68 module_r_max_ = module_r_min_ * (2 / sqrt(3));
70 cell_r_min_ = (sqrt(3.) / 2.) * cell_r_max_;
71
72 ldmx_log(debug) << "Building module map with gap " << std::setprecision(2)
73 << gap_ << ", nCellRHeight " << n_cell_r_height_
74 << ", min/max radii of cell " << cell_r_min_ << " / "
75 << cell_r_max_ << ", and module " << module_r_min_ << " / "
77
83
84 ldmx_log(trace) << "Geometry fully constructed";
85}
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:75
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 251 of file EcalGeometry.cxx.

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

464 {
465 ldmx_log(trace) << "Building cellModule position map";
467 for (auto const& [module_id, module_xy] : module_pos_xy_) {
468 for (auto const& [cell_id, cell_pq] : cell_pos_in_module_) {
469 double cell_x{cell_pq.first}, cell_y{cell_pq.second};
470 // convert from (p,q) to (x,y) space
471 // when the corners are not up, x = p and y = q
472 // so no transformation needs to be done
473 if (corners_side_up_) unrotate(cell_x, cell_y);
474
475 // calculate cell's pq relative to entire layer center
476 auto cell_rel_to_layer =
477 std::make_pair(module_xy.first + cell_x, module_xy.second + cell_y);
478
479 // now add the layer-center values to get the global position
480 // of the cell
481 cell_pos_in_layer_[EcalID(0, module_id, cell_id)] = cell_rel_to_layer;
482 }
483 }
484
486 for (auto const& [layer_id, layer_xyz] : layer_pos_xy_) {
487 for (auto const& [flat_id, rel_to_layer] : cell_pos_in_layer_) {
488 // now add the layer-center values to get the global position
489 // of the cell
490 cell_global_pos_[EcalID(layer_id, flat_id.module(), flat_id.cell())] =
491 std::make_tuple(rel_to_layer.first + std::get<0>(layer_xyz),
492 rel_to_layer.second + std::get<1>(layer_xyz),
493 std::get<2>(layer_xyz));
494 }
495 }
496
497 ldmx_log(trace) << "Cell module map contains " << cell_global_pos_.size()
498 << " entries. ";
499 return;
500}
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 194 of file EcalGeometry.cxx.

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

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 224 of file EcalGeometry.cxx.

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

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 502 of file EcalGeometry.cxx.

502 {
516 ldmx_log(trace) << "Building Nearest and Next-Nearest Neighbor maps";
517
518 nn_map_.clear();
519 nnn_map_.clear();
520 for (auto const& [center_id, center_xyz] : cell_pos_in_layer_) {
521 for (auto const& [probe_id, probe_xyz] : cell_pos_in_layer_) {
523 double dist = distance(probe_xyz, center_xyz);
524 if (dist > 1 * cell_r_min_ && dist <= 3. * cell_r_min_) {
525 nn_map_[center_id].push_back(probe_id);
526 } else if (dist > 3. * cell_r_min_ && dist <= 4.5 * cell_r_min_) {
527 nnn_map_[center_id].push_back(probe_id);
528 }
529 }
530 // Keeping this commented out until the SimIDs string method is implemented
531 // ldmx_log(debug) << " Found " << nn_map_[center_id].size() << " NN and "
532 // << nnn_map_[center_id].size() << " NNN for cell " << center_id;
533 }
534 return;
535}
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 340 of file EcalGeometry.h.

340 {
341 return new EcalGeometry(p);
342 }
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 537 of file EcalGeometry.cxx.

537 {
538 // https://math.stackexchange.com/questions/1210572/find-the-distance-to-the-edge-of-a-hexagon
539 std::pair<double, double> cell_location = cell_pos_in_module_.at(id.cell());
540 double x = fabs(cell_location.first); // bring to first quadrant
541 double y = fabs(cell_location.second);
542 double r = sqrt(x * x + y * y);
543 double theta = (r > 1E-3) ? fabs(std::atan(y / x)) : 0;
544 if (x < module_r_max_ / 2.)
545 return (module_r_min_ -
546 y); // closest line is straight vertical to top edge
547 double dist =
548 sqrt(3.) * module_r_max_ / (std::sin(theta) + sqrt(3.) * std::cos(theta));
549 return dist;
550}

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 322 of file EcalGeometry.h.

322{ 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 315 of file EcalGeometry.h.

315{ 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 333 of file EcalGeometry.h.

333 {
334 for (auto const& [cell_id, cell_center] : cell_pos_in_module_) {
335 cell_id_in_module_.Fill(cell_center.first, cell_center.second, cell_id);
336 }
337 return &cell_id_in_module_;
338 }

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 208 of file EcalGeometry.h.

208{ return ecal_front_z_; }

References ecal_front_z_.

Referenced by ecal::EcalTrackFinderProcessor::createEcalSurfaces(), ecal::EcalTrackFinderProcessor::onNewRun(), and 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 87 of file EcalGeometry.cxx.

87 {
88 int layer_id{-1};
89 for (const auto& [lid, layer_xyz] : layer_pos_xy_) {
90 // check if the z coordinate is within the layer thickness
91 if (std::abs(std::get<2>(layer_xyz) - z) < si_thickness_) {
92 layer_id = lid;
93 break;
94 }
95 }
96 if (layer_id < 0) {
97 if (fallible) {
98 return ldmx::EcalID(0);
99 } else {
100 EXCEPTION_RAISE("BadConf", "z = " + std::to_string(z) +
101 " mm is not within any"
102 " of the configured layers.");
103 }
104 }
105 return getID(x, y, layer_id, fallible);
106}
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 108 of file EcalGeometry.cxx.

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

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 148 of file EcalGeometry.cxx.

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

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 308 of file EcalGeometry.h.

308{ 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 301 of file EcalGeometry.h.

301{ 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 247 of file EcalGeometry.h.

247 {
248 auto list = nn_map_.at(EcalID(0, id.module(), id.cell()));
249 for (auto& flat : list)
250 flat = EcalID(id.layer(), flat.module(), flat.cell());
251 return list;
252 }

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 274 of file EcalGeometry.h.

274 {
275 auto list = nnn_map_.at(EcalID(0, id.module(), id.cell()));
276 for (auto& flat : list)
277 flat = EcalID(id.layer(), flat.module(), flat.cell());
278 return list;
279 }

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 237 of file EcalGeometry.h.

237 {
238 return cell_id_in_module_.GetNumberOfBins();
239 }

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 215 of file EcalGeometry.h.

215{ return layer_pos_xy_.size(); }

References layer_pos_xy_.

Referenced by ecal::EcalTrackFinderProcessor::createEcalSurfaces(), and ecal::EcalTrackFinderProcessor::onNewRun().

◆ 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 229 of file EcalGeometry.h.

229{ 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 181 of file EcalGeometry.cxx.

181 {
182 return cell_global_pos_.at(id);
183}

References cell_global_pos_.

Referenced by ecal::EcalTrackFinderProcessor::createMeasurements(), ecal::EcalTriggerGeometry::globalPosition(), ecal::EcalPnetVetoProcessor::makeInputs(), ecal::EcalRecoilRemovalProcessor::produce(), ecal::EcalTrackFinderProcessor::produce(), 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 185 of file EcalGeometry.cxx.

185 {
186 auto pq = cell_pos_in_module_.at(cell_id);
187
188 // going from (p,q) to (x,y) is a unrotate
189 if (corners_side_up_) unrotate(pq.first, pq.second);
190
191 return pq;
192}

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 200 of file EcalGeometry.h.

200 {
201 return std::get<2>(layer_pos_xy_.at(layer));
202 }

References layer_pos_xy_.

Referenced by ecal::EcalTrackFinderProcessor::createEcalSurfaces(), ecal::EcalTrackFinderProcessor::onNewRun(), 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 464 of file EcalGeometry.h.

464 {
465 return (distanceToEdge(cellModuleID) < cell_r_max_);
466 }
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 552 of file EcalGeometry.cxx.

552 {
553 ldmx_log(trace) << std::fixed << std::setprecision(2)
554 << "Checking if normXY=(" << normX << "," << normY
555 << ") is inside.";
556 normX = fabs(normX), normY = fabs(normY);
557 double xvec = -1, yvec = -1. / sqrt(3);
558 double xref = 0.5, yref = sqrt(3) / 2.;
559 if ((normX > 1.) || (normY > yref)) {
560 ldmx_log(trace) << "They are outside quadrant.";
561 return false;
562 }
563 double dot_prod = (xvec * (normX - xref) + yvec * (normY - yref));
564 ldmx_log(trace) << std::fixed << std::setprecision(2)
565 << "They are inside quadrant. Dot product (>0 is inside): "
566 << dot_prod;
567 return (dot_prod > 0.);
568}

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 261 of file EcalGeometry.h.

261 {
262 for (auto& id : getNN(centroid)) {
263 if (id == probe) return true;
264 }
265 return false;
266 }
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 289 of file EcalGeometry.h.

289 {
290 for (auto& id : getNNN(centroid)) {
291 if (id == probe) return true;
292 }
293 return false;
294 }
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 351 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 607 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 631 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 596 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 585 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 496 of file EcalGeometry.h.

496{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 490 of file EcalGeometry.h.

490{0};

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

◆ CONDITIONS_OBJECT_NAME

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

Definition at line 103 of file EcalGeometry.h.

103{"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 506 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 559 of file EcalGeometry.h.

559{0};

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

◆ gap_

double ldmx::EcalGeometry::gap_
private

Gap between module flat sides [mm].

Definition at line 487 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 569 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 525 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 539 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 511 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 516 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 562 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 577 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 499 of file EcalGeometry.h.

499{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 493 of file EcalGeometry.h.

493{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 556 of file EcalGeometry.h.

556{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 614 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 621 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 547 of file EcalGeometry.h.

Referenced by EcalGeometry(), and getID().


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