Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 07:54:12

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 //  Created: Jun 28, 2013
0011 //  Author:  Christian Grefe, CERN
0012 //
0013 //==========================================================================
0014 
0015 /// Framework include files
0016 #include <DDSegmentation/CartesianGridXZ.h>
0017 
0018 namespace dd4hep {
0019 namespace DDSegmentation {
0020 
0021 using std::make_pair;
0022 using std::vector;
0023 
0024 /// default constructor using an encoding string
0025 CartesianGridXZ::CartesianGridXZ(const std::string& cellEncoding) :
0026     CartesianGrid(cellEncoding) {
0027     // define type and description
0028     _type = "CartesianGridXZ";
0029     _description = "Cartesian segmentation in the local XZ-plane";
0030 
0031     // register all necessary parameters
0032     registerParameter("grid_size_x", "Cell size in X", _gridSizeX, 1., SegmentationParameter::LengthUnit);
0033     registerParameter("grid_size_z", "Cell size in Z", _gridSizeZ, 1., SegmentationParameter::LengthUnit);
0034     registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true);
0035     registerParameter("offset_z", "Cell offset in Z", _offsetZ, 0., SegmentationParameter::LengthUnit, true);
0036     registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x");
0037     registerIdentifier("identifier_z", "Cell ID identifier for Z", _zId, "z");
0038 }
0039 
0040 /// Default constructor used by derived classes passing an existing decoder
0041 CartesianGridXZ::CartesianGridXZ(const BitFieldCoder* decode) :
0042     CartesianGrid(decode) {
0043     // define type and description
0044     _type = "CartesianGridXZ";
0045     _description = "Cartesian segmentation in the local XZ-plane";
0046 
0047     // register all necessary parameters
0048     registerParameter("grid_size_x", "Cell size in X", _gridSizeX, 1., SegmentationParameter::LengthUnit);
0049     registerParameter("grid_size_z", "Cell size in Z", _gridSizeZ, 1., SegmentationParameter::LengthUnit);
0050     registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true);
0051     registerParameter("offset_z", "Cell offset in Z", _offsetZ, 0., SegmentationParameter::LengthUnit, true);
0052     registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x");
0053     registerIdentifier("identifier_z", "Cell ID identifier for Z", _zId, "z");
0054 }
0055 
0056 /// destructor
0057 CartesianGridXZ::~CartesianGridXZ() {
0058 
0059 }
0060 
0061 /// determine the position based on the cell ID
0062 Vector3D CartesianGridXZ::position(const CellID& cID) const {
0063     vector<double> localPosition(3);
0064     Vector3D cellPosition;
0065     cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX);
0066     cellPosition.Z = binToPosition( _decoder->get(cID,_zId ), _gridSizeZ, _offsetZ);
0067     return cellPosition;
0068 }
0069 
0070 /// determine the cell ID based on the position
0071   CellID CartesianGridXZ::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const {
0072         CellID cID = vID ;
0073         _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX) );
0074     _decoder->set( cID,_zId, positionToBin(localPosition.Z, _gridSizeZ, _offsetZ) );
0075     return cID ;
0076 }
0077 
0078 std::vector<double> CartesianGridXZ::cellDimensions(const CellID&) const {
0079   return {_gridSizeX, _gridSizeZ};
0080 }
0081 
0082 
0083 } /* namespace DDSegmentation */
0084 } /* namespace dd4hep */