From 7754e378bcd07db9170f3e891ffa5368eb274fa5 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 15 Aug 2023 14:02:49 -0400 Subject: [PATCH 01/39] Added hex and staggered square segmentations src --- DDCore/src/segmentations/HexGrid.cpp | 150 ++++++++++++++++++++++++ DDCore/src/segmentations/SquareGrid.cpp | 105 +++++++++++++++++ 2 files changed, 255 insertions(+) create mode 100644 DDCore/src/segmentations/HexGrid.cpp create mode 100644 DDCore/src/segmentations/SquareGrid.cpp diff --git a/DDCore/src/segmentations/HexGrid.cpp b/DDCore/src/segmentations/HexGrid.cpp new file mode 100644 index 000000000..2c551505c --- /dev/null +++ b/DDCore/src/segmentations/HexGrid.cpp @@ -0,0 +1,150 @@ +/* + * HexGrid.cpp + * + * Created on: August 9, 2023 + * Author: Sebouh J. Paul, UC Riverside + */ +#include "DD4hep/Factories.h" +#include "HexGrid.h" + +namespace dd4hep { + namespace DDSegmentation { + + /// Default constructor used by derived classes passing the encoding string + HexGrid::HexGrid(const std::string& cellEncoding) : + Segmentation(cellEncoding) { + _type = "HexGridXY"; + _description = "Hexagonal segmentation in the local XY-plane"; + + // register all necessary parameters + registerParameter("stagger", "stagger mode", _stagger, 1); + registerParameter("side_length", "Cell size", _sideLength, 1., SegmentationParameter::LengthUnit); + registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); + registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); + registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); + registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); + } + + /// Default constructor used by derived classes passing an existing decoder + HexGrid::HexGrid(const BitFieldCoder* decode) : Segmentation(decode) { + // define type and description + _type = "HexGridXY"; + _description = "Hexagonal segmentation in the local XY-plane"; + + // register all necessary parameters + registerParameter("stagger", "stagger mode", _stagger, 1); + registerParameter("side_length", "Cell size", _sideLength, 1., SegmentationParameter::LengthUnit); + registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); + registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); + registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); + registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); + + } + + /// Destructor + HexGrid::~HexGrid() { + } + + /// determine the position based on the cell ID + Vector3D HexGrid::position(const CellID& cID) const { + int layer= _decoder->get(cID,"layer"); + Vector3D cellPosition; + cellPosition.X = _decoder->get(cID,_xId )*1.5*_sideLength+_offsetX+_sideLength/2.; + cellPosition.Y = _decoder->get(cID,_yId )*std::sqrt(3)/2.*_sideLength+ _offsetY+_sideLength*std::sqrt(3)/2.; + if (_stagger==0) + cellPosition.X+=_sideLength; + else if (_stagger==1) + cellPosition.X+=(layer%3)*_sideLength; + else if (_stagger==2){ + switch (layer%4){ + case 0: + cellPosition.X-=0.75*_sideLength; + break; + case 1: + //cellPosition.X+=0.75*_sideLength; + cellPosition.Y+=std::sqrt(3)/4*_sideLength; + break; + case 2: + //cellPosition.X-=0.75*_sideLength; + cellPosition.Y-=std::sqrt(3)/4*_sideLength; + break; + case 3: + cellPosition.X+=0.75*_sideLength; + break; + } + } + return cellPosition; + } + + inline double positive_modulo(double i, double n) { + return std::fmod(std::fmod(i,n) + n,n); + } + + //inline double positive_floor( + + /// determine the cell ID based on the position + CellID HexGrid::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { + CellID cID = vID ; + int layer= _decoder->get(cID,"layer"); + double _gridSizeY=std::sqrt(3)*_sideLength/2.; + double _gridSizeX=3*_sideLength/2; + + double x=localPosition.X-_offsetX; + double y=localPosition.Y-_offsetY; + if (_stagger==0) + x-=_sideLength; + else if (_stagger==1) + x-=(layer%3)*_sideLength; + else if (_stagger==2){ + switch (layer%4){ + case 0: + x+=0.75*_sideLength; + break; + case 1: + //x-=0.75*_sideLength; + y-=std::sqrt(3)/4*_sideLength; + break; + case 2: + //x+=0.75*_sideLength; + y+=std::sqrt(3)/4*_sideLength; + break; + case 3: + x-=0.75*_sideLength; + break; + } + } + + double a=positive_modulo(y/(std::sqrt(3)*_sideLength),1); + double b=positive_modulo(x/(3*_sideLength),1); + int ix = std::floor(x/(3*_sideLength/2.))+ + (b<0.5)*(-abs(a-.5)<(b-.5)*3)+(b>0.5)*(abs(a-.5)-.5<(b-1)*3); + int iy=std::floor(y/(std::sqrt(3)*_sideLength/2.)); + iy-=(ix+iy)&1; + + + //int ix=int(floor((localPosition.X - _offsetX) / (3/2*_sideLength))); + //int iy=int(floor((localPosition.Y - _offsetY) / (std::sqrt(3)/2*_sideLength))); + //if((ix+iy)%2 && + // ((localPosition.X-offset_X)/(2*_sideLength)+(localPosition.Y-_offsetX)/(std::sqrt(3)*_sideLength)) + //iy-=1; + + _decoder->set( cID,_xId, ix ); + _decoder->set( cID,_yId, iy ); + return cID ; + } + + std::vector HexGrid::cellDimensions(const CellID&) const { +#if __cplusplus >= 201103L + return {2*_sideLength, std::sqrt(3)*_sideLength}; +#else + std::vector cellDims(2,0.0); + cellDims[0] = 2*_sideLength; + cellDims[1] = std::sqrt(3)*_sideLength; + return cellDims; +#endif +} + + } /* namespace DDSegmentation */ +} /* namespace dd4hep */ + +DECLARE_SEGMENTATION(HexGrid, create_segmentation) diff --git a/DDCore/src/segmentations/SquareGrid.cpp b/DDCore/src/segmentations/SquareGrid.cpp new file mode 100644 index 000000000..a7d0e8dc7 --- /dev/null +++ b/DDCore/src/segmentations/SquareGrid.cpp @@ -0,0 +1,105 @@ +/* + * SquareGrid.cpp + * A square grid in X,Y which has options for staggering in the S2 pattern + * Created on: August 9, 2023 + * Author: Sebouh J. Paul, UC Riverside + */ +#include "DD4hep/Factories.h" +#include "SquareGrid.h" + +namespace dd4hep { + namespace DDSegmentation { + + /// Default constructor used by derived classes passing the encoding string + SquareGrid::SquareGrid(const std::string& cellEncoding) : + Segmentation(cellEncoding) { + _type = "SquareGridXY"; + _description = "Square segmentation in the local XY-plane"; + + // register all necessary parameters + registerParameter("stagger", "stagger mode", _stagger, 1); + registerParameter("side_length", "Cell size", _sideLength, 1., SegmentationParameter::LengthUnit); + registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); + registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); + registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); + registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); + } + + /// Default constructor used by derived classes passing an existing decoder + SquareGrid::SquareGrid(const BitFieldCoder* decode) : Segmentation(decode) { + // define type and description + _type = "SquareGridXY"; + _description = "Square segmentation in the local XY-plane"; + + // register all necessary parameters + registerParameter("stagger", "stagger mode", _stagger, 1); + registerParameter("side_length", "Cell size", _sideLength, 1., SegmentationParameter::LengthUnit); + registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); + registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); + registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); + registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); + + } + + /// Destructor + SquareGrid::~SquareGrid() { + } + + /// determine the position based on the cell ID + Vector3D SquareGrid::position(const CellID& cID) const { + int layer= _decoder->get(cID,"layer"); + Vector3D cellPosition; + cellPosition.X = _decoder->get(cID,_xId )*_sideLength+_offsetX+_sideLength/2.; + cellPosition.Y = _decoder->get(cID,_yId )*_sideLength+_offsetY+_sideLength/2.; + + + if (_stagger==1){ + cellPosition.X+=(layer%2)*_sideLength/2; + cellPosition.Y+=(layer%2)*_sideLength/2; + } + + return cellPosition; + } + + inline double positive_modulo(double i, double n) { + return std::fmod(std::fmod(i,n) + n,n); + } + + //inline double positive_floor( + + /// determine the cell ID based on the position + CellID SquareGrid::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { + CellID cID = vID ; + int layer= _decoder->get(cID,"layer"); + + double x=localPosition.X-_offsetX; + double y=localPosition.Y-_offsetY; + + if (_stagger==1){ + x-=(layer%2)*_sideLength/2; + y-=(layer%2)*_sideLength/2; + } + + int ix = std::floor(x/_sideLength); + int iy = std::floor(y/_sideLength); + + _decoder->set( cID,_xId, ix ); + _decoder->set( cID,_yId, iy ); + return cID ; + } + + std::vector SquareGrid::cellDimensions(const CellID&) const { +#if __cplusplus >= 201103L + return {_sideLength, _sideLength}; +#else + std::vector cellDims(2,0.0); + cellDims[0] = _sideLength; + cellDims[1] = _sideLength; + return cellDims; +#endif +} + + } /* namespace DDSegmentation */ +} /* namespace dd4hep */ + +DECLARE_SEGMENTATION(SquareGrid, create_segmentation) From 83eb4063b420208702d9c5dd6e77bf50152272da Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 15 Aug 2023 14:04:03 -0400 Subject: [PATCH 02/39] Added .h for hex and staggered square segmentation --- DDCore/include/DDSegmentation/HexGrid.h | 121 +++++++++++++++++++++ DDCore/include/DDSegmentation/SquareGrid.h | 120 ++++++++++++++++++++ 2 files changed, 241 insertions(+) create mode 100644 DDCore/include/DDSegmentation/HexGrid.h create mode 100644 DDCore/include/DDSegmentation/SquareGrid.h diff --git a/DDCore/include/DDSegmentation/HexGrid.h b/DDCore/include/DDSegmentation/HexGrid.h new file mode 100644 index 000000000..88c77174f --- /dev/null +++ b/DDCore/include/DDSegmentation/HexGrid.h @@ -0,0 +1,121 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +//========================================================================== + +/* + * CartesianGrid.h + * + * Created on: August 9, 2023 + * Author: Sebouh J. Paul, UC Riverside + */ + +#ifndef DDSEGMENTATION_HEXGRID_H +#define DDSEGMENTATION_HEXGRID_H + +#include "DDSegmentation/Segmentation.h" + +namespace dd4hep { + namespace DDSegmentation { + + /// Segmentation base class describing cartesian grid segmentation + class HexGrid: public Segmentation { + public: + /// Destructor + virtual ~HexGrid(); + //protected: + /// Default constructor used by derived classes passing the encoding string + HexGrid(const std::string& cellEncoding = ""); + /// Default constructor used by derived classes passing an existing decoder + HexGrid(const BitFieldCoder* decoder); + + /// determine the position based on the cell ID + virtual Vector3D position(const CellID& cellID) const; + /// determine the cell ID based on the position + virtual CellID cellID(const Vector3D& localPosition, const Vector3D& globalPosition, const VolumeID& volumeID) const; + // access the stagger mode: 0=no stagger; 1=stagger cycling through 3 offsets + int stagger() const { + return _stagger; + } + + /// access the grid size + double sideLength() const { + return _sideLength; + } + /// access the coordinate offset in X + double offsetX() const { + return _offsetX; + } + /// access the coordinate offset in Y + double offsetY() const { + return _offsetY; + } + /// access the field name used for X + const std::string& fieldNameX() const { + return _xId; + } + /// access the field name used for Y + const std::string& fieldNameY() const { + return _yId; + } + + /// set the stagger mode: 0=no stagger; 1=stagger cycling through 3 offsets + void setStagger(int stagger) { + _stagger= stagger; + } + /// set the grid size in X + void setSideLength(double cellSize) { + _sideLength = cellSize; + } + /// set the coordinate offset in X + void setOffsetX(double offset) { + _offsetX = offset; + } + /// set the coordinate offset in Y + void setOffsetY(double offset) { + _offsetY = offset; + } + /// set the field name used for X + void setFieldNameX(const std::string& fieldName) { + _xId = fieldName; + } + /// set the field name used for Y + void setFieldNameY(const std::string& fieldName) { + _yId = fieldName; + } + /** \brief Returns a vector of the cellDimensions of the given cell ID + in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi + + Returns a vector of the cellDimensions of the given cell ID + \param cellID is ignored as all cells have the same dimension + \return std::vector size 2: + -# size in x + -# size in y + */ + virtual std::vector cellDimensions(const CellID& cellID) const; + + protected: + /// the stagger mode: 0=off ; 1=cycle through 3 different offsets (H3) + // 2=cycle through 4 differnt offsets (H4) + int _stagger; + /// the length of one side of a hexagon + double _sideLength; + /// the coordinate offset in X + double _offsetX; + /// the coordinate offset in Y + double _offsetY; + /// the field name used for X + std::string _xId; + /// the field name used for Y + std::string _yId; + }; + + } /* namespace DDSegmentation */ +} /* namespace dd4hep */ +#endif // DDSEGMENTATION_HEXGRID_H diff --git a/DDCore/include/DDSegmentation/SquareGrid.h b/DDCore/include/DDSegmentation/SquareGrid.h new file mode 100644 index 000000000..730ff2dd7 --- /dev/null +++ b/DDCore/include/DDSegmentation/SquareGrid.h @@ -0,0 +1,120 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +//========================================================================== + +/* + * SquareGrid.h + * + * Created on: August 9, 2023 + * Author: Sebouh J. Paul, UC Riverside + */ + +#ifndef DDSEGMENTATION_SQUAREGRID_H +#define DDSEGMENTATION_SQUAREGRID_H + +#include "DDSegmentation/Segmentation.h" + +namespace dd4hep { + namespace DDSegmentation { + + /// Segmentation base class describing cartesian grid segmentation + class SquareGrid: public Segmentation { + public: + /// Destructor + virtual ~SquareGrid(); + //protected: + /// Default constructor used by derived classes passing the encoding string + SquareGrid(const std::string& cellEncoding = ""); + /// Default constructor used by derived classes passing an existing decoder + SquareGrid(const BitFieldCoder* decoder); + + /// determine the position based on the cell ID + virtual Vector3D position(const CellID& cellID) const; + /// determine the cell ID based on the position + virtual CellID cellID(const Vector3D& localPosition, const Vector3D& globalPosition, const VolumeID& volumeID) const; + // access the stagger mode: 0=no stagger; 1=stagger cycling through 3 offsets + int stagger() const { + return _stagger; + } + + /// access the grid size + double sideLength() const { + return _sideLength; + } + /// access the coordinate offset in X + double offsetX() const { + return _offsetX; + } + /// access the coordinate offset in Y + double offsetY() const { + return _offsetY; + } + /// access the field name used for X + const std::string& fieldNameX() const { + return _xId; + } + /// access the field name used for Y + const std::string& fieldNameY() const { + return _yId; + } + + /// set the stagger mode: 0=no stagger; 1=stagger cycling through 3 offsets + void setStagger(int stagger) { + _stagger= stagger; + } + /// set the grid size in X + void setSideLength(double cellSize) { + _sideLength = cellSize; + } + /// set the coordinate offset in X + void setOffsetX(double offset) { + _offsetX = offset; + } + /// set the coordinate offset in Y + void setOffsetY(double offset) { + _offsetY = offset; + } + /// set the field name used for X + void setFieldNameX(const std::string& fieldName) { + _xId = fieldName; + } + /// set the field name used for Y + void setFieldNameY(const std::string& fieldName) { + _yId = fieldName; + } + /** \brief Returns a vector of the cellDimensions of the given cell ID + in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi + + Returns a vector of the cellDimensions of the given cell ID + \param cellID is ignored as all cells have the same dimension + \return std::vector size 2: + -# size in x + -# size in y + */ + virtual std::vector cellDimensions(const CellID& cellID) const; + + protected: + /// the stagger mode: 0=off ; 1=cycle through 2 differnt offsets + int _stagger; + /// the length of one side of a square + double _sideLength; + /// the coordinate offset in X + double _offsetX; + /// the coordinate offset in Y + double _offsetY; + /// the field name used for X + std::string _xId; + /// the field name used for Y + std::string _yId; + }; + + } /* namespace DDSegmentation */ +} /* namespace dd4hep */ +#endif // DDSEGMENTATION_SQUAREGRID_H From 8be52c62980461497f1c6ff6a2e1328ed5a5674d Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 15 Aug 2023 14:09:29 -0400 Subject: [PATCH 03/39] Update HexGrid.h --- DDCore/include/DDSegmentation/HexGrid.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DDCore/include/DDSegmentation/HexGrid.h b/DDCore/include/DDSegmentation/HexGrid.h index 88c77174f..6e1627640 100644 --- a/DDCore/include/DDSegmentation/HexGrid.h +++ b/DDCore/include/DDSegmentation/HexGrid.h @@ -10,7 +10,7 @@ //========================================================================== /* - * CartesianGrid.h + * HexGrid.h * * Created on: August 9, 2023 * Author: Sebouh J. Paul, UC Riverside @@ -24,7 +24,7 @@ namespace dd4hep { namespace DDSegmentation { - /// Segmentation base class describing cartesian grid segmentation + /// Segmentation base class describing hexagonal grid segmentation, with or without staggering class HexGrid: public Segmentation { public: /// Destructor From 8ec6ab6df9f2362939a23b56fdf72b6c77dc1c8f Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 15 Aug 2023 14:10:25 -0400 Subject: [PATCH 04/39] Update SquareGrid.h --- DDCore/include/DDSegmentation/SquareGrid.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DDCore/include/DDSegmentation/SquareGrid.h b/DDCore/include/DDSegmentation/SquareGrid.h index 730ff2dd7..c1d5aa1e5 100644 --- a/DDCore/include/DDSegmentation/SquareGrid.h +++ b/DDCore/include/DDSegmentation/SquareGrid.h @@ -24,7 +24,8 @@ namespace dd4hep { namespace DDSegmentation { - /// Segmentation base class describing cartesian grid segmentation + /// Segmentation base class describing a cartesian grid segmentation with square + /// cells, with or without staggering class SquareGrid: public Segmentation { public: /// Destructor From 90124720701aeb0b40cddbe110cd23d9c7d73bff Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 25 Aug 2023 15:17:40 -0400 Subject: [PATCH 05/39] Update DDCore/src/segmentations/HexGrid.cpp Co-authored-by: Andre Sailer --- DDCore/src/segmentations/HexGrid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DDCore/src/segmentations/HexGrid.cpp b/DDCore/src/segmentations/HexGrid.cpp index 2c551505c..bafd784e7 100644 --- a/DDCore/src/segmentations/HexGrid.cpp +++ b/DDCore/src/segmentations/HexGrid.cpp @@ -5,7 +5,7 @@ * Author: Sebouh J. Paul, UC Riverside */ #include "DD4hep/Factories.h" -#include "HexGrid.h" +#include "DDSegmentation/HexGrid.h" namespace dd4hep { namespace DDSegmentation { From 195024aff130c4274e2bfe2a7f85c500013d55f8 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 25 Aug 2023 15:18:14 -0400 Subject: [PATCH 06/39] Update DDCore/src/segmentations/HexGrid.cpp Co-authored-by: Andre Sailer --- DDCore/src/segmentations/HexGrid.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/DDCore/src/segmentations/HexGrid.cpp b/DDCore/src/segmentations/HexGrid.cpp index bafd784e7..c2689da20 100644 --- a/DDCore/src/segmentations/HexGrid.cpp +++ b/DDCore/src/segmentations/HexGrid.cpp @@ -80,7 +80,6 @@ namespace dd4hep { return std::fmod(std::fmod(i,n) + n,n); } - //inline double positive_floor( /// determine the cell ID based on the position CellID HexGrid::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { From b1f76eb1c4c4b44931954e5780cbe76563c7ae7b Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 25 Aug 2023 15:19:32 -0400 Subject: [PATCH 07/39] Update DDCore/src/segmentations/SquareGrid.cpp Co-authored-by: Andre Sailer --- DDCore/src/segmentations/SquareGrid.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/DDCore/src/segmentations/SquareGrid.cpp b/DDCore/src/segmentations/SquareGrid.cpp index a7d0e8dc7..62441a47d 100644 --- a/DDCore/src/segmentations/SquareGrid.cpp +++ b/DDCore/src/segmentations/SquareGrid.cpp @@ -65,7 +65,6 @@ namespace dd4hep { return std::fmod(std::fmod(i,n) + n,n); } - //inline double positive_floor( /// determine the cell ID based on the position CellID SquareGrid::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { From 22576d0ed4e79e60bdc6573c15dbc6d584e9f62c Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 25 Aug 2023 15:19:47 -0400 Subject: [PATCH 08/39] Update DDCore/src/segmentations/SquareGrid.cpp Co-authored-by: Andre Sailer --- DDCore/src/segmentations/SquareGrid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DDCore/src/segmentations/SquareGrid.cpp b/DDCore/src/segmentations/SquareGrid.cpp index 62441a47d..f64781b07 100644 --- a/DDCore/src/segmentations/SquareGrid.cpp +++ b/DDCore/src/segmentations/SquareGrid.cpp @@ -5,7 +5,7 @@ * Author: Sebouh J. Paul, UC Riverside */ #include "DD4hep/Factories.h" -#include "SquareGrid.h" +#include "DDSegmentation/SquareGrid.h" namespace dd4hep { namespace DDSegmentation { From 84373a217539ac024beafacec1501327381224ab Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 25 Aug 2023 15:28:56 -0400 Subject: [PATCH 09/39] Update HexGrid.cpp removed commented code; fixed indentations --- DDCore/src/segmentations/HexGrid.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/DDCore/src/segmentations/HexGrid.cpp b/DDCore/src/segmentations/HexGrid.cpp index c2689da20..bb00db51b 100644 --- a/DDCore/src/segmentations/HexGrid.cpp +++ b/DDCore/src/segmentations/HexGrid.cpp @@ -13,7 +13,7 @@ namespace dd4hep { /// Default constructor used by derived classes passing the encoding string HexGrid::HexGrid(const std::string& cellEncoding) : Segmentation(cellEncoding) { - _type = "HexGridXY"; + _type = "HexGridXY"; _description = "Hexagonal segmentation in the local XY-plane"; // register all necessary parameters @@ -27,7 +27,7 @@ namespace dd4hep { /// Default constructor used by derived classes passing an existing decoder HexGrid::HexGrid(const BitFieldCoder* decode) : Segmentation(decode) { - // define type and description + // define type and description _type = "HexGridXY"; _description = "Hexagonal segmentation in the local XY-plane"; @@ -61,11 +61,9 @@ namespace dd4hep { cellPosition.X-=0.75*_sideLength; break; case 1: - //cellPosition.X+=0.75*_sideLength; cellPosition.Y+=std::sqrt(3)/4*_sideLength; break; case 2: - //cellPosition.X-=0.75*_sideLength; cellPosition.Y-=std::sqrt(3)/4*_sideLength; break; case 3: @@ -100,11 +98,9 @@ namespace dd4hep { x+=0.75*_sideLength; break; case 1: - //x-=0.75*_sideLength; y-=std::sqrt(3)/4*_sideLength; break; case 2: - //x+=0.75*_sideLength; y+=std::sqrt(3)/4*_sideLength; break; case 3: @@ -119,13 +115,6 @@ namespace dd4hep { (b<0.5)*(-abs(a-.5)<(b-.5)*3)+(b>0.5)*(abs(a-.5)-.5<(b-1)*3); int iy=std::floor(y/(std::sqrt(3)*_sideLength/2.)); iy-=(ix+iy)&1; - - - //int ix=int(floor((localPosition.X - _offsetX) / (3/2*_sideLength))); - //int iy=int(floor((localPosition.Y - _offsetY) / (std::sqrt(3)/2*_sideLength))); - //if((ix+iy)%2 && - // ((localPosition.X-offset_X)/(2*_sideLength)+(localPosition.Y-_offsetX)/(std::sqrt(3)*_sideLength)) - //iy-=1; _decoder->set( cID,_xId, ix ); _decoder->set( cID,_yId, iy ); From ade020d946c0fab99b8266a4a7823d225f314255 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 25 Aug 2023 15:37:21 -0400 Subject: [PATCH 10/39] Update HexGrid.cpp added license information --- DDCore/src/segmentations/HexGrid.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/DDCore/src/segmentations/HexGrid.cpp b/DDCore/src/segmentations/HexGrid.cpp index bb00db51b..77cbd1873 100644 --- a/DDCore/src/segmentations/HexGrid.cpp +++ b/DDCore/src/segmentations/HexGrid.cpp @@ -1,7 +1,15 @@ /* - * HexGrid.cpp + * AIDA Detector description implementation + * + * Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) + * All rights reserved. * - * Created on: August 9, 2023 + * For the licensing terms see $DD4hepINSTALL/LICENSE. + * For the list of contributors see $DD4hepINSTALL/doc/CREDITS. + * + * HexGrid.cpp + * + * Created on: August 9, 2023 * Author: Sebouh J. Paul, UC Riverside */ #include "DD4hep/Factories.h" From 9b7833c04431f588d29e13489c6ae65902e82534 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 25 Aug 2023 15:40:24 -0400 Subject: [PATCH 11/39] Update SquareGrid.cpp added license --- DDCore/src/segmentations/SquareGrid.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/DDCore/src/segmentations/SquareGrid.cpp b/DDCore/src/segmentations/SquareGrid.cpp index f64781b07..d08b441a8 100644 --- a/DDCore/src/segmentations/SquareGrid.cpp +++ b/DDCore/src/segmentations/SquareGrid.cpp @@ -1,4 +1,12 @@ /* + * AIDA Detector description implementation + * + * Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) + * All rights reserved. + * + * For the licensing terms see $DD4hepINSTALL/LICENSE. + * For the list of contributors see $DD4hepINSTALL/doc/CREDITS. + * * SquareGrid.cpp * A square grid in X,Y which has options for staggering in the S2 pattern * Created on: August 9, 2023 From 2ef97dd360aad8447866856eaf5ec9fc61f9da65 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Thu, 31 Aug 2023 08:28:47 -0400 Subject: [PATCH 12/39] Update CartesianGridXY.cpp --- DDCore/src/segmentations/CartesianGridXY.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/DDCore/src/segmentations/CartesianGridXY.cpp b/DDCore/src/segmentations/CartesianGridXY.cpp index f6cd2087f..8e597fd45 100644 --- a/DDCore/src/segmentations/CartesianGridXY.cpp +++ b/DDCore/src/segmentations/CartesianGridXY.cpp @@ -22,6 +22,8 @@ CartesianGridXY::CartesianGridXY(const std::string& cellEncoding) : registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); + registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", _staggerX, 0); + registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", _staggerY, 0); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); } @@ -51,16 +53,17 @@ CartesianGridXY::~CartesianGridXY() { /// determine the position based on the cell ID Vector3D CartesianGridXY::position(const CellID& cID) const { Vector3D cellPosition; - cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX); - cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY); + int layer= _decoder->get(cID,"layer"); + cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2.); + cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY+_staggerY*_gridSizeY*(layer%2)/2.); return cellPosition; } /// determine the cell ID based on the position CellID CartesianGridXY::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { CellID cID = vID ; - _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX) ); - _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY) ); + _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2) ); + _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY+_staggerY*_gridSizeY*(layer%2)/2) ); return cID ; } From 18151d18605c12eb3436cc1fe80eac80e845f576 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 4 Sep 2023 23:24:50 -0400 Subject: [PATCH 13/39] Update CartesianGridXY.h --- .../include/DDSegmentation/CartesianGridXY.h | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/DDCore/include/DDSegmentation/CartesianGridXY.h b/DDCore/include/DDSegmentation/CartesianGridXY.h index 28fef9718..12d5edf02 100644 --- a/DDCore/include/DDSegmentation/CartesianGridXY.h +++ b/DDCore/include/DDSegmentation/CartesianGridXY.h @@ -65,6 +65,18 @@ namespace dd4hep { const std::string& fieldNameY() const { return _yId; } + /// access the staggering option in X + int staggerX() const { + return _staggerX; + } + /// access the staggering option in Y + int staggerY() const { + return _staggerY; + } + /// access the keyword for staggering + const std::string& staggerKeyword() const { + return _staggerKeyword; + } /// set the grid size in X void setGridSizeX(double cellSize) { _gridSizeX = cellSize; @@ -89,6 +101,18 @@ namespace dd4hep { void setFieldNameY(const std::string& fieldName) { _yId = fieldName; } + /// set the staggering option in X + void setStaggerX(int staggerX) { + _staggerX = staggerX; + } + /// set the staggering option in Y + void setStaggerY(int staggerY) { + _staggerY = staggerY; + } + /// set the staggering option in Y + void setStaggerKeyword(const std::string& staggerKeyword) { + _staggerKeyword = staggerKeyword; + } /** \brief Returns a vector of the cellDimensions of the given cell ID in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi @@ -105,14 +129,20 @@ namespace dd4hep { double _gridSizeX; /// the coordinate offset in X double _offsetX; + /// staggering option in X. 0 = no staggering. 1 = stagger by _gridSizeX/2.0 in odd layers + int _staggerX; /// the grid size in Y double _gridSizeY; /// the coordinate offset in Y double _offsetY; + /// staggering option in Y. 0 = no staggering. 1 = stagger by _gridSizeY/2.0 in odd layers + int _staggerY; /// the field name used for X std::string _xId; /// the field name used for Y std::string _yId; + /// the keyword used for staggering + std::string _staggerKeyword; }; } /* namespace DDSegmentation */ From 7d9268e182b5eff80685a40934f50e79bfa79f0f Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 4 Sep 2023 23:28:21 -0400 Subject: [PATCH 14/39] Update CartesianGridXY.cpp --- DDCore/src/segmentations/CartesianGridXY.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DDCore/src/segmentations/CartesianGridXY.cpp b/DDCore/src/segmentations/CartesianGridXY.cpp index 8e597fd45..12d421748 100644 --- a/DDCore/src/segmentations/CartesianGridXY.cpp +++ b/DDCore/src/segmentations/CartesianGridXY.cpp @@ -26,6 +26,7 @@ CartesianGridXY::CartesianGridXY(const std::string& cellEncoding) : registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", _staggerY, 0); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); + registerIdentifier("stagger_keyword", "Cell ID identifier used in staggering", _staggerKeyword, "layer"); } /// Default constructor used by derived classes passing an existing decoder @@ -53,7 +54,7 @@ CartesianGridXY::~CartesianGridXY() { /// determine the position based on the cell ID Vector3D CartesianGridXY::position(const CellID& cID) const { Vector3D cellPosition; - int layer= _decoder->get(cID,"layer"); + int layer= _decoder->get(cID,_staggerKeyword); cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2.); cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY+_staggerY*_gridSizeY*(layer%2)/2.); return cellPosition; From ae359af6c81d32557a0861c46a4c1f307984d852 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 4 Sep 2023 23:29:52 -0400 Subject: [PATCH 15/39] Update CartesianGridXY.cpp --- DDCore/src/segmentations/CartesianGridXY.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/DDCore/src/segmentations/CartesianGridXY.cpp b/DDCore/src/segmentations/CartesianGridXY.cpp index 12d421748..341cc083b 100644 --- a/DDCore/src/segmentations/CartesianGridXY.cpp +++ b/DDCore/src/segmentations/CartesianGridXY.cpp @@ -63,6 +63,7 @@ Vector3D CartesianGridXY::position(const CellID& cID) const { /// determine the cell ID based on the position CellID CartesianGridXY::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { CellID cID = vID ; + int layer= _decoder->get(cID,"layer"); _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2) ); _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY+_staggerY*_gridSizeY*(layer%2)/2) ); return cID ; From 8ca1c9226941f6429c0702b295bb1c8ac78f1928 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 4 Sep 2023 23:31:48 -0400 Subject: [PATCH 16/39] Update HexGrid.cpp --- DDCore/src/segmentations/HexGrid.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/DDCore/src/segmentations/HexGrid.cpp b/DDCore/src/segmentations/HexGrid.cpp index 77cbd1873..889d97efe 100644 --- a/DDCore/src/segmentations/HexGrid.cpp +++ b/DDCore/src/segmentations/HexGrid.cpp @@ -31,6 +31,7 @@ namespace dd4hep { registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); + registerIdentifier("stagger_keyword", "Cell ID identifier used in staggering", _staggerKeyword, "layer"); } /// Default constructor used by derived classes passing an existing decoder @@ -55,7 +56,7 @@ namespace dd4hep { /// determine the position based on the cell ID Vector3D HexGrid::position(const CellID& cID) const { - int layer= _decoder->get(cID,"layer"); + int layer= _decoder->get(cID,_staggerKeyword); Vector3D cellPosition; cellPosition.X = _decoder->get(cID,_xId )*1.5*_sideLength+_offsetX+_sideLength/2.; cellPosition.Y = _decoder->get(cID,_yId )*std::sqrt(3)/2.*_sideLength+ _offsetY+_sideLength*std::sqrt(3)/2.; @@ -90,7 +91,7 @@ namespace dd4hep { /// determine the cell ID based on the position CellID HexGrid::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { CellID cID = vID ; - int layer= _decoder->get(cID,"layer"); + int layer= _decoder->get(cID,_staggerKeyword); double _gridSizeY=std::sqrt(3)*_sideLength/2.; double _gridSizeX=3*_sideLength/2; From 1375ffa0a4f8edeecb5539aaad6dc9889739512c Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 4 Sep 2023 23:32:17 -0400 Subject: [PATCH 17/39] Update CartesianGridXY.cpp --- DDCore/src/segmentations/CartesianGridXY.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DDCore/src/segmentations/CartesianGridXY.cpp b/DDCore/src/segmentations/CartesianGridXY.cpp index 341cc083b..33fd77e07 100644 --- a/DDCore/src/segmentations/CartesianGridXY.cpp +++ b/DDCore/src/segmentations/CartesianGridXY.cpp @@ -63,7 +63,7 @@ Vector3D CartesianGridXY::position(const CellID& cID) const { /// determine the cell ID based on the position CellID CartesianGridXY::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { CellID cID = vID ; - int layer= _decoder->get(cID,"layer"); + int layer= _decoder->get(cID,_staggerKeyword); _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2) ); _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY+_staggerY*_gridSizeY*(layer%2)/2) ); return cID ; From d128b9ab10ac4eb611bff1df96308aa307e87ce8 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 4 Sep 2023 23:32:49 -0400 Subject: [PATCH 18/39] Update CartesianGridXY.cpp --- DDCore/src/segmentations/CartesianGridXY.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/DDCore/src/segmentations/CartesianGridXY.cpp b/DDCore/src/segmentations/CartesianGridXY.cpp index 33fd77e07..b0532fb5e 100644 --- a/DDCore/src/segmentations/CartesianGridXY.cpp +++ b/DDCore/src/segmentations/CartesianGridXY.cpp @@ -44,6 +44,7 @@ CartesianGridXY::CartesianGridXY(const BitFieldCoder* decode) : registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); + registerIdentifier("stagger_keyword", "Cell ID identifier used in staggering", _staggerKeyword, "layer"); } /// destructor From f2dc23adf1b5ef716707d9de65d92963db495fd8 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 4 Sep 2023 23:33:18 -0400 Subject: [PATCH 19/39] Update HexGrid.cpp --- DDCore/src/segmentations/HexGrid.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/DDCore/src/segmentations/HexGrid.cpp b/DDCore/src/segmentations/HexGrid.cpp index 889d97efe..69210c485 100644 --- a/DDCore/src/segmentations/HexGrid.cpp +++ b/DDCore/src/segmentations/HexGrid.cpp @@ -47,6 +47,7 @@ namespace dd4hep { registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); + registerIdentifier("stagger_keyword", "Cell ID identifier used in staggering", _staggerKeyword, "layer"); } From 6546b6ba905c73ac853b244a1a7935b8d68f4e8c Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 4 Sep 2023 23:47:56 -0400 Subject: [PATCH 20/39] Update HexGrid.h --- DDCore/include/DDSegmentation/HexGrid.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/DDCore/include/DDSegmentation/HexGrid.h b/DDCore/include/DDSegmentation/HexGrid.h index 6e1627640..d6599da6a 100644 --- a/DDCore/include/DDSegmentation/HexGrid.h +++ b/DDCore/include/DDSegmentation/HexGrid.h @@ -64,7 +64,11 @@ namespace dd4hep { const std::string& fieldNameY() const { return _yId; } - + /// access the keyword for staggering + const std::string& staggerKeyword() const { + return _staggerKeyword; + } + /// set the stagger mode: 0=no stagger; 1=stagger cycling through 3 offsets void setStagger(int stagger) { _stagger= stagger; From bcefcd194cc96daabd1d11d926e2f751c1b7f96c Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 4 Sep 2023 23:49:11 -0400 Subject: [PATCH 21/39] Update CartesianGridXY.h --- DDCore/include/DDSegmentation/CartesianGridXY.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DDCore/include/DDSegmentation/CartesianGridXY.h b/DDCore/include/DDSegmentation/CartesianGridXY.h index 12d5edf02..6b56a2a27 100644 --- a/DDCore/include/DDSegmentation/CartesianGridXY.h +++ b/DDCore/include/DDSegmentation/CartesianGridXY.h @@ -73,7 +73,7 @@ namespace dd4hep { int staggerY() const { return _staggerY; } - /// access the keyword for staggering + /// access the keyword used to determine which volumes to stagger const std::string& staggerKeyword() const { return _staggerKeyword; } @@ -109,7 +109,7 @@ namespace dd4hep { void setStaggerY(int staggerY) { _staggerY = staggerY; } - /// set the staggering option in Y + /// set the keyword used to determine which volumes to stagger void setStaggerKeyword(const std::string& staggerKeyword) { _staggerKeyword = staggerKeyword; } @@ -141,7 +141,7 @@ namespace dd4hep { std::string _xId; /// the field name used for Y std::string _yId; - /// the keyword used for staggering + /// the keyword used to determine which volumes to stagger std::string _staggerKeyword; }; From 9851acd1df4709fe7b30e19c72a4269a7ad8e3f1 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 4 Sep 2023 23:50:37 -0400 Subject: [PATCH 22/39] Update HexGrid.h --- DDCore/include/DDSegmentation/HexGrid.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/DDCore/include/DDSegmentation/HexGrid.h b/DDCore/include/DDSegmentation/HexGrid.h index d6599da6a..a0c29e013 100644 --- a/DDCore/include/DDSegmentation/HexGrid.h +++ b/DDCore/include/DDSegmentation/HexGrid.h @@ -93,6 +93,10 @@ namespace dd4hep { void setFieldNameY(const std::string& fieldName) { _yId = fieldName; } + /// set the keyword used to determine which volumes to stagger + void setStaggerKeyword(const std::string& staggerKeyword) { + _staggerKeyword = staggerKeyword); + } /** \brief Returns a vector of the cellDimensions of the given cell ID in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi @@ -118,6 +122,8 @@ namespace dd4hep { std::string _xId; /// the field name used for Y std::string _yId; + /// the keyword used to determine which volumes to stagger + std::string _staggerKeyword; }; } /* namespace DDSegmentation */ From 1b8a78f02d9bc52e07ba485cadeecdd0b134cef3 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 4 Sep 2023 23:51:59 -0400 Subject: [PATCH 23/39] Update HexGrid.cpp --- DDCore/src/segmentations/HexGrid.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DDCore/src/segmentations/HexGrid.cpp b/DDCore/src/segmentations/HexGrid.cpp index 69210c485..c10ff1645 100644 --- a/DDCore/src/segmentations/HexGrid.cpp +++ b/DDCore/src/segmentations/HexGrid.cpp @@ -31,7 +31,7 @@ namespace dd4hep { registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); - registerIdentifier("stagger_keyword", "Cell ID identifier used in staggering", _staggerKeyword, "layer"); + registerIdentifier("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, "layer"); } /// Default constructor used by derived classes passing an existing decoder @@ -47,7 +47,7 @@ namespace dd4hep { registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); - registerIdentifier("stagger_keyword", "Cell ID identifier used in staggering", _staggerKeyword, "layer"); + registerIdentifier("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, "layer"); } From edc80c1e13d317e8498debe806b2912a1edf566a Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Mon, 4 Sep 2023 23:53:57 -0400 Subject: [PATCH 24/39] Update CartesianGridXY.cpp --- DDCore/src/segmentations/CartesianGridXY.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/DDCore/src/segmentations/CartesianGridXY.cpp b/DDCore/src/segmentations/CartesianGridXY.cpp index b0532fb5e..8bb948b9c 100644 --- a/DDCore/src/segmentations/CartesianGridXY.cpp +++ b/DDCore/src/segmentations/CartesianGridXY.cpp @@ -26,7 +26,7 @@ CartesianGridXY::CartesianGridXY(const std::string& cellEncoding) : registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", _staggerY, 0); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); - registerIdentifier("stagger_keyword", "Cell ID identifier used in staggering", _staggerKeyword, "layer"); + registerIdentifier("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, "layer"); } /// Default constructor used by derived classes passing an existing decoder @@ -42,9 +42,11 @@ CartesianGridXY::CartesianGridXY(const BitFieldCoder* decode) : registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); + registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", _staggerX, 0); + registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", _staggerY, 0); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); - registerIdentifier("stagger_keyword", "Cell ID identifier used in staggering", _staggerKeyword, "layer"); + registerIdentifier("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, "layer"); } /// destructor From d1e90a24a0ea8282b962b8b1a52fe45f842b31ed Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 5 Sep 2023 11:24:25 -0400 Subject: [PATCH 25/39] removed SquareGrid.h and SquareGrid.cpp, which became redundant when adding staggering option to the CartesianGridXY --- DDCore/include/DDSegmentation/SquareGrid.h | 121 --------------------- DDCore/src/segmentations/SquareGrid.cpp | 112 ------------------- 2 files changed, 233 deletions(-) delete mode 100644 DDCore/include/DDSegmentation/SquareGrid.h delete mode 100644 DDCore/src/segmentations/SquareGrid.cpp diff --git a/DDCore/include/DDSegmentation/SquareGrid.h b/DDCore/include/DDSegmentation/SquareGrid.h deleted file mode 100644 index c1d5aa1e5..000000000 --- a/DDCore/include/DDSegmentation/SquareGrid.h +++ /dev/null @@ -1,121 +0,0 @@ -//========================================================================== -// AIDA Detector description implementation -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see $DD4hepINSTALL/LICENSE. -// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. -// -//========================================================================== - -/* - * SquareGrid.h - * - * Created on: August 9, 2023 - * Author: Sebouh J. Paul, UC Riverside - */ - -#ifndef DDSEGMENTATION_SQUAREGRID_H -#define DDSEGMENTATION_SQUAREGRID_H - -#include "DDSegmentation/Segmentation.h" - -namespace dd4hep { - namespace DDSegmentation { - - /// Segmentation base class describing a cartesian grid segmentation with square - /// cells, with or without staggering - class SquareGrid: public Segmentation { - public: - /// Destructor - virtual ~SquareGrid(); - //protected: - /// Default constructor used by derived classes passing the encoding string - SquareGrid(const std::string& cellEncoding = ""); - /// Default constructor used by derived classes passing an existing decoder - SquareGrid(const BitFieldCoder* decoder); - - /// determine the position based on the cell ID - virtual Vector3D position(const CellID& cellID) const; - /// determine the cell ID based on the position - virtual CellID cellID(const Vector3D& localPosition, const Vector3D& globalPosition, const VolumeID& volumeID) const; - // access the stagger mode: 0=no stagger; 1=stagger cycling through 3 offsets - int stagger() const { - return _stagger; - } - - /// access the grid size - double sideLength() const { - return _sideLength; - } - /// access the coordinate offset in X - double offsetX() const { - return _offsetX; - } - /// access the coordinate offset in Y - double offsetY() const { - return _offsetY; - } - /// access the field name used for X - const std::string& fieldNameX() const { - return _xId; - } - /// access the field name used for Y - const std::string& fieldNameY() const { - return _yId; - } - - /// set the stagger mode: 0=no stagger; 1=stagger cycling through 3 offsets - void setStagger(int stagger) { - _stagger= stagger; - } - /// set the grid size in X - void setSideLength(double cellSize) { - _sideLength = cellSize; - } - /// set the coordinate offset in X - void setOffsetX(double offset) { - _offsetX = offset; - } - /// set the coordinate offset in Y - void setOffsetY(double offset) { - _offsetY = offset; - } - /// set the field name used for X - void setFieldNameX(const std::string& fieldName) { - _xId = fieldName; - } - /// set the field name used for Y - void setFieldNameY(const std::string& fieldName) { - _yId = fieldName; - } - /** \brief Returns a vector of the cellDimensions of the given cell ID - in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi - - Returns a vector of the cellDimensions of the given cell ID - \param cellID is ignored as all cells have the same dimension - \return std::vector size 2: - -# size in x - -# size in y - */ - virtual std::vector cellDimensions(const CellID& cellID) const; - - protected: - /// the stagger mode: 0=off ; 1=cycle through 2 differnt offsets - int _stagger; - /// the length of one side of a square - double _sideLength; - /// the coordinate offset in X - double _offsetX; - /// the coordinate offset in Y - double _offsetY; - /// the field name used for X - std::string _xId; - /// the field name used for Y - std::string _yId; - }; - - } /* namespace DDSegmentation */ -} /* namespace dd4hep */ -#endif // DDSEGMENTATION_SQUAREGRID_H diff --git a/DDCore/src/segmentations/SquareGrid.cpp b/DDCore/src/segmentations/SquareGrid.cpp deleted file mode 100644 index d08b441a8..000000000 --- a/DDCore/src/segmentations/SquareGrid.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * AIDA Detector description implementation - * - * Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) - * All rights reserved. - * - * For the licensing terms see $DD4hepINSTALL/LICENSE. - * For the list of contributors see $DD4hepINSTALL/doc/CREDITS. - * - * SquareGrid.cpp - * A square grid in X,Y which has options for staggering in the S2 pattern - * Created on: August 9, 2023 - * Author: Sebouh J. Paul, UC Riverside - */ -#include "DD4hep/Factories.h" -#include "DDSegmentation/SquareGrid.h" - -namespace dd4hep { - namespace DDSegmentation { - - /// Default constructor used by derived classes passing the encoding string - SquareGrid::SquareGrid(const std::string& cellEncoding) : - Segmentation(cellEncoding) { - _type = "SquareGridXY"; - _description = "Square segmentation in the local XY-plane"; - - // register all necessary parameters - registerParameter("stagger", "stagger mode", _stagger, 1); - registerParameter("side_length", "Cell size", _sideLength, 1., SegmentationParameter::LengthUnit); - registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); - registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); - registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); - registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); - } - - /// Default constructor used by derived classes passing an existing decoder - SquareGrid::SquareGrid(const BitFieldCoder* decode) : Segmentation(decode) { - // define type and description - _type = "SquareGridXY"; - _description = "Square segmentation in the local XY-plane"; - - // register all necessary parameters - registerParameter("stagger", "stagger mode", _stagger, 1); - registerParameter("side_length", "Cell size", _sideLength, 1., SegmentationParameter::LengthUnit); - registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); - registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); - registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); - registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); - - } - - /// Destructor - SquareGrid::~SquareGrid() { - } - - /// determine the position based on the cell ID - Vector3D SquareGrid::position(const CellID& cID) const { - int layer= _decoder->get(cID,"layer"); - Vector3D cellPosition; - cellPosition.X = _decoder->get(cID,_xId )*_sideLength+_offsetX+_sideLength/2.; - cellPosition.Y = _decoder->get(cID,_yId )*_sideLength+_offsetY+_sideLength/2.; - - - if (_stagger==1){ - cellPosition.X+=(layer%2)*_sideLength/2; - cellPosition.Y+=(layer%2)*_sideLength/2; - } - - return cellPosition; - } - - inline double positive_modulo(double i, double n) { - return std::fmod(std::fmod(i,n) + n,n); - } - - - /// determine the cell ID based on the position - CellID SquareGrid::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { - CellID cID = vID ; - int layer= _decoder->get(cID,"layer"); - - double x=localPosition.X-_offsetX; - double y=localPosition.Y-_offsetY; - - if (_stagger==1){ - x-=(layer%2)*_sideLength/2; - y-=(layer%2)*_sideLength/2; - } - - int ix = std::floor(x/_sideLength); - int iy = std::floor(y/_sideLength); - - _decoder->set( cID,_xId, ix ); - _decoder->set( cID,_yId, iy ); - return cID ; - } - - std::vector SquareGrid::cellDimensions(const CellID&) const { -#if __cplusplus >= 201103L - return {_sideLength, _sideLength}; -#else - std::vector cellDims(2,0.0); - cellDims[0] = _sideLength; - cellDims[1] = _sideLength; - return cellDims; -#endif -} - - } /* namespace DDSegmentation */ -} /* namespace dd4hep */ - -DECLARE_SEGMENTATION(SquareGrid, create_segmentation) From c90594c9ffeb445beb52ea78e70a00dedf824213 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 5 Sep 2023 14:35:21 -0400 Subject: [PATCH 26/39] Update DDCore/include/DDSegmentation/HexGrid.h Co-authored-by: Andre Sailer --- DDCore/include/DDSegmentation/HexGrid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DDCore/include/DDSegmentation/HexGrid.h b/DDCore/include/DDSegmentation/HexGrid.h index a0c29e013..434177790 100644 --- a/DDCore/include/DDSegmentation/HexGrid.h +++ b/DDCore/include/DDSegmentation/HexGrid.h @@ -95,7 +95,7 @@ namespace dd4hep { } /// set the keyword used to determine which volumes to stagger void setStaggerKeyword(const std::string& staggerKeyword) { - _staggerKeyword = staggerKeyword); + _staggerKeyword = staggerKeyword; } /** \brief Returns a vector of the cellDimensions of the given cell ID in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi From 45e43859a63da09057ccf0b5e2592c630424beff Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 5 Sep 2023 14:47:30 -0400 Subject: [PATCH 27/39] Update HexGrid.cpp removed unused variables --- DDCore/src/segmentations/HexGrid.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/DDCore/src/segmentations/HexGrid.cpp b/DDCore/src/segmentations/HexGrid.cpp index c10ff1645..63dab2dde 100644 --- a/DDCore/src/segmentations/HexGrid.cpp +++ b/DDCore/src/segmentations/HexGrid.cpp @@ -93,8 +93,6 @@ namespace dd4hep { CellID HexGrid::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { CellID cID = vID ; int layer= _decoder->get(cID,_staggerKeyword); - double _gridSizeY=std::sqrt(3)*_sideLength/2.; - double _gridSizeX=3*_sideLength/2; double x=localPosition.X-_offsetX; double y=localPosition.Y-_offsetY; From 9816e48825c1f0bb6746a4db90e8e07d477d1af5 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 5 Sep 2023 17:39:14 -0400 Subject: [PATCH 28/39] Update CartesianGridXY.cpp make staggering parameters optional for CartesianGridXY --- DDCore/src/segmentations/CartesianGridXY.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/DDCore/src/segmentations/CartesianGridXY.cpp b/DDCore/src/segmentations/CartesianGridXY.cpp index 8bb948b9c..3bb2dca33 100644 --- a/DDCore/src/segmentations/CartesianGridXY.cpp +++ b/DDCore/src/segmentations/CartesianGridXY.cpp @@ -22,11 +22,14 @@ CartesianGridXY::CartesianGridXY(const std::string& cellEncoding) : registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); - registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", _staggerX, 0); - registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", _staggerY, 0); + registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", _staggerX, 0, + SegmentationParameter::NoUnit, false); + registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", _staggerY, 0, + SegmentationParameter::NoUnit, false); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); - registerIdentifier("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, "layer"); + registerIdentifier("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, "layer", + SegmentationParameter::NoUnit, false); } /// Default constructor used by derived classes passing an existing decoder @@ -42,11 +45,14 @@ CartesianGridXY::CartesianGridXY(const BitFieldCoder* decode) : registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); - registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", _staggerX, 0); - registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", _staggerY, 0); + registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", _staggerX, 0, + SegmentationParameter::NoUnit, false); + registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", _staggerY, 0, + SegmentationParameter::NoUnit, false); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); - registerIdentifier("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, "layer"); + registerIdentifier("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, "layer", + SegmentationParameter::NoUnit, false); } /// destructor From 9ce45fb7b64af4858f8f550f6b16cb460b45b35d Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 5 Sep 2023 18:50:57 -0400 Subject: [PATCH 29/39] Update CartesianGridXY.cpp --- DDCore/src/segmentations/CartesianGridXY.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/DDCore/src/segmentations/CartesianGridXY.cpp b/DDCore/src/segmentations/CartesianGridXY.cpp index 3bb2dca33..b5db3be47 100644 --- a/DDCore/src/segmentations/CartesianGridXY.cpp +++ b/DDCore/src/segmentations/CartesianGridXY.cpp @@ -23,13 +23,13 @@ CartesianGridXY::CartesianGridXY(const std::string& cellEncoding) : registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", _staggerX, 0, - SegmentationParameter::NoUnit, false); + SegmentationParameter::NoUnit, true); registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", _staggerY, 0, - SegmentationParameter::NoUnit, false); + SegmentationParameter::NoUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); registerIdentifier("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, "layer", - SegmentationParameter::NoUnit, false); + SegmentationParameter::NoUnit, true); } /// Default constructor used by derived classes passing an existing decoder @@ -46,13 +46,13 @@ CartesianGridXY::CartesianGridXY(const BitFieldCoder* decode) : registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", _staggerX, 0, - SegmentationParameter::NoUnit, false); + SegmentationParameter::NoUnit, true); registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", _staggerY, 0, - SegmentationParameter::NoUnit, false); + SegmentationParameter::NoUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); registerIdentifier("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, "layer", - SegmentationParameter::NoUnit, false); + SegmentationParameter::NoUnit, true); } /// destructor From e2ed0506988c376beb75ed1b8aefbfb81237615c Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Wed, 6 Sep 2023 12:51:28 -0400 Subject: [PATCH 30/39] ... --- DDCore/src/segmentations/CartesianGridXY.cpp | 4 ++-- DDCore/src/segmentations/HexGrid.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DDCore/src/segmentations/CartesianGridXY.cpp b/DDCore/src/segmentations/CartesianGridXY.cpp index b5db3be47..1a80d7a27 100644 --- a/DDCore/src/segmentations/CartesianGridXY.cpp +++ b/DDCore/src/segmentations/CartesianGridXY.cpp @@ -28,7 +28,7 @@ CartesianGridXY::CartesianGridXY(const std::string& cellEncoding) : SegmentationParameter::NoUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); - registerIdentifier("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, "layer", + registerParameter("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, (std::string)"layer", SegmentationParameter::NoUnit, true); } @@ -51,7 +51,7 @@ CartesianGridXY::CartesianGridXY(const BitFieldCoder* decode) : SegmentationParameter::NoUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); - registerIdentifier("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, "layer", + registerParameter("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, (std::string)"layer", SegmentationParameter::NoUnit, true); } diff --git a/DDCore/src/segmentations/HexGrid.cpp b/DDCore/src/segmentations/HexGrid.cpp index 63dab2dde..a5a6e7b64 100644 --- a/DDCore/src/segmentations/HexGrid.cpp +++ b/DDCore/src/segmentations/HexGrid.cpp @@ -31,7 +31,7 @@ namespace dd4hep { registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); - registerIdentifier("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, "layer"); + registerParameter("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, (std::string)"layer", SegmentationParameter::NoUnit, true); } /// Default constructor used by derived classes passing an existing decoder @@ -47,7 +47,7 @@ namespace dd4hep { registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); - registerIdentifier("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, "layer"); + registerParameter("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, (std::string)"layer", SegmentationParameter::NoUnit, true); } From c07dfd4321782066c330afb13e764b7ec6fdc76f Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 12 Sep 2023 12:16:06 -0400 Subject: [PATCH 31/39] Update CartesianGridXY.cpp do not assume that there exists a keyword corresponding to the layer, unless staggering is enabled --- DDCore/src/segmentations/CartesianGridXY.cpp | 22 ++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/DDCore/src/segmentations/CartesianGridXY.cpp b/DDCore/src/segmentations/CartesianGridXY.cpp index 1a80d7a27..bd4e2a73b 100644 --- a/DDCore/src/segmentations/CartesianGridXY.cpp +++ b/DDCore/src/segmentations/CartesianGridXY.cpp @@ -63,18 +63,28 @@ CartesianGridXY::~CartesianGridXY() { /// determine the position based on the cell ID Vector3D CartesianGridXY::position(const CellID& cID) const { Vector3D cellPosition; - int layer= _decoder->get(cID,_staggerKeyword); - cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2.); - cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY+_staggerY*_gridSizeY*(layer%2)/2.); + if (_staggerX || _staggerY){ + int layer= _decoder->get(cID,_staggerKeyword); + cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2.); + cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY+_staggerY*_gridSizeY*(layer%2)/2.); + } else { + cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX); + cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY); + } return cellPosition; } /// determine the cell ID based on the position CellID CartesianGridXY::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { CellID cID = vID ; - int layer= _decoder->get(cID,_staggerKeyword); - _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2) ); - _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY+_staggerY*_gridSizeY*(layer%2)/2) ); + if (_staggerX || _staggerY){ + int layer= _decoder->get(cID,_staggerKeyword); + _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2) ); + _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY+_staggerY*_gridSizeY*(layer%2)/2) ); + } else { + _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX); + _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY); + } return cID ; } From c16d729fb109a2d68fd2f7d1b4c432b51c55591b Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 12 Sep 2023 12:18:51 -0400 Subject: [PATCH 32/39] Update HexGrid.cpp avoid crashing if there is no field called "layer" or some equivalent thereof. --- DDCore/src/segmentations/HexGrid.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/DDCore/src/segmentations/HexGrid.cpp b/DDCore/src/segmentations/HexGrid.cpp index a5a6e7b64..ce35e74d4 100644 --- a/DDCore/src/segmentations/HexGrid.cpp +++ b/DDCore/src/segmentations/HexGrid.cpp @@ -57,7 +57,10 @@ namespace dd4hep { /// determine the position based on the cell ID Vector3D HexGrid::position(const CellID& cID) const { - int layer= _decoder->get(cID,_staggerKeyword); + int layer=0; + if (_stagger) + layer= _decoder->get(cID,_staggerKeyword); + Vector3D cellPosition; cellPosition.X = _decoder->get(cID,_xId )*1.5*_sideLength+_offsetX+_sideLength/2.; cellPosition.Y = _decoder->get(cID,_yId )*std::sqrt(3)/2.*_sideLength+ _offsetY+_sideLength*std::sqrt(3)/2.; @@ -92,7 +95,8 @@ namespace dd4hep { /// determine the cell ID based on the position CellID HexGrid::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { CellID cID = vID ; - int layer= _decoder->get(cID,_staggerKeyword); + int layer=0; + if (_stagger) layer= _decoder->get(cID,_staggerKeyword); double x=localPosition.X-_offsetX; double y=localPosition.Y-_offsetY; From 551fe45a8c85f604ee755c0d04b3f46634ea265b Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 12 Sep 2023 12:19:10 -0400 Subject: [PATCH 33/39] Update HexGrid.cpp --- DDCore/src/segmentations/HexGrid.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/DDCore/src/segmentations/HexGrid.cpp b/DDCore/src/segmentations/HexGrid.cpp index ce35e74d4..f051a8f61 100644 --- a/DDCore/src/segmentations/HexGrid.cpp +++ b/DDCore/src/segmentations/HexGrid.cpp @@ -58,8 +58,7 @@ namespace dd4hep { /// determine the position based on the cell ID Vector3D HexGrid::position(const CellID& cID) const { int layer=0; - if (_stagger) - layer= _decoder->get(cID,_staggerKeyword); + if (_stagger) layer= _decoder->get(cID,_staggerKeyword); Vector3D cellPosition; cellPosition.X = _decoder->get(cID,_xId )*1.5*_sideLength+_offsetX+_sideLength/2.; From 898186b32b706cae08b1777196b93fca44f394b8 Mon Sep 17 00:00:00 2001 From: Andre Sailer Date: Tue, 12 Sep 2023 19:06:17 +0200 Subject: [PATCH 34/39] CartesianGridXY: add missing parenthesis --- DDCore/src/segmentations/CartesianGridXY.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DDCore/src/segmentations/CartesianGridXY.cpp b/DDCore/src/segmentations/CartesianGridXY.cpp index bd4e2a73b..53828803e 100644 --- a/DDCore/src/segmentations/CartesianGridXY.cpp +++ b/DDCore/src/segmentations/CartesianGridXY.cpp @@ -82,8 +82,8 @@ Vector3D CartesianGridXY::position(const CellID& cID) const { _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2) ); _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY+_staggerY*_gridSizeY*(layer%2)/2) ); } else { - _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX); - _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY); + _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX)); + _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY)); } return cID ; } From 18146dee705843b79600f11beba5fd1180ba0c71 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 15 Sep 2023 13:42:05 -0400 Subject: [PATCH 35/39] added CartesianGridXYStaggered.cpp and .h --- .../DDSegmentation/CartesianGridXYStaggered.h | 150 ++++++++++++++++++ .../CartesianGridXYStaggered.cpp | 98 ++++++++++++ 2 files changed, 248 insertions(+) create mode 100644 DDCore/include/DDSegmentation/CartesianGridXYStaggered.h create mode 100644 DDCore/src/segmentations/CartesianGridXYStaggered.cpp diff --git a/DDCore/include/DDSegmentation/CartesianGridXYStaggered.h b/DDCore/include/DDSegmentation/CartesianGridXYStaggered.h new file mode 100644 index 000000000..441026adf --- /dev/null +++ b/DDCore/include/DDSegmentation/CartesianGridXYStaggered.h @@ -0,0 +1,150 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +//========================================================================== + + + + +/* + * CartesianGridXYStaggered.h + * + * Created on: September 15, 2023 + * Author: Sebouh J. Paul, UCR + */ + +#ifndef DDSEGMENTATION_CARTESIANGRIDXYSTAGGERED_H +#define DDSEGMENTATION_CARTESIANGRIDXYSTAGGERED_H + +#include "DDSegmentation/CartesianGrid.h" + +namespace dd4hep { + namespace DDSegmentation { + + /// Segmentation base class describing cartesian grid segmentation in the X-Y plane + class CartesianGridXYStaggered: public CartesianGrid { + public: + /// Default constructor passing the encoding string + CartesianGridXYStaggered(const std::string& cellEncoding = ""); + /// Default constructor used by derived classes passing an existing decoder + CartesianGridXYStaggered(const BitFieldCoder* decoder); + /// destructor + virtual ~CartesianGridXYStaggered(); + + /// determine the position based on the cell ID + virtual Vector3D position(const CellID& cellID) const; + /// determine the cell ID based on the position + virtual CellID cellID(const Vector3D& localPosition, const Vector3D& globalPosition, const VolumeID& volumeID) const; + /// access the grid size in X + double gridSizeX() const { + return _gridSizeX; + } + /// access the grid size in Y + double gridSizeY() const { + return _gridSizeY; + } + /// access the coordinate offset in X + double offsetX() const { + return _offsetX; + } + /// access the coordinate offset in Y + double offsetY() const { + return _offsetY; + } + /// access the field name used for X + const std::string& fieldNameX() const { + return _xId; + } + /// access the field name used for Y + const std::string& fieldNameY() const { + return _yId; + } + /// access the staggering option in X + int staggerX() const { + return _staggerX; + } + /// access the staggering option in Y + int staggerY() const { + return _staggerY; + } + /// access the keyword used to determine which volumes to stagger + const std::string& staggerKeyword() const { + return _staggerKeyword; + } + /// set the grid size in X + void setGridSizeX(double cellSize) { + _gridSizeX = cellSize; + } + /// set the grid size in Y + void setGridSizeY(double cellSize) { + _gridSizeY = cellSize; + } + /// set the coordinate offset in X + void setOffsetX(double offset) { + _offsetX = offset; + } + /// set the coordinate offset in Y + void setOffsetY(double offset) { + _offsetY = offset; + } + /// set the field name used for X + void setFieldNameX(const std::string& fieldName) { + _xId = fieldName; + } + /// set the field name used for Y + void setFieldNameY(const std::string& fieldName) { + _yId = fieldName; + } + /// set the staggering option in X + void setStaggerX(int staggerX) { + _staggerX = staggerX; + } + /// set the staggering option in Y + void setStaggerY(int staggerY) { + _staggerY = staggerY; + } + /// set the keyword used to determine which volumes to stagger + void setStaggerKeyword(const std::string& staggerKeyword) { + _staggerKeyword = staggerKeyword; + } + /** \brief Returns a vector of the cellDimensions of the given cell ID + in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi + + Returns a vector of the cellDimensions of the given cell ID + \param cellID is ignored as all cells have the same dimension + \return std::vector size 2: + -# size in x + -# size in y + */ + virtual std::vector cellDimensions(const CellID& cellID) const; + + protected: + /// the grid size in X + double _gridSizeX; + /// the coordinate offset in X + double _offsetX; + /// staggering option in X. 0 = no staggering. 1 = stagger by _gridSizeX/2.0 in odd layers + int _staggerX; + /// the grid size in Y + double _gridSizeY; + /// the coordinate offset in Y + double _offsetY; + /// staggering option in Y. 0 = no staggering. 1 = stagger by _gridSizeY/2.0 in odd layers + int _staggerY; + /// the field name used for X + std::string _xId; + /// the field name used for Y + std::string _yId; + /// the keyword used to determine which volumes to stagger + std::string _staggerKeyword; + }; + + } /* namespace DDSegmentation */ +} /* namespace dd4hep */ +#endif // DDSEGMENTATION_CARTESIANGRIDXYSTAGGERED_H diff --git a/DDCore/src/segmentations/CartesianGridXYStaggered.cpp b/DDCore/src/segmentations/CartesianGridXYStaggered.cpp new file mode 100644 index 000000000..1a6066aa2 --- /dev/null +++ b/DDCore/src/segmentations/CartesianGridXYStaggered.cpp @@ -0,0 +1,98 @@ +/* + * CartesianGridXYStaggered.cpp + * + * Created on: September 15, 2023 + * Author: Sebouh J. Paul, UCR + */ + +#include "DDSegmentation/CartesianGridXYStaggered.h" + +namespace dd4hep { +namespace DDSegmentation { + +/// default constructor using an encoding string +CartesianGridXYStaggered::CartesianGridXYStaggered(const std::string& cellEncoding) : + CartesianGrid(cellEncoding) { + // define type and description + _type = "CartesianGridXYStaggered"; + _description = "Cartesian segmentation in the local XY-plane, with options for staggering"; + + // register all necessary parameters + registerParameter("grid_size_x", "Cell size in X", _gridSizeX, 1., SegmentationParameter::LengthUnit); + registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); + registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); + registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); + registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", _staggerX, 0, + SegmentationParameter::NoUnit, true); + registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", _staggerY, 0, + SegmentationParameter::NoUnit, true); + registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); + registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); + registerParameter("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, (std::string)"layer", + SegmentationParameter::NoUnit, true); +} + +/// Default constructor used by derived classes passing an existing decoder +CartesianGridXYStaggered::CartesianGridXYStaggered(const BitFieldCoder* decode) : + CartesianGrid(decode) +{ + // define type and description + _type = "CartesianGridXYStaggered"; + _description = "Cartesian segmentation in the local XY-plane, with options for staggering"; + + // register all necessary parameters + registerParameter("grid_size_x", "Cell size in X", _gridSizeX, 1., SegmentationParameter::LengthUnit); + registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); + registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); + registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); + registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", _staggerX, 0, + SegmentationParameter::NoUnit, true); + registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", _staggerY, 0, + SegmentationParameter::NoUnit, true); + registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); + registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); + registerParameter("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, (std::string)"layer", + SegmentationParameter::NoUnit, true); +} + +/// destructor +CartesianGridXYStaggered::~CartesianGridXYStaggered() { + +} + +/// determine the position based on the cell ID +Vector3D CartesianGridXYStaggered::position(const CellID& cID) const { + Vector3D cellPosition; + int layer= _decoder->get(cID,_staggerKeyword); + cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2.); + cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY+_staggerY*_gridSizeY*(layer%2)/2.); + return cellPosition; +} + +/// determine the cell ID based on the position + CellID CartesianGridXYStaggered::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { + CellID cID = vID ; + int layer= _decoder->get(cID,_staggerKeyword); + _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2) ); + _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY+_staggerY*_gridSizeY*(layer%2)/2) ); + return cID ; +} + +std::vector CartesianGridXYStaggered::cellDimensions(const CellID&) const { +#if __cplusplus >= 201103L + return {_gridSizeX, _gridSizeY}; +#else + std::vector cellDims(2,0.0); + cellDims[0] = _gridSizeX; + cellDims[1] = _gridSizeY; + return cellDims; +#endif +} + + +} /* namespace DDSegmentation */ +} /* namespace dd4hep */ + +// This is done DDCore/src/plugins/ReadoutSegmentations.cpp so the plugin is not part of libDDCore +// needs also #include "DD4hep/Factories.h" +// DECLARE_SEGMENTATION(CartesianGridXYStaggered,dd4hep::create_segmentation) From 1138508795533a566b0af3b6dde44ed017812e8b Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 15 Sep 2023 13:45:14 -0400 Subject: [PATCH 36/39] reverted CartesianGridXY.h and CartesianGridXY.cpp to the upstream master versions --- .../include/DDSegmentation/CartesianGridXY.h | 30 ------------------- DDCore/src/segmentations/CartesianGridXY.cpp | 22 +++----------- 2 files changed, 4 insertions(+), 48 deletions(-) diff --git a/DDCore/include/DDSegmentation/CartesianGridXY.h b/DDCore/include/DDSegmentation/CartesianGridXY.h index 6b56a2a27..28fef9718 100644 --- a/DDCore/include/DDSegmentation/CartesianGridXY.h +++ b/DDCore/include/DDSegmentation/CartesianGridXY.h @@ -65,18 +65,6 @@ namespace dd4hep { const std::string& fieldNameY() const { return _yId; } - /// access the staggering option in X - int staggerX() const { - return _staggerX; - } - /// access the staggering option in Y - int staggerY() const { - return _staggerY; - } - /// access the keyword used to determine which volumes to stagger - const std::string& staggerKeyword() const { - return _staggerKeyword; - } /// set the grid size in X void setGridSizeX(double cellSize) { _gridSizeX = cellSize; @@ -101,18 +89,6 @@ namespace dd4hep { void setFieldNameY(const std::string& fieldName) { _yId = fieldName; } - /// set the staggering option in X - void setStaggerX(int staggerX) { - _staggerX = staggerX; - } - /// set the staggering option in Y - void setStaggerY(int staggerY) { - _staggerY = staggerY; - } - /// set the keyword used to determine which volumes to stagger - void setStaggerKeyword(const std::string& staggerKeyword) { - _staggerKeyword = staggerKeyword; - } /** \brief Returns a vector of the cellDimensions of the given cell ID in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi @@ -129,20 +105,14 @@ namespace dd4hep { double _gridSizeX; /// the coordinate offset in X double _offsetX; - /// staggering option in X. 0 = no staggering. 1 = stagger by _gridSizeX/2.0 in odd layers - int _staggerX; /// the grid size in Y double _gridSizeY; /// the coordinate offset in Y double _offsetY; - /// staggering option in Y. 0 = no staggering. 1 = stagger by _gridSizeY/2.0 in odd layers - int _staggerY; /// the field name used for X std::string _xId; /// the field name used for Y std::string _yId; - /// the keyword used to determine which volumes to stagger - std::string _staggerKeyword; }; } /* namespace DDSegmentation */ diff --git a/DDCore/src/segmentations/CartesianGridXY.cpp b/DDCore/src/segmentations/CartesianGridXY.cpp index 1a80d7a27..f6cd2087f 100644 --- a/DDCore/src/segmentations/CartesianGridXY.cpp +++ b/DDCore/src/segmentations/CartesianGridXY.cpp @@ -22,14 +22,8 @@ CartesianGridXY::CartesianGridXY(const std::string& cellEncoding) : registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); - registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", _staggerX, 0, - SegmentationParameter::NoUnit, true); - registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", _staggerY, 0, - SegmentationParameter::NoUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); - registerParameter("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, (std::string)"layer", - SegmentationParameter::NoUnit, true); } /// Default constructor used by derived classes passing an existing decoder @@ -45,14 +39,8 @@ CartesianGridXY::CartesianGridXY(const BitFieldCoder* decode) : registerParameter("grid_size_y", "Cell size in Y", _gridSizeY, 1., SegmentationParameter::LengthUnit); registerParameter("offset_x", "Cell offset in X", _offsetX, 0., SegmentationParameter::LengthUnit, true); registerParameter("offset_y", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true); - registerParameter("stagger_x", "Option to stagger the layers in x (ie, add grid_size_x/2 to offset_x for odd layers)", _staggerX, 0, - SegmentationParameter::NoUnit, true); - registerParameter("stagger_y", "Option to stagger the layers in y (ie, add grid_size_y/2 to offset_y for odd layers)", _staggerY, 0, - SegmentationParameter::NoUnit, true); registerIdentifier("identifier_x", "Cell ID identifier for X", _xId, "x"); registerIdentifier("identifier_y", "Cell ID identifier for Y", _yId, "y"); - registerParameter("stagger_keyword", "Volume ID identifier used for determining which volumes to stagger", _staggerKeyword, (std::string)"layer", - SegmentationParameter::NoUnit, true); } /// destructor @@ -63,18 +51,16 @@ CartesianGridXY::~CartesianGridXY() { /// determine the position based on the cell ID Vector3D CartesianGridXY::position(const CellID& cID) const { Vector3D cellPosition; - int layer= _decoder->get(cID,_staggerKeyword); - cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2.); - cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY+_staggerY*_gridSizeY*(layer%2)/2.); + cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX); + cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY); return cellPosition; } /// determine the cell ID based on the position CellID CartesianGridXY::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { CellID cID = vID ; - int layer= _decoder->get(cID,_staggerKeyword); - _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2) ); - _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY+_staggerY*_gridSizeY*(layer%2)/2) ); + _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX) ); + _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY) ); return cID ; } From 4aec387ed4ed773d2ad342692aac4c8ba8b0b594 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Fri, 15 Sep 2023 14:00:21 -0400 Subject: [PATCH 37/39] fixed merge --- .../CartesianGridXYStaggered.cpp | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/DDCore/src/segmentations/CartesianGridXYStaggered.cpp b/DDCore/src/segmentations/CartesianGridXYStaggered.cpp index 1a6066aa2..67a458092 100644 --- a/DDCore/src/segmentations/CartesianGridXYStaggered.cpp +++ b/DDCore/src/segmentations/CartesianGridXYStaggered.cpp @@ -1,7 +1,7 @@ /* * CartesianGridXYStaggered.cpp * - * Created on: September 15, 2023 + * Created on: Sept 15, 2023 * Author: Sebouh J. Paul, UCR */ @@ -63,22 +63,32 @@ CartesianGridXYStaggered::~CartesianGridXYStaggered() { /// determine the position based on the cell ID Vector3D CartesianGridXYStaggered::position(const CellID& cID) const { Vector3D cellPosition; - int layer= _decoder->get(cID,_staggerKeyword); - cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2.); - cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY+_staggerY*_gridSizeY*(layer%2)/2.); + if (_staggerX || _staggerY){ + int layer= _decoder->get(cID,_staggerKeyword); + cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2.); + cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY+_staggerY*_gridSizeY*(layer%2)/2.); + } else { + cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX); + cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY); + } return cellPosition; } /// determine the cell ID based on the position CellID CartesianGridXYStaggered::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { CellID cID = vID ; - int layer= _decoder->get(cID,_staggerKeyword); - _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2) ); - _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY+_staggerY*_gridSizeY*(layer%2)/2) ); + if (_staggerX || _staggerY){ + int layer= _decoder->get(cID,_staggerKeyword); + _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX+_staggerX*_gridSizeX*(layer%2)/2) ); + _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY+_staggerY*_gridSizeY*(layer%2)/2) ); + } else { + _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX)); + _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY)); + } return cID ; } -std::vector CartesianGridXYStaggered::cellDimensions(const CellID&) const { + #if __cplusplus >= 201103L return {_gridSizeX, _gridSizeY}; #else From dccd89f91faf28dbc4a9d70d2557e890be8b7ae2 Mon Sep 17 00:00:00 2001 From: Andre Sailer Date: Tue, 19 Sep 2023 12:37:50 +0200 Subject: [PATCH 38/39] CartesianGridXYStaggered: fix cellDimensions function declaration --- DDCore/src/segmentations/CartesianGridXYStaggered.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/DDCore/src/segmentations/CartesianGridXYStaggered.cpp b/DDCore/src/segmentations/CartesianGridXYStaggered.cpp index 67a458092..9017c4388 100644 --- a/DDCore/src/segmentations/CartesianGridXYStaggered.cpp +++ b/DDCore/src/segmentations/CartesianGridXYStaggered.cpp @@ -89,14 +89,8 @@ Vector3D CartesianGridXYStaggered::position(const CellID& cID) const { } -#if __cplusplus >= 201103L +std::vector cellDimensions(const CellID& cellID) const { return {_gridSizeX, _gridSizeY}; -#else - std::vector cellDims(2,0.0); - cellDims[0] = _gridSizeX; - cellDims[1] = _gridSizeY; - return cellDims; -#endif } From 87689b907227b7902934d15a3546ed342075f5b8 Mon Sep 17 00:00:00 2001 From: Sebouh Paul Date: Tue, 19 Sep 2023 07:36:03 -0400 Subject: [PATCH 39/39] Update CartesianGridXYStaggered.cpp added "CartesianGridXYStaggered::" to the cellDimensions method in CartesianGridXYStaggered.cpp. --- DDCore/src/segmentations/CartesianGridXYStaggered.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DDCore/src/segmentations/CartesianGridXYStaggered.cpp b/DDCore/src/segmentations/CartesianGridXYStaggered.cpp index 9017c4388..871958ffe 100644 --- a/DDCore/src/segmentations/CartesianGridXYStaggered.cpp +++ b/DDCore/src/segmentations/CartesianGridXYStaggered.cpp @@ -89,7 +89,7 @@ Vector3D CartesianGridXYStaggered::position(const CellID& cID) const { } -std::vector cellDimensions(const CellID& cellID) const { +std::vector CartesianGridXYStaggered::cellDimensions(const CellID& cellID) const { return {_gridSizeX, _gridSizeY}; }