diff --git a/DDCore/include/DDSegmentation/StereoStrip.h b/DDCore/include/DDSegmentation/StereoStrip.h new file mode 100644 index 0000000000000000000000000000000000000000..7d6acf13b335dbd29b6cacca50c175c15eb83e15 --- /dev/null +++ b/DDCore/include/DDSegmentation/StereoStrip.h @@ -0,0 +1,76 @@ +//========================================================================== +// 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. +// +//========================================================================== + +/* + * StereoStrip.h + * + * Created on: April 12, 2020 + * Author: Whitney Armstrong, ANL + */ + +#ifndef DDSegmentation_StereoStrip_H_ +#define DDSegmentation_StereoStrip_H_ + +#include "DDSegmentation/CartesianStrip.h" + +namespace dd4hep { +namespace DDSegmentation { + + /// Segmentation base class describing cartesian strip segmentation in X +class StereoStrip : public DDSegmentation::CartesianStrip { + public: + /// Default constructor passing the encoding string + StereoStrip(const std::string& cellEncoding = ""); + /// Default constructor used by derived classes passing an existing decoder + StereoStrip(const BitFieldCoder* decoder); + /// destructor + virtual ~StereoStrip(); + + /// 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 strip size in X + double stripSizeU() const { return _stripSizeU; } + /// access the coordinate offset in X + double offsetU() const { return _offsetU; } + /// access the field name used for X + const std::string& fieldNameU() const { return _uId; } + /// set the strip size in X + void setStripSizeU(double cellSize) { _stripSizeU = cellSize; } + /// set the coordinate offset in X + void setOffsetU(double offset) { _offsetU = offset; } + /// set the field name used for X + void setFieldNameU(const std::string& fieldName) { _uId = fieldName; } + /** \brief Returns a vector<double> 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<double> size 1: + -# size in x + */ + virtual std::vector<double> cellDimensions(const CellID& cellID) const; + + protected: + /// the U strip angle + double _stripAngle; + /// the strip size in X + double _stripSizeU; + /// the coordinate offset in X + double _offsetU; + /// the field name used for X + std::string _uId; +}; +} // namespace DDSegmentation +} /* namespace dd4hep */ +#endif // DDSegmentation_StereoStrip_H_ diff --git a/DDCore/src/SegmentationDictionary.h b/DDCore/src/SegmentationDictionary.h index 81dfb52751bf77bd4f823645b9fafa168b99bb1a..185f701b983d4117994f54e845bd376ea967a02e 100644 --- a/DDCore/src/SegmentationDictionary.h +++ b/DDCore/src/SegmentationDictionary.h @@ -40,6 +40,7 @@ #include "DDSegmentation/PolarGridRPhi2.h" #include "DDSegmentation/PolarGridRPhi.h" #include "DDSegmentation/ProjectiveCylinder.h" +#include "DDSegmentation/StereoStrip.h" #include "DDSegmentation/SegmentationParameter.h" #include "DDSegmentation/TiledLayerGridXY.h" @@ -89,6 +90,7 @@ typedef dd4hep::DDSegmentation::CellID CellID; #pragma link C++ class dd4hep::DDSegmentation::TiledLayerGridXY+; #pragma link C++ class dd4hep::DDSegmentation::TiledLayerSegmentation+; #pragma link C++ class dd4hep::DDSegmentation::WaferGridXY+; +#pragma link C++ class dd4hep::DDSegmentation::StereoStrip+; #pragma link C++ class dd4hep::DDSegmentation::BitFieldElement+; #pragma link C++ class dd4hep::DDSegmentation::BitFieldCoder+; diff --git a/DDCore/src/Segmentations.cpp b/DDCore/src/Segmentations.cpp index b21ea68ca982de57e5ccb523cc6599d477796360..b105aca248916ad76338a218be34830ae5a13517 100644 --- a/DDCore/src/Segmentations.cpp +++ b/DDCore/src/Segmentations.cpp @@ -175,3 +175,6 @@ DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::ProjectiveCylinder); #include "DDSegmentation/MultiSegmentation.h" DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::MultiSegmentation); + +#include "DDSegmentation/StereoStrip.h" +DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::StereoStrip); diff --git a/DDCore/src/plugins/ReadoutSegmentations.cpp b/DDCore/src/plugins/ReadoutSegmentations.cpp index 7462e7d931e8557762d2a7cc375ff5ec24ba8b44..24f5cfee24545924f0dff2887dea9390ed50e659 100644 --- a/DDCore/src/plugins/ReadoutSegmentations.cpp +++ b/DDCore/src/plugins/ReadoutSegmentations.cpp @@ -75,3 +75,6 @@ DECLARE_SEGMENTATION(ProjectiveCylinder,create_segmentation<dd4hep::DDSegmentati #include "DDSegmentation/MultiSegmentation.h" DECLARE_SEGMENTATION(MultiSegmentation,create_segmentation<dd4hep::DDSegmentation::MultiSegmentation>) + +#include "DDSegmentation/StereoStrip.h" +DECLARE_SEGMENTATION(StereoStrip,create_segmentation<dd4hep::DDSegmentation::StereoStrip>) diff --git a/DDCore/src/segmentations/StereoStrip.cpp b/DDCore/src/segmentations/StereoStrip.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9f5d14c8288671b000216c4e629a05c1f2c87dc1 --- /dev/null +++ b/DDCore/src/segmentations/StereoStrip.cpp @@ -0,0 +1,71 @@ +/* + * StereoStrip.cpp + * + * Created on: April 12, 2020 + * Author: Whitney Armstrong, ANL + * + */ + +#include "DDSegmentation/StereoStrip.h" +#include "DD4hep/Objects.h" + +namespace dd4hep { +namespace DDSegmentation { +/// default constructor using an encoding string +StereoStrip::StereoStrip(const std::string& cellEncoding) : CartesianStrip(cellEncoding) { + // define type and description + _type = "StereoStrip"; + _description = "Strip segmentation U rotated some angle from local X axis"; + + // register all necessary parameters + registerParameter("strip_angle", "Strip stereo angle in U direction", _stripAngle, 1., SegmentationParameter::AngleUnit); + registerParameter("strip_size", "Cell size in U", _stripSizeU, 1., SegmentationParameter::LengthUnit); + registerParameter("offset_u", "Cell offset in u", _offsetU, 0., SegmentationParameter::LengthUnit, true); + registerIdentifier("identifier_u", "Cell ID identifier for U", _uId, "u"); +} + +/// Default constructor used by derived classes passing an existing decoder +StereoStrip::StereoStrip(const BitFieldCoder* decode) : CartesianStrip(decode) { + // define type and description + _type = "StereoStrip"; + _description = "Cartesian segmentation on the local X axis"; + + // register all necessary parameters + registerParameter("strip_angle", "Strip stereo angle in U direction", _stripAngle, 1., SegmentationParameter::AngleUnit); + registerParameter("strip_size", "Cell size in U", _stripSizeU, 1., SegmentationParameter::LengthUnit); + registerParameter("offset_u", "Cell offset in U", _offsetU, 0., SegmentationParameter::LengthUnit, true); + registerIdentifier("identifier_u", "Cell ID identifier for U", _uId, "u"); +} + +/// destructor +StereoStrip::~StereoStrip() {} + +/// determine the position based on the cell ID +Vector3D StereoStrip::position(const CellID& cID) const { + Position cellPosition; + cellPosition.SetX( binToPosition(_decoder->get(cID, _uId), _stripSizeU, _offsetU)); + cellPosition = RotationZ(_stripAngle)*cellPosition; + return cellPosition; +} + +/// determine the cell ID based on the position +CellID StereoStrip::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, + const VolumeID& vID) const { + CellID cID = vID; + _decoder->set(cID, _uId, positionToBin((RotationZ(-1.0*_stripAngle)*localPosition).X, _stripSizeU, _offsetU)); + return cID; +} + +std::vector<double> StereoStrip::cellDimensions(const CellID&) const { +#if __cplusplus >= 201103L + return {_stripSizeU}; +#else + std::vector<double> cellDims(1, 0.0); + cellDims[0] = _stripSizeU; + return cellDims; +#endif +} + +REGISTER_SEGMENTATION(StereoStrip) +} // namespace DDSegmentation +} /* namespace dd4hep */