diff --git a/DDCore/include/DD4hep/BitField64.h b/DDCore/include/DD4hep/BitField64.h index 3dfdcb0d85d396d7c6759ec9026c07635b4add85..855f003fed32deea5ab34e621249c021c859de6d 100644 --- a/DDCore/include/DD4hep/BitField64.h +++ b/DDCore/include/DD4hep/BitField64.h @@ -23,7 +23,7 @@ namespace dd4hep { namespace detail { using DDSegmentation::BitField64; - using DDSegmentation::BitFieldValue; + using DDSegmentation::BitFieldElement; } /* End namespace detail */ } /* End namespace dd4hep */ diff --git a/DDCore/include/DD4hep/Factories.h b/DDCore/include/DD4hep/Factories.h index 799a8d627c59b0970a42527cf6c66bf561291b4d..12c6ae6b98d74975370ed9e7df097761c7697d6c 100644 --- a/DDCore/include/DD4hep/Factories.h +++ b/DDCore/include/DD4hep/Factories.h @@ -43,7 +43,7 @@ namespace dd4hep { /// Namespace describing generic detector segmentations namespace DDSegmentation { - class BitField64; + class BitFieldCoder; } @@ -80,7 +80,7 @@ namespace dd4hep { */ template <typename T> class SegmentationFactory : public PluginFactoryBase { public: - static SegmentationObject* create(DDSegmentation::BitField64* decoder); + static SegmentationObject* create(const DDSegmentation::BitFieldCoder* decoder); }; /// Template class with a generic signature to apply Detector plugins @@ -203,7 +203,7 @@ namespace { typedef dd4hep::json::Handle_t json_h; typedef dd4hep::Handle<Named> ref_t; typedef dd4hep::SegmentationObject SegmentationObject; - typedef dd4hep::DDSegmentation::BitField64 BitField64; + typedef dd4hep::DDSegmentation::BitFieldCoder BitFieldCoder; } DD4HEP_PLUGIN_FACTORY_ARGS_1(void*,const char*) @@ -212,7 +212,7 @@ namespace { DD4HEP_PLUGIN_FACTORY_ARGS_1(ns::Named*,dd4hep::Detector*) { return dd4hep::TranslationFactory<P>::create(*a0).ptr(); } - DD4HEP_PLUGIN_FACTORY_ARGS_1(ns::SegmentationObject*,ns::BitField64*) + DD4HEP_PLUGIN_FACTORY_ARGS_1(ns::SegmentationObject*,const ns::BitFieldCoder*) { return dd4hep::SegmentationFactory<P>::create(a0); } DD4HEP_PLUGIN_FACTORY_ARGS_3(void*,dd4hep::Detector*,int,char**) @@ -250,12 +250,12 @@ namespace { #define DECLARE_NAMED_DETELEMENT_FACTORY(n,x) namespace dd4hep \ { DD4HEP_PLUGINSVC_FACTORY(n::x,x,dd4hep::*(),__LINE__) } -// Call function of the type [SegmentationObject (*func)(dd4hep::Detector*,DDSegmentation::BitField64*)] +// Call function of the type [SegmentationObject (*func)(dd4hep::Detector*,DDSegmentation::BitFieldCoder*)] #define DECLARE_SEGMENTATION(name,func) DD4HEP_OPEN_PLUGIN(dd4hep,name) { \ template <> SegmentationObject* \ - SegmentationFactory<name>::create(DDSegmentation::BitField64* d) { return func(d); } \ + SegmentationFactory<name>::create(const DDSegmentation::BitFieldCoder* d) { return func(d); } \ DD4HEP_PLUGINSVC_FACTORY(name,segmentation_constructor__##name, \ - SegmentationObject*(DDSegmentation::BitField64*),__LINE__)} + SegmentationObject*(const DDSegmentation::BitFieldCoder*),__LINE__)} // Call function of the type [long (*func)(const char* arg)] #define DECLARE_APPLY(name,func) DD4HEP_OPEN_PLUGIN(dd4hep,name) { \ diff --git a/DDCore/include/DD4hep/IDDescriptor.h b/DDCore/include/DD4hep/IDDescriptor.h index c031454ac84c6d36cea3e179ea3b2f04b55af5cb..07dab4362d9cfe56039aa6619c4d0b141e098300 100644 --- a/DDCore/include/DD4hep/IDDescriptor.h +++ b/DDCore/include/DD4hep/IDDescriptor.h @@ -15,7 +15,7 @@ // Framework include files #include "DD4hep/Handle.h" -#include "DD4hep/BitField64.h" +#include "DD4hep/BitFieldCoder.h" // C++ include files #include <string> @@ -36,7 +36,7 @@ namespace dd4hep { */ class IDDescriptor: public Handle<IDDescriptorObject> { public: - typedef std::vector<std::pair<std::string, BitFieldValue*> > FieldMap; + typedef std::vector<std::pair<std::string, const BitFieldElement*> > FieldMap; typedef std::vector<std::pair<size_t, std::string> > FieldIDs; public: @@ -55,25 +55,25 @@ namespace dd4hep { /// Access the fieldmap container const FieldMap& fields() const; /// Get the field descriptor of one field by name - const BitFieldValue* field(const std::string& field_name) const; + const BitFieldElement* field(const std::string& field_name) const; /// Get the field identifier of one field by name size_t fieldID(const std::string& field_name) const; /// Get the field descriptor of one field by its identifier - const BitFieldValue* field(size_t identifier) const; + const BitFieldElement* field(size_t identifier) const; #ifndef __MAKECINT__ /// Encode a set of volume identifiers (corresponding to this description of course!) to a volumeID. VolumeID encode(const std::vector<std::pair<std::string, int> >& ids) const; #endif /// Decode volume IDs and return filled descriptor with all fields - void decodeFields(VolumeID vid, std::vector<std::pair<const BitFieldValue*, VolumeID> >& fields) const; + void decodeFields(VolumeID vid, std::vector<std::pair<const BitFieldElement*, VolumeID> >& fields) const; /// Decode volume IDs and return string reprensentation for debugging purposes std::string str(VolumeID vid) const; /// Decode volume IDs and return string reprensentation for debugging purposes std::string str(VolumeID vid, VolumeID mask) const; /// Access string representation std::string toString() const; - /// Access the BitField64 object - BitField64* decoder(); + /// Access the BitFieldCoder object + BitFieldCoder* decoder(); /// Re-build object in place void rebuild(const std::string& description); }; diff --git a/DDCore/include/DD4hep/MultiSegmentation.h b/DDCore/include/DD4hep/MultiSegmentation.h index 135622f389022fe5da05d494c01fce2a5f10d7f1..719a0f3b92a0fe4deebdde403639eda1dfebc6fb 100644 --- a/DDCore/include/DD4hep/MultiSegmentation.h +++ b/DDCore/include/DD4hep/MultiSegmentation.h @@ -72,7 +72,7 @@ namespace dd4hep { /// access the field name used to discriminate sub-segmentations const std::string& discriminatorName() const; /// Discriminating bitfield entry - BitFieldValue* discriminator() const; + const BitFieldElement* discriminator() const; /// The underlying sub-segementations const Segmentations& subSegmentations() const; /// determine the position based on the cell ID diff --git a/DDCore/include/DD4hep/Primitives.h b/DDCore/include/DD4hep/Primitives.h index 078d680bcb14103a9fe04ac67fa73a6904d3efbb..95900fa7df4ec808bda57f8db8b2d3c3f3f7dd31 100644 --- a/DDCore/include/DD4hep/Primitives.h +++ b/DDCore/include/DD4hep/Primitives.h @@ -32,8 +32,8 @@ namespace dd4hep { /// Namespace describing generic detector segmentations namespace DDSegmentation { - class BitField64; - class BitFieldValue; + class BitFieldCoder; + class BitFieldElement; /// Useful typedefs to differentiate cell IDs and volume IDs typedef long long int CellID; typedef long long int VolumeID; @@ -44,13 +44,13 @@ namespace dd4hep { #ifdef __CINT__ typedef DDSegmentation::CellID CellID; typedef DDSegmentation::VolumeID VolumeID; - typedef DDSegmentation::BitField64 BitField64; - typedef DDSegmentation::BitFieldValue BitFieldValue; + typedef DDSegmentation::BitFieldCoder BitFieldCoder; + typedef DDSegmentation::BitFieldElement BitFieldElement; #else using DDSegmentation::CellID; using DDSegmentation::VolumeID; - using DDSegmentation::BitField64; - using DDSegmentation::BitFieldValue; + using DDSegmentation::BitFieldCoder; + using DDSegmentation::BitFieldElement; #endif /// Specialized exception to be thrown if invalid handles are accessed diff --git a/DDCore/include/DD4hep/Segmentations.h b/DDCore/include/DD4hep/Segmentations.h index 6e80edf0422117c05a6052ec697ae6d38101d71f..495620b67316c54912c6814e2f1a6df8c27a3717 100644 --- a/DDCore/include/DD4hep/Segmentations.h +++ b/DDCore/include/DD4hep/Segmentations.h @@ -16,7 +16,7 @@ // Framework include files #include "DD4hep/Handle.h" #include "DD4hep/Objects.h" -#include "DD4hep/BitField64.h" +#include "DD4hep/BitFieldCoder.h" #include "DDSegmentation/Segmentation.h" /// Namespace for the AIDA detector description toolkit @@ -41,7 +41,7 @@ namespace dd4hep { class Segmentation : public Handle<SegmentationObject> { public: /// Initializing constructor creating a new object of the given DDSegmentation type - Segmentation(const std::string& type, const std::string& name, BitField64* decoder); + Segmentation(const std::string& type, const std::string& name, const BitFieldCoder* decoder); /// Default constructor Segmentation() = default; /// Copy Constructor from object @@ -69,9 +69,9 @@ namespace dd4hep { /// Access the sensitive detector using this segmetnation object Handle<SensitiveDetectorObject> sensitive() const; /// Access the underlying decoder - const BitField64* decoder() const; + const BitFieldCoder* decoder() const; /// Set the underlying decoder - void setDecoder(BitField64* decoder) const; + void setDecoder(const BitFieldCoder* decoder) const; /// determine the local position based on the cell ID Position position(const long64& cellID) const; /// determine the cell ID based on the local position diff --git a/DDCore/include/DD4hep/detail/ObjectsInterna.h b/DDCore/include/DD4hep/detail/ObjectsInterna.h index fd6e600e8dc7ef3b624a543abad15e8fc3a5fbe0..664c0721a96ebb5bad57cd1776de2a95c1d909a2 100644 --- a/DDCore/include/DD4hep/detail/ObjectsInterna.h +++ b/DDCore/include/DD4hep/detail/ObjectsInterna.h @@ -18,7 +18,7 @@ #include "DD4hep/NamedObject.h" #include "DD4hep/IDDescriptor.h" #include "DD4hep/Segmentations.h" -#include "DD4hep/BitField64.h" +#include "DD4hep/BitFieldCoder.h" // C/C++ include files #include <set> @@ -192,14 +192,14 @@ namespace dd4hep { */ class IDDescriptorObject: public NamedObject { public: - typedef std::vector<std::pair<std::string, BitFieldValue*> > FieldMap; + typedef std::vector<std::pair<std::string, const BitFieldElement*> > FieldMap; typedef std::vector<std::pair<size_t, std::string> > FieldIDs; /// Map of id-fields in the descriptor FieldMap fieldMap; //! not ROOT-persistent /// String map of id descriptors FieldIDs fieldIDs; //! not ROOT-persistent /// Decoder object - BitField64 decoder; //! not ROOT-persistent + BitFieldCoder decoder; //! not ROOT-persistent /// The description string to build the bit-field descriptors. std::string description; @@ -211,8 +211,8 @@ namespace dd4hep { virtual ~IDDescriptorObject(); #if 0 #ifndef __CINT__ - /// Access to the field container of the BitField64 - const std::vector<BitFieldValue*>& fields() const { + /// Access to the field container of the BitFieldCoder + const std::vector<BitFieldElement*>& fields() const { return decoder.fields(); } #endif diff --git a/DDCore/include/DD4hep/detail/SegmentationsInterna.h b/DDCore/include/DD4hep/detail/SegmentationsInterna.h index 83b9fccf04102b3308ece040a075f47d61b3756f..4eceaa372b69ce507c9cf6a3d9f4906f73cc8326 100644 --- a/DDCore/include/DD4hep/detail/SegmentationsInterna.h +++ b/DDCore/include/DD4hep/detail/SegmentationsInterna.h @@ -16,7 +16,7 @@ // Framework include files #include "DD4hep/Handle.h" #include "DD4hep/Objects.h" -#include "DD4hep/BitField64.h" +#include "DD4hep/BitFieldCoder.h" #include "DDSegmentation/Segmentation.h" // C/C++ include files @@ -55,9 +55,9 @@ namespace dd4hep { /// Access the description of the segmentation const std::string& description() const; /// Access the underlying decoder - const BitField64* decoder() const; + const BitFieldCoder* decoder() const; /// Set the underlying decoder - void setDecoder(BitField64* decoder) const; + void setDecoder(const BitFieldCoder* decoder) const; /// Access to parameter by name DDSegmentation::Parameter parameter(const std::string& parameterName) const; /// Access to all parameters @@ -106,14 +106,14 @@ namespace dd4hep { SegmentationWrapper() : SegmentationObject(implementation=new IMP(0)) { } #endif /// Standard constructor - SegmentationWrapper(BitField64* decoder); + SegmentationWrapper(const BitFieldCoder* decoder); /// Default destructor virtual ~SegmentationWrapper(); }; /// Standard constructor template <typename IMP> inline - SegmentationWrapper<IMP>::SegmentationWrapper(BitField64* decode) + SegmentationWrapper<IMP>::SegmentationWrapper(const BitFieldCoder* decode) : SegmentationObject(implementation=new IMP(decode)) { } diff --git a/DDCore/include/DD4hep/detail/VolumeManagerInterna.h b/DDCore/include/DD4hep/detail/VolumeManagerInterna.h index 77b997fa3ccff74548b24c490c9d5303ceb225e3..1d727e739a6a2836722b4a47d76703185315f51c 100644 --- a/DDCore/include/DD4hep/detail/VolumeManagerInterna.h +++ b/DDCore/include/DD4hep/detail/VolumeManagerInterna.h @@ -58,7 +58,7 @@ namespace dd4hep { /// The reference to the TOP level VolumeManager VolumeManagerObject* top = 0; /// The system field descriptor - const BitFieldValue* system = 0; //! Not ROOT persistent + const BitFieldElement* system = 0; //! Not ROOT persistent /// System identifier VolumeID sysID = 0; /// Sub-detector mask diff --git a/DDCore/include/DDSegmentation/BitField64.h b/DDCore/include/DDSegmentation/BitField64.h index bf3e37ce426d5792bb579a8bacb65c4ca51596d6..e74a8c73bda3947c1837b658d8aafd64e48e9800 100644 --- a/DDCore/include/DDSegmentation/BitField64.h +++ b/DDCore/include/DDSegmentation/BitField64.h @@ -25,14 +25,14 @@ namespace dd4hep { class BitFieldValue{ long64& _value ; - const BitFieldCoder::BitFieldValue& _bv ; + const BitFieldElement& _bv ; public : BitFieldValue() = delete ; - /// only c'tor with reference to bitfield and BitFieldCoder::BitFieldValue - BitFieldValue( long64& bitfield, const BitFieldCoder::BitFieldValue& bv ) : + /// only c'tor with reference to bitfield and BitFieldElement + BitFieldValue( long64& bitfield, const BitFieldElement& bv ) : _value( bitfield ), _bv( bv) {} /** Returns the current field value diff --git a/DDCore/include/DDSegmentation/BitFieldCoder.h b/DDCore/include/DDSegmentation/BitFieldCoder.h index 0fb9f9083783df72d99791763ece2d1ce2d03aa5..c222db00f560c5c321f440d43394f54d5d97063d 100644 --- a/DDCore/include/DDSegmentation/BitFieldCoder.h +++ b/DDCore/include/DDSegmentation/BitFieldCoder.h @@ -15,48 +15,22 @@ typedef unsigned long long ulong64 ; namespace DDSegmentation { - class BitFieldValue ; class StringTokenizer ; - - /** Helper class for decoding and encoding a bit field of 64bits for convenient declaration and - * manipulation of sub fields of various widths.<br> - * This is a thread safe re-implementation of the functionality in the deprected BitField64. - * - * Example:<br> - * BitFieldCoder bc("layer:7,system:-3,barrel:3,theta:32:11,phi:11" ) ; <br> - * bc.set( field, "layer" , 123 ); <br> - * bc.set( field, "system" , -4 ); <br> - * bc.set( field, "barrel" , 7 ); <br> - * bc.set( field, "theta" , 180 ); <br> - * bc.set( field, "phi" , 270 ); <br> - * ... <br> - * int theta = bc.get( field, "theta" ) ; <br> - * ... <br> - * unsigned phiIndex = bc.index("phi") ; <br> - * int phi = bc.get( field, phiIndex ) ; <br> - * - * @author F.Gaede, DESY - * @date 2017-09 - */ - class BitFieldCoder{ - - public: - - /** Helper class for BitFieldCoder that corresponds to one field value. + /** Helper class for BitFieldCoder that corresponds to one field value. */ - class BitFieldValue{ + class BitFieldElement{ public : - virtual ~BitFieldValue() {} + virtual ~BitFieldElement() {} /** The default c'tor. * @param name name of the field * @param offset offset of field * @param signedWidth width of field, negative if field is signed */ - BitFieldValue( const std::string& name, + BitFieldElement( const std::string& name, unsigned offset, int signedWidth ) ; /// calculate this field's value given an external 64 bit bitmap @@ -101,12 +75,35 @@ namespace DDSegmentation { }; + + /** Helper class for decoding and encoding a bit field of 64bits for convenient declaration and + * manipulation of sub fields of various widths.<br> + * This is a thread safe re-implementation of the functionality in the deprected BitField64. + * + * Example:<br> + * BitFieldCoder bc("layer:7,system:-3,barrel:3,theta:32:11,phi:11" ) ; <br> + * bc.set( field, "layer" , 123 ); <br> + * bc.set( field, "system" , -4 ); <br> + * bc.set( field, "barrel" , 7 ); <br> + * bc.set( field, "theta" , 180 ); <br> + * bc.set( field, "phi" , 270 ); <br> + * ... <br> + * int theta = bc.get( field, "theta" ) ; <br> + * ... <br> + * unsigned phiIndex = bc.index("phi") ; <br> + * int phi = bc.get( field, phiIndex ) ; <br> + * + * @author F.Gaede, DESY + * @date 2017-09 + */ + class BitFieldCoder{ + public : typedef std::map<std::string, unsigned int> IndexMap ; /** No default c'tor */ - BitFieldCoder() = delete ; + BitFieldCoder() {} ; ~BitFieldCoder() { // clean up for(unsigned i=0;i<_fields.size();i++){ @@ -191,14 +188,14 @@ namespace DDSegmentation { /** Const Access to field through name . */ - const BitFieldValue& operator[](const std::string& name) const { + const BitFieldElement& operator[](const std::string& name) const { return *_fields[ index( name ) ] ; } /** Const Access to field through index . */ - const BitFieldValue& operator[](unsigned index) const { + const BitFieldElement& operator[](unsigned index) const { return *_fields[ index ] ; } @@ -211,7 +208,7 @@ namespace DDSegmentation { */ std::string valueString(ulong64 bitfield) const ; - const std::vector<BitFieldValue*>& fields() const { + const std::vector<BitFieldElement*>& fields() const { return _fields; } @@ -236,7 +233,7 @@ namespace DDSegmentation { // -------------- data members:-------------- - std::vector<BitFieldValue*> _fields{} ; + std::vector<BitFieldElement*> _fields{} ; IndexMap _map{} ; long64 _joined{} ; diff --git a/DDCore/include/DDSegmentation/CartesianGrid.h b/DDCore/include/DDSegmentation/CartesianGrid.h index 3f054f8c3b22aa6ef1a8a23d206c2bf0e06256aa..4f57c10807dd3f2f8e032b5253f224daaf79ab4d 100644 --- a/DDCore/include/DDSegmentation/CartesianGrid.h +++ b/DDCore/include/DDSegmentation/CartesianGrid.h @@ -21,7 +21,7 @@ protected: /// Default constructor used by derived classes passing the encoding string CartesianGrid(const std::string& cellEncoding = ""); /// Default constructor used by derived classes passing an existing decoder - CartesianGrid(BitField64* decoder); + CartesianGrid(const BitFieldCoder* decoder); }; } /* namespace DDSegmentation */ diff --git a/DDCore/include/DDSegmentation/CartesianGridXY.h b/DDCore/include/DDSegmentation/CartesianGridXY.h index da28508bc4a73d27e1d6cfcf8ca69d656d76f088..337af434593e344cb91211e405ea32e9882194f5 100644 --- a/DDCore/include/DDSegmentation/CartesianGridXY.h +++ b/DDCore/include/DDSegmentation/CartesianGridXY.h @@ -18,7 +18,7 @@ public: /// Default constructor passing the encoding string CartesianGridXY(const std::string& cellEncoding = ""); /// Default constructor used by derived classes passing an existing decoder - CartesianGridXY(BitField64* decoder); + CartesianGridXY(const BitFieldCoder* decoder); /// destructor virtual ~CartesianGridXY(); diff --git a/DDCore/include/DDSegmentation/CartesianGridXYZ.h b/DDCore/include/DDSegmentation/CartesianGridXYZ.h index 887306edc7d2a8bb4c3a2eb40c8a44bef55287e9..0ee1b1c214914be9a7ea307510fec9c94043de0d 100644 --- a/DDCore/include/DDSegmentation/CartesianGridXYZ.h +++ b/DDCore/include/DDSegmentation/CartesianGridXYZ.h @@ -18,7 +18,7 @@ public: /// default constructor using an arbitrary type CartesianGridXYZ(const std::string& cellEncoding); /// Default constructor used by derived classes passing an existing decoder - CartesianGridXYZ(BitField64* decoder); + CartesianGridXYZ(const BitFieldCoder* decoder); /// destructor virtual ~CartesianGridXYZ(); diff --git a/DDCore/include/DDSegmentation/CartesianGridXZ.h b/DDCore/include/DDSegmentation/CartesianGridXZ.h index 7181b7e50cb09ac23c473fae684fa686ea539302..c0ed76b592f50bf869262f63c5314aa006db12a4 100644 --- a/DDCore/include/DDSegmentation/CartesianGridXZ.h +++ b/DDCore/include/DDSegmentation/CartesianGridXZ.h @@ -18,7 +18,7 @@ public: /// default constructor using an arbitrary type CartesianGridXZ(const std::string& cellEncoding); /// Default constructor used by derived classes passing an existing decoder - CartesianGridXZ(BitField64* decoder); + CartesianGridXZ(const BitFieldCoder* decoder); /// destructor virtual ~CartesianGridXZ(); diff --git a/DDCore/include/DDSegmentation/CartesianGridYZ.h b/DDCore/include/DDSegmentation/CartesianGridYZ.h index 1cc12060c0914dd4c133a34d26076cc95e2f9393..9c7bb534c5c4b1c60cb21edd69ed79e711489437 100644 --- a/DDCore/include/DDSegmentation/CartesianGridYZ.h +++ b/DDCore/include/DDSegmentation/CartesianGridYZ.h @@ -20,7 +20,7 @@ public: /// Default constructor passing the encoding string CartesianGridYZ(const std::string& cellEncoding = ""); /// Default constructor used by derived classes passing an existing decoder - CartesianGridYZ(BitField64* decoder); + CartesianGridYZ(const BitFieldCoder* decoder); /// destructor virtual ~CartesianGridYZ(); diff --git a/DDCore/include/DDSegmentation/CylindricalSegmentation.h b/DDCore/include/DDSegmentation/CylindricalSegmentation.h index f5213b00a390d2ae87216f3627cfd535b529a1fc..c06ec0b2cde761f22277b390abb7e0d2be2b4fc0 100644 --- a/DDCore/include/DDSegmentation/CylindricalSegmentation.h +++ b/DDCore/include/DDSegmentation/CylindricalSegmentation.h @@ -24,7 +24,7 @@ protected: /// default constructor using an arbitrary type CylindricalSegmentation(const std::string& cellEncoding); /// Default constructor used by derived classes passing an existing decoder - CylindricalSegmentation(BitField64* decoder); + CylindricalSegmentation(const BitFieldCoder* decoder); }; diff --git a/DDCore/include/DDSegmentation/GridPhiEta.h b/DDCore/include/DDSegmentation/GridPhiEta.h index 830dd9748746e33ec328e765ffc5ef6dfb5a98ae..b7d2f9476175884d42add886b486af4812b34fe2 100644 --- a/DDCore/include/DDSegmentation/GridPhiEta.h +++ b/DDCore/include/DDSegmentation/GridPhiEta.h @@ -20,7 +20,7 @@ public: /// default constructor using an arbitrary type GridPhiEta(const std::string& aCellEncoding); /// Default constructor used by derived classes passing an existing decoder - GridPhiEta(BitField64* aDecoder); + GridPhiEta(const BitFieldCoder* decoder); /// destructor virtual ~GridPhiEta() = default; @@ -128,10 +128,6 @@ public: } protected: - /// determine the pseudorapidity based on the current cell ID - double eta() const; - /// determine the azimuthal angle phi based on the current cell ID - double phi() const; /// the grid size in eta double m_gridSizeEta; diff --git a/DDCore/include/DDSegmentation/GridRPhiEta.h b/DDCore/include/DDSegmentation/GridRPhiEta.h index 80257f5c4852c4cc4bbf45ee6b99d058a495cd9b..ef3188e5e35b434f1f1d5f417c9caab9248f4e66 100644 --- a/DDCore/include/DDSegmentation/GridRPhiEta.h +++ b/DDCore/include/DDSegmentation/GridRPhiEta.h @@ -21,7 +21,7 @@ public: GridRPhiEta(const std::string& aCellEncoding); /// Default constructor used by derived classes passing an existing decoder - GridRPhiEta(BitField64* aDecoder); + GridRPhiEta(const BitFieldCoder* decoder); /// destructor virtual ~GridRPhiEta() = default; @@ -81,8 +81,6 @@ public: } private: - /// determine the radial distance R based on the current cell ID - double r() const; /// the grid size in r double m_gridSizeR; diff --git a/DDCore/include/DDSegmentation/MegatileLayerGridXY.h b/DDCore/include/DDSegmentation/MegatileLayerGridXY.h index 462c9d802673dbf512823108d81b56fd093ac8bb..2e8f03c624e9ee64fecf72d6d6a3f2daaf9343c1 100644 --- a/DDCore/include/DDSegmentation/MegatileLayerGridXY.h +++ b/DDCore/include/DDSegmentation/MegatileLayerGridXY.h @@ -43,7 +43,7 @@ namespace dd4hep { MegatileLayerGridXY(const std::string& cellEncoding = ""); /// Default constructor used by derived classes passing an existing decoder - MegatileLayerGridXY(BitField64* decoder); + MegatileLayerGridXY(const BitFieldCoder* decoder); /// destructor virtual ~MegatileLayerGridXY(); diff --git a/DDCore/include/DDSegmentation/MultiSegmentation.h b/DDCore/include/DDSegmentation/MultiSegmentation.h index b0393f1323a8de38944b9e9f2574ee87f492811a..b8d8616bcaa316201025d20a15aa7d6bdeb8eab6 100644 --- a/DDCore/include/DDSegmentation/MultiSegmentation.h +++ b/DDCore/include/DDSegmentation/MultiSegmentation.h @@ -44,7 +44,7 @@ namespace dd4hep { std::string m_discriminatorId; /// Bitfield corresponding to dicriminator identifier - BitFieldValue* m_discriminator; + const BitFieldElement* m_discriminator; /// Debug flags int m_debug; @@ -54,7 +54,7 @@ namespace dd4hep { MultiSegmentation(const std::string& cellEncoding = ""); /// Default constructor used by derived classes passing an existing decoder - MultiSegmentation(BitField64* decoder); + MultiSegmentation(const BitFieldCoder* decoder); /// Default destructor virtual ~MultiSegmentation(); @@ -83,10 +83,10 @@ namespace dd4hep { const std::string& discriminatorName() const { return m_discriminatorId; } /// Discriminating bitfield entry - BitFieldValue* discriminator() const { return m_discriminator; } + const BitFieldElement* discriminator() const { return m_discriminator; } /// Set the underlying decoder - virtual void setDecoder(BitField64* decoder); + virtual void setDecoder(const BitFieldCoder* decoder); /// The underlying sub-segementations const Segmentations& subSegmentations() const { return m_segmentations; } diff --git a/DDCore/include/DDSegmentation/NoSegmentation.h b/DDCore/include/DDSegmentation/NoSegmentation.h index 54e70a5ca4948e278add59e1c7eb93e1cfb66db2..6de5b699755d5625b747e4caada23bbdb2dc046e 100644 --- a/DDCore/include/DDSegmentation/NoSegmentation.h +++ b/DDCore/include/DDSegmentation/NoSegmentation.h @@ -20,7 +20,7 @@ namespace dd4hep { virtual ~NoSegmentation(); NoSegmentation(const std::string& cellEncoding = ""); - NoSegmentation(BitField64* decoder); + NoSegmentation(const BitFieldCoder* decoder); virtual Vector3D position(const CellID& cellID) const; virtual CellID cellID(const Vector3D& localPosition, const Vector3D& globalPosition, const VolumeID& volumeID) const; diff --git a/DDCore/include/DDSegmentation/PolarGrid.h b/DDCore/include/DDSegmentation/PolarGrid.h index b1a5877306af9c58cddb898399684d6821d378ba..f1d033d8b43c6143ccb1084b89200329c8b9797b 100644 --- a/DDCore/include/DDSegmentation/PolarGrid.h +++ b/DDCore/include/DDSegmentation/PolarGrid.h @@ -21,7 +21,7 @@ protected: /// Default constructor used by derived classes passing the encoding string PolarGrid(const std::string& cellEncoding = ""); /// Default constructor used by derived classes passing an existing decoder - PolarGrid(BitField64* decoder); + PolarGrid(const BitFieldCoder* decoder); }; } /* namespace DDSegmentation */ diff --git a/DDCore/include/DDSegmentation/PolarGridRPhi.h b/DDCore/include/DDSegmentation/PolarGridRPhi.h index 089d3c322285a82a91170ba3b185da5389a934f9..cc21a093000d3a465ba2cdc7ce7b3403cf61772e 100644 --- a/DDCore/include/DDSegmentation/PolarGridRPhi.h +++ b/DDCore/include/DDSegmentation/PolarGridRPhi.h @@ -19,7 +19,7 @@ public: /// Default constructor passing the encoding string PolarGridRPhi(const std::string& cellEncoding = ""); /// Default constructor used by derived classes passing an existing decoder - PolarGridRPhi(BitField64* decoder); + PolarGridRPhi(const BitFieldCoder* decoder); /// destructor virtual ~PolarGridRPhi(); diff --git a/DDCore/include/DDSegmentation/PolarGridRPhi2.h b/DDCore/include/DDSegmentation/PolarGridRPhi2.h index 013f662eb3aaa9cef9063c37736331e1e0f0b72c..663133862266564a90d732e1304b5c705cefecc0 100644 --- a/DDCore/include/DDSegmentation/PolarGridRPhi2.h +++ b/DDCore/include/DDSegmentation/PolarGridRPhi2.h @@ -47,7 +47,7 @@ public: /// Default constructor passing the encoding string PolarGridRPhi2(const std::string& cellEncoding = ""); /// Default constructor used by derived classes passing an existing decoder - PolarGridRPhi2(BitField64* decoder); + PolarGridRPhi2(const BitFieldCoder* decoder); /// destructor virtual ~PolarGridRPhi2(); diff --git a/DDCore/include/DDSegmentation/ProjectiveCylinder.h b/DDCore/include/DDSegmentation/ProjectiveCylinder.h index 5cc6cb32cf65bd41cc599ad8641571bac5adf6b1..94c63ca688a0e4900995018442f9703064039a15 100644 --- a/DDCore/include/DDSegmentation/ProjectiveCylinder.h +++ b/DDCore/include/DDSegmentation/ProjectiveCylinder.h @@ -18,7 +18,7 @@ public: /// default constructor using an arbitrary type ProjectiveCylinder(const std::string& cellEncoding); /// Default constructor used by derived classes passing an existing decoder - ProjectiveCylinder(BitField64* decoder); + ProjectiveCylinder(const BitFieldCoder* decoder); /// destructor virtual ~ProjectiveCylinder(); @@ -93,11 +93,6 @@ protected: /// the field name used for phi std::string _phiID; - /// determine the polar angle theta based on the current cell ID - double theta() const; - /// determine the azimuthal angle phi based on the current cell ID - double phi() const; - }; } /* namespace DDSegmentation */ diff --git a/DDCore/include/DDSegmentation/Segmentation.h b/DDCore/include/DDSegmentation/Segmentation.h index fdbbbd40cfa6a81d7a67cc5fb5ac09196a4879c4..475379b936ef3d9b2f7332d75c29b6dee4205655 100644 --- a/DDCore/include/DDSegmentation/Segmentation.h +++ b/DDCore/include/DDSegmentation/Segmentation.h @@ -8,7 +8,7 @@ #ifndef DDSegmentation_SEGMENTATION_H_ #define DDSegmentation_SEGMENTATION_H_ -#include "DDSegmentation/BitField64.h" +#include "DDSegmentation/BitFieldCoder.h" #include "DDSegmentation/SegmentationFactory.h" #include "DDSegmentation/SegmentationParameter.h" @@ -102,11 +102,11 @@ public: return _description; } /// Access the underlying decoder - virtual BitField64* decoder() const { + virtual const BitFieldCoder* decoder() const { return _decoder; } /// Set the underlying decoder - virtual void setDecoder(BitField64* decoder); + virtual void setDecoder(const BitFieldCoder* decoder); /// Access to parameter by name virtual Parameter parameter(const std::string& parameterName) const; /// Access to all parameters @@ -125,7 +125,7 @@ protected: /// Default constructor used by derived classes passing the encoding string Segmentation(const std::string& cellEncoding = ""); /// Default constructor used by derived classes passing an existing decoder - Segmentation(BitField64* decoder); + Segmentation(const BitFieldCoder* decoder); /// Add a parameter to this segmentation. Used by derived classes to define their parameters template<typename TYPE> void registerParameter(const std::string& nam, const std::string& desc, @@ -158,8 +158,8 @@ protected: /// The indices used for the encoding std::map<std::string, StringParameter> _indexIdentifiers; //! No ROOT persistency /// The cell ID encoder and decoder - mutable BitField64* _decoder = 0; //! Not ROOT persistent - /// Keeps track of the decoder ownership + const BitFieldCoder* _decoder = 0; + /// Keeps track of the decoder ownership bool _ownsDecoder = false; private: /// No copy constructor allowed diff --git a/DDCore/include/DDSegmentation/TiledLayerGridXY.h b/DDCore/include/DDSegmentation/TiledLayerGridXY.h index 67eb83bd3d41a5f7c87d39b29fc1a67e16d322f5..4379ef1a63f0e85d2751d7e4228c52bc495597f8 100644 --- a/DDCore/include/DDSegmentation/TiledLayerGridXY.h +++ b/DDCore/include/DDSegmentation/TiledLayerGridXY.h @@ -22,7 +22,7 @@ public: /// Default constructor passing the encoding string TiledLayerGridXY(const std::string& cellEncoding = ""); /// Default constructor used by derived classes passing an existing decoder - TiledLayerGridXY(BitField64* decoder); + TiledLayerGridXY(const BitFieldCoder* decoder); /// destructor virtual ~TiledLayerGridXY(); diff --git a/DDCore/include/DDSegmentation/TiledLayerSegmentation.h b/DDCore/include/DDSegmentation/TiledLayerSegmentation.h index 5de79d6a5ae725587c874f3f62f4f89a9dadda90..801b61763a6addfb0625085e7b53d57ddbfd4b87 100644 --- a/DDCore/include/DDSegmentation/TiledLayerSegmentation.h +++ b/DDCore/include/DDSegmentation/TiledLayerSegmentation.h @@ -29,7 +29,7 @@ public: /// Default constructor passing the encoding string TiledLayerSegmentation(const std::string& cellEncoding = ""); /// Default constructor used by derived classes passing an existing decoder - TiledLayerSegmentation(BitField64* decoder); + TiledLayerSegmentation(const BitFieldCoder* decoder); /// destructor virtual ~TiledLayerSegmentation(); diff --git a/DDCore/include/DDSegmentation/WaferGridXY.h b/DDCore/include/DDSegmentation/WaferGridXY.h index 4387aaac44266a3e7e8b05411a49fe63f0c0d5a4..63975a57b512972b99cbb7766aecfbeec83a7cb6 100644 --- a/DDCore/include/DDSegmentation/WaferGridXY.h +++ b/DDCore/include/DDSegmentation/WaferGridXY.h @@ -21,7 +21,7 @@ namespace dd4hep { /// Default constructor passing the encoding string WaferGridXY(const std::string& cellEncoding = ""); /// Default constructor used by derived classes passing an existing decoder - WaferGridXY(BitField64* decoder); + WaferGridXY(const BitFieldCoder* decoder); /// destructor virtual ~WaferGridXY(); diff --git a/DDCore/src/DetectorTools.cpp b/DDCore/src/DetectorTools.cpp index 8f0cde3ea90b8438d6ec84a4d720d8393d842414..3fbd3fde07eb16bd56528fb6a4e3c1516db4a9c8 100644 --- a/DDCore/src/DetectorTools.cpp +++ b/DDCore/src/DetectorTools.cpp @@ -388,7 +388,7 @@ std::string detail::tools::toString(const PlacedVolume::VolIDs& ids) { std::string detail::tools::toString(const IDDescriptor& dsc, const PlacedVolume::VolIDs& ids, VolumeID code) { stringstream log; for( const auto& id : ids ) { - const BitFieldValue* f = dsc.field(id.first); + const BitFieldElement* f = dsc.field(id.first); VolumeID value = f->value(code); log << id.first << "=" << id.second << "," << value << " [" << f->offset() << "," << f->width() << "] "; } diff --git a/DDCore/src/IDDescriptor.cpp b/DDCore/src/IDDescriptor.cpp index b2a6fbf4cceea943efc99350413e3843988670d3..fe9a19496890d9c54d5c9629aa590ad7469421d4 100644 --- a/DDCore/src/IDDescriptor.cpp +++ b/DDCore/src/IDDescriptor.cpp @@ -26,12 +26,12 @@ using namespace dd4hep::detail; namespace { void _construct(IDDescriptor::Object* o, const string& dsc) { - BitField64& bf = o->decoder; + BitFieldCoder& bf = o->decoder; o->fieldIDs.clear(); o->fieldMap.clear(); o->description = dsc; for (size_t i = 0; i < bf.size(); ++i) { - BitFieldValue* f = &bf[i]; + const BitFieldElement* f = &bf[i]; o->fieldIDs.push_back(make_pair(i, f->name())); o->fieldMap.push_back(make_pair(f->name(), f)); } @@ -49,8 +49,8 @@ IDDescriptor::IDDescriptor(const string& nam, const string& description) { void IDDescriptor::rebuild(const string& description) { Object* p = ptr(); string dsc = description; - p->decoder.~BitField64(); - new(&p->decoder) BitField64(dsc); + p->decoder.~BitFieldCoder(); + new(&p->decoder) BitFieldCoder(dsc); _construct(p, dsc); } @@ -63,7 +63,7 @@ string IDDescriptor::toString() const { } std::string IDDescriptor::fieldDescription() const { - BitField64& bf = data<Object>()->decoder; + BitFieldCoder& bf = data<Object>()->decoder; return bf.fieldDescription(); } @@ -89,7 +89,7 @@ const IDDescriptor::FieldMap& IDDescriptor::fields() const { } /// Get the field descriptor of one field by name -const BitFieldValue* IDDescriptor::field(const string& field_name) const { +const BitFieldElement* IDDescriptor::field(const string& field_name) const { const FieldMap& m = fields(); // This already checks the object validity for (const auto& i : m ) if (i.first == field_name) @@ -100,7 +100,7 @@ const BitFieldValue* IDDescriptor::field(const string& field_name) const { } /// Get the field descriptor of one field by its identifier -const BitFieldValue* IDDescriptor::field(size_t identifier) const { +const BitFieldElement* IDDescriptor::field(size_t identifier) const { const FieldMap& m = fields(); // This already checks the object validity return m[identifier].second; } @@ -123,7 +123,7 @@ VolumeID IDDescriptor::encode(const std::vector<std::pair<std::string, int> >& i //const PlacedVolume::VolIDs* ids = (const PlacedVolume::VolIDs*)&id_vector; //printout(INFO,"IDDescriptor","VolIDs: %s",ids->str().c_str()); for (const auto& i : id_vector ) { - const BitFieldValue* fld = field(i.first); + const BitFieldElement* fld = field(i.first); int off = fld->offset(); VolumeID val = i.second; id |= ((fld->value(val<<off) << off)&fld->mask()); @@ -133,9 +133,9 @@ VolumeID IDDescriptor::encode(const std::vector<std::pair<std::string, int> >& i /// Decode volume IDs and return filled descriptor with all fields void IDDescriptor::decodeFields(VolumeID vid, - vector<pair<const BitFieldValue*, VolumeID> >& flds) const + vector<pair<const BitFieldElement*, VolumeID> >& flds) const { - const vector<BitFieldValue*>& v = access()->decoder.fields(); + const vector<BitFieldElement*>& v = access()->decoder.fields(); flds.clear(); for (auto f : v ) flds.push_back(make_pair(f, f->value(vid))); @@ -143,7 +143,7 @@ void IDDescriptor::decodeFields(VolumeID vid, /// Decode volume IDs and return string reprensentation for debugging purposes string IDDescriptor::str(VolumeID vid) const { - const vector<BitFieldValue*>& v = access()->decoder.fields(); + const vector<BitFieldElement*>& v = access()->decoder.fields(); stringstream str; for (auto f : v ) str << f->name() << ":" << setw(4) << setfill('0') << hex << right << f->value(vid) @@ -153,7 +153,7 @@ string IDDescriptor::str(VolumeID vid) const { /// Decode volume IDs and return string reprensentation for debugging purposes string IDDescriptor::str(VolumeID vid, VolumeID mask) const { - const vector<BitFieldValue*>& v = access()->decoder.fields(); + const vector<BitFieldElement*>& v = access()->decoder.fields(); stringstream str; for (auto f : v ) { if ( 0 == (mask&f->mask()) ) continue; @@ -163,7 +163,7 @@ string IDDescriptor::str(VolumeID vid, VolumeID mask) const { return str.str().substr(0,str.str().length()-1); } -/// Access the BitField64 object -BitField64* IDDescriptor::decoder() { +/// Access the BitFieldCoder object +BitFieldCoder* IDDescriptor::decoder() { return &(data<Object>()->decoder); } diff --git a/DDCore/src/MultiSegmentation.cpp b/DDCore/src/MultiSegmentation.cpp index 2834fc35d578a47099785cb9041bed3750cd34dd..d293c7ed1c30520deccd847e2b201643648ab60e 100644 --- a/DDCore/src/MultiSegmentation.cpp +++ b/DDCore/src/MultiSegmentation.cpp @@ -27,7 +27,7 @@ const std::string& MultiSegmentation::discriminatorName() const { } /// Discriminating bitfield entry -BitFieldValue* MultiSegmentation::discriminator() const { +const BitFieldElement* MultiSegmentation::discriminator() const { return access()->implementation->discriminator(); } diff --git a/DDCore/src/SegmentationDictionary.h b/DDCore/src/SegmentationDictionary.h index f7ba2cb898ed677d7ea728b68e3cc82a181ef03d..5253260383759518baf84f61323357845db3a8fd 100644 --- a/DDCore/src/SegmentationDictionary.h +++ b/DDCore/src/SegmentationDictionary.h @@ -85,7 +85,7 @@ typedef dd4hep::DDSegmentation::CellID CellID; #pragma link C++ class dd4hep::DDSegmentation::WaferGridXY+; #pragma link C++ class dd4hep::DDSegmentation::BitFieldValue+; -#pragma link C++ class dd4hep::DDSegmentation::BitField64+; +#pragma link C++ class dd4hep::DDSegmentation::BitFieldCoder+; #endif // __CINT__ #endif // __HAVE_DDSEGMENTATION__ diff --git a/DDCore/src/Segmentations.cpp b/DDCore/src/Segmentations.cpp index a44be35097dcfec638854ab83bec8bfc5c8ac120..817005bd2a2e6c0fe8815ff1147a4bd5a6fd3afe 100644 --- a/DDCore/src/Segmentations.cpp +++ b/DDCore/src/Segmentations.cpp @@ -30,7 +30,7 @@ using namespace dd4hep::detail; DD4HEP_INSTANTIATE_HANDLE_UNNAMED(SegmentationObject); /// Constructor to used when creating a new object -Segmentation::Segmentation(const string& typ, const string& nam, BitField64* dec) : Handle<Object>() +Segmentation::Segmentation(const string& typ, const string& nam, const BitFieldCoder* dec) : Handle<Object>() { string seg_type = "segmentation_constructor__"+typ; SegmentationObject* obj = PluginService::Create<SegmentationObject*>(seg_type, dec); @@ -103,12 +103,12 @@ DDSegmentation::Segmentation* Segmentation::segmentation() const { } /// Access the underlying decoder -const BitField64* Segmentation::decoder() const { +const BitFieldCoder* Segmentation::decoder() const { return data<Object>()->segmentation->decoder(); } /// Set the underlying decoder -void Segmentation::setDecoder(BitField64* decode) const { +void Segmentation::setDecoder(const BitFieldCoder* decode) const { data<Object>()->segmentation->setDecoder(decode); } diff --git a/DDCore/src/SegmentationsInterna.cpp b/DDCore/src/SegmentationsInterna.cpp index e793fdeb17df0adfe89104459483168089de133c..53fbc63828964ca0962a1fb6f9f42ff677d3f950 100644 --- a/DDCore/src/SegmentationsInterna.cpp +++ b/DDCore/src/SegmentationsInterna.cpp @@ -59,12 +59,12 @@ const string& SegmentationObject::description() const { } /// Access the underlying decoder -const BitField64* SegmentationObject::decoder() const { +const BitFieldCoder* SegmentationObject::decoder() const { return segmentation->decoder(); } /// Set the underlying decoder -void SegmentationObject::setDecoder(BitField64* ptr_decoder) const { +void SegmentationObject::setDecoder(const BitFieldCoder* ptr_decoder) const { segmentation->setDecoder(ptr_decoder); } diff --git a/DDCore/src/VolumeManager.cpp b/DDCore/src/VolumeManager.cpp index 1791f12b565b8430086928d900bf34757a4cc5a0..2d6bc5cf777220072f914444336c9ae36d7f3674 100644 --- a/DDCore/src/VolumeManager.cpp +++ b/DDCore/src/VolumeManager.cpp @@ -335,7 +335,7 @@ namespace dd4hep { VolumeID volume_id = initial.first, mask = initial.second; for (VolIDs::const_iterator i = ids.begin(); i != ids.end(); ++i) { const auto& id = (*i); - const BitFieldValue* f = iddesc.field(id.first); + const BitFieldElement* f = iddesc.field(id.first); VolumeID msk = f->mask(); int off = f->offset(); VolumeID val = id.second; // Necessary to extend volume IDs > 32 bit @@ -349,7 +349,7 @@ namespace dd4hep { VolumeID volume_id = 0, mask = 0; for (VolIDs::const_iterator i = ids.begin(); i != ids.end(); ++i) { const auto& id = (*i); - const BitFieldValue* f = iddesc.field(id.first); + const BitFieldElement* f = iddesc.field(id.first); VolumeID msk = f->mask(); int off = f->offset(); VolumeID val = id.second; // Necessary to extend volume IDs > 32 bit @@ -508,7 +508,7 @@ VolumeManager VolumeManager::addSubdetector(DetElement det, Readout ro) { i = o.subdetectors.insert(make_pair(det, VolumeManager(det,ro))).first; const auto& id = (*vit); VolumeManager m = (*i).second; - const BitFieldValue* field = ro.idSpec().field(id.first); + const BitFieldElement* field = ro.idSpec().field(id.first); if (!field) { throw runtime_error("dd4hep: VolumeManager::addSubdetector: IdDescriptor of " + string(det.name()) + " has no field " + id.first); diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp index 14852f8bcb3049e1b9f08897bc8141d55c3022a0..ad2bf134dd80b153dfa46a3d15dc421bed9c115f 100644 --- a/DDCore/src/plugins/Compact2Objects.cpp +++ b/DDCore/src/plugins/Compact2Objects.cpp @@ -630,7 +630,7 @@ template <> void Converter<Segmentation>::operator()(xml_h seg) const { string name = seg.hasAttr(_U(name)) ? seg.attr<string>(_U(name)) : string(); std::pair<Segmentation,IDDescriptor>* opt = _option<pair<Segmentation,IDDescriptor> >(); - BitField64* bitfield = &opt->second->decoder; + const BitFieldCoder* bitfield = &opt->second->decoder; Segmentation segment(type, name, bitfield); if ( segment.isValid() ) { const DDSegmentation::Parameters& pars = segment.parameters(); diff --git a/DDCore/src/plugins/LCDDConverter.cpp b/DDCore/src/plugins/LCDDConverter.cpp index 10dbc3f97d8ebb5f2b056c1df56c1d15f4c685d2..da74cd441e3a6cd3e945f8e1b79add516c11ce2d 100644 --- a/DDCore/src/plugins/LCDDConverter.cpp +++ b/DDCore/src/plugins/LCDDConverter.cpp @@ -934,7 +934,7 @@ xml_h LCDDConverter::handleIdSpec(const std::string& name, IDDescriptor id_spec) for (const auto& i : fm ) { xml_h idfield = xml_elt_t(geo.doc, _U(idfield)); #if 0 - const BitFieldValue* f = i.second; + const BitFieldElement* f = i.second; start = f.first; length = f.second<0 ? -f.second : f.second; idfield.setAttr(_U(signed),f.second<0 ? true : false); @@ -942,7 +942,7 @@ xml_h LCDDConverter::handleIdSpec(const std::string& name, IDDescriptor id_spec) idfield.setAttr(_U(length),length); idfield.setAttr(_U(start),start); #else - const BitFieldValue* f = i.second; + const BitFieldElement* f = i.second; idfield.setAttr(_U(signed),f->isSigned() ? true : false); idfield.setAttr(_U(label), f->name()); idfield.setAttr(_U(length), (int) f->width()); diff --git a/DDCore/src/plugins/ReadoutSegmentations.cpp b/DDCore/src/plugins/ReadoutSegmentations.cpp index e7ac8394cff2f6d6f5322897df1471334240f846..036d115c226ec57343212211d59136fc29935d87 100644 --- a/DDCore/src/plugins/ReadoutSegmentations.cpp +++ b/DDCore/src/plugins/ReadoutSegmentations.cpp @@ -20,7 +20,7 @@ using namespace dd4hep::DDSegmentation; namespace { template<typename T> dd4hep::SegmentationObject* - create_segmentation(dd4hep::BitField64* decoder) { + create_segmentation(const dd4hep::BitFieldCoder* decoder) { return new dd4hep::SegmentationWrapper<T>(decoder); } } diff --git a/DDCore/src/segmentations/BitField64.cpp b/DDCore/src/segmentations/BitField64.cpp index d5dbabfac6dd579c1c9a27a6841b2efc83a5c35b..c5ae4a462617c0bdb9739d25e32bef001820c875 100644 --- a/DDCore/src/segmentations/BitField64.cpp +++ b/DDCore/src/segmentations/BitField64.cpp @@ -17,7 +17,7 @@ namespace DDSegmentation { if( i != 0 ) os << "," ; - os << fields()[i]->name() << ":" << _coder->get( _value , i ) ; + os << _coder->fields()[i]->name() << ":" << _coder->get( _value , i ) ; } return os.str() ; @@ -29,9 +29,10 @@ namespace DDSegmentation { os << " bitfield: 0x" << std::hex // << std::ios::width(16) << std::ios::fill('0') << << b._value << std::dec << std::endl ; - for(unsigned i=0;i<_coder->size();i++){ + + for(unsigned i=0;i<b._coder->size();i++){ - const BitFieldCoder::BitFieldValue* bv = b.fields()[i] ; + const BitFieldElement* bv = b._coder->fields()[i] ; os << " " << bv->name() << " [" << bv->offset() << ":" ; @@ -40,7 +41,7 @@ namespace DDSegmentation { os << bv->width() << "] : " ; - os << _coder->get( _value , i) + os << b._coder->get( b._value , i) << std::endl ; } diff --git a/DDCore/src/segmentations/BitFieldCoder.cpp b/DDCore/src/segmentations/BitFieldCoder.cpp index 02f2e334e62593630bf5e8df3d8e7cf6d88b4ced..abc27d7bb3999962501ab5a2b9f87081abc72aeb 100644 --- a/DDCore/src/segmentations/BitFieldCoder.cpp +++ b/DDCore/src/segmentations/BitFieldCoder.cpp @@ -8,8 +8,8 @@ namespace dd4hep{ namespace DDSegmentation { - BitFieldCoder::BitFieldValue::BitFieldValue( const std::string& fieldName, - unsigned fieldOffset, int signedWidth ) : + BitFieldElement::BitFieldElement( const std::string& fieldName, + unsigned fieldOffset, int signedWidth ) : _mask(0), _offset( fieldOffset ), _width( abs( signedWidth ) ), @@ -22,7 +22,7 @@ namespace DDSegmentation { if( _offset > 63 || _offset+_width > 64 ) { std::stringstream s ; - s << " BitFieldValue '" << _name << "': out of range - offset : " + s << " BitFieldElement '" << _name << "': out of range - offset : " << _offset << " width " << _width ; throw( std::runtime_error( s.str() ) ) ; @@ -45,7 +45,7 @@ namespace DDSegmentation { } - long64 BitFieldCoder::BitFieldValue::value(long64 id) const { + long64 BitFieldElement::value(long64 id) const { if( _isSigned ) { @@ -64,13 +64,13 @@ namespace DDSegmentation { } } - void BitFieldCoder::BitFieldValue::set(long64& field, long64 in) { + void BitFieldElement::set(long64& field, long64 in) const { // check range if( in < _minVal || in > _maxVal ) { std::stringstream s ; - s << " BitFieldValue '" << _name << "': out of range : " << in + s << " BitFieldElement '" << _name << "': out of range : " << in << " for width " << _width ; throw( std::runtime_error( s.str() ) ); @@ -94,7 +94,7 @@ namespace DDSegmentation { return it->second ; else - throw std::runtime_error(" BitFieldValue: unknown name: " + name ) ; + throw std::runtime_error(" BitFieldElement: unknown name: " + name ) ; } unsigned BitFieldCoder::highestBit() const { @@ -163,7 +163,7 @@ namespace DDSegmentation { void BitFieldCoder::addField( const std::string& name, unsigned offset, int width ){ - BitFieldValue* bfv = new BitFieldValue( name, offset, width ) ; + BitFieldElement* bfv = new BitFieldElement( name, offset, width ) ; _fields.push_back( bfv ) ; @@ -172,7 +172,7 @@ namespace DDSegmentation { if( _joined & bfv->mask() ) { std::stringstream s ; - s << " BitFieldValue::addField(" << name << "): bits already used " << std::hex << _joined + s << " BitFieldElement::addField(" << name << "): bits already used " << std::hex << _joined << " for mask " << bfv->mask() ; throw( std::runtime_error( s.str() ) ) ; diff --git a/DDCore/src/segmentations/CartesianGrid.cpp b/DDCore/src/segmentations/CartesianGrid.cpp index 924eb7e066bbcbfcb13635b8fd1eca53fa728e73..0dc1ca2a93b357da870ee3bf9b15cea46dcae53a 100644 --- a/DDCore/src/segmentations/CartesianGrid.cpp +++ b/DDCore/src/segmentations/CartesianGrid.cpp @@ -16,7 +16,7 @@ namespace dd4hep { } /// Default constructor used by derived classes passing an existing decoder - CartesianGrid::CartesianGrid(BitField64* decode) : Segmentation(decode) { + CartesianGrid::CartesianGrid(const BitFieldCoder* decode) : Segmentation(decode) { } /// Destructor diff --git a/DDCore/src/segmentations/CartesianGridXY.cpp b/DDCore/src/segmentations/CartesianGridXY.cpp index d5ca8386c65b275bcd8dc0ca47987051c32c784c..dae82fb7d0684aa63d39635a06843caa26e14e45 100644 --- a/DDCore/src/segmentations/CartesianGridXY.cpp +++ b/DDCore/src/segmentations/CartesianGridXY.cpp @@ -27,7 +27,7 @@ CartesianGridXY::CartesianGridXY(const std::string& cellEncoding) : } /// Default constructor used by derived classes passing an existing decoder -CartesianGridXY::CartesianGridXY(BitField64* decode) : +CartesianGridXY::CartesianGridXY(const BitFieldCoder* decode) : CartesianGrid(decode) { // define type and description @@ -50,19 +50,18 @@ CartesianGridXY::~CartesianGridXY() { /// determine the position based on the cell ID Vector3D CartesianGridXY::position(const CellID& cID) const { - _decoder->setValue(cID); Vector3D cellPosition; - cellPosition.X = binToPosition((*_decoder)[_xId].value(), _gridSizeX, _offsetX); - cellPosition.Y = binToPosition((*_decoder)[_yId].value(), _gridSizeY, _offsetY); + cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX); + cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY); return cellPosition; } /// determine the cell ID based on the position CellID CartesianGridXY::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { - _decoder->setValue(vID); - (*_decoder)[_xId] = positionToBin(localPosition.X, _gridSizeX, _offsetX); - (*_decoder)[_yId] = positionToBin(localPosition.Y, _gridSizeY, _offsetY); - return _decoder->getValue(); + CellID cID = vID ; + _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX) ); + _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY) ); + return cID ; } std::vector<double> CartesianGridXY::cellDimensions(const CellID&) const { diff --git a/DDCore/src/segmentations/CartesianGridXYZ.cpp b/DDCore/src/segmentations/CartesianGridXYZ.cpp index 11c7e873b3a4d4098dda77f67cd2f22e2752e3b4..440981497657f97ff2cb01c775a85d4284ac229d 100644 --- a/DDCore/src/segmentations/CartesianGridXYZ.cpp +++ b/DDCore/src/segmentations/CartesianGridXYZ.cpp @@ -24,7 +24,7 @@ CartesianGridXYZ::CartesianGridXYZ(const std::string& cellEncoding) : } /// Default constructor used by derived classes passing an existing decoder -CartesianGridXYZ::CartesianGridXYZ(BitField64* decode) : +CartesianGridXYZ::CartesianGridXYZ(const BitFieldCoder* decode) : CartesianGridXY(decode) { // define type and description _type = "CartesianGridXYZ"; @@ -43,21 +43,20 @@ CartesianGridXYZ::~CartesianGridXYZ() { /// determine the position based on the cell ID Vector3D CartesianGridXYZ::position(const CellID& cID) const { - _decoder->setValue(cID); Vector3D cellPosition; - cellPosition.X = binToPosition((*_decoder)[_xId].value(), _gridSizeX, _offsetX); - cellPosition.Y = binToPosition((*_decoder)[_yId].value(), _gridSizeY, _offsetY); - cellPosition.Z = binToPosition((*_decoder)[_zId].value(), _gridSizeZ, _offsetZ); + cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX); + cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY); + cellPosition.Z = binToPosition( _decoder->get(cID,_zId ), _gridSizeZ, _offsetZ); return cellPosition; } /// determine the cell ID based on the position CellID CartesianGridXYZ::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { - _decoder->setValue(vID); - (*_decoder)[_xId] = positionToBin(localPosition.X, _gridSizeX, _offsetX); - (*_decoder)[_yId] = positionToBin(localPosition.Y, _gridSizeY, _offsetY); - (*_decoder)[_zId] = positionToBin(localPosition.Z, _gridSizeZ, _offsetZ); - return _decoder->getValue(); + CellID cID = vID ; + _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX) ); + _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY) ); + _decoder->set( cID,_zId, positionToBin(localPosition.Z, _gridSizeZ, _offsetZ) ); + return cID ; } std::vector<double> CartesianGridXYZ::cellDimensions(const CellID&) const { diff --git a/DDCore/src/segmentations/CartesianGridXZ.cpp b/DDCore/src/segmentations/CartesianGridXZ.cpp index e4ce6eed72e6a1c19cb61838a3170f8f835e5d1d..396dc2ec676e9ed0bb72de62a438832f1c6a4fc6 100644 --- a/DDCore/src/segmentations/CartesianGridXZ.cpp +++ b/DDCore/src/segmentations/CartesianGridXZ.cpp @@ -30,7 +30,7 @@ CartesianGridXZ::CartesianGridXZ(const std::string& cellEncoding) : } /// Default constructor used by derived classes passing an existing decoder -CartesianGridXZ::CartesianGridXZ(BitField64* decode) : +CartesianGridXZ::CartesianGridXZ(const BitFieldCoder* decode) : CartesianGrid(decode) { // define type and description _type = "CartesianGridXZ"; @@ -52,20 +52,19 @@ CartesianGridXZ::~CartesianGridXZ() { /// determine the position based on the cell ID Vector3D CartesianGridXZ::position(const CellID& cID) const { - _decoder->setValue(cID); vector<double> localPosition(3); Vector3D cellPosition; - cellPosition.X = binToPosition((*_decoder)[_xId].value(), _gridSizeX, _offsetX); - cellPosition.Z = binToPosition((*_decoder)[_zId].value(), _gridSizeZ, _offsetZ); + cellPosition.X = binToPosition( _decoder->get(cID,_xId ), _gridSizeX, _offsetX); + cellPosition.Z = binToPosition( _decoder->get(cID,_zId ), _gridSizeZ, _offsetZ); return cellPosition; } /// determine the cell ID based on the position CellID CartesianGridXZ::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { - _decoder->setValue(vID); - (*_decoder)[_xId] = positionToBin(localPosition.X, _gridSizeX, _offsetX); - (*_decoder)[_zId] = positionToBin(localPosition.Z, _gridSizeZ, _offsetZ); - return _decoder->getValue(); + CellID cID = vID ; + _decoder->set( cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX) ); + _decoder->set( cID,_zId, positionToBin(localPosition.Z, _gridSizeZ, _offsetZ) ); + return cID ; } std::vector<double> CartesianGridXZ::cellDimensions(const CellID&) const { diff --git a/DDCore/src/segmentations/CartesianGridYZ.cpp b/DDCore/src/segmentations/CartesianGridYZ.cpp index b26f9e605753cefa8ca69c6c224ead87c41cef1a..652506190f128bba624f76e960e6a0764676b02f 100644 --- a/DDCore/src/segmentations/CartesianGridYZ.cpp +++ b/DDCore/src/segmentations/CartesianGridYZ.cpp @@ -29,7 +29,7 @@ CartesianGridYZ::CartesianGridYZ(const std::string& cellEncoding) : /// Default constructor used by derived classes passing an existing decoder -CartesianGridYZ::CartesianGridYZ(BitField64* decode) : CartesianGrid(decode) +CartesianGridYZ::CartesianGridYZ(const BitFieldCoder* decode) : CartesianGrid(decode) { // define type and description _type = "CartesianGridYZ"; @@ -51,19 +51,18 @@ CartesianGridYZ::~CartesianGridYZ() { /// determine the position based on the cell ID Vector3D CartesianGridYZ::position(const CellID& cID) const { - _decoder->setValue(cID); Vector3D cellPosition; - cellPosition.Y = binToPosition((*_decoder)[_yId].value(), _gridSizeY, _offsetY); - cellPosition.Z = binToPosition((*_decoder)[_zId].value(), _gridSizeZ, _offsetZ); + cellPosition.Y = binToPosition( _decoder->get(cID,_yId ), _gridSizeY, _offsetY); + cellPosition.Z = binToPosition( _decoder->get(cID,_zId ), _gridSizeZ, _offsetZ); return cellPosition; } /// determine the cell ID based on the position CellID CartesianGridYZ::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { - _decoder->setValue(vID); - (*_decoder)[_yId] = positionToBin(localPosition.Y, _gridSizeY, _offsetY); - (*_decoder)[_zId] = positionToBin(localPosition.Z, _gridSizeZ, _offsetZ); - return _decoder->getValue(); + CellID cID = vID ; + _decoder->set( cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY) ); + _decoder->set( cID,_zId, positionToBin(localPosition.Z, _gridSizeZ, _offsetZ) ); + return cID ; } std::vector<double> CartesianGridYZ::cellDimensions(const CellID&) const { diff --git a/DDCore/src/segmentations/CylindricalSegmentation.cpp b/DDCore/src/segmentations/CylindricalSegmentation.cpp index 605e3b6c79e6871dae723d40dd7ab7570c25f757..8ed982b3bde1cf356cd2adf3b5b32135871f23a9 100644 --- a/DDCore/src/segmentations/CylindricalSegmentation.cpp +++ b/DDCore/src/segmentations/CylindricalSegmentation.cpp @@ -16,7 +16,7 @@ namespace dd4hep { } /// Default constructor used by derived classes passing an existing decoder - CylindricalSegmentation::CylindricalSegmentation(BitField64* decode) : + CylindricalSegmentation::CylindricalSegmentation(const BitFieldCoder* decode) : Segmentation(decode) { } diff --git a/DDCore/src/segmentations/GridPhiEta.cpp b/DDCore/src/segmentations/GridPhiEta.cpp index 0a2b27a1d4f4292f184708eb3ce23ba2241729aa..0b4b640305621ade4bf0ca6360bba2799aa31bbd 100644 --- a/DDCore/src/segmentations/GridPhiEta.cpp +++ b/DDCore/src/segmentations/GridPhiEta.cpp @@ -19,7 +19,7 @@ GridPhiEta::GridPhiEta(const std::string& cellEncoding) : registerIdentifier("identifier_phi", "Cell ID identifier for phi", m_phiID, "phi"); } -GridPhiEta::GridPhiEta(BitField64* aDecoder) : +GridPhiEta::GridPhiEta(const BitFieldCoder* aDecoder) : Segmentation(aDecoder) { // define type and description _type = "GridPhiEta"; @@ -35,36 +35,24 @@ GridPhiEta::GridPhiEta(BitField64* aDecoder) : } Vector3D GridPhiEta::position(const CellID& cID) const { - _decoder->setValue(cID); - return Util::positionFromREtaPhi(1.0, eta(), phi()); + return Util::positionFromREtaPhi(1.0, eta(cID), phi(cID)); } CellID GridPhiEta::cellID(const Vector3D& /* localPosition */, const Vector3D& globalPosition, const VolumeID& vID) const { - _decoder->setValue(vID); double lEta = Util::etaFromXYZ(globalPosition); double lPhi = Util::phiFromXYZ(globalPosition); - (*_decoder)[m_etaID] = positionToBin(lEta, m_gridSizeEta, m_offsetEta); - (*_decoder)[m_phiID] = positionToBin(lPhi, 2 * M_PI / (double) m_phiBins, m_offsetPhi); - return _decoder->getValue(); -} - -double GridPhiEta::eta() const { - CellID etaValue = (*_decoder)[m_etaID].value(); - return binToPosition(etaValue, m_gridSizeEta, m_offsetEta); -} -double GridPhiEta::phi() const { - CellID phiValue = (*_decoder)[m_phiID].value(); - return binToPosition(phiValue, 2.*M_PI/(double)m_phiBins, m_offsetPhi); + CellID cID = vID ; + _decoder->set( cID, m_etaID, positionToBin(lEta, m_gridSizeEta, m_offsetEta) ); + _decoder->set( cID, m_phiID, positionToBin(lPhi, 2 * M_PI / (double) m_phiBins, m_offsetPhi) ); + return cID; } double GridPhiEta::eta(const CellID& cID) const { - _decoder->setValue(cID); - CellID etaValue = (*_decoder)[m_etaID].value(); + CellID etaValue = _decoder->get(cID, m_etaID); return binToPosition(etaValue, m_gridSizeEta, m_offsetEta); } double GridPhiEta::phi(const CellID& cID) const { - _decoder->setValue(cID); - CellID phiValue = (*_decoder)[m_phiID].value(); + CellID phiValue = _decoder->get(cID, m_phiID); return binToPosition(phiValue, 2.*M_PI/(double)m_phiBins, m_offsetPhi); } REGISTER_SEGMENTATION(GridPhiEta) diff --git a/DDCore/src/segmentations/GridRPhiEta.cpp b/DDCore/src/segmentations/GridRPhiEta.cpp index 78cc4b89a7619ad4746ecc990a1526d74591f20b..00335d125f3f5cc0de4f9b3b5132fd00edda0b56 100644 --- a/DDCore/src/segmentations/GridRPhiEta.cpp +++ b/DDCore/src/segmentations/GridRPhiEta.cpp @@ -16,7 +16,7 @@ GridRPhiEta::GridRPhiEta(const std::string& cellEncoding) : registerIdentifier("identifier_r", "Cell ID identifier for R", m_rID, "r"); } -GridRPhiEta::GridRPhiEta(BitField64* aDecoder) : +GridRPhiEta::GridRPhiEta(const BitFieldCoder* aDecoder) : GridPhiEta(aDecoder) { // define type and description _type = "GridRPhiEta"; @@ -29,29 +29,22 @@ GridRPhiEta::GridRPhiEta(BitField64* aDecoder) : } Vector3D GridRPhiEta::position(const CellID& cID) const { - _decoder->setValue(cID); - return Util::positionFromREtaPhi(r(), eta(), phi()); + return Util::positionFromREtaPhi(r(cID), eta(cID), phi(cID)); } CellID GridRPhiEta::cellID(const Vector3D& /* localPosition */, const Vector3D& globalPosition, const VolumeID& vID) const { - _decoder->setValue(vID); double lRadius = Util::radiusFromXYZ(globalPosition); double lEta = Util::etaFromXYZ(globalPosition); double lPhi = Util::phiFromXYZ(globalPosition); - (*_decoder)[m_etaID] = positionToBin(lEta, m_gridSizeEta, m_offsetEta); - (*_decoder)[m_phiID] = positionToBin(lPhi, 2 * M_PI / (double) m_phiBins, m_offsetPhi); - (*_decoder)[m_rID] = positionToBin(lRadius, m_gridSizeR, m_offsetR); - return _decoder->getValue(); -} - -double GridRPhiEta::r() const { - CellID rValue = (*_decoder)[m_rID].value(); - return binToPosition(rValue, m_gridSizeR, m_offsetR); + CellID cID = vID ; + _decoder->set( cID, m_etaID, positionToBin(lEta, m_gridSizeEta, m_offsetEta) ); + _decoder->set( cID, m_phiID, positionToBin(lPhi, 2 * M_PI / (double) m_phiBins, m_offsetPhi) ); + _decoder->set( cID, m_rID , positionToBin(lRadius, m_gridSizeR, m_offsetR) ); + return cID; } double GridRPhiEta::r(const CellID& cID) const { - _decoder->setValue(cID); - CellID rValue = (*_decoder)[m_rID].value(); + CellID rValue = _decoder->get(cID, m_rID); return binToPosition(rValue, m_gridSizeR, m_offsetR); } REGISTER_SEGMENTATION(GridRPhiEta) diff --git a/DDCore/src/segmentations/MegatileLayerGridXY.cpp b/DDCore/src/segmentations/MegatileLayerGridXY.cpp index 77c40261de6c9ac72cad6cfc1cd1a2f5b741b6ec..1bb022e00afba32fd72a121a95f9914daee0e86d 100644 --- a/DDCore/src/segmentations/MegatileLayerGridXY.cpp +++ b/DDCore/src/segmentations/MegatileLayerGridXY.cpp @@ -12,6 +12,7 @@ #include <cmath> #include <cassert> #include <algorithm> +#include <iostream> namespace dd4hep { namespace DDSegmentation { @@ -23,7 +24,7 @@ namespace dd4hep { setup(); } - MegatileLayerGridXY::MegatileLayerGridXY(BitField64* decode) : + MegatileLayerGridXY::MegatileLayerGridXY(const BitFieldCoder* decode) : CartesianGrid(decode) { setup(); } @@ -62,11 +63,10 @@ namespace dd4hep { Vector3D MegatileLayerGridXY::position(const CellID& cID) const { // this is local position within the megatile - _decoder->setValue(cID); - unsigned int layerIndex = (*_decoder)[_identifierLayer]; - unsigned int waferIndex = (*_decoder)[_identifierWafer]; - int cellIndexX = (*_decoder)[_xId]; - int cellIndexY = (*_decoder)[_yId]; + unsigned int layerIndex = _decoder->get(cID,_identifierLayer); + unsigned int waferIndex = _decoder->get(cID,_identifierWafer); + int cellIndexX = _decoder->get(cID,_xId); + int cellIndexY = _decoder->get(cID,_yId); // segmentation info for this megatile ("wafer") getSegInfo(layerIndex, waferIndex); @@ -94,9 +94,8 @@ namespace dd4hep { // this is the local position within a megatile, local coordinates // get the layer, wafer, module indices from the volumeID - _decoder->setValue(vID); - unsigned int layerIndex = (*_decoder)[_identifierLayer]; - unsigned int waferIndex = (*_decoder)[_identifierWafer]; + unsigned int layerIndex = _decoder->get(vID,_identifierLayer); + unsigned int waferIndex = _decoder->get(vID,_identifierWafer); // segmentation info for this megatile ("wafer") getSegInfo(layerIndex, waferIndex); @@ -112,17 +111,17 @@ namespace dd4hep { int _cellIndexX = int ( localX / ( _currentSegInfo.megaTileSizeX / _currentSegInfo.nCellsX ) ); int _cellIndexY = int ( localY / ( _currentSegInfo.megaTileSizeY / _currentSegInfo.nCellsY ) ); - (*_decoder)[_xId] = _cellIndexX; - (*_decoder)[_yId] = _cellIndexY; + CellID cID = vID ; + _decoder->set(cID,_xId,_cellIndexX); + _decoder->set(cID,_yId,_cellIndexY); - return _decoder->getValue(); + return cID; } std::vector<double> MegatileLayerGridXY::cellDimensions(const CellID& cID) const { - _decoder->setValue( cID ); - unsigned int layerIndex = (*_decoder)[_identifierLayer]; - unsigned int waferIndex = (*_decoder)[_identifierWafer]; + unsigned int layerIndex = _decoder->get(cID,_identifierLayer); + unsigned int waferIndex = _decoder->get(cID,_identifierWafer); return cellDimensions(layerIndex, waferIndex); } diff --git a/DDCore/src/segmentations/MultiSegmentation.cpp b/DDCore/src/segmentations/MultiSegmentation.cpp index adc75c2e44fc1cbe966fc2ed05fa783172381fcb..c04d1a4b51e8c42420230217068b1b5add2ad538 100644 --- a/DDCore/src/segmentations/MultiSegmentation.cpp +++ b/DDCore/src/segmentations/MultiSegmentation.cpp @@ -8,6 +8,7 @@ #include "DDSegmentation/MultiSegmentation.h" #include <iomanip> #include <stdexcept> +#include <iostream> using namespace std; @@ -26,7 +27,7 @@ namespace dd4hep { } /// Default constructor used by derived classes passing an existing decoder - MultiSegmentation::MultiSegmentation(BitField64* decode) + MultiSegmentation::MultiSegmentation(const BitFieldCoder* decode) : Segmentation(decode), m_discriminator(0), m_debug(0) { // define type and description @@ -53,7 +54,7 @@ namespace dd4hep { } /// Set the underlying decoder - void MultiSegmentation::setDecoder(BitField64* newDecoder) { + void MultiSegmentation::setDecoder(const BitFieldCoder* newDecoder) { this->Segmentation::setDecoder(newDecoder); for(Segmentations::iterator i=m_segmentations.begin(); i != m_segmentations.end(); ++i) (*i).segmentation->setDecoder(newDecoder); diff --git a/DDCore/src/segmentations/NoSegmentation.cpp b/DDCore/src/segmentations/NoSegmentation.cpp index c627d36d5d141913b04e73bb79f9e65df895ab22..ae3f50049f075a4f1fd89d2902b8bb1d0862e676 100644 --- a/DDCore/src/segmentations/NoSegmentation.cpp +++ b/DDCore/src/segmentations/NoSegmentation.cpp @@ -17,7 +17,7 @@ namespace dd4hep { _description = "None Segmentation"; } - NoSegmentation::NoSegmentation(BitField64* decode) : Segmentation(decode) + NoSegmentation::NoSegmentation(const BitFieldCoder* decode) : Segmentation(decode) { _type = "NoSegmentation"; _description = "None Segmentation"; diff --git a/DDCore/src/segmentations/PolarGrid.cpp b/DDCore/src/segmentations/PolarGrid.cpp index 99d01127c323c7aac87e23b23095009f003d6d80..ef858e55430fb881aaef24cabde26362e6eb59c2 100644 --- a/DDCore/src/segmentations/PolarGrid.cpp +++ b/DDCore/src/segmentations/PolarGrid.cpp @@ -15,7 +15,7 @@ namespace dd4hep { Segmentation(cellEncoding) { } /// Default constructor used by derived classes passing an existing decoder - PolarGrid::PolarGrid(BitField64* decode) : Segmentation(decode) { + PolarGrid::PolarGrid(const BitFieldCoder* decode) : Segmentation(decode) { } /// Destructor diff --git a/DDCore/src/segmentations/PolarGridRPhi.cpp b/DDCore/src/segmentations/PolarGridRPhi.cpp index a0ea66a4ecbd0de8b2eff25539de4f9a087e2482..7822119453dafb73bbf326724f3c3047491127fd 100644 --- a/DDCore/src/segmentations/PolarGridRPhi.cpp +++ b/DDCore/src/segmentations/PolarGridRPhi.cpp @@ -28,7 +28,7 @@ PolarGridRPhi::PolarGridRPhi(const std::string& cellEncoding) : /// Default constructor used by derived classes passing an existing decoder -PolarGridRPhi::PolarGridRPhi(BitField64* decode) : PolarGrid(decode) { +PolarGridRPhi::PolarGridRPhi(const BitFieldCoder* decode) : PolarGrid(decode) { // define type and description _type = "PolarGridRPhi"; _description = "Polar RPhi segmentation in the local XY-plane"; @@ -49,10 +49,9 @@ PolarGridRPhi::~PolarGridRPhi() { /// determine the position based on the cell ID Vector3D PolarGridRPhi::position(const CellID& cID) const { - _decoder->setValue(cID); Vector3D cellPosition; - double R = binToPosition((*_decoder)[_rId].value(), _gridSizeR, _offsetR); - double phi = binToPosition((*_decoder)[_phiId].value(), _gridSizePhi, _offsetPhi); + double R = binToPosition(_decoder->get(cID,_rId), _gridSizeR, _offsetR); + double phi = binToPosition(_decoder->get(cID,_phiId), _gridSizePhi, _offsetPhi); cellPosition.X = R * cos(phi); cellPosition.Y = R * sin(phi); @@ -62,18 +61,16 @@ Vector3D PolarGridRPhi::position(const CellID& cID) const { /// determine the cell ID based on the position CellID PolarGridRPhi::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { - _decoder->setValue(vID); double phi = atan2(localPosition.Y,localPosition.X); double R = sqrt( localPosition.X * localPosition.X + localPosition.Y * localPosition.Y ); - - (*_decoder)[_rId] = positionToBin(R, _gridSizeR, _offsetR); - (*_decoder)[_phiId] = positionToBin(phi, _gridSizePhi, _offsetPhi); - return _decoder->getValue(); + CellID cID = vID ; + _decoder->set(cID,_rId , positionToBin(R, _gridSizeR, _offsetR)); + _decoder->set(cID,_phiId, positionToBin(phi, _gridSizePhi, _offsetPhi)); + return cID; } std::vector<double> PolarGridRPhi::cellDimensions(const CellID& cID) const { - _decoder->setValue(cID); - const double rPhiSize = binToPosition((*_decoder)[_rId].value(), _gridSizeR, _offsetR)*_gridSizePhi; + const double rPhiSize = binToPosition(_decoder->get(cID,_rId), _gridSizeR, _offsetR)*_gridSizePhi; #if __cplusplus >= 201103L return {_gridSizeR, rPhiSize}; #else diff --git a/DDCore/src/segmentations/PolarGridRPhi2.cpp b/DDCore/src/segmentations/PolarGridRPhi2.cpp index 003b4c725c6340f77fe7acff91904e7fc84aedae..73c1d29e499848a8096d04209a8c5829e164c3c6 100644 --- a/DDCore/src/segmentations/PolarGridRPhi2.cpp +++ b/DDCore/src/segmentations/PolarGridRPhi2.cpp @@ -27,7 +27,7 @@ PolarGridRPhi2::PolarGridRPhi2(const std::string& cellEncoding) : } /// Default constructor used by derived classes passing an existing decoder -PolarGridRPhi2::PolarGridRPhi2(BitField64* decode) : +PolarGridRPhi2::PolarGridRPhi2(const BitFieldCoder* decode) : PolarGrid(decode) { // define type and description _type = "PolarGridRPhi2"; @@ -49,11 +49,10 @@ PolarGridRPhi2::~PolarGridRPhi2() { /// determine the position based on the cell ID Vector3D PolarGridRPhi2::position(const CellID& cID) const { - _decoder->setValue(cID); Vector3D cellPosition; - const int rBin = (*_decoder)[_rId].value(); + const int rBin = _decoder->get(cID,_rId); double R = binToPosition(rBin, _gridRValues, _offsetR); - double phi = binToPosition((*_decoder)[_phiId].value(), _gridPhiValues[rBin], _offsetPhi+_gridPhiValues[rBin]*0.5); + double phi = binToPosition(_decoder->get(cID,_phiId), _gridPhiValues[rBin], _offsetPhi+_gridPhiValues[rBin]*0.5); if ( phi < _offsetPhi) { phi += 2*M_PI; @@ -67,28 +66,28 @@ Vector3D PolarGridRPhi2::position(const CellID& cID) const { /// determine the cell ID based on the position CellID PolarGridRPhi2::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { - _decoder->setValue(vID); + double phi = atan2(localPosition.Y,localPosition.X); double R = sqrt( localPosition.X * localPosition.X + localPosition.Y * localPosition.Y ); const int rBin = positionToBin(R, _gridRValues, _offsetR); - (*_decoder)[_rId] = rBin; + + CellID cID = vID ; + _decoder->set(cID,_rId, rBin); if ( phi < _offsetPhi) { phi += 2*M_PI; } const int pBin = positionToBin(phi, _gridPhiValues[rBin], _offsetPhi+_gridPhiValues[rBin]*0.5); - (*_decoder)[_phiId] = pBin; + _decoder->set(cID,_phiId,pBin); - return _decoder->getValue(); + return cID; } std::vector<double> PolarGridRPhi2::cellDimensions(const CellID& cID) const { - _decoder->setValue(cID); - - const int rBin = (*_decoder)[_rId].value(); + const int rBin = _decoder->get(cID,_rId); const double rCenter = binToPosition(rBin, _gridRValues, _offsetR); const double rPhiSize = _gridPhiValues[rBin]*rCenter; diff --git a/DDCore/src/segmentations/ProjectiveCylinder.cpp b/DDCore/src/segmentations/ProjectiveCylinder.cpp index 6f483088b5379b294eee7e7858b4e86a063957a9..37c5ce675509611c912c1c2be78f0ee2c36f1a91 100644 --- a/DDCore/src/segmentations/ProjectiveCylinder.cpp +++ b/DDCore/src/segmentations/ProjectiveCylinder.cpp @@ -35,7 +35,7 @@ ProjectiveCylinder::ProjectiveCylinder(const std::string& cellEncoding) : /// Default constructor used by derived classes passing an existing decoder -ProjectiveCylinder::ProjectiveCylinder(BitField64* decode) : CylindricalSegmentation(decode) { +ProjectiveCylinder::ProjectiveCylinder(const BitFieldCoder* decode) : CylindricalSegmentation(decode) { // define type and description _type = "ProjectiveCylinder"; _description = "Projective segmentation in the global coordinates"; @@ -56,41 +56,27 @@ ProjectiveCylinder::~ProjectiveCylinder() { /// determine the local based on the cell ID Vector3D ProjectiveCylinder::position(const CellID& cID) const { - _decoder->setValue(cID); - return Util::positionFromRThetaPhi(1.0, theta(), phi()); + return Util::positionFromRThetaPhi(1.0, theta(cID), phi(cID)); } /// determine the cell ID based on the position CellID ProjectiveCylinder::cellID(const Vector3D& /* localPosition */, const Vector3D& globalPosition, const VolumeID& vID) const { - _decoder->setValue(vID); + CellID cID = vID ; double lTheta = thetaFromXYZ(globalPosition); double lPhi = phiFromXYZ(globalPosition); - (*_decoder)[_thetaID] = positionToBin(lTheta, M_PI / (double) _thetaBins, _offsetTheta); - (*_decoder)[_phiID] = positionToBin(lPhi, 2 * M_PI / (double) _phiBins, _offsetPhi); - return _decoder->getValue(); -} - -/// determine the polar angle theta based on the current cell ID -double ProjectiveCylinder::theta() const { - CellID thetaIndex = (*_decoder)[_thetaID].value(); - return M_PI * ((double) thetaIndex + 0.5) / (double) _thetaBins; -} -/// determine the azimuthal angle phi based on the current cell ID -double ProjectiveCylinder::phi() const { - CellID phiIndex = (*_decoder)[_phiID].value(); - return 2. * M_PI * ((double) phiIndex + 0.5) / (double) _phiBins; + _decoder->set(cID,_thetaID, positionToBin(lTheta, M_PI / (double) _thetaBins, _offsetTheta)); + _decoder->set(cID,_phiID , positionToBin(lPhi, 2 * M_PI / (double) _phiBins, _offsetPhi)); + return cID; } /// determine the polar angle theta based on the cell ID double ProjectiveCylinder::theta(const CellID& cID) const { - _decoder->setValue(cID); - CellID thetaIndex = (*_decoder)[_thetaID].value(); + CellID thetaIndex = _decoder->get(cID,_thetaID); return M_PI * ((double) thetaIndex + 0.5) / (double) _thetaBins; } /// determine the azimuthal angle phi based on the cell ID double ProjectiveCylinder::phi(const CellID& cID) const { - _decoder->setValue(cID); - CellID phiIndex = (*_decoder)[_phiID].value(); + CellID phiIndex = _decoder->get(cID,_phiID); return 2. * M_PI * ((double) phiIndex + 0.5) / (double) _phiBins; } diff --git a/DDCore/src/segmentations/Segmentation.cpp b/DDCore/src/segmentations/Segmentation.cpp index 8a8f0538114c5d232e238539d25b44dc2334647f..52039388e399a0557b9ecb27faa87a2ecd8977a9 100644 --- a/DDCore/src/segmentations/Segmentation.cpp +++ b/DDCore/src/segmentations/Segmentation.cpp @@ -27,12 +27,12 @@ namespace dd4hep { /// Default constructor used by derived classes passing the encoding string Segmentation::Segmentation(const std::string& cellEncoding) : - _name("Segmentation"), _type("Segmentation"), _decoder(new BitField64(cellEncoding)), _ownsDecoder(true) { + _name("Segmentation"), _type("Segmentation"), _decoder(new BitFieldCoder(cellEncoding)), _ownsDecoder(true) { } /// Default constructor used by derived classes passing an existing decoder - Segmentation::Segmentation(BitField64* newDecoder) : + Segmentation::Segmentation(const BitFieldCoder* newDecoder) : _name("Segmentation"), _type("Segmentation"), _decoder(newDecoder), _ownsDecoder(false) { } @@ -55,12 +55,12 @@ namespace dd4hep { /// Determine the volume ID from the full cell ID by removing all local fields VolumeID Segmentation::volumeID(const CellID& cID) const { map<std::string, StringParameter>::const_iterator it; - _decoder->setValue(cID); + VolumeID vID = cID ; for (it = _indexIdentifiers.begin(); it != _indexIdentifiers.end(); ++it) { std::string identifier = it->second->typedValue(); - (*_decoder)[identifier] = 0; + _decoder->set(vID,identifier,0); } - return _decoder->getValue(); + return vID; } /// Calculates the neighbours of the given cell ID and adds them to the list of neighbours @@ -68,18 +68,18 @@ namespace dd4hep { map<std::string, StringParameter>::const_iterator it; for (it = _indexIdentifiers.begin(); it != _indexIdentifiers.end(); ++it) { const std::string& identifier = it->second->typedValue(); - _decoder->setValue(cID); - int currentValue = (*_decoder)[identifier]; + CellID nID = cID ; + int currentValue = _decoder->get(cID,identifier); // add both neighbouring cell IDs, don't add out of bound indices try { - (*_decoder)[identifier] = currentValue - 1; - cellNeighbours.insert(_decoder->getValue()); + _decoder->set(nID,identifier,currentValue - 1); + cellNeighbours.insert(nID); } catch (runtime_error& e) { // nothing to do } try { - (*_decoder)[identifier] = currentValue + 1; - cellNeighbours.insert(_decoder->getValue()); + _decoder->set(nID,identifier,currentValue + 1); + cellNeighbours.insert(nID); } catch (runtime_error& e) { // nothing to do } @@ -87,7 +87,7 @@ namespace dd4hep { } /// Set the underlying decoder - void Segmentation::setDecoder(BitField64* newDecoder) { + void Segmentation::setDecoder(const BitFieldCoder* newDecoder) { if ( _decoder == newDecoder ) return; //self assignment else if (_ownsDecoder) diff --git a/DDCore/src/segmentations/TiledLayerGridXY.cpp b/DDCore/src/segmentations/TiledLayerGridXY.cpp index 4367c6c30473b769cf092e997d82227b8124cbe8..aa46448d9c2c9f73a5ace2dee03b1bafe67f9df7 100644 --- a/DDCore/src/segmentations/TiledLayerGridXY.cpp +++ b/DDCore/src/segmentations/TiledLayerGridXY.cpp @@ -10,6 +10,7 @@ // C/C++ includes #include <algorithm> #include <sstream> +#include <iostream> #include <stdexcept> #include <cmath> @@ -40,7 +41,7 @@ TiledLayerGridXY::TiledLayerGridXY(const std::string& cellEncoding) : } /// Default constructor used by derived classes passing an existing decoder -TiledLayerGridXY::TiledLayerGridXY(BitField64* decode) : CartesianGrid(decode) { +TiledLayerGridXY::TiledLayerGridXY(const BitFieldCoder* decode) : CartesianGrid(decode) { // define type and description _type = "TiledLayerGridXY"; _description = "Cartesian segmentation in the local XY-plane using optimal tiling depending on the layer dimensions"; @@ -68,15 +69,14 @@ TiledLayerGridXY::~TiledLayerGridXY() { /// determine the position based on the cell ID Vector3D TiledLayerGridXY::position(const CellID& cID) const { - _decoder->setValue(cID); unsigned int _layerIndex; Vector3D cellPosition; // AHcal: _layerIndex is [1,48], _layerOffsetX is [0,47] - _layerIndex = (*_decoder)[_identifierLayer]; + _layerIndex = _decoder->get(cID,_identifierLayer); if ( _layerOffsetX.size() != 0 && _layerIndex <=_layerOffsetX.size() ) { - cellPosition.X = binToPosition((*_decoder)[_xId].value(), _gridSizeX, _layerOffsetX[_layerIndex - 1]*_gridSizeX/2.); + cellPosition.X = binToPosition(_decoder->get(cID,_xId), _gridSizeX, _layerOffsetX[_layerIndex - 1]*_gridSizeX/2.); // check the integer cell boundary in x, if ( ( _layerDimX.size() != 0 && _layerIndex <= _layerDimX.size() ) &&( _fractCellSizeXPerLayer.size() != 0 && _layerIndex <= _fractCellSizeXPerLayer.size() ) @@ -88,27 +88,27 @@ Vector3D TiledLayerGridXY::position(const CellID& cID) const { *(_layerDimX.at(_layerIndex - 1) - _fractCellSizeXPerLayer.at(_layerIndex - 1)/2.0) ; } } else { - cellPosition.X = binToPosition((*_decoder)[_xId].value(), _gridSizeX, _offsetX); + cellPosition.X = binToPosition(_decoder->get(cID,_xId), _gridSizeX, _offsetX); } - cellPosition.Y = binToPosition((*_decoder)[_yId].value(), _gridSizeY, _offsetY); + cellPosition.Y = binToPosition(_decoder->get(cID,_yId), _gridSizeY, _offsetY); return cellPosition; } /// determine the cell ID based on the position CellID TiledLayerGridXY::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { - _decoder->setValue(vID); + CellID cID = vID ; unsigned int _layerIndex; // AHcal: _layerIndex is [1,48], _layerOffsetX is [0,47] - _layerIndex = (*_decoder)[_identifierLayer]; + _layerIndex = _decoder->get(cID,_identifierLayer); if ( _layerOffsetX.size() != 0 && _layerIndex <=_layerOffsetX.size() ) { - (*_decoder)[_xId] = positionToBin(localPosition.X, _gridSizeX, _layerOffsetX[_layerIndex - 1]*_gridSizeX/2.); + _decoder->set(cID,_xId,positionToBin(localPosition.X, _gridSizeX, _layerOffsetX[_layerIndex - 1]*_gridSizeX/2.)); } else { - (*_decoder)[_xId] = positionToBin(localPosition.X, _gridSizeX, _offsetX); + _decoder->set(cID,_xId,positionToBin(localPosition.X, _gridSizeX, _offsetX)); } - (*_decoder)[_yId] = positionToBin(localPosition.Y, _gridSizeY, _offsetY); - return _decoder->getValue(); + _decoder->set(cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY)); + return cID; } std::vector<double> TiledLayerGridXY::cellDimensions(const CellID&) const { diff --git a/DDCore/src/segmentations/TiledLayerSegmentation.cpp b/DDCore/src/segmentations/TiledLayerSegmentation.cpp index 4956e68bf1c1fbd63421d92b8b0cf4bf8d956eb1..c79f44c18b9620cdcaeedb370f616050d9013c01 100644 --- a/DDCore/src/segmentations/TiledLayerSegmentation.cpp +++ b/DDCore/src/segmentations/TiledLayerSegmentation.cpp @@ -42,7 +42,7 @@ TiledLayerSegmentation::TiledLayerSegmentation(const std::string& cellEncoding) } /// Default constructor used by derived classes passing an existing decoder -TiledLayerSegmentation::TiledLayerSegmentation(BitField64* decode) : Segmentation(decode) { +TiledLayerSegmentation::TiledLayerSegmentation(const BitFieldCoder* decode) : Segmentation(decode) { _type = "TiledLayerSegmentation"; _description = "Cartesian segmentation using optimal tiling depending on the layer dimensions"; @@ -116,30 +116,29 @@ TiledLayerSegmentation::LayerDimensions TiledLayerSegmentation::layerDimensions( /// determine the position based on the cell ID Vector3D TiledLayerSegmentation::position(const CellID& cID) const { - _decoder->setValue(cID); - int layerIndex = (*_decoder)[_identifierLayer]; + int layerIndex = _decoder->get(cID,_identifierLayer); double cellSizeX = layerGridSizeX(layerIndex); double cellSizeY = layerGridSizeY(layerIndex); LayerDimensions dimensions = layerDimensions(layerIndex); double offsetX = calculateOffset(cellSizeX, dimensions.x); double offsetY = calculateOffset(cellSizeY, dimensions.y); - double localX = binToPosition((*_decoder)[_identifierX], cellSizeX, offsetX); - double localY = binToPosition((*_decoder)[_identifierY], cellSizeY, offsetY); + double localX = binToPosition(_decoder->get(cID,_identifierX), cellSizeX, offsetX); + double localY = binToPosition(_decoder->get(cID,_identifierY), cellSizeY, offsetY); return Vector3D(localX, localY, 0.); } /// determine the cell ID based on the position CellID TiledLayerSegmentation::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { - _decoder->setValue(vID); - int layerIndex = (*_decoder)[_identifierLayer]; + CellID cID = vID ; + int layerIndex = _decoder->get(cID,_identifierLayer); double cellSizeX = layerGridSizeX(layerIndex); double cellSizeY = layerGridSizeY(layerIndex); LayerDimensions dimensions = layerDimensions(layerIndex); double offsetX = calculateOffset(cellSizeX, dimensions.x); double offsetY = calculateOffset(cellSizeY, dimensions.y); - (*_decoder)[_identifierX] = positionToBin(localPosition.x(), cellSizeX, offsetX); - (*_decoder)[_identifierY] = positionToBin(localPosition.y(), cellSizeY, offsetY); - return _decoder->getValue(); + _decoder->set(cID,_identifierX, positionToBin(localPosition.x(), cellSizeX, offsetX)); + _decoder->set(cID,_identifierY, positionToBin(localPosition.y(), cellSizeY, offsetY)); + return cID; } /// helper method to calculate optimal cell size based on total size diff --git a/DDCore/src/segmentations/WaferGridXY.cpp b/DDCore/src/segmentations/WaferGridXY.cpp index 198095605e1defaf8c0e84490a36bd107c477940..5b7ad38485132393ea76eb93ca1081df8582ce9e 100644 --- a/DDCore/src/segmentations/WaferGridXY.cpp +++ b/DDCore/src/segmentations/WaferGridXY.cpp @@ -31,7 +31,7 @@ WaferGridXY::WaferGridXY(const std::string& cellEncoding) : } /// Default constructor used by derived classes passing an existing decoder -WaferGridXY::WaferGridXY(BitField64* decode) : CartesianGrid(decode) { +WaferGridXY::WaferGridXY(const BitFieldCoder* decode) : CartesianGrid(decode) { // define type and description _type = "WaferGridXY"; _description = "Cartesian segmentation in the local XY-plane for both Normal wafer and Magic wafer(depending on the layer dimensions)"; @@ -56,30 +56,29 @@ WaferGridXY::~WaferGridXY() { /// determine the position based on the cell ID Vector3D WaferGridXY::position(const CellID& cID) const { - _decoder->setValue(cID); unsigned int _groupMGWaferIndex; unsigned int _waferIndex; Vector3D cellPosition; - _groupMGWaferIndex = (*_decoder)[_identifierMGWaferGroup]; - _waferIndex = (*_decoder)[_identifierWafer]; + _groupMGWaferIndex = _decoder->get(cID,_identifierMGWaferGroup); + _waferIndex = _decoder->get(cID,_identifierWafer); if ( _waferOffsetX[_groupMGWaferIndex][_waferIndex] > 0 || _waferOffsetX[_groupMGWaferIndex][_waferIndex] < 0 ) { - cellPosition.X = binToPosition((*_decoder)[_xId].value(), _gridSizeX, _offsetX+_waferOffsetX[_groupMGWaferIndex][_waferIndex]); + cellPosition.X = binToPosition(_decoder->get(cID,_xId), _gridSizeX, _offsetX+_waferOffsetX[_groupMGWaferIndex][_waferIndex]); } else { - cellPosition.X = binToPosition((*_decoder)[_xId].value(), _gridSizeX, _offsetX); + cellPosition.X = binToPosition(_decoder->get(cID,_xId), _gridSizeX, _offsetX); } if ( _waferOffsetY[_groupMGWaferIndex][_waferIndex] > 0 || _waferOffsetY[_groupMGWaferIndex][_waferIndex] < 0 ) { - cellPosition.Y = binToPosition((*_decoder)[_yId].value(), _gridSizeY, _offsetY+_waferOffsetY[_groupMGWaferIndex][_waferIndex]); + cellPosition.Y = binToPosition(_decoder->get(cID,_yId), _gridSizeY, _offsetY+_waferOffsetY[_groupMGWaferIndex][_waferIndex]); } else { - cellPosition.Y = binToPosition((*_decoder)[_yId].value(), _gridSizeY, _offsetY); + cellPosition.Y = binToPosition(_decoder->get(cID,_yId), _gridSizeY, _offsetY); } return cellPosition; @@ -87,32 +86,33 @@ Vector3D WaferGridXY::position(const CellID& cID) const { /// determine the cell ID based on the position CellID WaferGridXY::cellID(const Vector3D& localPosition, const Vector3D& /* globalPosition */, const VolumeID& vID) const { - _decoder->setValue(vID); unsigned int _groupMGWaferIndex; unsigned int _waferIndex; - _groupMGWaferIndex = (*_decoder)[_identifierMGWaferGroup]; - _waferIndex = (*_decoder)[_identifierWafer]; + CellID cID = vID ; + + _groupMGWaferIndex = _decoder->get(cID,_identifierMGWaferGroup); + _waferIndex = _decoder->get(cID,_identifierWafer); if ( _waferOffsetX[_groupMGWaferIndex][_waferIndex] > 0 || _waferOffsetX[_groupMGWaferIndex][_waferIndex] < 0 ) { - (*_decoder)[_xId] = positionToBin(localPosition.X, _gridSizeX, _offsetX+_waferOffsetX[_groupMGWaferIndex][_waferIndex]); + _decoder->set(cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX+_waferOffsetX[_groupMGWaferIndex][_waferIndex])); } else { - (*_decoder)[_xId] = positionToBin(localPosition.X, _gridSizeX, _offsetX); + _decoder->set(cID,_xId, positionToBin(localPosition.X, _gridSizeX, _offsetX)); } if ( _waferOffsetY[_groupMGWaferIndex][_waferIndex] > 0 || _waferOffsetY[_groupMGWaferIndex][_waferIndex] < 0) { - (*_decoder)[_yId] = positionToBin(localPosition.Y, _gridSizeY, _offsetY+_waferOffsetY[_groupMGWaferIndex][_waferIndex]); + _decoder->set(cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY+_waferOffsetY[_groupMGWaferIndex][_waferIndex])); } else { - (*_decoder)[_yId] = positionToBin(localPosition.Y, _gridSizeY, _offsetY); + _decoder->set(cID,_yId, positionToBin(localPosition.Y, _gridSizeY, _offsetY)); } - return _decoder->getValue(); + return cID; } std::vector<double> WaferGridXY::cellDimensions(const CellID&) const { diff --git a/DDG4/include/DDG4/Geant4ReadoutVolumeFilter.h b/DDG4/include/DDG4/Geant4ReadoutVolumeFilter.h index 9507cd2069a0c8116712092cf3abb8516407b1cf..c3ee8bc2a52c2719281afeee491185642fa61c23 100644 --- a/DDG4/include/DDG4/Geant4ReadoutVolumeFilter.h +++ b/DDG4/include/DDG4/Geant4ReadoutVolumeFilter.h @@ -37,7 +37,7 @@ namespace dd4hep { /// Collection index const HitCollection* m_collection; /// Bit field value from ID descriptor - const BitFieldValue* m_key; + const BitFieldElement* m_key; public: /// Standard constructor diff --git a/DDG4/include/DDG4/Geant4VolumeManager.h b/DDG4/include/DDG4/Geant4VolumeManager.h index d9fd903c198af780752db2ee54102d392dd5b1d4..cb5c178fe1f412e8227d7374d09f6b1f3edc1dea 100644 --- a/DDG4/include/DDG4/Geant4VolumeManager.h +++ b/DDG4/include/DDG4/Geant4VolumeManager.h @@ -75,10 +75,10 @@ namespace dd4hep { VolumeID volumeID(const G4VTouchable* touchable) const; /// Accessfully decoded volume fields by placement path void volumeDescriptor(const std::vector<const G4VPhysicalVolume*>& path, - std::pair<VolumeID,std::vector<std::pair<const BitFieldValue*, VolumeID> > >& volume_desc) const; + std::pair<VolumeID,std::vector<std::pair<const BitFieldElement*, VolumeID> > >& volume_desc) const; /// Access fully decoded volume fields by Geant4 touchable object void volumeDescriptor(const G4VTouchable* touchable, - std::pair<VolumeID,std::vector<std::pair<const BitFieldValue*, VolumeID> > >& volume_desc) const; + std::pair<VolumeID,std::vector<std::pair<const BitFieldElement*, VolumeID> > >& volume_desc) const; }; } // End namespace sim diff --git a/DDG4/src/Geant4VolumeManager.cpp b/DDG4/src/Geant4VolumeManager.cpp index 4090ba2238c79d87ff029b58aa1e78d567a9aee1..61284cc980b0e6fa1b33655b5aeb1b6fb46983a7 100644 --- a/DDG4/src/Geant4VolumeManager.cpp +++ b/DDG4/src/Geant4VolumeManager.cpp @@ -36,7 +36,7 @@ using namespace dd4hep; using namespace std; #include "DDG4/Geant4AssemblyVolume.h" -typedef pair<VolumeID,vector<pair<const BitFieldValue*, VolumeID> > > VolIDDescriptor; +typedef pair<VolumeID,vector<pair<const BitFieldElement*, VolumeID> > > VolIDDescriptor; namespace { /// Helper class to populate the Geant4 volume manager diff --git a/DDTest/src/test_PolarGridRPhi2.cc b/DDTest/src/test_PolarGridRPhi2.cc index 37f61a4028d877532bd8222a1ef32a7e6e03af13..0649cc2a890bb8fdf7839e6ff31c52e5235feebf 100644 --- a/DDTest/src/test_PolarGridRPhi2.cc +++ b/DDTest/src/test_PolarGridRPhi2.cc @@ -129,8 +129,8 @@ int main() { << std::endl; std::cout << std::setw(20) << "Calculated" - << std::setw(20) << (*seg.decoder())["r"] - << std::setw(20) << (*seg.decoder())["phi"] + << std::setw(20) << seg.decoder()->get(cid,"r") + << std::setw(20) << seg.decoder()->get(cid,"phi") << std::endl; } @@ -164,10 +164,11 @@ int main() { const long long rB = (*it)._rB; const long long pB = (*it)._pB; - (*seg.decoder())["r"] = rB; - (*seg.decoder())["phi"] = pB; + dd4hep::DDSegmentation::CellID cellID ; + + seg.decoder()->set(cellID,"r" , rB); + seg.decoder()->set(cellID,"phi", pB); - dd4hep::DDSegmentation::CellID cellID = (*seg.decoder()).getValue(); std::cout << "CellID: " << cellID << std::endl; dd4hep::DDSegmentation::Vector3D expectedPosition( r*cos(phi), r*sin(phi), 0.0); diff --git a/DDTest/src/test_cellDimensionsRPhi2.cc b/DDTest/src/test_cellDimensionsRPhi2.cc index 5fdfe057433df03dc31dfa497b9523f297bcad98..1565c4d32ea19653e052836a2c036eab093a67e0 100644 --- a/DDTest/src/test_cellDimensionsRPhi2.cc +++ b/DDTest/src/test_cellDimensionsRPhi2.cc @@ -100,9 +100,10 @@ Segmentation* createPolarGridRPhi2() { } CellID getCellID(dd4hep::DDSegmentation::Segmentation* seg, long long rB, long long pB){ - (*seg->decoder())["r"] = rB; - (*seg->decoder())["phi"] = pB; - return (*seg->decoder()).getValue(); + CellID cID ; + seg->decoder()->set(cID,"r",rB) ; + seg->decoder()->set(cID,"phi",pB); + return cID; } void testRPhi2(){ diff --git a/DDTest/src/test_segmentationHandles.cc b/DDTest/src/test_segmentationHandles.cc index b8045ffaed98c6cb94060b515105147f4228f858..5c0427487184a07d44631f8f744b86b0a5152525 100644 --- a/DDTest/src/test_segmentationHandles.cc +++ b/DDTest/src/test_segmentationHandles.cc @@ -16,10 +16,11 @@ static dd4hep::DDTest test( "CellDimensions" ) ; using namespace dd4hep; using namespace dd4hep::detail; +//using dd4hep::DDSegmentation::BitFieldCoder; int main() { try{ - BitField64 bf("system:8,barrel:3,layer:8,slice:5,x:16,y:16"); + BitFieldCoder bf("system:8,barrel:3,layer:8,slice:5,x:16,y:16"); Segmentation base("CartesianGridXY","Test",&bf); CartesianGridXY seg(base); const double xSize=12343.43243; @@ -41,7 +42,7 @@ int main() { } try{ - BitField64 bf("system:8,barrel:3,layer:8,slice:5,x:16,z:16"); + BitFieldCoder bf("system:8,barrel:3,layer:8,slice:5,x:16,z:16"); Segmentation base("CartesianGridXZ","Test",&bf); CartesianGridXZ seg(base); @@ -64,7 +65,7 @@ int main() { } try{ - BitField64 bf("system:8,barrel:3,layer:8,slice:5,y:16,z:16"); + BitFieldCoder bf("system:8,barrel:3,layer:8,slice:5,y:16,z:16"); Segmentation base("CartesianGridYZ","Test",&bf); CartesianGridYZ seg = base; @@ -87,7 +88,7 @@ int main() { } try{ - BitField64 bf("system:8,barrel:3,layer:8,slice:7,x:10,y:10,z:10"); + BitFieldCoder bf("system:8,barrel:3,layer:8,slice:7,x:10,y:10,z:10"); Segmentation base("CartesianGridXYZ","Test",&bf); CartesianGridXYZ seg = base; diff --git a/UtilityApps/src/test_cellid_position_converter.cpp b/UtilityApps/src/test_cellid_position_converter.cpp index 64f5adf36c8d8b942f862e9ab6dff276799abda8..7f8e90dd9df76da7f1082d8711a10ad42d722f46 100644 --- a/UtilityApps/src/test_cellid_position_converter.cpp +++ b/UtilityApps/src/test_cellid_position_converter.cpp @@ -16,7 +16,7 @@ #include "DD4hep/DDTest.h" #include "DD4hep/DD4hepUnits.h" -#include "DD4hep/BitField64.h" +#include "DD4hep/BitFieldCoder.h" #include "DDRec/CellIDPositionConverter.h" #include "lcio.h" @@ -124,8 +124,8 @@ int main_wrapper(int argc, char** argv ){ std::string cellIDEcoding = col->getParameters().getStringVal("CellIDEncoding") ; - dd4hep::BitField64 idDecoder0( cellIDEcoding ) ; - dd4hep::BitField64 idDecoder1( cellIDEcoding ) ; + dd4hep::BitFieldCoder idDecoder0( cellIDEcoding ) ; + dd4hep::BitFieldCoder idDecoder1( cellIDEcoding ) ; int nHit = std::min( col->getNumberOfElements(), maxHit ) ; @@ -137,10 +137,7 @@ int main_wrapper(int argc, char** argv ){ dd4hep::long64 id0 = sHit->getCellID0() ; dd4hep::long64 id1 = sHit->getCellID1() ; - idDecoder0.setValue( id0 , id1 ) ; - - dd4hep::long64 id = idDecoder0.getValue() ; - + dd4hep::long64 id = idDecoder0.toLong( id0 , id1 ) ; Position point( sHit->getPosition()[0]* dd4hep::mm , sHit->getPosition()[1]* dd4hep::mm , sHit->getPosition()[2]* dd4hep::mm ) ; @@ -150,11 +147,8 @@ int main_wrapper(int argc, char** argv ){ CellID idFromDecoder = idposConv.cellID( point ) ; - idDecoder1.setValue( idFromDecoder ) ; - - std::stringstream sst ; - sst << " compare ids: " << det.name() << " " << idDecoder0.valueString() << " - " << idDecoder1.valueString() ; + sst << " compare ids: " << det.name() << " " << idDecoder0.valueString(id) << " - " << idDecoder1.valueString(idFromDecoder) ; test( id, idFromDecoder, sst.str() ) ; diff --git a/UtilityApps/src/test_surfaces.cpp b/UtilityApps/src/test_surfaces.cpp index 7476bbc6b346968043c9b85e920bec975c9d6240..3eb4e5f3976fc845e3233bd3d5a44ee408dba38d 100644 --- a/UtilityApps/src/test_surfaces.cpp +++ b/UtilityApps/src/test_surfaces.cpp @@ -114,7 +114,7 @@ int main_wrapper(int argc, char** argv ){ std::string cellIDEcoding = col->getParameters().getStringVal("CellIDEncoding") ; - dd4hep::BitField64 idDecoder( cellIDEcoding ) ; + BitField64 idDecoder( cellIDEcoding ) ; int nHit = col->getNumberOfElements() ;