From 563c15f5e1e3d2f96988a7cf41bf5b1a0fc3e33d Mon Sep 17 00:00:00 2001
From: Markus Frank <markus.frank@cern.ch>
Date: Mon, 4 Nov 2013 17:24:07 +0000
Subject: [PATCH] Fix bad previous commit by me.

---
 .../include/DDSegmentation/Segmentation.h     | 23 +++++++++++--------
 DDSegmentation/src/BitField64.cpp             | 19 ++++++++++-----
 2 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/DDSegmentation/include/DDSegmentation/Segmentation.h b/DDSegmentation/include/DDSegmentation/Segmentation.h
index fc8d2504a..c1d5c730e 100644
--- a/DDSegmentation/include/DDSegmentation/Segmentation.h
+++ b/DDSegmentation/include/DDSegmentation/Segmentation.h
@@ -50,20 +50,20 @@ public:
 		return _decoder->fieldDescription();
 	}
 	/// access the segmentation name
-	const std::string& name() const {
+	std::string name() const {
 		return _name;
 	}
 	/// Set the segmentation name
-	void setName(const std::string& value)  {
-	  _name = value;
+	void setName(const std::string& value) {
+		_name = value;
 	}
 	/// access the segmentation type
-	const std::string& type() const {
+	std::string type() const {
 		return _type;
 	}
 	/// Set the segmentation type
 	void setType(const std::string& value)  {
-	  _type = value;
+		_type = value;
 	}
 	/// access the underlying decoder
 	BitField64* decoder() {
@@ -79,12 +79,17 @@ protected:
 	mutable BitField64* _decoder;
 	/// keeps track of the decoder ownership
 	bool _ownsDecoder;
-	/// the segmentation type
-	std::string _type;
 	/// the segmentation name
 	std::string _name;
-        // M.Frank: Temp fix for compilation
-        bool _isLocal;
+	/// the segmentation type
+	std::string _type;
+	/// distinguish between local and global coordinate systems
+	bool _isLocal;
+
+	/// helper method to convert a bin number to a 1D position
+	double binToPosition(long64 bin, double cellSize, double offset = 0.) const;
+	/// helper method to convert a 1D position to a cell ID
+	int positionToBin(double position, double cellSize, double offset = 0.) const;
 };
 
 } /* namespace DDSegmentation */
diff --git a/DDSegmentation/src/BitField64.cpp b/DDSegmentation/src/BitField64.cpp
index c98bd659e..1deac192d 100644
--- a/DDSegmentation/src/BitField64.cpp
+++ b/DDSegmentation/src/BitField64.cpp
@@ -72,15 +72,22 @@ namespace DDSegmentation {
     }
   }
 
-  long64 BitFieldValue::value(long64 id) const {       
+  long64 BitFieldValue::value(long64 id) const { 
+      
     if(  _isSigned   ) {
-      long64 val = (id & _mask) >> _offset ;
-      if( (val  & (1LL << (_width - 1))) != 0 ) { // negative value
-	val -= (1LL << _width);
+
+      long64 val = ( id & _mask ) >> _offset ;
+      
+      if( ( val  & ( 1LL << ( _width - 1 ) ) ) != 0 ) { // negative value
+	  
+	val -= ( 1LL << _width );
       }
+	
       return val ;
-    } else {
-      return  (id & _mask) >> _offset ;
+
+    } else { 
+      
+      return  ( id & _mask ) >> _offset ;
     }
   }
 
-- 
GitLab