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 /*
0012  * CartesianStripZ.cpp
0013  *
0014  *  Created on: Jun 28, 2013
0015  *      Author: Christian Grefe, CERN
0016  *              David Blyth, ANL
0017  */
0018 
0019 #include <DDSegmentation/CartesianStripZ.h>
0020 
0021 namespace dd4hep {
0022 namespace DDSegmentation {
0023 /// default constructor using an encoding string
0024 CartesianStripZ::CartesianStripZ(const std::string& cellEncoding) : CartesianStrip(cellEncoding) {
0025     // define type and description
0026     _type = "CartesianStripZ";
0027     _description = "Cartesian segmentation on the local Z axis";
0028 
0029     // register all necessary parameters
0030     registerParameter("strip_size_x", "Cell size in Z", _stripSizeZ, 1., SegmentationParameter::LengthUnit);
0031     registerParameter("offset_x", "Cell offset in Z", _offsetZ, 0., SegmentationParameter::LengthUnit, true);
0032     registerIdentifier("identifier_x", "Cell ID identifier for Z", _xId, "strip");
0033 }
0034 
0035 /// Default constructor used by derived classes passing an existing decoder
0036 CartesianStripZ::CartesianStripZ(const BitFieldCoder* decode) : CartesianStrip(decode) {
0037     // define type and description
0038     _type = "CartesianStripZ";
0039     _description = "Cartesian segmentation on the local Z axis";
0040 
0041     // register all necessary parameters
0042     registerParameter("strip_size_x", "Cell size in Z", _stripSizeZ, 1., SegmentationParameter::LengthUnit);
0043     registerParameter("offset_x", "Cell offset in Z", _offsetZ, 0., SegmentationParameter::LengthUnit, true);
0044     registerIdentifier("identifier_x", "Cell ID identifier for Z", _xId, "strip");
0045 }
0046 
0047 /// destructor
0048 CartesianStripZ::~CartesianStripZ() {}
0049 
0050 /// determine the position based on the cell ID
0051 Vector3D CartesianStripZ::position(const CellID& cID) const {
0052     Vector3D cellPosition;
0053     cellPosition.Z = binToPosition(_decoder->get(cID, _xId), _stripSizeZ, _offsetZ);
0054     return cellPosition;
0055 }
0056 
0057 /// determine the cell ID based on the position
0058 CellID CartesianStripZ::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */,
0059                                const VolumeID& vID) const {
0060     CellID cID = vID;
0061     _decoder->set(cID, _xId, positionToBin(localPosition.Z, _stripSizeZ, _offsetZ));
0062     return cID;
0063 }
0064 
0065 std::vector<double> CartesianStripZ::cellDimensions(const CellID&) const {
0066 #if __cplusplus >= 201103L
0067     return {_stripSizeZ};
0068 #else
0069     std::vector<double> cellDims(1, 0.0);
0070     cellDims[0] = _stripSizeZ;
0071     return cellDims;
0072 #endif
0073 }
0074 
0075 }  // namespace DDSegmentation
0076 } /* namespace dd4hep */