DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Segmentations.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 // Author : M.Frank
11 //
12 //==========================================================================
13 
14 // Framework include files
15 #include <DD4hep/Segmentations.h>
16 #include <DD4hep/InstanceCount.h>
17 #include <DD4hep/Printout.h>
18 #include <DD4hep/Plugins.h>
19 #include <DD4hep/detail/Handle.inl>
21 
22 // C/C++ include files
23 #include <iostream>
24 #include <stdexcept>
25 
26 using namespace dd4hep;
27 
29 
31 Segmentation::Segmentation(const std::string& typ, const std::string& nam, const BitFieldCoder* dec) : Handle<Object>()
32 {
33  std::string seg_type = "segmentation_constructor__"+typ;
34  SegmentationObject* obj = PluginService::Create<SegmentationObject*>(seg_type, dec);
35  if ( obj != 0 ) {
36  assign(obj, nam, typ);
37  if ( !nam.empty() ) obj->setName(nam);
38  return;
39  }
40  // This is fatal and cannot be recovered. We need to throw an exception here.
41  except("Segmentation","FAILED to create segmentation: %s. [Missing factory]",typ.c_str());
42 }
43 
45 const char* Segmentation::name() const {
46  return access()->name().c_str();
47 }
48 
50 std::string Segmentation::type() const {
51  return access()->type();
52 }
53 
55  return access()->useForHitPosition != 0;
56 }
57 
60  return access()->parameters();
61 }
62 
64 DDSegmentation::Parameter Segmentation::parameter(const std::string& parameterName) const {
65  return access()->parameter(parameterName);
66 }
67 
70  return Position(access()->segmentation->position(cell));
71 }
72 
74 CellID Segmentation::cellID(const Position& localPosition, const Position& globalPosition, const CellID & volID) const {
75  return access()->segmentation->cellID(localPosition, globalPosition, volID);
76 }
77 
80  return access()->segmentation->volumeID(cell);
81 }
82 
84 void Segmentation::neighbours(const CellID& cell, std::set<CellID>& nb) const {
85  access()->segmentation->neighbours(cell, nb);
86 }
87 
94 std::vector<double> Segmentation::cellDimensions(const CellID& cell) const {
95  return access()->segmentation->cellDimensions(cell);
96 }
97 
100  return access()->segmentation;
101 }
102 
104 const BitFieldCoder* Segmentation::decoder() const {
105  return access()->segmentation->decoder();
106 }
107 
109 void Segmentation::setDecoder(const BitFieldCoder* decode) const {
110  access()->segmentation->setDecoder(decode);
111 }
112 
115  return access()->detector;
116 }
117 
120  return access()->sensitive;
121 }
122 
125 
128 
131 
134 
137 
140 
143 
146 
149 
152 
155 
158 
161 
164 
167 
170 
173 
176 
179 
CartesianGridUV.h
dd4hep::SegmentationObject::parameters
DDSegmentation::Parameters parameters() const
Access to all parameters.
Definition: SegmentationsInterna.cpp:78
dd4hep::Segmentation::position
Position position(const CellID &cellID) const
determine the local position based on the cell ID
Definition: Segmentations.cpp:69
Segmentations.h
dd4hep::DDSegmentation::PolarGridRPhi2
A segmentation for arbitrary sizes in R and R-dependent sizes in Phi.
Definition: PolarGridRPhi2.h:57
PolarGridRPhi2.h
WaferGridXY.h
dd4hep::DDSegmentation::CartesianGridXY
Segmentation base class describing cartesian grid segmentation in the X-Y plane.
Definition: CartesianGridXY.h:27
CartesianGridXZ.h
dd4hep::Segmentation::useForHitPosition
bool useForHitPosition() const
Access flag for hit positioning.
Definition: Segmentations.cpp:54
dd4hep::SegmentationObject::segmentation
DDSegmentation::Segmentation * segmentation
Reference to base segmentation.
Definition: SegmentationsInterna.h:96
MultiSegmentation.h
CartesianStripY.h
MegatileLayerGridXY.h
CylindricalGridPhiZ.h
dd4hep::SegmentationObject::sensitive
Handle< SensitiveDetectorObject > sensitive
Reference to hosting top level sensitve detector structure.
Definition: SegmentationsInterna.h:94
dd4hep::Segmentation::sensitive
Handle< SensitiveDetectorObject > sensitive() const
Access the sensitive detector using this segmentation object.
Definition: Segmentations.cpp:119
dd4hep::Handle
Handle: a templated class like a shared pointer, which allows specialized access to tgeometry objects...
Definition: Handle.h:84
dd4hep::Segmentation::detector
Handle< DetElementObject > detector() const
Access the main detector element using this segmentation object.
Definition: Segmentations.cpp:114
dd4hep::SegmentationObject
Implementation class supporting generic Segmentation of sensitive detectors.
Definition: SegmentationsInterna.h:46
dd4hep::DDSegmentation::SegmentationParameter
Class to hold a segmentation parameter with its description.
Definition: SegmentationParameter.h:107
dd4hep::DDSegmentation::CartesianGridXZ
Segmentation base class describing cartesian grid segmentation in the X-Z plane.
Definition: CartesianGridXZ.h:27
CartesianGridYZ.h
dd4hep::DDSegmentation::MultiSegmentation
Wrapper to support multiple segmentations.
Definition: MultiSegmentation.h:29
NoSegmentation.h
CartesianGridXY.h
dd4hep::SegmentationObject::useForHitPosition
unsigned char useForHitPosition
Flag to use segmentation for hit positioning.
Definition: SegmentationsInterna.h:90
GridPhiEta.h
ProjectiveCylinder.h
dd4hep::DDSegmentation::CartesianStripZ
Segmentation base class describing cartesian strip segmentation in Z.
Definition: CartesianStripZ.h:29
dd4hep::Segmentation::cellDimensions
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: Segmentations.cpp:94
dd4hep::Segmentation::setDecoder
void setDecoder(const BitFieldCoder *decoder) const
Set the underlying decoder.
Definition: Segmentations.cpp:109
dd4hep::Handle< SegmentationObject >::assign
void assign(Object *n, const std::string &nam, const std::string &title)
Assign a new named object. Note: object references must be managed by the user.
CartesianStripZ.h
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE
DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::NoSegmentation)
CartesianGrid.h
dd4hep::DDSegmentation::Parameters
std::vector< Parameter > Parameters
Definition: SegmentationsInterna.h:35
dd4hep::Segmentation::neighbours
void neighbours(const CellID &cellID, std::set< CellID > &neighbours) const
Calculates the neighbours of the given cell ID and adds them to the list of neighbours.
Definition: Segmentations.cpp:84
CartesianStripX.h
dd4hep::DDSegmentation::PolarGridRPhi
A segmentation for arbitrary sizes in R and R-dependent sizes in Phi.
Definition: PolarGridRPhi.h:29
dd4hep::DDSegmentation::MegatileLayerGridXY
a megatile is a rectangule in x-y, split into a grid along x and y, with an exactly integer number of...
Definition: MegatileLayerGridXY.h:48
Plugins.h
dd4hep::DDSegmentation::Segmentation::decoder
virtual const BitFieldCoder * decoder() const
Access the underlying decoder.
Definition: Segmentation.h:112
dd4hep::DDSegmentation::CylindricalGridPhiZ
Segmentation base class describing cylindrical grid segmentation in the Phi-Z cylinder.
Definition: CylindricalGridPhiZ.h:27
dd4hep::DDSegmentation::CartesianGridXYZ
Segmentation base class describing cartesian grid segmentation in space.
Definition: CartesianGridXYZ.h:27
dd4hep::DDSegmentation::ProjectiveCylinder
A segmentation class to describe projective cylinders.
Definition: ProjectiveCylinder.h:28
dd4hep::SegmentationObject::detector
Handle< DetElementObject > detector
Reference to hosting top level DetElement structure.
Definition: SegmentationsInterna.h:92
dd4hep::SegmentationObject::type
const std::string & type() const
Access the segmentation type.
Definition: SegmentationsInterna.cpp:53
dd4hep::Segmentation::cellID
CellID cellID(const Position &localPosition, const Position &globalPosition, const VolumeID &volumeID) const
determine the cell ID based on the local position
Definition: Segmentations.cpp:74
CartesianGridXYZ.h
TiledLayerGridXY.h
dd4hep::SegmentationObject::name
const std::string & name() const
Access the segmentation name.
Definition: SegmentationsInterna.cpp:44
dd4hep::DDSegmentation::CartesianStripY
Segmentation base class describing cartesian strip segmentation in Y.
Definition: CartesianStripY.h:28
dd4hep::Segmentation::volumeID
VolumeID volumeID(const CellID &cellID) const
Determine the volume ID from the full cell ID by removing all local fields.
Definition: Segmentations.cpp:79
DD4HEP_INSTANTIATE_HANDLE_UNNAMED
DD4HEP_INSTANTIATE_HANDLE_UNNAMED(SegmentationObject)
dd4hep::DDSegmentation::Segmentation::setDecoder
virtual void setDecoder(const BitFieldCoder *decoder)
Set the underlying decoder.
Definition: Segmentation.cpp:100
dd4hep::Segmentation::name
const char * name() const
Accessor: Segmentation type.
Definition: Segmentations.cpp:45
dd4hep::Position
ROOT::Math::XYZVector Position
Definition: Objects.h:81
GridRPhiEta.h
dd4hep::Segmentation::type
std::string type() const
Accessor: Segmentation type.
Definition: Segmentations.cpp:50
dd4hep::DDSegmentation::Segmentation::volumeID
virtual VolumeID volumeID(const CellID &cellID) const
Determine the volume ID from the full cell ID by removing all local fields.
Definition: Segmentation.cpp:66
dd4hep::DDSegmentation::CartesianGridUV
Segmentation base class describing cartesian grid segmentation in along U,V rotated some angle from l...
Definition: CartesianGridUV.h:27
dd4hep::DDSegmentation::NoSegmentation
This class exists to provide a segmenation when it is need but doesn't exist.
Definition: NoSegmentation.h:28
SegmentationsInterna.h
VolumeID
dd4hep::DDSegmentation::VolumeID VolumeID
Definition: SegmentationDictionary.h:50
dd4hep::DDSegmentation::Segmentation::cellID
virtual CellID cellID(const Vector3D &localPosition, const Vector3D &globalPosition, const VolumeID &volumeID) const =0
Determine the cell ID based on the position.
dd4hep::Segmentation::segmentation
DDSegmentation::Segmentation * segmentation() const
Access to the base DDSegmentation object. WARNING: Deprecated call!
Definition: Segmentations.cpp:99
dd4hep::Handle< SegmentationObject >::access
SegmentationObject * access() const
Checked object access. Throws invalid handle runtime exception if invalid handle.
dd4hep::DDSegmentation::CartesianGridYZ
Segmentation base class describing cartesian grid segmentation in the Y-Z plane.
Definition: CartesianGridYZ.h:29
PolarGridRPhi.h
dd4hep::Segmentation::decoder
const BitFieldCoder * decoder() const
Access the underlying decoder.
Definition: Segmentations.cpp:104
dd4hep::Segmentation::parameters
DDSegmentation::Parameters parameters() const
Access to the parameters.
Definition: Segmentations.cpp:59
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::DDSegmentation::Segmentation::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: Segmentation.cpp:195
dd4hep::DDSegmentation::GridRPhiEta
Segmentation class describing segmentation in R-Phi-Eta.
Definition: GridRPhiEta.h:31
dd4hep::DDSegmentation::Segmentation::neighbours
virtual void neighbours(const CellID &cellID, std::set< CellID > &neighbours) const
Calculates the neighbours of the given cell ID and adds them to the list of neighbours.
Definition: Segmentation.cpp:77
dd4hep::Segmentation::Segmentation
Segmentation()=default
Default constructor.
dd4hep::DDSegmentation::GridPhiEta
Segmentation class describing segmentation in Phi-Eta.
Definition: GridPhiEta.h:30
dd4hep::DDSegmentation::CartesianStripX
Segmentation base class describing cartesian strip segmentation in X.
Definition: CartesianStripX.h:29
dd4hep::Segmentation::parameter
DDSegmentation::Parameter parameter(const std::string &parameterName) const
Access to parameter by name.
Definition: Segmentations.cpp:64
dd4hep::DDSegmentation::TiledLayerGridXY
A segmentation class to describe tiled layers.
Definition: TiledLayerGridXY.h:32
InstanceCount.h
dd4hep::DDSegmentation::Segmentation
Base class for all segmentations.
Definition: Segmentation.h:75
Printout.h
dd4hep::DDSegmentation::WaferGridXY
A segmentation class to describe wafer grids in X-Y.
Definition: WaferGridXY.h:31
dd4hep::SegmentationObject::parameter
DDSegmentation::Parameter parameter(const std::string &parameterName) const
Access to parameter by name.
Definition: SegmentationsInterna.cpp:73
dd4hep::DDSegmentation::CartesianGrid
Segmentation base class describing cartesian grid segmentation.
Definition: CartesianGrid.h:28
dd4hep::DDSegmentation::Segmentation::position
virtual Vector3D position(const CellID &cellID) const =0
Determine the local position based on the cell ID.
dd4hep::SegmentationObject::setName
void setName(const std::string &value)
Set the segmentation name.
Definition: SegmentationsInterna.cpp:48
CellID
dd4hep::DDSegmentation::CellID CellID
Definition: SegmentationDictionary.h:51