Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /DD4hep/DDCore/src/segmentations/CartesianGridXYZ.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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/CartesianGridXYZ.h>
0017 
0018 namespace dd4hep {
0019 namespace DDSegmentation {
0020 
0021 /// default constructor using an encoding string
0022 CartesianGridXYZ::CartesianGridXYZ(const std::string& cellEncoding) :
0023         CartesianGridXY(cellEncoding) {
0024     // define type and description
0025     _type = "CartesianGridXYZ";
0026     _description = "Cartesian segmentation in the local coordinates";
0027 
0028     // register all necessary parameters
0029     registerParameter("grid_size_z", "Cell size in Z", _gridSizeZ, 1., SegmentationParameter::LengthUnit);
0030     registerParameter("offset_z", "Cell offset in Z", _offsetZ, 0., SegmentationParameter::LengthUnit, true);
0031     registerIdentifier("identifier_z", "Cell ID identifier for Z", _zId, "z");
0032 }
0033 
0034 /// Default constructor used by derived classes passing an existing decoder
0035 CartesianGridXYZ::CartesianGridXYZ(const BitFieldCoder* decode) :
0036         CartesianGridXY(decode) {
0037     // define type and description
0038     _type = "CartesianGridXYZ";
0039     _description = "Cartesian segmentation in the local coordinates";
0040 
0041     // register all necessary parameters
0042     registerParameter("grid_size_z", "Cell size in Z", _gridSizeZ, 1., SegmentationParameter::LengthUnit);
0043     registerParameter("offset_z", "Cell offset in Z", _offsetZ, 0., SegmentationParameter::LengthUnit, true);
0044     registerIdentifier("identifier_z", "Cell ID identifier for Z", _zId, "z");
0045 }
0046 
0047 /// destructor
0048 CartesianGridXYZ::~CartesianGridXYZ() {
0049 
0050 }
0051 
0052 /// determine the position based on the cell ID
0053 Vector3D CartesianGridXYZ::position(const CellID& cID) const {
0054     Vector3D cellPosition;
0055     cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX);
0056     cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY);
0057     cellPosition.Z = binToPosition( _decoder->get(cID,_zId ), _gridSizeZ, _offsetZ);
0058     return cellPosition;
0059 }
0060 
0061 /// determine the cell ID based on the position
0062   CellID CartesianGridXYZ::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const {
0063         CellID cID = vID ;
0064     _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX) );
0065     _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY) );
0066     _decoder->set( cID,_zId, positionToBin(localPosition.Z, _gridSizeZ, _offsetZ) );
0067     return cID ;
0068 }
0069 
0070 std::vector<double> CartesianGridXYZ::cellDimensions(const CellID&) const {
0071   return {_gridSizeX, _gridSizeY, _gridSizeZ};
0072 }
0073 
0074 
0075 } /* namespace DDSegmentation */
0076 } /* namespace dd4hep */