Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move CellID data type to uint64_t #1125

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions DDCore/include/DD4hep/Segmentations.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
#define DD4HEP_SEGMENTATIONS_H

// Framework include files
#include "DD4hep/Handle.h"
#include "DD4hep/Objects.h"
#include "DD4hep/BitFieldCoder.h"
#include "DDSegmentation/Segmentation.h"
#include <DD4hep/Handle.h>
#include <DD4hep/Objects.h>
#include <DD4hep/BitFieldCoder.h>
#include <DDSegmentation/Segmentation.h>

/// Namespace for the AIDA detector description toolkit
namespace dd4hep {
Expand Down Expand Up @@ -79,9 +79,9 @@ namespace dd4hep {
/// Set the underlying decoder
void setDecoder(const BitFieldCoder* decoder) const;
/// determine the local position based on the cell ID
Position position(const long64& cellID) const;
Position position(const CellID& cellID) const;
/// determine the cell ID based on the local position
long64 cellID(const Position& localPosition, const Position& globalPosition, const long64& volumeID) const;
CellID cellID(const Position& localPosition, const Position& globalPosition, const VolumeID& volumeID) const;
/// Determine the volume ID from the full cell ID by removing all local fields
VolumeID volumeID(const CellID& cellID) const;
/// Calculates the neighbours of the given cell ID and adds them to the list of neighbours
Expand Down
37 changes: 16 additions & 21 deletions DDCore/include/DDSegmentation/BitField64.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
/// Namespace for the AIDA detector description toolkit
namespace dd4hep {

typedef long long int long64 ;
typedef unsigned long long ulong64 ;

/// DDSegmentation namespace declaration
namespace DDSegmentation {

Expand All @@ -38,34 +35,34 @@ namespace dd4hep {
*/
class BitFieldValue{

long64& _value ;
CellID& _value ;
const BitFieldElement& _bv ;

public :

BitFieldValue() = delete ;

/// only c'tor with reference to bitfield and BitFieldElement
BitFieldValue( long64& bitfield, const BitFieldElement& bv ) :
BitFieldValue( CellID& bitfield, const BitFieldElement& bv ) :
_value( bitfield ), _bv( bv) {}

/** Returns the current field value
*/
long64 value() const { return _bv.value( _value ) ; }
FieldID value() const { return _bv.value( _value ) ; }

/// Calculate Field value given an external 64 bit bitmap value
long64 value(long64 id) const { return _bv.value( id ) ; }
FieldID value(CellID id) const { return _bv.value( id ) ; }

//// Assignment operator for user convenience
BitFieldValue& operator=(long64 in) {
BitFieldValue& operator=(FieldID in) {
_bv.set( _value, in ) ;
return *this ;
}

/** Conversion operator for long64 - allows to write:<br>
* long64 index = myBitFieldValue ;
*/
operator long64() const { return value() ; }
operator FieldID() const { return value() ; }

/** The field's name */
const std::string& name() const { return _bv.name() ; }
Expand All @@ -74,13 +71,13 @@ namespace dd4hep {
unsigned offset() const { return _bv.offset() ; }

/** The field's width */
unsigned width() const { return _bv.width() ; }
unsigned width() const { return _bv.width() ; }

/** True if field is interpreted as signed */
bool isSigned() const { return _bv.isSigned() ; }
bool isSigned() const { return _bv.isSigned() ; }

/** The field's mask */
ulong64 mask() const { return _bv.mask() ; }
CellID mask() const { return _bv.mask() ; }

/** Minimal value */
int minValue() const { return _bv.minValue(); }
Expand Down Expand Up @@ -119,8 +116,8 @@ namespace dd4hep {
virtual ~BitField64() {
if( _owner)
delete _coder ;
} ;
};

/** No default c'tor */
BitField64() = delete ;

Expand All @@ -139,7 +136,6 @@ namespace dd4hep {
* Example: "layer:7,system:-3,barrel:3,theta:32:11,phi:11"
*/
BitField64( const std::string& initString ){

_coder = new BitFieldCoder( initString ) ;
}

Expand All @@ -150,11 +146,11 @@ namespace dd4hep {

/** Returns the current 64bit value
*/
long64 getValue() const { return _value ; }
CellID getValue() const { return _value ; }

/** Set a new 64bit value - bits not used in description are set to 0.
*/
void setValue(long64 value ) { _value = ( _coder->mask() & value ) ; }
void setValue(CellID value ) { _value = ( _coder->mask() & value ) ; }

/** Set a new 64bit value given as high and low 32bit words.
*/
Expand All @@ -163,7 +159,7 @@ namespace dd4hep {
}

/** Operator for setting a new value and accessing the BitField directly */
BitField64& operator()(long64 val) { setValue( val ) ; return *this ; }
BitField64& operator()(CellID val) { setValue( val ) ; return *this ; }

/** Reset - same as setValue(0) - useful if the same encoder is used for many objects.
*/
Expand Down Expand Up @@ -196,7 +192,6 @@ namespace dd4hep {
/** Access to field through name .
*/
BitFieldValue operator[](const std::string& name) {

return BitFieldValue( _value, _coder->operator[]( name ) ) ;
}
// /** Const Access to field through name .
Expand Down Expand Up @@ -231,8 +226,8 @@ namespace dd4hep {
protected:

// -------------- data members:--------------
bool _owner{true} ;
long64 _value{} ;
bool _owner{true} ;
CellID _value{} ;
const BitFieldCoder* _coder{} ;

};
Expand Down
Loading