Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:13:37

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 #ifndef DDSEGMENTATION_MULTISEGMENTATION_H
0014 #define DDSEGMENTATION_MULTISEGMENTATION_H
0015 
0016 #include <DDSegmentation/Segmentation.h>
0017 
0018 /// Main handle class to hold a TGeo alignment object of type TGeoPhysicalNode
0019 namespace dd4hep {
0020 
0021   namespace DDSegmentation {
0022 
0023     /// Wrapper to support multiple segmentations
0024     /**
0025      *  \author  M.Frank
0026      *  \version 1.0
0027      *  \ingroup DD4HEP_DDSEGMENTATION
0028      */
0029     class MultiSegmentation : public Segmentation {
0030     public:
0031       /// Helper structure to describe a sub-segmentation entry
0032       struct Entry {
0033         long key_min, key_max;
0034         Segmentation* segmentation;
0035       };
0036       typedef std::vector<Entry> Segmentations;
0037 
0038     protected:
0039       /// Sub-segmentaion container
0040       Segmentations  m_segmentations;
0041 
0042       /// the field name used to discriminate sub-segmentations
0043       std::string    m_discriminatorId;
0044 
0045       /// Bitfield corresponding to dicriminator identifier
0046       const BitFieldElement* m_discriminator;
0047 
0048       /// Debug flags
0049       int m_debug;
0050 
0051     public:
0052       /// Default constructor passing the encoding string
0053       MultiSegmentation(const std::string& cellEncoding = "");
0054 
0055       /// Default constructor used by derived classes passing an existing decoder
0056       MultiSegmentation(const BitFieldCoder* decoder);
0057 
0058       /// Default destructor
0059       virtual ~MultiSegmentation();
0060 
0061       /// Add subsegmentation.
0062       virtual void addSubsegmentation(long key_min, long key_max, Segmentation* entry);
0063 
0064       /// Access subsegmentation by cell identifier
0065       const Segmentation& subsegmentation(const CellID& cellID) const;
0066 
0067       /// determine the position based on the cell ID
0068       virtual Vector3D position(const CellID& cellID) const;
0069 
0070       /// determine the cell ID based on the position
0071       virtual CellID cellID(const Vector3D& localPosition, const Vector3D& globalPosition, const VolumeID& volumeID) const;
0072 
0073       /** \brief Returns a vector<double> of the cellDimensions of the given cell ID
0074           in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi
0075 
0076           \param cellID cellID of the cell for which parameters are returned
0077           \return vector<double> in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi
0078       */
0079       virtual std::vector<double> cellDimensions(const CellID& cellID) const;
0080 
0081       /// access the field name used to discriminate sub-segmentations
0082       const std::string& discriminatorName() const {  return m_discriminatorId;  }
0083 
0084       /// Discriminating bitfield entry
0085       const BitFieldElement* discriminator() const         {  return m_discriminator;    }
0086 
0087       /// Set the underlying decoder
0088       virtual void setDecoder(const BitFieldCoder* decoder);
0089 
0090       /// The underlying sub-segementations
0091       const Segmentations& subSegmentations()  const { return m_segmentations;   }
0092 
0093     };
0094 
0095   } /* namespace DDSegmentation */
0096 } /* namespace dd4hep */
0097 
0098 #endif // DDSEGMENTATION_MULTISEGMENTATION_H