Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-12 07:54:17

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 
0024 using namespace dd4hep;
0025 
0026 DD4HEP_INSTANTIATE_HANDLE_UNNAMED(SegmentationObject);
0027 
0028 /// Constructor to used when creating a new object
0029 Segmentation::Segmentation(const std::string& typ, const std::string& nam, const BitFieldCoder* dec) : Handle<Object>()
0030 {
0031   std::string seg_type = "segmentation_constructor__"+typ;
0032   SegmentationObject* obj = PluginService::Create<SegmentationObject*>(seg_type, dec);
0033   if ( obj != 0 )  {
0034     assign(obj, nam, typ);
0035     if ( !nam.empty() ) obj->setName(nam);
0036     return;
0037   }
0038   // This is fatal and cannot be recovered. We need to throw an exception here.
0039   except("Segmentation","FAILED to create segmentation: %s. [Missing factory]",typ.c_str());
0040 }
0041 
0042 /// Accessor: Segmentation type
0043 const char* Segmentation::name() const {
0044   return access()->name().c_str();
0045 }
0046 
0047 /// Accessor: Segmentation type
0048 std::string Segmentation::type() const {
0049   return access()->type();
0050 }
0051 
0052 bool Segmentation::useForHitPosition() const {
0053   return access()->useForHitPosition != 0;
0054 }
0055 
0056 /// Access to the parameters
0057 DDSegmentation::Parameters Segmentation::parameters() const {
0058   return access()->parameters();
0059 }
0060 
0061 /// Access to parameter by name
0062 DDSegmentation::Parameter  Segmentation::parameter(const std::string& parameterName) const   {
0063   return access()->parameter(parameterName);
0064 }
0065 
0066 /// determine the local position based on the cell ID
0067 Position Segmentation::position(const CellID& cell) const {
0068   return Position(access()->segmentation->position(cell));
0069 }
0070 
0071 /// determine the cell ID based on the local position
0072 CellID Segmentation::cellID(const Position& localPosition, const Position& globalPosition, const CellID & volID) const {
0073   return access()->segmentation->cellID(localPosition, globalPosition, volID);
0074 }
0075 
0076 /// Determine the volume ID from the full cell ID by removing all local fields
0077 VolumeID Segmentation::volumeID(const CellID& cell) const   {
0078   return access()->segmentation->volumeID(cell);
0079 }
0080 
0081 /// Calculates the neighbours of the given cell ID and adds them to the list of neighbours
0082 void Segmentation::neighbours(const CellID& cell, std::set<CellID>& nb) const  {
0083   access()->segmentation->neighbours(cell, nb);
0084 }
0085 
0086 /** \brief Returns a vector<double> of the cellDimensions of the given cell ID
0087  *  in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi
0088  *
0089  *   \param cellID cellID of the cell for which parameters are returned
0090  *   \return vector<double> in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi
0091  */
0092 std::vector<double> Segmentation::cellDimensions(const CellID& cell) const  {
0093   return access()->segmentation->cellDimensions(cell);
0094 }
0095 
0096 /// Return true if this segmentation can have cells that span multiple
0097 /// volumes.  That is, points from multiple distinct volumes may
0098 /// be assigned to the same cell.
0099 bool Segmentation::cellsSpanVolumes() const
0100 {
0101   return access()->segmentation->cellsSpanVolumes();
0102 }
0103 
0104 /// Access to the base DDSegmentation object. WARNING: Deprecated call!
0105 DDSegmentation::Segmentation* Segmentation::segmentation() const  {
0106   return access()->segmentation;
0107 }
0108 
0109 /// Access the underlying decoder
0110 const BitFieldCoder* Segmentation::decoder()  const {
0111   return access()->segmentation->decoder();
0112 }
0113 
0114 /// Set the underlying decoder
0115 void Segmentation::setDecoder(const BitFieldCoder* decode) const  {
0116   access()->segmentation->setDecoder(decode);
0117 }
0118 
0119 /// Access the main detector element using this segmentation object
0120 Handle<DetElementObject> Segmentation::detector() const  {
0121   return access()->detector;
0122 }
0123 
0124 /// Access the sensitive detector using this segmentation object
0125 Handle<SensitiveDetectorObject> Segmentation::sensitive() const  {
0126   return access()->sensitive;
0127 }
0128 
0129 #include <DDSegmentation/NoSegmentation.h>
0130 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::NoSegmentation);
0131 
0132 #include <DDSegmentation/CartesianGrid.h>
0133 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGrid);
0134 
0135 #include <DDSegmentation/CartesianGridXY.h>
0136 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridXY);
0137 
0138 #include <DDSegmentation/CartesianGridXZ.h>
0139 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridXZ);
0140 
0141 #include <DDSegmentation/CartesianGridYZ.h>
0142 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridYZ);
0143 
0144 #include <DDSegmentation/CartesianGridUV.h>
0145 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridUV);
0146 
0147 #include <DDSegmentation/CartesianGridXYZ.h>
0148 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianGridXYZ);
0149 
0150 #include <DDSegmentation/CartesianStripX.h>
0151 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianStripX);
0152 
0153 #include <DDSegmentation/CartesianStripY.h>
0154 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianStripY);
0155 
0156 #include <DDSegmentation/CartesianStripZ.h>
0157 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CartesianStripZ);
0158 
0159 #include <DDSegmentation/TiledLayerGridXY.h>
0160 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::TiledLayerGridXY);
0161 
0162 #include <DDSegmentation/MegatileLayerGridXY.h>
0163 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::MegatileLayerGridXY);
0164 
0165 #include <DDSegmentation/WaferGridXY.h>
0166 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::WaferGridXY);
0167 
0168 #include <DDSegmentation/PolarGridRPhi.h>
0169 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::PolarGridRPhi);
0170 
0171 #include <DDSegmentation/PolarGridRPhi2.h>
0172 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::PolarGridRPhi2);
0173 
0174 #include <DDSegmentation/GridPhiEta.h>
0175 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::GridPhiEta);
0176 
0177 #include <DDSegmentation/GridRPhiEta.h>
0178 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::GridRPhiEta);
0179 
0180 #include <DDSegmentation/ProjectiveCylinder.h>
0181 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::ProjectiveCylinder);
0182 
0183 #include <DDSegmentation/MultiSegmentation.h>
0184 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::MultiSegmentation);
0185 
0186 #include <DDSegmentation/CylindricalGridPhiZ.h>
0187 DD4HEP_INSTANTIATE_SEGMENTATION_HANDLE(DDSegmentation::CylindricalGridPhiZ);