DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
GridPhiEta.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 //==========================================================================
13 
14 namespace dd4hep {
15 namespace DDSegmentation {
16 
17 GridPhiEta::GridPhiEta(const std::string& cellEncoding) :
18  Segmentation(cellEncoding) {
19  // define type and description
20  _type = "GridPhiEta";
21  _description = "Phi-eta segmentation in the global coordinates";
22 
23  // register all necessary parameters
24  registerParameter("grid_size_eta", "Cell size in Eta", m_gridSizeEta, 1., SegmentationParameter::LengthUnit);
25  registerParameter("phi_bins", "Number of bins phi", m_phiBins, 1);
26  registerParameter("offset_eta", "Angular offset in eta", m_offsetEta, 0., SegmentationParameter::AngleUnit, true);
27  registerParameter("offset_phi", "Angular offset in phi", m_offsetPhi, 0., SegmentationParameter::AngleUnit, true);
28  registerIdentifier("identifier_eta", "Cell ID identifier for eta", m_etaID, "eta");
29  registerIdentifier("identifier_phi", "Cell ID identifier for phi", m_phiID, "phi");
30 }
31 
33  Segmentation(aDecoder) {
34  // define type and description
35  _type = "GridPhiEta";
36  _description = "Phi-eta segmentation in the global coordinates";
37 
38  // register all necessary parameters
39  registerParameter("grid_size_eta", "Cell size in Eta", m_gridSizeEta, 1., SegmentationParameter::LengthUnit);
40  registerParameter("phi_bins", "Number of bins phi", m_phiBins, 1);
41  registerParameter("offset_eta", "Angular offset in eta", m_offsetEta, 0., SegmentationParameter::AngleUnit, true);
42  registerParameter("offset_phi", "Angular offset in phi", m_offsetPhi, 0., SegmentationParameter::AngleUnit, true);
43  registerIdentifier("identifier_eta", "Cell ID identifier for eta", m_etaID, "eta");
44  registerIdentifier("identifier_phi", "Cell ID identifier for phi", m_phiID, "phi");
45 }
46 
48  return Util::positionFromREtaPhi(1.0, eta(cID), phi(cID));
49 }
50 
51 CellID GridPhiEta::cellID(const Vector3D& /* localPosition */, const Vector3D& globalPosition, const VolumeID& vID) const {
52  double lEta = Util::etaFromXYZ(globalPosition);
53  double lPhi = Util::phiFromXYZ(globalPosition);
54  CellID cID = vID ;
56  _decoder->set( cID, m_phiID, positionToBin(lPhi, 2 * M_PI / (double) m_phiBins, m_offsetPhi) );
57  return cID;
58 }
59 
60 double GridPhiEta::eta(const CellID& cID) const {
61  CellID etaValue = _decoder->get(cID, m_etaID);
62  return binToPosition(etaValue, m_gridSizeEta, m_offsetEta);
63 }
64 double GridPhiEta::phi(const CellID& cID) const {
65  CellID phiValue = _decoder->get(cID, m_phiID);
66  return binToPosition(phiValue, 2.*M_PI/(double)m_phiBins, m_offsetPhi);
67 }
68 }
69 }
dd4hep::DDSegmentation::VolumeID
uint64_t VolumeID
Definition: BitFieldCoder.h:27
SegmentationUtil.h
dd4hep::DDSegmentation::Segmentation::_decoder
const BitFieldCoder * _decoder
The cell ID encoder and decoder.
Definition: Segmentation.h:168
dd4hep::DDSegmentation::GridPhiEta::m_phiID
std::string m_phiID
the field name used for phi
Definition: GridPhiEta.h:155
dd4hep::DDSegmentation::Vector3D
Simple container for a physics vector.
Definition: Segmentation.h:48
M_PI
#define M_PI
Definition: Handle.h:33
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
dd4hep::DDSegmentation::SegmentationParameter::AngleUnit
@ AngleUnit
Definition: SegmentationParameter.h:111
dd4hep::DDSegmentation::BitFieldCoder::get
FieldID get(CellID bitfield, size_t idx) const
Definition: BitFieldCoder.h:165
dd4hep::DDSegmentation::GridPhiEta::m_phiBins
int m_phiBins
the number of bins in phi
Definition: GridPhiEta.h:147
dd4hep::DDSegmentation::GridPhiEta::m_offsetEta
double m_offsetEta
the coordinate offset in eta
Definition: GridPhiEta.h:149
dd4hep::DDSegmentation::GridPhiEta::m_offsetPhi
double m_offsetPhi
the coordinate offset in phi
Definition: GridPhiEta.h:151
dd4hep::DDSegmentation::GridPhiEta::position
virtual Vector3D position(const CellID &aCellID) const
Definition: GridPhiEta.cpp:47
GridPhiEta.h
dd4hep::DDSegmentation::GridPhiEta::GridPhiEta
GridPhiEta(const std::string &aCellEncoding)
default constructor using an arbitrary type
Definition: GridPhiEta.cpp:17
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::Util::phiFromXYZ
double phiFromXYZ(const Vector3D &position)
calculates the azimuthal angle phi from Cartesian coordinates
Definition: SegmentationUtil.h:64
dd4hep::DDSegmentation::GridPhiEta::m_etaID
std::string m_etaID
the field name used for eta
Definition: GridPhiEta.h:153
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::GridPhiEta::eta
double eta(const CellID &aCellID) const
Definition: GridPhiEta.cpp:60
dd4hep::DDSegmentation::GridPhiEta::m_gridSizeEta
double m_gridSizeEta
the grid size in eta
Definition: GridPhiEta.h:145
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::DDSegmentation::Util::positionFromREtaPhi
Vector3D positionFromREtaPhi(double ar, double aeta, double aphi)
calculates the Cartesian position from spherical coordinates (r, phi, eta)
Definition: SegmentationUtil.h:123
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::DDSegmentation::Segmentation::_type
std::string _type
The segmentation type.
Definition: Segmentation.h:160
dd4hep::DDSegmentation::GridPhiEta::phi
double phi(const CellID &aCellID) const
Definition: GridPhiEta.cpp:64
dd4hep::DDSegmentation::Segmentation
Base class for all segmentations.
Definition: Segmentation.h:75
dd4hep::DDSegmentation::Util::etaFromXYZ
double etaFromXYZ(const Vector3D &aposition)
calculates the pseudorapidity from Cartesian coordinates
Definition: SegmentationUtil.h:70
dd4hep::DDSegmentation::GridPhiEta::cellID
virtual CellID cellID(const Vector3D &aLocalPosition, const Vector3D &aGlobalPosition, const VolumeID &aVolumeID) const
Definition: GridPhiEta.cpp:51