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  * MegatileLayerGridXY.h
0014  *
0015  *  Created on: April 19, 2016
0016  *      Author: S. Lu, DESY
0017  */
0018 
0019 #ifndef DDSEGMENTATION_MEGATILELAYERGRIDXY_H
0020 #define DDSEGMENTATION_MEGATILELAYERGRIDXY_H
0021 
0022 #include <DDSegmentation/CartesianGrid.h>
0023 
0024 #include <cassert>
0025 
0026 
0027 namespace dd4hep {
0028   namespace DDSegmentation {
0029 
0030     ///  a megatile is a rectangule in x-y, split into a grid along x and y, with an exactly integer number of cells in x and y.
0031     /**
0032      * this class assumes a mostly-common megatile size, with possibility for a number of "special" megatiles of non-standard size / segmentation
0033      *
0034      *  the segmentation of standard megatiles is defined layer-by-layer.
0035      *
0036      *  some changes wrt previous version from Kotera et al.
0037      *  - significantly simplified. 
0038      *  - complications due to end-of-slab moved to higher level detector drivers.
0039      *
0040      *  D. Jeans - Nov 2016
0041      *
0042      *  July 2017 - DJeans
0043      *  some changes for easier use of multi-layer segmentations
0044      *  - for uniform segmentation, allow setting of ncellsx/y via parameter
0045      *  - use std::vector, rather than fixed array to store ncells values
0046      *
0047      */
0048     class MegatileLayerGridXY: public CartesianGrid {
0049     public:
0050       /// Default constructor passing the encoding string
0051       MegatileLayerGridXY(const std::string& cellEncoding = "");
0052 
0053       /// Default constructor used by derived classes passing an existing decoder
0054       MegatileLayerGridXY(const BitFieldCoder* decoder);
0055 
0056       /// destructor
0057       virtual ~MegatileLayerGridXY();
0058 
0059       void setup();
0060 
0061       /// determine the position based on the cell ID
0062       virtual Vector3D position(const CellID& cellID) const;
0063       /// determine the cell ID based on the position
0064       virtual CellID cellID(const Vector3D& localPosition, const Vector3D& globalPosition, const VolumeID& volumeID) const;
0065 
0066       // set size of megatile in X,Y
0067       void setMegaTileSizeXY(double x, double y) {
0068         _megaTileSizeX = x;
0069         _megaTileSizeY = y;
0070       }
0071 
0072       /// set the coordinate offset in X, Y
0073       void setMegaTileOffsetXY( double x, double y) {
0074         _megaTileOffsetX = x;
0075         _megaTileOffsetY = y;
0076       }
0077 
0078       void setMegaTileCellsXY( unsigned int layer, int ix, int iy ) {
0079         while ( _nCellsX.size()<=layer ) {
0080           _nCellsX.emplace_back(0);
0081           _nCellsY.emplace_back(0);
0082         }
0083         _nCellsX[layer] = ix;
0084         _nCellsY[layer] = iy;
0085 
0086       }
0087 
0088       void setSpecialMegaTile( unsigned int layer, unsigned int tile, 
0089                                double sizex, double sizey,
0090                                double offsetx, double offsety,
0091                                unsigned int ncellsx, unsigned int ncellsy );
0092 
0093       /// access the field name used for X
0094       const std::string& fieldNameX() const {
0095         return _xId;
0096       }
0097       /// access the field name used for Y
0098       const std::string& fieldNameY() const {
0099         return _yId;
0100       }
0101       
0102       /// set the field name used for X
0103       void setFieldNameX(const std::string& fieldName) {
0104         _xId = fieldName;
0105       }
0106       /// set the field name used for Y
0107       void setFieldNameY(const std::string& fieldName) {
0108         _yId = fieldName;
0109       }
0110 
0111       virtual std::vector<double> cellDimensions(const CellID& cellID) const;
0112       virtual std::vector<double> cellDimensions(const unsigned int ilayer, const unsigned int iwafer) const;
0113 
0114       int getUnifNCellsX() {return _unif_nCellsX;}
0115       int getUnifNCellsY() {return _unif_nCellsY;}
0116 
0117       /// Helper structure
0118       struct segInfo {
0119         double megaTileSizeX = 0;
0120         double megaTileSizeY = 0;
0121         double megaTileOffsetX = 0;
0122         double megaTileOffsetY = 0;
0123         unsigned int nCellsX = 0;
0124         unsigned int nCellsY = 0;
0125         segInfo() = default;
0126       };
0127 
0128     protected:
0129 
0130 
0131       mutable segInfo _currentSegInfo;
0132 
0133       void getSegInfo( unsigned int layerIndex, unsigned int waferIndex) const;
0134 
0135       // the "usual" megatiles
0136       //  megatile size and offset is constant in all layers
0137       //  the segmentation may change layer-to-layer (e.g. orthogonal strips)
0138 
0139       // total size of surface in X,Y
0140       double  _megaTileSizeX = 0; // [MAX_LAYERS][MAX_WAFERS];
0141       double  _megaTileSizeY = 0; //[MAX_LAYERS][MAX_WAFERS];
0142 
0143       double  _megaTileOffsetX = 0;
0144       double  _megaTileOffsetY = 0;
0145 
0146       // number of cells per megatile in X, Y
0147       std::vector < int > _nCellsX;
0148       std::vector < int > _nCellsY;
0149 
0150       int _unif_nCellsX;
0151       int _unif_nCellsY;
0152 
0153       std::map < std::pair < unsigned int, unsigned int > , segInfo > specialMegaTiles_layerWafer;
0154 
0155       
0156       /// the field name used for X
0157       std::string _xId;
0158       /// the field name used for Y
0159       std::string _yId;
0160       /// encoding field used for the layer
0161       std::string _identifierLayer;
0162       /// encoding field used for the wafer
0163       std::string _identifierWafer;
0164 
0165       std::string _layerConfig;
0166 
0167       std::string _identifierModule;
0168 
0169     };
0170 
0171   }    /* namespace DDSegmentation              */
0172 }      /* namespace dd4hep                      */
0173 #endif // DDSEGMENTATION_MEGATILELAYERGRIDXY_H