Commit in lcio/src on MAIN
aid/EVENT/LCIO.aid+10-11.50 -> 1.51
cpp/include/LCIOTypes.h+31.2 -> 1.3
cpp/include/UTIL/BitField64.h+252added 1.1
                /CellIDDecoder.h+104added 1.1
cpp/src/EXAMPLE/dumpevent.cc+111.7 -> 1.8
               /simjob.cc+14-21.47 -> 1.48
cpp/src/IMPL/LCIO.cc+21.19 -> 1.20
cpp/src/UTIL/BitField64.cc+259added 1.1
            /LCTOOLS.cc+28-1241.45 -> 1.46
+683-127
3 added + 6 modified, total 9 files
introduced convenient code for decoding cellIDs from encoding string 

lcio/src/aid/EVENT
LCIO.aid 1.50 -> 1.51
diff -u -r1.50 -r1.51
--- LCIO.aid	8 Mar 2006 09:57:27 -0000	1.50
+++ LCIO.aid	10 Mar 2006 16:23:14 -0000	1.51
@@ -16,7 +16,7 @@
 /** Global constants used in LCIO.
  * 
  * @author gaede 
- * @version $Id: LCIO.aid,v 1.50 2006/03/08 09:57:27 gaede Exp $
+ * @version $Id: LCIO.aid,v 1.51 2006/03/10 16:23:14 gaede Exp $
  * @see LCObject
  * @see LCIO
  */
@@ -106,6 +106,10 @@
     static const char* RECONSTRUCTEDPARTICLE ; 
     static const char* LCRELATION ; 
     static const char* LCGENERICOBJECT ; 
+
+    // reserved names, e.g. name of event/collections paramaters
+    
+    static const char* CellIDEncoding ; 
 }
 @else
     // current version number of lcio
@@ -182,6 +186,11 @@
   public static const String RECONSTRUCTEDPARTICLE = "ReconstructedParticle"; 
   public static const String LCRELATION = "LCRelation" ; 
   public static const String LCGENERICOBJECT = "LCGenericObject"; 
+
+  // reserved names, e.g. name of event/collections paramaters
+    
+  public static const String CellIDEncoding = "CellIDEncoding"; 
+
 @endif
 }
 

lcio/src/cpp/include
LCIOTypes.h 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- LCIOTypes.h	15 Apr 2005 08:37:33 -0000	1.2
+++ LCIOTypes.h	10 Mar 2006 16:23:15 -0000	1.3
@@ -12,6 +12,9 @@
 
   /** 64 bit signed integer,e.g.to be used for timestamps **/
   typedef long long long64 ;
+
+  /** 64 bit unsigned integer,e.g.to be used for masks **/
+  typedef unsigned long long ulong64 ;
   
   //fg: this might have to be modified for other architectures, e.g. 64bit systems, or windows ?
   

