Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:17:03

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 
0014 // Framework include files
0015 #include <DD4hep/Segmentations.h>
0016 #include <DD4hep/InstanceCount.h>
0017 #include <DD4hep/Printout.h>
0018 #include <DD4hep/Plugins.h>
0019 #include <DD4hep/detail/Handle.inl>
0020 #include <DD4hep/detail/SegmentationsInterna.h>
0021 
0022 // C/C++ include files
0023 #include <iostream>
0024 #include <stdexcept>
0025 
0026 using namespace dd4hep;
0027 
0028 DD4HEP_INSTANTIATE_HANDLE_UNNAMED(SegmentationObject);
0029 
0030 /// Constructor to used when creating a new object
0031 Segmentation::Segmentation(const std::string& typ, const std::string& nam, const BitFieldCoder* dec) : Handle<Object>()
0032 {
0033   std::string seg_type = "segmentation_constructor__"+typ;
0034   SegmentationObject* obj = PluginService::Create<SegmentationObject*>(seg_type, dec);
0035   if ( obj != 0 )  {
0036     assign(obj, nam, typ);
0037     if ( !nam.empty() ) obj->setName(nam);
0038     return;
0039   }
0040   // This is fatal and cannot be recovered. We need to throw an exception here.
0041   except("Segmentation","FAILED to create segmentation: %s. [Missing factory]",typ.c_str());
0042 }
0043 
0044 /// Accessor: Segmentation type
0045 const char* Segmentation::name() const {
0046   return access()->name().c_str();
0047 }
0048 
0049 /// Accessor: Segmentation type
0050 std::string Segmentation::type() const {
0051   return access()->type();
0052 }
0053 
0054 bool Segmentation::useForHitPosition() const {
0055   return access()->useForHitPosition != 0;
0056 }
0057 
0058 /// Access to the parameters
0059 DDSegmentation::Parameters Segmentation::parameters() const {
0060   return access()->parameters();
0061 }
0062 
0063 /// Access to parameter by name
0064 DDSegmentation::Parameter  Segmentation::parameter(const std::string& parameterName) const   {
0065   return access()->parameter(parameterName);
0066 }
0067 
0068 /// determine the local position based on the cell ID
0069 Position Segmentation::position(const CellID& cell) const {
0070   return Position(access()->segmentation->position(cell));
0071 }
0072 
0073 /// determine the cell ID based on the local position
0074 CellID Segmentation::cellID(const Position& localPosition, const Position& globalPosition, const CellID & volID) const {
0075   return access()->segmentation->cellID(localPosition, globalPosition, volID);
0076 }
0077 
0078 /// Determine the volume ID from the full cell ID by removing all local fields
0079 VolumeID Segmentation::volumeID(const CellID& cell) const   {
0080   return access()->segmentation->volumeID(cell);
0081 }
0082 
0083 /// Calculates the neighbours of the given cell ID and adds them to the list of neighbours
0084 void Segmentation::neighbours(const CellID& cell, std::set<CellID>& nb) const  {
0085   access()->segmentation->neighbours(cell, nb);
0086 }
0087 
0088 /** \brief Returns a vector<double> of the cellDimensions of the given cell ID
0089  *  in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi
0090  *
0091  *   \param cellID cellID of the cell for which parameters are returned
0092  *   \return vector<double> in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi
0093  */
0094 std::vector<double> Segmentation::cellDimensions(const CellID& cell) const  {
0095   return access()->segmentation->cellDimensions(cell);
0096 }
0097 
0098 /// Access to the base DDSegmentation object. WARNING: Deprecated call!
0099 DDSegmentation::Segmentation* Segmentation::segmentation() const  {
0100   return access()->segmentation;
0101 }
0102 
0103 /// Access the underlying decoder
0104 const BitFieldCoder* Segmentation::decoder()  const {
0105   return access()->segmentation->decoder();
0106 }
0107 
0108 /// Set the underlying decoder
0109 void Segmentation::setDecoder(const BitFieldCoder* decode) const  {
0110   access()->segmentation->setDecoder(decode);
0111 }
0112 
0113 /// Access the main detector element using this segmentation object
0114 Handle<DetElementObject> Segmentation::detector() const  {
0115   return access()->detector;
0116 }
0117 
0118 /// Access the sensitive detector using this segmentation object
0119 Handle<SensitiveDetectorObject> Segmentation::sensitive() const  {
0120   return access()->sensitive;
0121 }
0122 
0123 #include <DDSegmentation/NoSegmentation.h>
0124 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::NoSegmentation);
0125 
0126 #include <DDSegmentation/CartesianGrid.h>
0127 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGrid);
0128 
0129 #include <DDSegmentation/CartesianGridXY.h>
0130 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridXY);
0131 
0132 #include <DDSegmentation/CartesianGridXZ.h>
0133 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridXZ);
0134 
0135 #include <DDSegmentation/CartesianGridYZ.h>
0136 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridYZ);
0137 
0138 #include <DDSegmentation/CartesianGridUV.h>
0139 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridUV);
0140 
0141 #include <DDSegmentation/CartesianGridXYZ.h>
0142 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridXYZ);
0143 
0144 #include <DDSegmentation/CartesianStripX.h>
0145 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianStripX);
0146 
0147 #include <DDSegmentation/CartesianStripY.h>
0148 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianStripY);
0149 
0150 #include <DDSegmentation/CartesianStripZ.h>
0151 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianStripZ);
0152 
0153 #include <DDSegmentation/TiledLayerGridXY.h>
0154 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::TiledLayerGridXY);
0155 
0156 #include <DDSegmentation/MegatileLayerGridXY.h>
0157 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::MegatileLayerGridXY);
0158 
0159 #include <DDSegmentation/WaferGridXY.h>
0160 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::WaferGridXY);
0161 
0162 #include <DDSegmentation/PolarGridRPhi.h>
0163 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::PolarGridRPhi);
0164 
0165 #include <DDSegmentation/PolarGridRPhi2.h>
0166 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::PolarGridRPhi2);
0167 
0168 #include <DDSegmentation/GridPhiEta.h>
0169 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::GridPhiEta);
0170 
0171 #include <DDSegmentation/GridRPhiEta.h>
0172 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::GridRPhiEta);
0173 
0174 #include <DDSegmentation/ProjectiveCylinder.h>
0175 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::ProjectiveCylinder);
0176 
0177 #include <DDSegmentation/MultiSegmentation.h>
0178 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::MultiSegmentation);
0179 
0180 #include <DDSegmentation/CylindricalGridPhiZ.h>
0181 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CylindricalGridPhiZ);