Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:13:37

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  * TiledLayerSegmentation.h
0014  *
0015  *  Created on: Mar 10, 2014
0016  *      Author: cgrefe
0017  */
0018 
0019 #ifndef DDSEGMENTATION_TILEDLAYERSEGMENTATION_H
0020 #define DDSEGMENTATION_TILEDLAYERSEGMENTATION_H
0021 
0022 #include <DDSegmentation/Segmentation.h>
0023 
0024 // C/C++ includes
0025 #include <string>
0026 #include <vector>
0027 
0028 namespace dd4hep {
0029   namespace DDSegmentation {
0030 
0031     /// A segmentation class to describe tiled layers
0032     class TiledLayerSegmentation: public Segmentation {
0033     public:
0034       /// Helper class to store x and y dimensions of a layer
0035       struct LayerDimensions {
0036         LayerDimensions(double _x = 1., double _y = 1.) :
0037           x(_x), y(_y) {}
0038         double x, y;
0039       };
0040 
0041       /// Default constructor passing the encoding string
0042       TiledLayerSegmentation(const std::string& cellEncoding = "");
0043       /// Default constructor used by derived classes passing an existing decoder
0044       TiledLayerSegmentation(const BitFieldCoder* decoder);
0045       /// destructor
0046       virtual ~TiledLayerSegmentation();
0047 
0048       /// determine the position based on the cell ID
0049       virtual Vector3D position(const CellID& cellID) const;
0050       /// determine the cell ID based on the position
0051       virtual CellID cellID(const Vector3D& localPosition, const Vector3D& globalPosition,
0052                             const VolumeID& volumeID) const;
0053 
0054       /// access the default grid size in X
0055       double gridSizeX() const {
0056         return _gridSizeX;
0057       }
0058       /// access the default grid size in Y
0059       double gridSizeY() const {
0060         return _gridSizeY;
0061       }
0062 
0063       /// access the actual grid size in X for a given layer
0064       double layerGridSizeX(int layerIndex) const;
0065       /// access the actual grid size in Y for a given layer
0066       double layerGridSizeY(int layerIndex) const;
0067 
0068       /// access the encoding field name used for X
0069       const std::string& identifierX() const {
0070         return _identifierX;
0071       }
0072       /// access the encoding field name used for Y
0073       const std::string& identifierY() const {
0074         return _identifierY;
0075       }
0076       /// access the encoding field name used for Y
0077       const std::string& identifierLayer() const {
0078         return _identifierLayer;
0079       }
0080 
0081       /// access to the dimensions of the given layer
0082       LayerDimensions layerDimensions(int layerIndex) const;
0083 
0084       /// set the default grid size in X
0085       void setGridSizeX(double cellSize) {
0086         _gridSizeX = cellSize;
0087       }
0088       /// set the default grid size in Y
0089       void setGridSizeY(double cellSize) {
0090         _gridSizeY = cellSize;
0091       }
0092 
0093       /// set the encoding field name used for X
0094       void setIdentifierX(const std::string& fieldName) {
0095         _identifierX = fieldName;
0096       }
0097       /// set the encoding field name used for Y
0098       void setIdentifierY(const std::string& fieldName) {
0099         _identifierY = fieldName;
0100       }
0101       /// set the encoding field name used for layer
0102       void setIdentifierLayer(const std::string& fieldName) {
0103         _identifierLayer = fieldName;
0104       }
0105 
0106       /// set the dimensions of the given layer
0107       void setLayerDimensions(int layerIndex, double x, double y);
0108 
0109 
0110 
0111     protected:
0112       double _gridSizeX; /// default grid size in X
0113       double _gridSizeY; /// default grid size in Y
0114       std::string _identifierX; /// encoding field used for X
0115       std::string _identifierY; /// encoding field used for Y
0116       std::string _identifierLayer; /// encoding field used for the layer
0117       std::vector<int> _layerIndices; /// list of valid layer identifiers
0118       std::vector<double> _layerDimensionsX; /// list of layer x dimensions
0119       std::vector<double> _layerDimensionsY; /// list of layer y dimensions
0120 
0121       /// helper method to calculate optimal cell size based on total size
0122       static double calculateOptimalCellSize(double nominalCellSize, double totalSize);
0123       /// helper method to calculate offset of bin 0 based on the total size
0124       static double calculateOffset(double cellSize, double totalSize);
0125     };
0126 
0127   } /* namespace DDSegmentation */
0128 } /* namespace dd4hep */
0129 
0130 #endif // DDSEGMENTATION_TILEDLAYERSEGMENTATION_H