lcio/src/cpp/include/UTIL
BitField64.h added at 1.1
diff -N BitField64.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ BitField64.h	10 Mar 2006 16:23:15 -0000	1.1
@@ -0,0 +1,252 @@
+#ifndef UTIL_LCFOURVECTOR_H
+#define UTIL_LCFOURVECTOR_H 1
+
+#include <iostream>
+
+#include <string>
+#include <vector>
+#include <map>
+#include <sstream>
+
+#include "lcio.h"
+#include "LCIOTypes.h"
+
+namespace UTIL {
+  
+  /** Helper class  for string tokenization. Usage:<br>
+   *    std::vector<std::string> tokens ; <br>
+   *    LCTokenizer t( tokens ,',') ; <br>
+   *    std::for_each( aString.begin(), aString.end(), t ) ;  <br>
+   */
+  class LCTokenizer{
+    
+    std::vector< std::string >& _tokens ;
+    char _del ;
+    char _last ;
+
+  public:
+    
+    /** Only c'tor, give (empty) token vector and delimeter character */
+    LCTokenizer( std::vector< std::string >& tokens, char del ) 
+      : _tokens(tokens) 
+	, _del(del), 
+	_last(del) {
+    }
+    
+    /** Operator for use with algorithms, e.g. for_each */
+    void operator()(const char& c) { 
+      
+      if( c != _del  ) {
+	
+	if( _last == _del  ) {
+	  _tokens.push_back("") ; 
+	}
+	_tokens.back() += c ;
+      }
+      _last = c ;
+    } 
+    
+  };
+
+
+  /** Helper class for BitField64 that corresponds to one field value. 
+   */
+
+  class BitFieldValue{
+  
+  public :
+    virtual ~BitFieldValue() {}
+  
+    /** The default c'tor.
+     * @param  bitfield      reference to the 64bit bitfield
+     * @param  offset        offset of field
+     * @param  signedWidth   width of field, negative if field is signed
+     */
+    BitFieldValue( lcio::long64& bitfield, const std::string& name, 
+		   unsigned offset, int signedWidth ) ; 
+
+
+    /** Returns the current field value 
+     */
+    lcio::long64 value() const ;
+  
+    /** Assignment operator for user convenience 
+     */
+    BitFieldValue& operator=(lcio::long64 in) ;
+
+    /** Conversion operator for lcio::long64 - allows to write:<br>
+     *  lcio::long64 index = myBitFieldValue ;
+     */
+    operator lcio::long64() const { return value() ; } 
+    
+    /** Conversion operator for int - allows to write:<br>
+     *  int index = myBitFieldValue ;
+     */
+    operator int() const { return (int) value() ; } 
+    
+    /** The field's name */
+    const std::string& name() const { return _name ; }
+
+    /** The field's offset */
+    int offset() const { return _offset ; }
+
+    /** The field's width */
+    unsigned width() const { return _width ; }
+
+    /** True if field is interpreted as signed */
+    bool isSigned() const { return _isSigned ; }
+
+    /** The field's mask */
+    lcio::ulong64 mask() const { return _mask ; }
+
+
+  protected:
+  
+    lcio::long64& _b ;
+    lcio::ulong64 _mask ;
+    std::string _name ;
+    unsigned _offset ;
+    unsigned _width ;
+    int _minVal ;
+    int _maxVal ;
+    bool _isSigned ;
+
+  };
+
+  /** A bit field of 64bits that allows convenient declaration and 
+   *  manipulation of sub fields of various widths.<br>
+   *  Example:<br>
+   *    BitField64 b("layer:7,system:-3,barrel:3,theta:32:11,phi:11" ) ; <br> 
+   *    b[ "layer"  ]  = 123 ;         <br> 
+   *    b[ "system" ]  = -4 ;          <br> 
+   *    b[ "barrel" ]  = 7 ;           <br> 
+   *    b[ "theta" ]   = 180 ;         <br> 
+   *    b[ "phi" ]     = 270 ;         <br> 
+   *    ...                            <br>
+   *    int theta = b["theta"] ;                    <br>
+   *    ...                                         <br>
+   *    unsigned phiIndex = b.index("phi) ;         <br>
+   *    int phi = b[  phiIndex ] ;                  <br>
+   */  
+  class BitField64{
+
+    friend std::ostream& operator<<(std::ostream& os, const BitField64& b) ;
+
+  public :
+
+    typedef std::map<std::string, unsigned int> IndexMap ;
+
+
+    ~BitField64() {  // clean up
+      for(unsigned i=0;i<_fields.size();i++){
+	delete _fields[i] ;
+      }
+    }
+  
+    /** The c'tor takes an initialization string of the form:<br>
+     *  <fieldDesc>[,<fieldDesc>...]<br>
+     *  fieldDesc = name:[start]:[-]length<br>
+     *  where:<br>
+     *  name: The name of the field<br>
+     *  start: The start bit of the field. If omitted assumed to start 
+     *  immediately following previous field, or at the least significant 
+     *  bit if the first field.<br>
+     *  length: The number of bits in the field. If preceeded by '-' 
+     *  the field is signed, otherwise unsigned.<br>
+     *  Bit numbering is from the least significant bit (bit 0) to the most 
+     *  significant (bit 63). <br>
+     *  Example: "layer:7,system:-3,barrel:3,theta:32:11,phi:11"
+     */
+    BitField64( const std::string& initString ) : _value(0), _joined(0){
+    
+      init( initString ) ;
+    }
+
+    /** Returns the current 64bit value 
+     */
+    lcio::long64 getValue() { return _value ; } 
+    
+    /** Set a new 64bit value 
+     */
+    void  setValue(lcio::long64 value ) { _value = value ; }
+    
+
+    /** Acces to field through index 
+     */
+    BitFieldValue& operator[](size_t index) { 
+      return *_fields.at( index )  ; 
+    }
+    
+    /** Const acces to field through index 
+     */
+    const BitFieldValue& operator[](size_t index) const { 
+      return *_fields.at( index )  ; 
+    }
+
+    /** Index for field named 'name' 
+     */
+    size_t index( const std::string& name) ;
+
+    /** Access to field through name .
+     */
+    BitFieldValue& operator[](const std::string& name) { 
+
+      return *_fields[ index( name ) ] ;
+    }
+      
+    /** The low  word, bits 0-31
+     */
+    unsigned lowWord() const { return unsigned( _value &  0xffffFFFF )  ; } 
+
+    /** The high  word, bits 32-63
+     */
+    unsigned highWord() const { return unsigned( _value >> 32  ) ; } 
+
+
+    /** Return a valid description string of all fields
+     */
+    std::string fieldDescription() const ;
+
+    /** Return a string with a comma separated list of the current sub field values 
+     */
+    std::string valueString() const ;
+
+  protected:
+
+    /** Add an additional field to the list 
+     */
+    void addField( const std::string& name,  unsigned offset, int width ); 
+
+    /** Decode the initialization string as described in the constructor.
+     *  @see BitField64( const std::string& initString )
+     */
+    void init( const std::string& initString) ;
+
+    /** No default c'tor */
+    BitField64() : _value(0) , _joined(0) { }
+
+
+    // -------------- data members:--------------
+
+    std::vector<BitFieldValue*>  _fields ;
+    lcio::long64 _value ;
+    IndexMap _map ;
+    lcio::long64 _joined ;
+
+
+  };
+
+
+
+  /** Operator for dumping BitField64 to streams 
+   */
+  std::ostream& operator<<(std::ostream& os, const BitField64& b) ;
+
+
+} // end namespace
+
+#endif
+
+
+
+

