DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
CartesianStripY.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 //==========================================================================
11 /*
12  * CartesianStripY.cpp
13  *
14  * Created on: Jun 28, 2013
15  * Author: Christian Grefe, CERN
16  * David Blyth, ANL
17  */
18 
20 
21 namespace dd4hep {
22 namespace DDSegmentation {
24 CartesianStripY::CartesianStripY(const std::string& cellEncoding) : CartesianStrip(cellEncoding) {
25  // define type and description
26  _type = "CartesianStripY";
27  _description = "Cartesian segmentation on the local Y axis";
28 
29  // register all necessary parameters
30  registerParameter("strip_size_x", "Cell size in Y", _stripSizeY, 1., SegmentationParameter::LengthUnit);
31  registerParameter("offset_x", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true);
32  registerIdentifier("identifier_x", "Cell ID identifier for Y", _xId, "strip");
33 }
34 
37  // define type and description
38  _type = "CartesianStripY";
39  _description = "Cartesian segmentation on the local Y axis";
40 
41  // register all necessary parameters
42  registerParameter("strip_size_x", "Cell size in Y", _stripSizeY, 1., SegmentationParameter::LengthUnit);
43  registerParameter("offset_x", "Cell offset in Y", _offsetY, 0., SegmentationParameter::LengthUnit, true);
44  registerIdentifier("identifier_x", "Cell ID identifier for Y", _xId, "strip");
45 }
46 
49 
52  Vector3D cellPosition;
53  cellPosition.Y = binToPosition(_decoder->get(cID, _xId), _stripSizeY, _offsetY);
54  return cellPosition;
55 }
56 
58 CellID CartesianStripY::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */,
59  const VolumeID& vID) const {
60  CellID cID = vID;
61  _decoder->set(cID, _xId, positionToBin(localPosition.Y, _stripSizeY, _offsetY));
62  return cID;
63 }
64 
65 std::vector<double> CartesianStripY::cellDimensions(const CellID&) const {
66 #if __cplusplus >= 201103L
67  return {_stripSizeY};
68 #else
69  std::vector<double> cellDims(1, 0.0);
70  cellDims[0] = _stripSizeY;
71  return cellDims;
72 #endif
73 }
74 
75 } // namespace DDSegmentation
76 } /* namespace dd4hep */
77 
dd4hep::DDSegmentation::VolumeID
uint64_t VolumeID
Definition: BitFieldCoder.h:27
dd4hep::DDSegmentation::Segmentation::_decoder
const BitFieldCoder * _decoder
The cell ID encoder and decoder.
Definition: Segmentation.h:168
dd4hep::DDSegmentation::Vector3D
Simple container for a physics vector.
Definition: Segmentation.h:48
dd4hep::DDSegmentation::CartesianStripY::_stripSizeY
double _stripSizeY
the strip size in Y
Definition: CartesianStripY.h:66
dd4hep::DDSegmentation::SegmentationParameter::LengthUnit
@ LengthUnit
Definition: SegmentationParameter.h:111
dd4hep::DDSegmentation::BitFieldCoder
Helper class for decoding and encoding a bit field of 64bits for convenient declaration.
Definition: BitFieldCoder.h:114
CartesianStripY.h
dd4hep::DDSegmentation::BitFieldCoder::get
FieldID get(CellID bitfield, size_t idx) const
Definition: BitFieldCoder.h:165
dd4hep::DDSegmentation::CartesianStripY::_offsetY
double _offsetY
the coordinate offset in Y
Definition: CartesianStripY.h:68
dd4hep::DDSegmentation::CartesianStripY::cellID
virtual CellID cellID(const Vector3D &localPosition, const Vector3D &globalPosition, const VolumeID &volumeID) const
determine the cell ID based on the position
Definition: CartesianStripY.cpp:58
dd4hep::DDSegmentation::CartesianStripY::_xId
std::string _xId
the field name used for Y
Definition: CartesianStripY.h:70
dd4hep::DDSegmentation::CartesianStripY::~CartesianStripY
virtual ~CartesianStripY()
destructor
Definition: CartesianStripY.cpp:48
dd4hep::DDSegmentation::Segmentation::registerParameter
void registerParameter(const std::string &nam, const std::string &desc, TYPE &param, const TYPE &defaultVal, UnitType unitTyp=SegmentationParameter::NoUnit, bool isOpt=false)
Add a parameter to this segmentation. Used by derived classes to define their parameters.
Definition: Segmentation.h:138
dd4hep::DDSegmentation::CartesianStripY::CartesianStripY
CartesianStripY(const std::string &cellEncoding="")
Default constructor passing the encoding string.
Definition: CartesianStripY.cpp:24
dd4hep::DDSegmentation::Vector3D::Y
double Y
Definition: Segmentation.h:71
dd4hep::DDSegmentation::BitFieldCoder::set
void set(CellID &bitfield, size_t idx, FieldID value) const
Definition: BitFieldCoder.h:177
dd4hep::DDSegmentation::CellID
uint64_t CellID
Definition: BitFieldCoder.h:26
dd4hep::DDSegmentation::Segmentation::registerIdentifier
void registerIdentifier(const std::string &nam, const std::string &desc, std::string &ident, const std::string &defaultVal)
Add a cell identifier to this segmentation. Used by derived classes to define their required identifi...
Definition: Segmentation.cpp:135
dd4hep::DDSegmentation::CartesianStripY::position
virtual Vector3D position(const CellID &cellID) const
determine the position based on the cell ID
Definition: CartesianStripY.cpp:51
dd4hep::DDSegmentation::Segmentation::_description
std::string _description
The description of the segmentation.
Definition: Segmentation.h:162
dd4hep::DDSegmentation::Segmentation::positionToBin
static int positionToBin(double position, double cellSize, double offset=0.)
Helper method to convert a 1D position to a cell ID.
Definition: Segmentation.cpp:150
dd4hep::DDSegmentation::Segmentation::binToPosition
static double binToPosition(FieldID bin, double cellSize, double offset=0.)
Helper method to convert a bin number to a 1D position.
Definition: Segmentation.cpp:145
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::DDSegmentation::CartesianStrip
Segmentation base class describing cartesian strip segmentation.
Definition: CartesianStrip.h:28
dd4hep::DDSegmentation::Segmentation::_type
std::string _type
The segmentation type.
Definition: Segmentation.h:160
dd4hep::DDSegmentation::CartesianStripY::cellDimensions
virtual std::vector< double > cellDimensions(const CellID &cellID) const
Returns a vector<double> of the cellDimensions of the given cell ID in natural order of dimensions,...
Definition: CartesianStripY.cpp:65