Back to home page

EIC code displayed by LXR

 
 

    


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

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 /* CartesianGridYZ.cpp
0012  *
0013  *  @date:     Sep 03, 2014
0014  *  @author:   F.Gaede CERN/Desy
0015  *  @version:  1.0
0016  *     direkt copy of CartesianGridXY
0017  *     by Christian Grefe, CERN
0018  */
0019 #include <DDSegmentation/CartesianGridYZ.h>
0020 
0021 namespace dd4hep {
0022 namespace DDSegmentation {
0023 
0024 /// default constructor using an encoding string
0025 CartesianGridYZ::CartesianGridYZ(const std::string& cellEncoding) :
0026         CartesianGrid(cellEncoding) {
0027     // define type and description
0028     _type = "CartesianGridYZ";
0029     _description = "Cartesian segmentation in the local YZ-plane";
0030 
0031     // register all necessary parameters
0032     registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit);
0033     registerParameter("grid_size_z", "Cell size in Z", _gridSizeZ, 1., SegmentationParameter::LengthUnit);
0034     registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true);
0035     registerParameter("offset_z", "Cell offset in Z", _offsetZ, 0., SegmentationParameter::LengthUnit, true);
0036     registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y");
0037     registerIdentifier("identifier_z", "Cell ID identifier for Z", _zId, "z");
0038 }
0039 
0040 
0041 /// Default constructor used by derived classes passing an existing decoder
0042 CartesianGridYZ::CartesianGridYZ(const BitFieldCoder* decode) : CartesianGrid(decode)
0043 {
0044     // define type and description
0045     _type = "CartesianGridYZ";
0046     _description = "Cartesian segmentation in the local YZ-plane";
0047 
0048     // register all necessary parameters
0049     registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit);
0050     registerParameter("grid_size_z", "Cell size in Z", _gridSizeZ, 1., SegmentationParameter::LengthUnit);
0051     registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true);
0052     registerParameter("offset_z", "Cell offset in Z", _offsetZ, 0., SegmentationParameter::LengthUnit, true);
0053     registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y");
0054     registerIdentifier("identifier_z", "Cell ID identifier for Z", _zId, "z");
0055 }
0056 
0057 /// destructor
0058 CartesianGridYZ::~CartesianGridYZ() {
0059 
0060 }
0061 
0062 /// determine the position based on the cell ID
0063 Vector3D CartesianGridYZ::position(const CellID& cID) const {
0064     Vector3D cellPosition;
0065     cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY);
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 CartesianGridYZ::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const {
0072         CellID cID = vID ;
0073     _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY) );
0074     _decoder->set( cID,_zId, positionToBin(localPosition.Z, _gridSizeZ, _offsetZ) );
0075     return cID ;
0076 }
0077 
0078 std::vector<double> CartesianGridYZ::cellDimensions(const CellID&) const {
0079 #if __cplusplus >= 201103L
0080   return {_gridSizeY, _gridSizeZ};
0081 #else
0082   std::vector<double> cellDims(2,0.0);
0083   cellDims[0] = _gridSizeY;
0084   cellDims[1] = _gridSizeZ;
0085   return cellDims;
0086 #endif
0087 }
0088 
0089 
0090 } /* namespace DDSegmentation */
0091 } /* namespace dd4hep */