lcio/src/cpp/include/UTIL
CellIDDecoder.h added at 1.1
diff -N CellIDDecoder.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CellIDDecoder.h	10 Mar 2006 16:23:15 -0000	1.1
@@ -0,0 +1,104 @@
+#ifndef CellIDDecoder_h
+#define CellIDDecoder_h 1
+
+//#include <vector>
+//#include "EVENT/LCObject.h"
+#include "EVENT/LCCollection.h"
+#include "UTIL/BitField64.h"
+#include "lcio.h"
+#include <string>
+
+//#include <sstream>
+//#include <typeinfo>
+
+using namespace lcio ;
+
+namespace UTIL{
+
+
+  /** Convenient class for decoding cellIDs from collection parameter LCIO::CellIDEncoding.
+   *  See UTIL::BitField64 for a description of the encoding string. 
+   * 
+   *  @see BitField64
+   *  @version $Id: CellIDDecoder.h,v 1.1 2006/03/10 16:23:15 gaede Exp $
+   */
+  template <class T> 
+  class CellIDDecoder {
+    
+  public:  
+    
+    /** Constructor reads encoding string from collection parameter LCIO::CellIDEncoding.
+     */
+    CellIDDecoder( const LCCollection* col ) : _oldHit(0) {
+      
+      std::string initString = col->getParameters().getStringVal(  LCIO::CellIDEncoding ) ;
+      
+      if( initString.size() == 0 ) {
+	
+	initString = *_defaultEncoding ;
+
+	std::cout << "    ----------------------------------------- " << std::endl  
+		  << "       WARNING: CellIDDecoder - no CellIDEncoding parameter in collection ! " 
+		  << std::endl 
+		  << "         -> using default : \"" << initString << "\"" 
+		  << std::endl 
+		  << "    ------------------------------------------ "  
+		  << std::endl ;
+      }
+      
+      _b = new BitField64(  initString ) ; 
+    }
+    
+    ~CellIDDecoder(){ 
+      
+      delete _b ;
+    } 
+    
+    
+    /** Provides access to the bit fields, e.g. <br>
+     *   int layer =  myCellIDEncoding( hit )[ "layer" ] ;
+     * 
+     */
+    const BitField64 & operator()( T* hit ){  
+
+      if( hit != _oldHit && hit ) {
+	
+
+	long64 val = long64( hit->getCellID0() & 0xffffffff ) 
+ 	  |        ( long64( hit->getCellID1() ) << 32      ) ;
+	
+	_b->setValue( val ) ;
+
+	_oldHit = hit ;
+      }
+      
+      return  *_b ;
+    }
+    
+
+    /** This can be used to set the default encoding that is used if no
+     *  CellIDEncoding parameter is set in the collection, e.g. in older lcio files.
+     */ 
+    static void setDefaultEncoding(const std::string& defaultEncoding ) {
+      
+      delete _defaultEncoding ;
+      
+      _defaultEncoding = new std::string( defaultEncoding ) ;
+    }
+    
+  protected:
+    BitField64* _b ;
+    T* _oldHit ;
+    
+    static std::string*  _defaultEncoding ;
+  } ; 
+  
+  template <class T>
+  std::string* CellIDDecoder<T>::_defaultEncoding 
+  = new std::string("byte0:8,byte1:8,byte2:8,byte3:8,byte4:8,byte5:8,byte6:8,byte7:8") ;
+
+
+} // namespace
+#endif
+
+

lcio/src/cpp/src/EXAMPLE
dumpevent.cc 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- dumpevent.cc	7 Mar 2006 17:42:18 -0000	1.7
+++ dumpevent.cc	10 Mar 2006 16:23:17 -0000	1.8
@@ -4,7 +4,12 @@
 #include "IMPL/LCTOOLS.h"
 #include "EVENT/LCRunHeader.h" 
 
+#include "EVENT/SimCalorimeterHit.h" 
+#include "EVENT/CalorimeterHit.h" 
+#include "EVENT/RawCalorimeterHit.h" 
+// #include "EVENT/SimTrackerHit.h" 
 
