diff --git a/DDDigi/include/DDDigi/DigiData.h b/DDDigi/include/DDDigi/DigiData.h index 8ea9ced76142a19b9a24ca6c82bc543ef11383cb..53543785c9cf680bf0df5ffdef042bbbb8082570 100644 --- a/DDDigi/include/DDDigi/DigiData.h +++ b/DDDigi/include/DDDigi/DigiData.h @@ -99,51 +99,35 @@ namespace dd4hep { void set(const std::string& name, int mask); /// Set key mask - Key& set_mask(mask_type m) { - this->values.mask = m; - return *this; - } + Key& set_mask(mask_type m); + /// Set key item identifier + Key& set_item(itemkey_type i); + /// Set key mask + Key& set_segment(segment_type seg); /// Set key submask - Key& set_submask(submask_type m) { - this->values.submask = m; - return *this; - } + Key& set_submask(submask_type m); /// Set key submask Key& set_submask(const char* opt_tag); - /// Set key item identifier - Key& set_item(itemkey_type i) { - this->values.item = i; - return *this; - } - /// Set key mask - Key& set_segment(segment_type seg) { - this->values.segment = seg; - return *this; - } + /// Project the item part of the key - mask_type mask() const { - return this->values.mask; - } + mask_type mask() const; /// Project the mask part of the key - itemkey_type item() const { - return this->values.item; - } + itemkey_type item() const; /// Project the segment part of the key - segment_type segment() const { - return this->values.segment; - } + segment_type segment() const; + /// Project the item part of the key + submask_type submask() const; /// Access key as long integer - key_type value() const { - return this->key; - } + key_type value() const; + /// Project the mask part of the key - static itemkey_type item(Key k) { - return k.values.item; - } + static itemkey_type item(Key k); + /// Project the item part of the key + static mask_type mask(Key k); /// Project the item part of the key - static mask_type mask(Key k) { - return k.values.mask; - } + static segment_type segment(Key k); + /// Project the item part of the key + static submask_type submask(Key k); /// Access key name (if registered properly) static std::string key_name(const Key& key); }; @@ -199,6 +183,75 @@ namespace dd4hep { return this->key > other.key; } + /// Set key mask + inline Key& Key::set_mask(mask_type m) { + this->values.mask = m; + return *this; + } + + /// Set key submask + inline Key& Key::set_submask(submask_type m) { + this->values.submask = m; + return *this; + } + + /// Set key item identifier + inline Key& Key::set_item(itemkey_type i) { + this->values.item = i; + return *this; + } + + /// Set key mask + inline Key& Key::set_segment(segment_type seg) { + this->values.segment = seg; + return *this; + } + + /// Access key as long integer + inline Key::key_type Key::value() const { + return this->key; + } + /// Project the item part of the key + inline Key::mask_type Key::mask() const { + return this->values.mask; + } + /// Project the mask part of the key + inline Key::itemkey_type Key::item() const { + return this->values.item; + } + /// Project the segment part of the key + inline Key::segment_type Key::segment() const { + return this->values.segment; + } + /// Project the item part of the key + inline Key::submask_type Key::submask() const { + return this->values.submask; + } + + /// Project the mask part of the key + inline Key::itemkey_type Key::item(Key k) { + return k.values.item; + } + /// Project the item part of the key + inline Key::mask_type Key::mask(Key k) { + return k.values.mask; + } + /// Project the item part of the key + inline Key::segment_type Key::segment(Key k) { + return k.values.segment; + } + /// Project the item part of the key + inline Key::submask_type Key::submask(Key k) { + return k.values.submask; + } + + /// Base class for objects in a DataSegment + /** + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_DIGITIZATION + */ class SegmentEntry { public: std::string name { }; diff --git a/DDDigi/src/DigiData.cpp b/DDDigi/src/DigiData.cpp index 5c4f183430c0a06fc49496d4bdc3ceab4c716c62..d579ad29f6b874ffa5788627e2079ae4538ce450 100644 --- a/DDDigi/src/DigiData.cpp +++ b/DDDigi/src/DigiData.cpp @@ -214,12 +214,7 @@ std::size_t ParticleMapping::merge(ParticleMapping&& updates) { } void ParticleMapping::push(Key particle_key, Particle&& particle_data) { -#if defined(__GNUC__) && (__GNUC__ < 10) - /// Lower compiler version have a bad implementation of std::any - bool ret = false; -#else bool ret = data.emplace(particle_key, std::move(particle_data)).second; -#endif if ( !ret ) { except("ParticleMapping","Error in particle map. Duplicate ID: mask:%04X Number:%d History:%s", particle_key.mask(), particle_key.item(), yes_no(1/*particle_data.history.has_value()*/)); @@ -227,11 +222,7 @@ void ParticleMapping::push(Key particle_key, Particle&& particle_data) { } void ParticleMapping::insert(Key particle_key, const Particle& particle_data) { -#if defined(__GNUC__) && (__GNUC__ < 10) - bool ret = false; -#else bool ret = data.emplace(particle_key, particle_data).second; -#endif if ( !ret ) { except("ParticleMapping","Error in particle map. Duplicate ID: mask:%04X Number:%d History:%s", particle_key.mask(), particle_key.item(), yes_no(1/*particle_data.history.has_value()*/)); @@ -240,11 +231,7 @@ void ParticleMapping::insert(Key particle_key, const Particle& particle_data) { /// Insert new entry void ParticleMapping::emplace(Key particle_key, Particle&& particle_data) { -#if defined(__GNUC__) && (__GNUC__ < 10) - //return std::make_pair(false); -#else data.emplace(particle_key, std::move(particle_data)).second; -#endif } /// Merge new deposit map onto existing map (not thread safe!)