DD4hep  1.32.0
Detector Description Toolkit for High Energy Physics
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 <ostream>
15 #include <sstream>
16 #include <string>
17 
18 namespace dd4hep{
19 
20 namespace DDSegmentation {
21 
22 
23  std::string BitField64::valueString() const {
24 
25  std::stringstream os ;
26 
27  for(unsigned i=0;i<size();i++){
28 
29  if( i != 0 ) os << "," ;
30 
31  os << _coder->fields()[i].name() << ":" << _coder->get( _value , i ) ;
32 
33  }
34  return os.str() ;
35  }
36 
37 
38  std::ostream& operator<<(std::ostream& os, const BitField64& b){
39 
40  os << " bitfield: 0x" << std::hex // << std::ios::width(16) << std::ios::fill('0') <<
41  << b._value << std::dec << std::endl ;
42 
43 
44  for(unsigned i=0;i<b._coder->size();i++){
45 
46  const BitFieldElement& bv = b._coder->fields()[i] ;
47 
48  os << " " << bv.name()
49  << " [" << bv.offset() << ":" ;
50 
51  if( bv.isSigned() ) os << "-" ;
52 
53  os << bv.width() << "] : " ;
54 
55  os << b._coder->get( b._value , i)
56  << std::endl ;
57 
58  }
59 
60  return os ;
61  }
62 
63 } // namespace
64 
65 } // namespace
dd4hep::DDSegmentation::BitFieldElement::offset
unsigned offset() const
Definition: BitFieldCoder.h:63
dd4hep::DDSegmentation::BitFieldElement
Helper class for BitFieldCoder that corresponds to one field value.
Definition: BitFieldCoder.h:31
dd4hep::DDSegmentation::BitField64::_value
CellID _value
Definition: BitField64.h:227
dd4hep::DDSegmentation::BitFieldElement::isSigned
bool isSigned() const
Definition: BitFieldCoder.h:69
dd4hep::DDSegmentation::BitFieldCoder::get
FieldID get(CellID bitfield, size_t idx) const
Definition: BitFieldCoder.h:164
dd4hep::DDSegmentation::BitField64
A bit field of 64bits that allows convenient declaration.
Definition: BitField64.h:107
dd4hep::DDSegmentation::BitFieldCoder::fields
const std::vector< BitFieldElement > & fields() const
Definition: BitFieldCoder.h:217
dd4hep::DDSegmentation::BitField64::valueString
std::string valueString() const
Definition: BitField64.cpp:23
BitField64.h
dd4hep::DDSegmentation::BitFieldElement::name
const std::string & name() const
Definition: BitFieldCoder.h:60
dd4hep::DDSegmentation::BitFieldElement::width
unsigned width() const
Definition: BitFieldCoder.h:66
dd4hep::DDSegmentation::BitField64::_coder
const BitFieldCoder * _coder
Definition: BitField64.h:228
dd4hep::DDSegmentation::BitField64::size
size_t size() const
Definition: BitField64.h:183
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::DDSegmentation::BitFieldCoder::size
size_t size() const
Definition: BitFieldCoder.h:191
dd4hep::DDSegmentation::operator<<
std::ostream & operator<<(std::ostream &os, const BitField64 &b)
Definition: BitField64.cpp:38