Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:21

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 DDDIGI_DIGISEGMENTATIONTOOL_H
0014 #define DDDIGI_DIGISEGMENTATIONTOOL_H
0015 
0016 // Framework include files
0017 #include <DDDigi/DigiData.h>
0018 #include <DD4hep/Detector.h>
0019 #include <DD4hep/DetElement.h>
0020 
0021 /// Namespace for the AIDA detector description toolkit
0022 namespace dd4hep {
0023 
0024   /// Namespace for the Digitization part of the AIDA detector description toolkit
0025   namespace digi {
0026 
0027     /// Forward declarations
0028     class DigiSegmentContext;
0029     class DigiSegmentationTool;
0030 
0031     /// Segmentation split context
0032     /**
0033      *
0034      *  \author  M.Frank
0035      *  \version 1.0
0036      *  \ingroup DD4HEP_DIGITIZATION
0037      */
0038     class DigiSegmentContext  {
0039     public:
0040       using field_t = const BitFieldElement;
0041       DetElement   detector   { };
0042       IDDescriptor idspec     { };
0043       field_t*     field      { nullptr };
0044       uint64_t     cell_mask  { ~0x0UL };
0045       uint64_t     det_mask   { 0UL };
0046       uint64_t     split_mask { 0UL };
0047       int32_t      offset     { 0 };
0048       int32_t      width      { 0 };
0049       int32_t      max_split  { 0 };
0050 
0051     public:
0052       /// Default constructor
0053       DigiSegmentContext() = default;
0054       /// Default move constructor
0055       DigiSegmentContext(DigiSegmentContext&& copy) = default;
0056       /// Default copy constructor
0057       DigiSegmentContext(const DigiSegmentContext& copy) = default;
0058       /// Default destructor
0059       virtual ~DigiSegmentContext() = default;
0060       /// Default move assignment
0061       DigiSegmentContext& operator=(DigiSegmentContext&& copy) = default;
0062       /// Default copy assignment
0063       DigiSegmentContext& operator=(const DigiSegmentContext& copy) = default;
0064 
0065       /// Split field name
0066       const std::string& name()  const;
0067       /// Split field name
0068       const char* cname()  const;
0069       /// Full identifier (field + id)
0070       std::string identifier(uint32_t id)  const;
0071       
0072       /// Get the identifier of the cell to be split
0073       uint32_t split_id(uint64_t cell)  const  {
0074     return uint32_t( (cell & this->split_mask) >> this->offset );
0075       }
0076       /// The CELL ID part of the identifier
0077       uint64_t cell_id(uint64_t cell)  const  {
0078     return uint64_t( uint64_t(cell & this->cell_mask) >> (this->offset + width) );
0079       }
0080       /// The identifier of the parent detector
0081       uint64_t detector_id(uint64_t cell)  const  {
0082     return uint64_t(cell & this->det_mask);
0083       }
0084     };
0085 
0086     /// Tool to handle segmentation manipulations
0087     /**
0088      *  
0089      *  
0090      *
0091      *  \author  M.Frank
0092      *  \version 1.0
0093      *  \ingroup DD4HEP_DIGITIZATION
0094      */
0095     class DigiSegmentationTool  {
0096     public:
0097       Detector&         description;
0098       DetElement        detector;
0099       SensitiveDetector sensitive;
0100       IDDescriptor      iddescriptor;
0101 
0102     public:
0103       /// Initializing constructor
0104       DigiSegmentationTool(Detector& desc);
0105       /// Default destructor
0106       virtual ~DigiSegmentationTool() = default;
0107 
0108       /// Setup tool to handle a given detector of the geometry
0109       void set_detector(const std::string& det_name);
0110 
0111       /// Access the readout collection keys
0112       std::vector<std::string> collection_names()   const;
0113       /// Access the readout collection keys (mask is empty!)
0114       std::vector<Key> collection_keys()   const;
0115       /// Access the readout collection keys with predefined mask
0116       std::vector<Key> collection_keys(Key::mask_type mask)   const;
0117       /// Access the collection keys from readout structures of multiple subdetectors
0118       std::vector<Key> collection_keys(const std::vector<std::string>& detectors)   const;
0119       /// Access the collection keys from readout structures of multiple subdetectors
0120       std::vector<Key> collection_keys(const std::vector<std::string>& detectors, Key::mask_type mask)   const;
0121 
0122       /// Create a split context depending on the segmentation field
0123       DigiSegmentContext split_context(const std::string& split_by)  const;
0124 
0125       /// Create full set of detector segments which can be split according to the context
0126       std::set<uint32_t> split_segmentation(const std::string& split_by)  const;
0127     };
0128   }    // End namespace digi
0129 }      // End namespace dd4hep
0130 #endif // DDDIGI_DIGISEGMENTATIONTOOL_H