+#include "UTIL/CellIDDecoder.h"
 
 
 using namespace std ;
@@ -55,6 +60,12 @@
     evtNumber = atoi( argv[3] ) ;
   }
   
+
+  // set the default encoding for cellid's according to the old Mokka convention
+  CellIDDecoder<SimCalorimeterHit>::setDefaultEncoding("M:3,S-1:3,I:9,J:9,K-1:6") ;
+  CellIDDecoder<CalorimeterHit>::setDefaultEncoding("M:3,S-1:3,I:9,J:9,K-1:6") ;
+  CellIDDecoder<RawCalorimeterHit>::setDefaultEncoding("M:3,S-1:3,I:9,J:9,K-1:6") ;
+
   LCReader* lcReader = LCFactory::getInstance()->createLCReader() ;
   
   LCEvent* evt(0) ;

lcio/src/cpp/src/EXAMPLE
simjob.cc 1.47 -> 1.48
diff -u -r1.47 -r1.48
--- simjob.cc	19 Sep 2005 15:40:27 -0000	1.47
+++ simjob.cc	10 Mar 2006 16:23:18 -0000	1.48
@@ -21,6 +21,7 @@
 
 #include "UTIL/LCRelationNavigator.h"
 #include "UTIL/LCTime.h"
+#include "UTIL/BitField64.h"
 
 #include <cstdlib>
 #include <iostream>
@@ -189,6 +190,10 @@
 	chFlag.setBit( LCIO::CHBIT_ID1 ) ;
 	calVec->setFlag( chFlag.getFlag()  ) ;
 	
+	std::string cellIDEncoding( "M:3,S-1:3,I:9,J:9,K-1:6") ;// old Mokka convention
+	calVec->parameters().setValue( LCIO::CellIDEncoding , cellIDEncoding ) ;
+
+	BitField64 b( cellIDEncoding  ) ;
 	
 	for(int j=0;j<NHITS;j++){
 	  
@@ -198,9 +203,16 @@
 	  
 	  float pos[3] = { 1.1* rand()/RAND_MAX , 2.2* rand()/RAND_MAX , 3.3* rand()/RAND_MAX } ;
 	  
-	  hit->setCellID0( j+65335 ) ;
-	  hit->setCellID1( 65535 ) ;
+	  // cell indices
+	  b["M"] = j % 8 ;
+	  b["S-1"] = (j+2) % 8 ;
+	  b["I"] = j % 512 ;
+	  b["J"] = (j+128) % 512 ;
+	  b["K-1"] = (j+32) % 64 ;
 
+	  hit->setCellID0( b.lowWord()  ) ;
+	  hit->setCellID1( b.highWord() ) ;
+	  
 	  hit->setPosition( pos ) ;
 	  
 	  calVec->push_back( hit ) ;

lcio/src/cpp/src/IMPL
LCIO.cc 1.19 -> 1.20
diff -u -r1.19 -r1.20
--- LCIO.cc	31 May 2005 07:52:57 -0000	1.19
+++ LCIO.cc	10 Mar 2006 16:23:19 -0000	1.20
@@ -25,4 +25,6 @@
 const char* LCIO::RECONSTRUCTEDPARTICLE = "ReconstructedParticle" ; 
 const char* LCIO::LCRELATION = "LCRelation" ; 
 const char* LCIO::LCGENERICOBJECT = "LCGenericObject" ; 
+
+const char* LCIO::CellIDEncoding = "CellIDEncoding" ; 
 }

