DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
CartesianGridUV.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 //==========================================================================
11 /*
12  * CartesianGridUV.cpp
13  *
14  * Created on: December 5, 2024
15  * Author: Yann Bedfer, ePIC/Saclay
16  *
17  * Derived from "./CartesianGridXY.cpp".
18  */
20 
21 namespace dd4hep {
22 namespace DDSegmentation {
23 
25 CartesianGridUV::CartesianGridUV(const std::string& cellEncoding) :
26  CartesianGrid(cellEncoding) {
27  // define type and description
28  _type = "CartesianGridUV";
29  _description = "Cartesian segmentation along U,V rotated some angle from local X,Y axes";
30 
31  // register all necessary parameters
32  registerParameter("grid_size_u", "Cell size in U", _gridSizeU, 1., SegmentationParameter::LengthUnit);
33  registerParameter("grid_size_v", "Cell size in V", _gridSizeV, 1., SegmentationParameter::LengthUnit);
34  registerParameter("offset_u", "Cell offset in U", _offsetU, 0., SegmentationParameter::LengthUnit, true);
35  registerParameter("offset_v", "Cell offset in V", _offsetV, 0., SegmentationParameter::LengthUnit, true);
36  registerIdentifier("identifier_u", "Cell ID identifier for U", _uId, "u");
37  registerIdentifier("identifier_v", "Cell ID identifier for V", _vId, "v");
38  registerParameter("grid_angle", "Angle of U measurement axis in X,Y frame", _gridAngle, 0., SegmentationParameter::AngleUnit);
39 };
40 
43  CartesianGrid(decode)
44 {
45  // define type and description
46  _type = "CartesianGridUV";
47  _description = "Cartesian segmentation along U,V rotated some angle from local X,Y axes";
48 
49  // register all necessary parameters
50  registerParameter("grid_size_u", "Cell size in U", _gridSizeU, 1., SegmentationParameter::LengthUnit);
51  registerParameter("grid_size_v", "Cell size in V", _gridSizeV, 1., SegmentationParameter::LengthUnit);
52  registerParameter("offset_u", "Cell offset in U", _offsetU, 0., SegmentationParameter::LengthUnit, true);
53  registerParameter("offset_v", "Cell offset in V", _offsetV, 0., SegmentationParameter::LengthUnit, true);
54  registerIdentifier("identifier_u", "Cell ID identifier for U", _uId, "u");
55  registerIdentifier("identifier_v", "Cell ID identifier for V", _vId, "v");
56  registerParameter("grid_angle", "Angle of U measurement axis in X,Y frame", _gridAngle, 0., SegmentationParameter::AngleUnit);
57 };
58 
61 
62 }
63 
66  Vector3D cellPosition;
67  cellPosition.X = binToPosition( _decoder->get(cID,_uId ), _gridSizeU, _offsetU);
68  cellPosition.Y = binToPosition( _decoder->get(cID,_vId ), _gridSizeV, _offsetV);
69  cellPosition = RotationZ(-_gridAngle)*cellPosition;
70  return cellPosition;
71 }
72 
75  const Vector3D& /* globalPosition */,
76  const VolumeID& vID) const {
77  CellID cID = vID;
78  const Vector3D& localUV = RotationZ(_gridAngle)*localPosition;
79  _decoder->set( cID,_uId, positionToBin(localUV.X, _gridSizeU, _offsetU) );
80  _decoder->set( cID,_vId, positionToBin(localUV.Y, _gridSizeV, _offsetV) );
81  return cID;
82 }
83 
84 std::vector<double> CartesianGridUV::cellDimensions(const CellID& /* cellID */) const {
85  return {_gridSizeU, _gridSizeV};
86 }
87 
88 
89 } /* namespace DDSegmentation */
90 } /* namespace dd4hep */
91 
92 // This is done DDCore/src/plugins/ReadoutSegmentations.cpp so the plugin is not part of libDDCore
93 // needs also #include <DD4hep/Factories.h>
94 // DECLARE_SEGMENTATION(CartesianGridUV,dd4hep::create_segmentation<dd4hep::DDSegmentation::CartesianGridUV>)
CartesianGridUV.h
dd4hep::DDSegmentation::CartesianGridUV::cellID
virtual CellID cellID(const Vector3D &localPosition, const Vector3D &globalPosition, const VolumeID &volumeID) const
determine the cell ID based on the position
Definition: CartesianGridUV.cpp:74
dd4hep::DDSegmentation::VolumeID
uint64_t VolumeID
Definition: BitFieldCoder.h:27
dd4hep::DDSegmentation::Segmentation::_decoder
const BitFieldCoder * _decoder
The cell ID encoder and decoder.
Definition: Segmentation.h:168
dd4hep::DDSegmentation::Vector3D
Simple container for a physics vector.
Definition: Segmentation.h:48
dd4hep::DDSegmentation::SegmentationParameter::LengthUnit
@ LengthUnit
Definition: SegmentationParameter.h:111
dd4hep::DDSegmentation::BitFieldCoder
Helper class for decoding and encoding a bit field of 64bits for convenient declaration.
Definition: BitFieldCoder.h:114
dd4hep::DDSegmentation::CartesianGridUV::cellDimensions
virtual std::vector< double > cellDimensions(const CellID &cellID) const
Returns a vector<double> of the cellDimensions of the given cell ID in natural order of dimensions,...
Definition: CartesianGridUV.cpp:84
dd4hep::DDSegmentation::SegmentationParameter::AngleUnit
@ AngleUnit
Definition: SegmentationParameter.h:111
dd4hep::DDSegmentation::BitFieldCoder::get
FieldID get(CellID bitfield, size_t idx) const
Definition: BitFieldCoder.h:165
dd4hep::DDSegmentation::CartesianGridUV::_gridSizeU
double _gridSizeU
the grid size in U
Definition: CartesianGridUV.h:109
dd4hep::DDSegmentation::CartesianGridUV::_uId
std::string _uId
the field name used for U
Definition: CartesianGridUV.h:117
dd4hep::DDSegmentation::Segmentation::registerParameter
void registerParameter(const std::string &nam, const std::string &desc, TYPE &param, const TYPE &defaultVal, UnitType unitTyp=SegmentationParameter::NoUnit, bool isOpt=false)
Add a parameter to this segmentation. Used by derived classes to define their parameters.
Definition: Segmentation.h:138
dd4hep::DDSegmentation::CartesianGridUV::position
virtual Vector3D position(const CellID &cellID) const
determine the position based on the cell ID
Definition: CartesianGridUV.cpp:65
dd4hep::RotationZ
ROOT::Math::RotationZ RotationZ
Definition: Objects.h:107
dd4hep::DDSegmentation::CartesianGridUV::_offsetU
double _offsetU
the coordinate offset in U
Definition: CartesianGridUV.h:111
dd4hep::DDSegmentation::Vector3D::Y
double Y
Definition: Segmentation.h:71
dd4hep::DDSegmentation::CartesianGridUV::_vId
std::string _vId
the field name used for V
Definition: CartesianGridUV.h:119
dd4hep::DDSegmentation::BitFieldCoder::set
void set(CellID &bitfield, size_t idx, FieldID value) const
Definition: BitFieldCoder.h:177
dd4hep::DDSegmentation::CellID
uint64_t CellID
Definition: BitFieldCoder.h:26
dd4hep::DDSegmentation::Segmentation::registerIdentifier
void registerIdentifier(const std::string &nam, const std::string &desc, std::string &ident, const std::string &defaultVal)
Add a cell identifier to this segmentation. Used by derived classes to define their required identifi...
Definition: Segmentation.cpp:135
dd4hep::DDSegmentation::Segmentation::_description
std::string _description
The description of the segmentation.
Definition: Segmentation.h:162
dd4hep::DDSegmentation::CartesianGridUV::~CartesianGridUV
virtual ~CartesianGridUV()
destructor
Definition: CartesianGridUV.cpp:60
dd4hep::DDSegmentation::CartesianGridUV::_gridAngle
double _gridAngle
the U grid angle
Definition: CartesianGridUV.h:121
dd4hep::DDSegmentation::Segmentation::positionToBin
static int positionToBin(double position, double cellSize, double offset=0.)
Helper method to convert a 1D position to a cell ID.
Definition: Segmentation.cpp:150
dd4hep::DDSegmentation::Vector3D::X
double X
Definition: Segmentation.h:71
dd4hep::DDSegmentation::Segmentation::binToPosition
static double binToPosition(FieldID bin, double cellSize, double offset=0.)
Helper method to convert a bin number to a 1D position.
Definition: Segmentation.cpp:145
dd4hep::DDSegmentation::CartesianGridUV::_gridSizeV
double _gridSizeV
the grid size in V
Definition: CartesianGridUV.h:113
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::DDSegmentation::CartesianGridUV::_offsetV
double _offsetV
the coordinate offset in V
Definition: CartesianGridUV.h:115
dd4hep::DDSegmentation::Segmentation::_type
std::string _type
The segmentation type.
Definition: Segmentation.h:160
dd4hep::DDSegmentation::CartesianGridUV::CartesianGridUV
CartesianGridUV(const std::string &cellEncoding="")
Default constructor passing the encoding string.
Definition: CartesianGridUV.cpp:25
dd4hep::DDSegmentation::CartesianGrid
Segmentation base class describing cartesian grid segmentation.
Definition: CartesianGrid.h:28