Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:26

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 /*
0013  * HexGrid.h
0014  *
0015  *  Created on: August 9, 2023
0016  *      Author: Sebouh J. Paul, UC Riverside
0017  */
0018 
0019 #ifndef DDSEGMENTATION_HEXGRID_H
0020 #define DDSEGMENTATION_HEXGRID_H
0021 
0022 #include <DDSegmentation/Segmentation.h>
0023 
0024 namespace dd4hep {
0025   namespace DDSegmentation {
0026 
0027     /// Segmentation base class describing hexagonal grid segmentation, with or without staggering
0028     class HexGrid: public Segmentation {
0029     public:
0030       /// Destructor
0031       virtual ~HexGrid();
0032       //protected:
0033       /// Default constructor used by derived classes passing the encoding string
0034       HexGrid(const std::string& cellEncoding = "");
0035       /// Default constructor used by derived classes passing an existing decoder
0036       HexGrid(const BitFieldCoder* decoder);
0037 
0038       /// determine the position based on the cell ID
0039       virtual Vector3D position(const CellID& cellID) const;
0040       /// determine the cell ID based on the position
0041       virtual CellID cellID(const Vector3D& localPosition, const Vector3D& globalPosition, const VolumeID& volumeID) const;
0042       // access the stagger mode: 0=no stagger; 1=stagger cycling through 3 offsets
0043       int stagger() const {
0044     return _stagger;
0045       }
0046       
0047       /// access the grid size 
0048       double sideLength() const {
0049         return _sideLength;
0050       }
0051       /// access the coordinate offset in X
0052       double offsetX() const {
0053         return _offsetX;
0054       }
0055       /// access the coordinate offset in Y
0056       double offsetY() const {
0057         return _offsetY;
0058       }
0059       /// access the field name used for X
0060       const std::string& fieldNameX() const {
0061         return _xId;
0062       }
0063       /// access the field name used for Y
0064       const std::string& fieldNameY() const {
0065         return _yId;
0066       }
0067       /// access the keyword for staggering
0068       const std::string& staggerKeyword() const {
0069         return _staggerKeyword;
0070       }
0071 
0072       /// set the stagger mode: 0=no stagger; 1=stagger cycling through 3 offsets
0073       void setStagger(int stagger) {
0074     _stagger= stagger;
0075       }
0076       /// set the grid size in X
0077       void setSideLength(double cellSize) {
0078         _sideLength = cellSize;
0079       }
0080       /// set the coordinate offset in X
0081       void setOffsetX(double offset) {
0082         _offsetX = offset;
0083       }
0084       /// set the coordinate offset in Y
0085       void setOffsetY(double offset) {
0086         _offsetY = offset;
0087       }
0088       /// set the field name used for X
0089       void setFieldNameX(const std::string& fieldName) {
0090         _xId = fieldName;
0091       }
0092       /// set the field name used for Y
0093       void setFieldNameY(const std::string& fieldName) {
0094         _yId = fieldName;
0095       }
0096       /// set the keyword used to determine which volumes to stagger
0097       void setStaggerKeyword(const std::string& staggerKeyword) {
0098         _staggerKeyword = staggerKeyword;
0099       }
0100       /** \brief Returns a vector<double> of the cellDimensions of the given cell ID
0101           in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi
0102 
0103           Returns a vector of the cellDimensions of the given cell ID
0104           \param cellID is ignored as all cells have the same dimension
0105           \return std::vector<double> size 2:
0106           -# size in x
0107           -# size in y
0108       */
0109       virtual std::vector<double> cellDimensions(const CellID& cellID) const;
0110 
0111     protected:
0112       /// the stagger mode:  0=off ; 1=cycle through 3 different offsets (H3)
0113       //  2=cycle through 4 differnt offsets (H4)
0114       int _stagger;
0115       /// the length of one side of a hexagon
0116       double _sideLength;
0117       /// the coordinate offset in X
0118       double _offsetX;
0119       /// the coordinate offset in Y
0120       double _offsetY;
0121       /// the field name used for X
0122       std::string _xId;
0123       /// the field name used for Y
0124       std::string _yId;
0125       /// the keyword used to determine which volumes to stagger
0126       std::string _staggerKeyword;
0127     };
0128 
0129   } /* namespace DDSegmentation */
0130 } /* namespace dd4hep */
0131 #endif // DDSEGMENTATION_HEXGRID_H