lcio/src/cpp/src/UTIL
BitField64.cc added at 1.1
diff -N BitField64.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ BitField64.cc	10 Mar 2006 16:23:19 -0000	1.1
@@ -0,0 +1,259 @@
+#include "UTIL/BitField64.h"
+
+using namespace EVENT ;
+
+namespace UTIL{
+  
+  
+    BitFieldValue::BitFieldValue( lcio::long64& bitfield, const std::string& name, 
+				  unsigned offset, int signedWidth ) :
+    _b(bitfield),
+    _mask(0), 
+    _name( name ), 
+    _offset( offset ),
+    _width( abs( signedWidth ) ),
+    _minVal(0),
+    _maxVal(0),
+    _isSigned( signedWidth < 0 ) {
+    
+    // sanity check
+    if( offset < 0 || offset > 63 || offset+_width > 64 ) {
+      
+      std::stringstream s ;
+      s << " BitFieldValue: out of range -  offset : " 
+	<< offset  << " width " << _width ; 
+      
+      throw( Exception( s.str() ) ) ;
+    }
+    
+    _mask = ( ( 0x0001LL << _width ) - 1 ) << offset ;
+    
+    
+    // compute extreme values for later checks
+    if( _isSigned ){
+      
+      _minVal =  ( 1LL << ( _width - 1 ) ) - ( 1LL << _width )  ;
+      _maxVal =  ( 1LL << ( _width - 1 ) ) - 1 ;
+      
+    } else {
+      
+      _maxVal = 0x0001<<_width  ;
+    }
+    
+    //       std::cout << " _mask :" << std::hex << _mask  
+    //                 <<  std::dec <<  std::endl ; 
+    //       std::cout << " min " << _minVal 
+    // 		<< " max " << _maxVal
+    // 		<< " width " << _width 
+    // 		<< std::endl ; 
+ 
+  }
+  
+
+  long64 BitFieldValue::value() const { 
+      
+    if(  _isSigned   ) {
+
+      long64 val = ( _b & _mask ) >> _offset ;
+      
+      if( ( val  & ( 1LL << ( _width - 1 ) ) ) != 0 ) { // negative value
+	  
+	val -= ( 1LL << _width );
+      }
+	
+      return val ;
+
+    } else { 
+      
+      return  ( _b & _mask ) >> _offset ;
+    }
+  }
+
+  BitFieldValue& BitFieldValue::operator=(long64 in) {
+    
+    // check range 
+    if( in < _minVal || in > _maxVal  ) {
+      
+      std::stringstream s ;
+      s << " BitFieldValue: out of range : " << in 
+	<< " for width " << _width ; 
+      
+      throw( Exception( s.str() ) );
+    }
+    
+    _b &= ~_mask ;  // zero out the field's range
+    
+    _b |=  ( (  in  << _offset )  & _mask  ) ; 
+    
+    return *this ;
+  }
+  
+
+
+
+  size_t BitField64::index( const std::string& name){
+    
+    IndexMap::iterator it = _map.find( name ) ;
+    
+    if( it != _map.end() ) 
+      
+      return it->second  ;
+    
+    else
+      throw Exception(" BitFieldValue: unknown name: " + name ) ;
+  }
+  
+  std::string BitField64::valueString() const {
+
+    std::stringstream  os ;
+
+    for(unsigned i=0;i<_fields.size();i++){
+      
+      if( i != 0 )   os << "," ;
+
+      os << _fields[i]->name() <<  ":" << _fields[i]->value() ;
+
+    }
+    return os.str() ;
+  }
+  
+  std::string BitField64::fieldDescription() const {
+    
+    std::stringstream  os ;
+    
+    for(unsigned i=0;i<_fields.size();i++){
+      
+      if( i != 0 )   os << "," ;
+      
+      os << _fields[i]->name() <<  ":"
+	 << _fields[i]->offset() << ":" ;
+      
+      if(  _fields[i]->isSigned()  )  
+	os << "-" ;
+      
+      os  << _fields[i]->width() ;
+      
+    }
+//     for( IndexMap::const_iterator it = _map.begin()  ;
+// 	 it !=  _map.end() ; ++it ){
+
+//       if( it !=  _map.begin() )
+// 	os << "," ;
+      
+//       os << it->first <<  ":"
+// 	 << _fields[ it->second ]->offset() << ":" ;
+      
+//       if(  _fields[ it->second ]->isSigned()  )  
+// 	os << "-" ;
+
+//       os  << _fields[ it->second ]->width() ;
+
+//     }
+    
+    return os.str() ;
+  }
+
+  void BitField64::addField( const std::string& name,  unsigned offset, int width ){
+
+      
+    BitFieldValue* bfv =  new  BitFieldValue( _value, name, offset, width ) ;
+
+    _fields.push_back(  bfv ) ;
+    
+    _map[ name ] = _fields.size()-1 ;
+
+    if( _joined & bfv->mask()  ) {
+      
+      std::stringstream s ;
+      s << " BitFieldValue: bits already used " << std::hex << _joined
+	<< " for mask " <<  bfv->mask()   ; 
+
+      throw( Exception( s.str() ) ) ;
+      
+    }
+
+    _joined |= _fields.back()->mask() ;
+
+  }
+
+  void BitField64::init( const std::string& initString) {
+
+    unsigned offset = 0  ;
+    
+    // need to compute bit field masks and offsets ...
+    std::vector<std::string> fieldDescriptors ;
+    LCTokenizer t( fieldDescriptors ,',') ;
+
+    std::for_each( initString.begin(), initString.end(), t ) ; 
+
+    for(unsigned i=0; i< fieldDescriptors.size() ; i++ ){
+      
+      std::vector<std::string> subfields ;
+      LCTokenizer ts( subfields ,':') ;
+      
+      std::for_each( fieldDescriptors[i].begin(), fieldDescriptors[i].end(), ts );
+
+      std::string name ; 
+      int  width ; 
+      unsigned thisOffset ;
+
+      switch( subfields.size() ){
+	
+      case 2: 
+
+	name = subfields[0] ; 
+	width = atol( subfields[1].c_str()  ) ;
+	thisOffset = offset ;
+
+	offset += abs( width ) ;
+	
+	break ;
+	
+      case 3: 
+	name = subfields[0] ;
+	thisOffset = atol( subfields[1].c_str()  ) ;
+	width = atol( subfields[2].c_str()  ) ;
+
+	offset = thisOffset + abs( width ) ;
+
+	break ;
+	
+      default:
+
+	std::stringstream s ;
+	s << " BitField64: invalid number of subfields " 
+	  <<  fieldDescriptors[i] ;
+
+	throw( Exception( s.str() ) ) ;
+      }
+
+      addField( name , thisOffset, width ) ;
+    }
+  }
+
+
+  std::ostream& operator<<(std::ostream& os, const BitField64& b){
+
+    os << " bitfield:  0x" << std::hex // << std::ios::width(16) << std::ios::fill('0') <<
+       << b._value << std::dec << std::endl ;
+
+    for( BitField64::IndexMap::const_iterator it = b._map.begin()  ;
+	 it !=  b._map.end() ; ++it ){
+      
+      os << "  " << it->first << " [" <<  b[ it->second ].offset()  << ":"  ;
+      
+      if(  b[ it->second ].isSigned()  )  os << "-" ;
+      
+      os <<  b[ it->second ].width() << "]  : "  ;
+      
+      
+      os <<    b[ it->second ].value() 
+	 << std::endl ;
+      
+    }
+  
+    return os ;
+  } 
+
+} // namespace
+ 

