DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
BitField64.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 //==========================================================================
12 
13 #include <cmath>
14 #include <algorithm>
15 #include <stdexcept>
16 
17 namespace dd4hep{
18 
19 namespace DDSegmentation {
20 
21 
22  std::string BitField64::valueString() const {
23 
24  std::stringstream os ;
25 
26  for(unsigned i=0;i<size();i++){
27 
28  if( i != 0 ) os << "," ;
29 
30  os << _coder->fields()[i].name() << ":" << _coder->get( _value , i ) ;
31 
32  }
33  return os.str() ;
34  }
35 
36 
37  std::ostream& operator<<(std::ostream& os, const BitField64& b){
38 
39  os << " bitfield: 0x" << std::hex // << std::ios::width(16) << std::ios::fill('0') <<
40  << b._value << std::dec << std::endl ;
41 
42 
43  for(unsigned i=0;i<b._coder->size();i++){
44 
45  const BitFieldElement& bv = b._coder->fields()[i] ;
46 
47  os << " " << bv.name()
48  << " [" << bv.offset() << ":" ;
49 
50  if( bv.isSigned() ) os << "-" ;
51 
52  os << bv.width() << "] : " ;
53 
54  os << b._coder->get( b._value , i)
55  << std::endl ;
56 
57  }
58 
59  return os ;
60  }
61 
62 } // namespace
63 
64 } // namespace
dd4hep::DDSegmentation::BitFieldElement::offset
unsigned offset() const
Definition: BitFieldCoder.h:64
dd4hep::DDSegmentation::BitFieldElement
Helper class for BitFieldCoder that corresponds to one field value.
Definition: BitFieldCoder.h:32
dd4hep::DDSegmentation::BitField64::_value
CellID _value
Definition: BitField64.h:230
dd4hep::DDSegmentation::BitFieldElement::isSigned
bool isSigned() const
Definition: BitFieldCoder.h:70
dd4hep::DDSegmentation::BitFieldCoder::get
FieldID get(CellID bitfield, size_t idx) const
Definition: BitFieldCoder.h:165
dd4hep::DDSegmentation::BitField64
A bit field of 64bits that allows convenient declaration.
Definition: BitField64.h:110
dd4hep::DDSegmentation::BitFieldCoder::fields
const std::vector< BitFieldElement > & fields() const
Definition: BitFieldCoder.h:218
dd4hep::DDSegmentation::BitField64::valueString
std::string valueString() const
Definition: BitField64.cpp:22
BitField64.h
dd4hep::DDSegmentation::BitFieldElement::name
const std::string & name() const
Definition: BitFieldCoder.h:61
dd4hep::DDSegmentation::BitFieldElement::width
unsigned width() const
Definition: BitFieldCoder.h:67
dd4hep::DDSegmentation::BitField64::_coder
const BitFieldCoder * _coder
Definition: BitField64.h:231
dd4hep::DDSegmentation::BitField64::size
size_t size() const
Definition: BitField64.h:186
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::DDSegmentation::BitFieldCoder::size
size_t size() const
Definition: BitFieldCoder.h:192
dd4hep::DDSegmentation::operator<<
std::ostream & operator<<(std::ostream &os, const BitField64 &b)
Definition: BitField64.cpp:37