diff --git a/DDSegmentation/include/DDSegmentation/MegatileLayerGridXY.h b/DDSegmentation/include/DDSegmentation/MegatileLayerGridXY.h index fbba4557b1b611c88b7d19d3137eed68e3a6e6f9..fd9104d1ec76159c5827ef88fc4c0c4c23099e92 100644 --- a/DDSegmentation/include/DDSegmentation/MegatileLayerGridXY.h +++ b/DDSegmentation/include/DDSegmentation/MegatileLayerGridXY.h @@ -38,9 +38,15 @@ namespace DD4hep { public: /// Default constructor passing the encoding string MegatileLayerGridXY(const std::string& cellEncoding = ""); + + /// Default constructor used by derived classes passing an existing decoder + MegatileLayerGridXY(BitField64* decoder); + /// destructor virtual ~MegatileLayerGridXY(); + void setup(); + /// determine the position based on the cell ID virtual Vector3D position(const CellID& cellID) const; /// determine the cell ID based on the position diff --git a/DDSegmentation/src/MegatileLayerGridXY.cpp b/DDSegmentation/src/MegatileLayerGridXY.cpp index 5446eee02364f04518e6d9911e297a14666912a4..7892d09279a66112da3a9ec056380577bb5a5d93 100644 --- a/DDSegmentation/src/MegatileLayerGridXY.cpp +++ b/DDSegmentation/src/MegatileLayerGridXY.cpp @@ -19,6 +19,20 @@ namespace DD4hep { /// default constructor using an encoding string MegatileLayerGridXY::MegatileLayerGridXY(const std::string& cellEncoding) : CartesianGrid(cellEncoding) { + setup(); + } + + MegatileLayerGridXY::MegatileLayerGridXY(BitField64* decode) : + CartesianGrid(decode) { + setup(); + } + + /// destructor + MegatileLayerGridXY::~MegatileLayerGridXY() { + + } + + void MegatileLayerGridXY::setup() { // define type and description _type = "MegatileLayerGridXY"; _description = "Cartesian segmentation in the local XY-plane: megatiles, containing integer number of tiles/strips/cells"; @@ -36,16 +50,11 @@ namespace DD4hep { SegmentationParameter::NoUnit, true); for (int i=0; i<MAX_LAYERS; i++) { - _nCellsX[i]=0; - _nCellsY[i]=0; + _nCellsX[i]=0; + _nCellsY[i]=0; } - } - /// destructor - MegatileLayerGridXY::~MegatileLayerGridXY() { - - } /// determine the position based on the cell ID Vector3D MegatileLayerGridXY::position(const CellID& cID) const { @@ -65,9 +74,9 @@ namespace DD4hep { cellPosition.Y = cellIndexY * (_currentSegInfo.megaTileSizeY / _currentSegInfo.nCellsY ) + _currentSegInfo.megaTileOffsetY; if ( abs( cellPosition.X )>10000 || abs( cellPosition.Y )>10000 ) { - std::cout << "crazy cell position: " << cellPosition.X << " " << cellPosition.Y << std::endl; - std::cout << "layer, wafer, cellx,y indices: " << layerIndex << " " << waferIndex << " " << cellIndexX << " " << cellIndexY << std::endl; - assert(0 && "crazy cell position?"); + std::cout << "crazy cell position: " << cellPosition.X << " " << cellPosition.Y << std::endl; + std::cout << "layer, wafer, cellx,y indices: " << layerIndex << " " << waferIndex << " " << cellIndexX << " " << cellIndexY << std::endl; + assert(0 && "crazy cell position?"); } return cellPosition; @@ -111,10 +120,10 @@ namespace DD4hep { return cellDimensions(layerIndex, waferIndex); } - void MegatileLayerGridXY::setSpecialMegaTile( unsigned int layer, unsigned int tile, - double sizex, double sizey, - double offsetx, double offsety, - unsigned int ncellsx, unsigned int ncellsy ) { + void MegatileLayerGridXY::setSpecialMegaTile( unsigned int layer, unsigned int tile, + double sizex, double sizey, + double offsetx, double offsety, + unsigned int ncellsx, unsigned int ncellsy ) { std::pair <int, int> tileid(layer, tile); segInfo sinf; @@ -134,15 +143,15 @@ namespace DD4hep { std::pair < unsigned int, unsigned int > tileid(layerIndex, waferIndex); if ( specialMegaTiles_layerWafer.find( tileid ) == specialMegaTiles_layerWafer.end() ) { // standard megatile - _currentSegInfo.megaTileSizeX = _megaTileSizeX; + _currentSegInfo.megaTileSizeX = _megaTileSizeX; _currentSegInfo.megaTileSizeY = _megaTileSizeY; _currentSegInfo.megaTileOffsetX = _megaTileOffsetX; _currentSegInfo.megaTileOffsetY = _megaTileOffsetY; _currentSegInfo.nCellsX = _nCellsX[layerIndex]; _currentSegInfo.nCellsY = _nCellsY[layerIndex]; } else { // special megatile - _currentSegInfo = specialMegaTiles_layerWafer.find( tileid )->second; - } + _currentSegInfo = specialMegaTiles_layerWafer.find( tileid )->second; + } } std::vector<double> MegatileLayerGridXY::cellDimensions(const unsigned int layerIndex, const unsigned int waferIndex) const {