lcio/src/cpp/src/UTIL
LCTOOLS.cc 1.45 -> 1.46
diff -u -r1.45 -r1.46
--- LCTOOLS.cc	7 Jun 2005 11:02:05 -0000	1.45
+++ LCTOOLS.cc	10 Mar 2006 16:23:19 -0000	1.46
@@ -27,20 +27,7 @@
 #endif
 #include "UTIL/LCObjectHandle.h"
 #include "UTIL/LCTime.h"
-
-// code copied from $MOKKA/source/Kernel/include/Control.hh
-// to be used to decode the calorimeter hit's cellids
-#define SHIFT_M 0
-#define SHIFT_S 3
-#define SHIFT_I 6
-#define SHIFT_J 15
-#define SHIFT_K 24
-#define MASK_M (unsigned int) 0x00000007
-#define MASK_S (unsigned int) 0x00000038
-#define MASK_I (unsigned int) 0x00007FC0
-#define MASK_J (unsigned int) 0x00FF8000
-#define MASK_K (unsigned int) 0x3F000000
-
+#include "UTIL/CellIDDecoder.h"
 #include <map>
 #include <set>
 #include <cstdio>
@@ -974,9 +961,9 @@
   }
 
   void LCTOOLS::printSimCalorimeterHits(const EVENT::LCCollection* col ){
-
+    
     if( col->getTypeName() != LCIO::SIMCALORIMETERHIT ){
-
+      
       cout << " collection not of type " << LCIO::SIMCALORIMETERHIT << endl ;
       return ;
     }
@@ -999,15 +986,14 @@
     int nHits =  col->getNumberOfElements() ;
     int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
 
-//     std::cout << endl
-// 	      << " cellId0 | cellId1 | energy | position (x,y,z) | nMCParticles " 
-// 	      << endl << "           -> MC contribution: prim. PDG |  energy | time | sec. PDG  "
-// 	      << endl 
-// 	      << endl ;
     
-    std::cout << "Note: ( M, S, I, J, K) are decoded using the Mokka convention ! " << std::endl ; 
+    CellIDDecoder<SimCalorimeterHit> idDecoder( col ) ; 
+
+    // std::cout << "Note: ( M, S, I, J, K) are decoded using the Mokka convention ! " 
+    // << std::endl ; 
+
     std::cout << endl
-	      << " [   id   ] |  cellId0 ( M, S, I, J, K) | cellId1  |   energy  |        position (x,y,z)          | nMCParticles "
+	      << " [   id   ] |  cellId0 | cellId1  |   energy  |        position (x,y,z)          | nMCParticles "
 	      << endl << "           -> MC contribution: prim. PDG |  energy | time | sec. PDG  "
 	      << endl 
 	      << endl ;
@@ -1020,41 +1006,12 @@
       int id0 = hit->getCellID0() ;
       int id1 = hit->getCellID1() ;
 	    
-//       cout << i << ": "
-// // 	   << hit->getCellID0() << " | "
-// // 	   << hit->getCellID1() << " | "
-// 	   << ((id0& 0xff000000)>>24) << "/" 
-// 	   << ((id0& 0x00ff0000)>>16) << "/" 
-// 	   << ((id0& 0x0000ff00)>> 8) << "/" 
-// 	   << ((id0& 0x000000ff)>> 0) << " | "
-// 	   << ((id1& 0xff000000)>>24) << "/" 
-// 	   << ((id1& 0x00ff0000)>>16) << "/" 
-// 	   << ((id1& 0x0000ff00)>> 8) << "/" 
-// 	   << ((id1& 0x000000ff)>> 0) << " | "
-	
-// 	   << hit->getEnergy() << " | (" ;
-      
-//       if( flag.bitSet( LCIO::CHBIT_LONG ) ){
-      
-// 	cout << hit->getPosition()[0] << ", "
-// 	     << hit->getPosition()[1]<< ", "
-// 	     << hit->getPosition()[2] << ") | " ;
-//       }else{
-// 	cout << "   no position avaliable  ) | " ;
-//       }
-//       cout << hit->getNMCContributions() 
-// 	   << endl ;
       
       if( flag.bitSet( LCIO::CHBIT_LONG ) ){
-	printf( " [%8.8x] | %8.8x (%1d,%1d,%3d,%3d,%2d) | %8.8x |"
+	printf( " [%8.8x] | %8.8x | %8.8x |"
 		" %5.3e | (%5.3e,%5.3e,%5.3e)| %d\n" , 
 		hit->id(), 
 		id0,
-		(  id0 & MASK_M ) >> SHIFT_M ,
-		(( id0 & MASK_S ) >> SHIFT_S ) + 1 ,
-		(  id0 & MASK_I ) >> SHIFT_I ,
-		(  id0 & MASK_J ) >> SHIFT_J ,
-		(( id0 & MASK_K ) >> SHIFT_K ) + 1 ,
 		id1,
 		hit->getEnergy() ,
 		hit->getPosition()[0] ,
@@ -1063,21 +1020,17 @@
 		hit->getNMCContributions()
 		) ;
       } else{
-	printf( " [%8.8x] | %8.8x (%1d,%1d,%3d,%3d,%2d) | %8.8x |"
+	printf( " [%8.8x] | %8.8x | %8.8x |"
 		" %5.3e |    no position available         | %d\n" , 
 		hit->id(), 
 		id0,
-		(  id0 & MASK_M ) >> SHIFT_M ,
-		(( id0 & MASK_S ) >> SHIFT_S ) + 1 ,
-		(  id0 & MASK_I ) >> SHIFT_I ,
-		(  id0 & MASK_J ) >> SHIFT_J ,
-		(( id0 & MASK_K ) >> SHIFT_K ) + 1 ,
 		id1,
 		hit->getEnergy() ,
 		hit->getNMCContributions()
 		) ;
        }
-
+      std::cout << "        id-fields: (" << idDecoder( hit ).valueString() << ")" << std::endl ; 
+      
       for(int k=0;k < hit->getNMCContributions();k++){
 
 	try{
@@ -1132,13 +1085,13 @@
     int nHits =  col->getNumberOfElements() ;
     int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
 
-//     std::cout << endl
-// 	      << " [   id   ] |  cellId0(bytes) | cellId1(bytes) | energy/amplitude | position (x,y,z) " 
-// 	      << endl ;
+    CellIDDecoder<CalorimeterHit> idDecoder( col ) ; 
+
+//     std::cout << "Note: ( M, S, I, J, K) are decoded using the Mokka convention ! " << std::endl ; 
+
 
-    std::cout << "Note: ( M, S, I, J, K) are decoded using the Mokka convention ! " << std::endl ; 
     std::cout << endl
-	      << " [   id   ] |  cellId0 ( M, S, I, J, K) | cellId1  |   energy  |        position (x,y,z)          |"
+	      << " [   id   ] |  cellId0 | cellId1  |   energy  |        position (x,y,z)          |"
 	      << endl ;
 
     for( int i=0 ; i< nPrint ; i++ ){
@@ -1149,40 +1102,11 @@
       int id0 = hit->getCellID0() ;
       int id1 = hit->getCellID1() ;
       
-//       printf( " [%8.8x] | " , hit->id() ) ;
-// 	// 	   << hit->getCellID0() << " | "
-// 	// 	   << hit->getCellID1() << " | "
-// 	cout << ((id0& 0xff000000)>>24) << "/" 
-// 	   << ((id0& 0x00ff0000)>>16) << "/" 
-// 	   << ((id0& 0x0000ff00)>> 8) << "/" 
-// 	   << ((id0& 0x000000ff)>> 0) << " | "
-// 	   << ((id1& 0xff000000)>>24) << "/" 
-// 	   << ((id1& 0x00ff0000)>>16) << "/" 
-// 	   << ((id1& 0x0000ff00)>> 8) << "/" 
-// 	   << ((id1& 0x000000ff)>> 0) << " | "
-// 	   << hit->getEnergy() << " | (" ;
-      
-//       if( flag.bitSet( LCIO::CHBIT_LONG ) ){
-	
-// 	cout << hit->getPosition()[0] << ", "
-// 	     << hit->getPosition()[1]<< ", "
-// 	     << hit->getPosition()[2] << ") | " ;
-//       }else{
-// 	cout << "   no position avaliable  ) | " ;
-//       }
-//       cout << endl ;
-
-
       if( flag.bitSet( LCIO::CHBIT_LONG ) ){
-	printf( " [%8.8x] | %8.8x (%1d,%1d,%3d,%3d,%2d) | %8.8x |"
+	printf( " [%8.8x] | %8.8x | %8.8x |"
 		" %5.3e | (%5.3e,%5.3e,%5.3e)|\n" , 
 		hit->id(), 
 		id0,
-		(  id0 & MASK_M ) >> SHIFT_M ,
-		(( id0 & MASK_S ) >> SHIFT_S ) + 1 ,
-		(  id0 & MASK_I ) >> SHIFT_I ,
-		(  id0 & MASK_J ) >> SHIFT_J ,
-		(( id0 & MASK_K ) >> SHIFT_K ) + 1 ,
 		id1,
 		hit->getEnergy() ,
 		hit->getPosition()[0] ,
@@ -1190,19 +1114,16 @@
 		hit->getPosition()[2]
 		) ;
       } else{
-	printf( " [%8.8x] | %8.8x (%1d,%1d,%3d,%3d,%2d) | %8.8x |"
+	printf( " [%8.8x] | %8.8x | %8.8x |"
 		" %5.3e |    no position available         \n" , 
 		hit->id(), 
 		id0,
-		(  id0 & MASK_M ) >> SHIFT_M ,
-		(( id0 & MASK_S ) >> SHIFT_S ) + 1 ,
-		(  id0 & MASK_I ) >> SHIFT_I ,
-		(  id0 & MASK_J ) >> SHIFT_J ,
-		(( id0 & MASK_K ) >> SHIFT_K ) + 1 ,
 		id1,
 		hit->getEnergy()
 		) ;
-       }
+      }
+      std::cout << "        id-fields: (" << idDecoder( hit ).valueString() << ")" << std::endl ; 
+
 
     }
     cout << endl 
@@ -1235,9 +1156,9 @@
     int nHits =  col->getNumberOfElements() ;
     int nPrint = nHits > MAX_HITS ? MAX_HITS : nHits ;
 
-//     std::cout << endl
-// 	      << " [   id   ] |  cellId0(bytes) | cellId1(bytes) | amplitude | time " << endl ;
-    std::cout << "Note: ( M, S, I, J, K) are decoded using the Mokka convention ! " << std::endl ; 
+
+    CellIDDecoder<RawCalorimeterHit> idDecoder( col ) ; 
+
     std::cout << endl
 	      << " [   id   ] |  cellId0 ( M, S, I, J, K) | cellId1  | amplitude |  time  "
 	      << endl ;
@@ -1250,32 +1171,15 @@
       int id0 = hit->getCellID0() ;
       int id1 = hit->getCellID1() ;
       
-//       printf( " [%8.8x] | " , hit->id() ) ;
-//       cout << ((id0& 0xff000000)>>24) << "/" 
-// 	   << ((id0& 0x00ff0000)>>16) << "/" 
-// 	   << ((id0& 0x0000ff00)>> 8) << "/" 
-// 	   << ((id0& 0x000000ff)>> 0) << " | "
-// 	   << ((id1& 0xff000000)>>24) << "/" 
-// 	   << ((id1& 0x00ff0000)>>16) << "/" 
-// 	   << ((id1& 0x0000ff00)>> 8) << "/" 
-// 	   << ((id1& 0x000000ff)>> 0) << " | "
-// 	   << hit->getAmplitude() << " | "
-// 	   << hit->getTimeStamp() << " | ";
-//       cout << endl ;
-
-      printf( " [%8.8x] | %8.8x (%1d,%1d,%3d,%3d,%2d) | %8.8x |"
+      printf( " [%8.8x] | %8.8x | %8.8x |"
 	      " %10d |  %10d \n" , 
 	      hit->id(), 
 	      id0,
-	      (  id0 & MASK_M ) >> SHIFT_M ,
-	      (( id0 & MASK_S ) >> SHIFT_S ) + 1 ,
-	      (  id0 & MASK_I ) >> SHIFT_I ,
-	      (  id0 & MASK_J ) >> SHIFT_J ,
-	      (( id0 & MASK_K ) >> SHIFT_K ) + 1 ,
 	      id1,
 	      hit->getAmplitude() ,
 	      hit->getTimeStamp()
 	      ) ;
+      std::cout << "        id-fields: (" << idDecoder( hit ).valueString() << ")" << std::endl ; 
 
 
 
CVSspam 0.2.8