Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /DD4hep/DDCore/src/segmentations/CartesianGridXY.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/CartesianGridXY.h>
0017 
0018 namespace dd4hep {
0019 
0020   namespace DDSegmentation {
0021 
0022 /// default constructor using an encoding string
0023 CartesianGridXY::CartesianGridXY(const std::string& cellEncoding) :
0024         CartesianGrid(cellEncoding) {
0025     // define type and description
0026     _type = "CartesianGridXY";
0027     _description = "Cartesian segmentation in the local XY-plane";
0028 
0029     // register all necessary parameters
0030     registerParameter("grid_size_x", "Cell size in X",   _gridSizeX, 1., SegmentationParameter::LengthUnit);
0031     registerParameter("grid_size_y", "Cell size in Y",   _gridSizeY, 1., SegmentationParameter::LengthUnit);
0032     registerParameter("offset_x",    "Cell offset in X", _offsetX,   0., SegmentationParameter::LengthUnit, true);
0033     registerParameter("offset_y",    "Cell offset in Y", _offsetY,   0., SegmentationParameter::LengthUnit, true);
0034     registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x");
0035     registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y");
0036 }
0037 
0038 /// Default constructor used by derived classes passing an existing decoder
0039 CartesianGridXY::CartesianGridXY(const BitFieldCoder* decode) :
0040         CartesianGrid(decode)
0041 {
0042     // define type and description
0043     _type = "CartesianGridXY";
0044     _description = "Cartesian segmentation in the local XY-plane";
0045 
0046     // register all necessary parameters
0047     registerParameter("grid_size_x", "Cell size in X",   _gridSizeX, 1., SegmentationParameter::LengthUnit);
0048     registerParameter("grid_size_y", "Cell size in Y",   _gridSizeY, 1., SegmentationParameter::LengthUnit);
0049     registerParameter("offset_x",    "Cell offset in X", _offsetX,   0., SegmentationParameter::LengthUnit, true);
0050     registerParameter("offset_y",    "Cell offset in Y", _offsetY,   0., SegmentationParameter::LengthUnit, true);
0051     registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x");
0052     registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y");
0053 }
0054 
0055 /// destructor
0056 CartesianGridXY::~CartesianGridXY() {
0057 
0058 }
0059 
0060 /// determine the position based on the cell ID
0061 Vector3D CartesianGridXY::position(const CellID& cID) const {
0062     Vector3D cellPosition;
0063     cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX);
0064     cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY);
0065     return cellPosition;
0066 }
0067 
0068 /// determine the cell ID based on the position
0069 CellID CartesianGridXY::cellID(const Vector3D& localPosition,
0070                                const Vector3D& /* globalPosition */,
0071                                const VolumeID& vID) const {
0072   CellID cID = vID;
0073     _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX) );
0074     _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY) );
0075     return cID;
0076 }
0077 
0078   std::vector<double> CartesianGridXY::cellDimensions(const CellID& /* cellID */) const {
0079   return {_gridSizeX, _gridSizeY};
0080 }
0081 
0082 
0083 } /* namespace DDSegmentation */
0084 } /* namespace dd4hep */
0085 
0086 // This is done DDCore/src/plugins/ReadoutSegmentations.cpp so the plugin is not part of libDDCore
0087 // needs also #include <DD4hep/Factories.h>
0088 // DECLARE_SEGMENTATION(CartesianGridXY,dd4hep::create_segmentation<dd4hep::DDSegmentation::CartesianGridXY>)