Back to home page

EIC code displayed by LXR

 
 

    


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