File indexing completed on 2025-01-18 09:55:21
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef DDDIGI_DIGISEGMENTATIONTOOL_H
0014 #define DDDIGI_DIGISEGMENTATIONTOOL_H
0015
0016
0017 #include <DDDigi/DigiData.h>
0018 #include <DD4hep/Detector.h>
0019 #include <DD4hep/DetElement.h>
0020
0021
0022 namespace dd4hep {
0023
0024
0025 namespace digi {
0026
0027
0028 class DigiSegmentContext;
0029 class DigiSegmentationTool;
0030
0031
0032
0033
0034
0035
0036
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
0053 DigiSegmentContext() = default;
0054
0055 DigiSegmentContext(DigiSegmentContext&& copy) = default;
0056
0057 DigiSegmentContext(const DigiSegmentContext& copy) = default;
0058
0059 virtual ~DigiSegmentContext() = default;
0060
0061 DigiSegmentContext& operator=(DigiSegmentContext&& copy) = default;
0062
0063 DigiSegmentContext& operator=(const DigiSegmentContext& copy) = default;
0064
0065
0066 const std::string& name() const;
0067
0068 const char* cname() const;
0069
0070 std::string identifier(uint32_t id) const;
0071
0072
0073 uint32_t split_id(uint64_t cell) const {
0074 return uint32_t( (cell & this->split_mask) >> this->offset );
0075 }
0076
0077 uint64_t cell_id(uint64_t cell) const {
0078 return uint64_t( uint64_t(cell & this->cell_mask) >> (this->offset + width) );
0079 }
0080
0081 uint64_t detector_id(uint64_t cell) const {
0082 return uint64_t(cell & this->det_mask);
0083 }
0084 };
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095 class DigiSegmentationTool {
0096 public:
0097 Detector& description;
0098 DetElement detector;
0099 SensitiveDetector sensitive;
0100 IDDescriptor iddescriptor;
0101
0102 public:
0103
0104 DigiSegmentationTool(Detector& desc);
0105
0106 virtual ~DigiSegmentationTool() = default;
0107
0108
0109 void set_detector(const std::string& det_name);
0110
0111
0112 std::vector<std::string> collection_names() const;
0113
0114 std::vector<Key> collection_keys() const;
0115
0116 std::vector<Key> collection_keys(Key::mask_type mask) const;
0117
0118 std::vector<Key> collection_keys(const std::vector<std::string>& detectors) const;
0119
0120 std::vector<Key> collection_keys(const std::vector<std::string>& detectors, Key::mask_type mask) const;
0121
0122
0123 DigiSegmentContext split_context(const std::string& split_by) const;
0124
0125
0126 std::set<uint32_t> split_segmentation(const std::string& split_by) const;
0127 };
0128 }
0129 }
0130 #endif