Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 09:36:48

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 //==========================================================================
0011 /*
0012  * CartesianGridUV.cpp
0013  *
0014  *  Created on: December 5, 2024
0015  *      Author: Yann Bedfer, ePIC/Saclay
0016  *
0017  *  Derived from "./CartesianGridXY.cpp".
0018  */
0019 #include <DDSegmentation/CartesianGridUV.h>
0020 
0021 namespace dd4hep {
0022 namespace DDSegmentation {
0023 
0024 /// default constructor using an encoding string
0025 CartesianGridUV::CartesianGridUV(const std::string& cellEncoding) :
0026         CartesianGrid(cellEncoding) {
0027     // define type and description
0028     _type = "CartesianGridUV";
0029     _description = "Cartesian segmentation along U,V rotated some angle from local X,Y axes";
0030 
0031     // register all necessary parameters
0032     registerParameter("grid_size_u", "Cell size in U",   _gridSizeU, 1., SegmentationParameter::LengthUnit);
0033     registerParameter("grid_size_v", "Cell size in V",   _gridSizeV, 1., SegmentationParameter::LengthUnit);
0034     registerParameter("offset_u",    "Cell offset in U", _offsetU,   0., SegmentationParameter::LengthUnit, true);
0035     registerParameter("offset_v",    "Cell offset in V", _offsetV,   0., SegmentationParameter::LengthUnit, true);
0036     registerIdentifier("identifier_u", "Cell ID identifier for U", _uId, "u");
0037     registerIdentifier("identifier_v", "Cell ID identifier for V", _vId, "v");
0038     registerParameter("grid_angle", "Angle of U measurement axis in X,Y frame", _gridAngle, 0., SegmentationParameter::AngleUnit);
0039 };
0040 
0041 /// Default constructor used by derived classes passing an existing decoder
0042 CartesianGridUV::CartesianGridUV(const BitFieldCoder* decode) :
0043         CartesianGrid(decode)
0044 {
0045     // define type and description
0046     _type = "CartesianGridUV";
0047     _description = "Cartesian segmentation along U,V rotated some angle from local X,Y axes";
0048 
0049     // register all necessary parameters
0050     registerParameter("grid_size_u", "Cell size in U",   _gridSizeU, 1., SegmentationParameter::LengthUnit);
0051     registerParameter("grid_size_v", "Cell size in V",   _gridSizeV, 1., SegmentationParameter::LengthUnit);
0052     registerParameter("offset_u",    "Cell offset in U", _offsetU,   0., SegmentationParameter::LengthUnit, true);
0053     registerParameter("offset_v",    "Cell offset in V", _offsetV,   0., SegmentationParameter::LengthUnit, true);
0054     registerIdentifier("identifier_u", "Cell ID identifier for U", _uId, "u");
0055     registerIdentifier("identifier_v", "Cell ID identifier for V", _vId, "v");
0056     registerParameter("grid_angle", "Angle of U measurement axis in X,Y frame", _gridAngle, 0., SegmentationParameter::AngleUnit);
0057 };
0058 
0059 /// destructor
0060 CartesianGridUV::~CartesianGridUV() {
0061 
0062 }
0063 
0064 /// determine the position based on the cell ID
0065 Vector3D CartesianGridUV::position(const CellID& cID) const {
0066     Vector3D cellPosition;
0067     cellPosition.X = binToPosition( _decoder->get(cID,_uId ), _gridSizeU, _offsetU);
0068     cellPosition.Y = binToPosition( _decoder->get(cID,_vId ), _gridSizeV, _offsetV);
0069     cellPosition = RotationZ(-_gridAngle)*cellPosition;
0070     return cellPosition;
0071 }
0072 
0073 /// determine the cell ID based on the position
0074 CellID CartesianGridUV::cellID(const Vector3D& localPosition,
0075                                const Vector3D& /* globalPosition */,
0076                                const VolumeID& vID) const {
0077     CellID cID = vID;
0078     const Vector3D& localUV = RotationZ(_gridAngle)*localPosition;
0079     _decoder->set( cID,_uId, positionToBin(localUV.X, _gridSizeU, _offsetU) );
0080     _decoder->set( cID,_vId, positionToBin(localUV.Y, _gridSizeV, _offsetV) );
0081     return cID;
0082 }
0083 
0084 std::vector<double> CartesianGridUV::cellDimensions(const CellID& /* cellID */) const {
0085     return {_gridSizeU, _gridSizeV};
0086 }
0087 
0088 
0089 } /* namespace DDSegmentation */
0090 } /* namespace dd4hep */
0091 
0092 // This is done DDCore/src/plugins/ReadoutSegmentations.cpp so the plugin is not part of libDDCore
0093 // needs also #include <DD4hep/Factories.h>
0094 // DECLARE_SEGMENTATION(CartesianGridUV,dd4hep::create_segmentation<dd4hep::DDSegmentation::CartesianGridUV>)