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