diff --git a/DDCore/include/DD4hep/Shapes.h b/DDCore/include/DD4hep/Shapes.h index 7c1611b5022d5aa844dd39ba38ffc7b779ef6ebd..aa3b2f0dc258ab83b02492b26279245f23a9b3f2 100644 --- a/DDCore/include/DD4hep/Shapes.h +++ b/DDCore/include/DD4hep/Shapes.h @@ -203,8 +203,8 @@ namespace dd4hep { Box(double x_val, double y_val, double z_val) { make("", x_val, y_val, z_val); } /// Constructor to create a named new box object (retrieves name from volume) - Box(const std::string& name, double x_val, double y_val, double z_val) - { make(name.c_str(), x_val, y_val, z_val); } + Box(const std::string& nam, double x_val, double y_val, double z_val) + { make(nam.c_str(), x_val, y_val, z_val); } /// Constructor to create an anonymous new box object (retrieves name from volume) template <typename X, typename Y, typename Z> @@ -212,8 +212,8 @@ namespace dd4hep { { make("", _toDouble(x_val), _toDouble(y_val), _toDouble(z_val)); } /// Constructor to create a named new box object (retrieves name from volume) template <typename X, typename Y, typename Z> - Box(const std::string& name, const X& x_val, const Y& y_val, const Z& z_val) - { make(name.c_str(), _toDouble(x_val), _toDouble(y_val), _toDouble(z_val)); } + Box(const std::string& nam, const X& x_val, const Y& y_val, const Z& z_val) + { make(nam.c_str(), _toDouble(x_val), _toDouble(y_val), _toDouble(z_val)); } /// Move Assignment operator Box& operator=(Box&& copy) = default; diff --git a/DDCore/include/DDSegmentation/BitFieldCoder.h b/DDCore/include/DDSegmentation/BitFieldCoder.h index 9f1030168fe52b016549d146364920210af518d3..25deb8d8702bb50603f12f94a8b27d3a8bf4f5e5 100644 --- a/DDCore/include/DDSegmentation/BitFieldCoder.h +++ b/DDCore/include/DDSegmentation/BitFieldCoder.h @@ -21,15 +21,15 @@ namespace dd4hep { -typedef long long int long64 ; -typedef unsigned long long ulong64 ; + typedef long long int long64 ; + typedef unsigned long long ulong64 ; -namespace DDSegmentation { + namespace DDSegmentation { - class StringTokenizer ; + class StringTokenizer ; - /// Helper class for BitFieldCoder that corresponds to one field value. - class BitFieldElement{ + /// Helper class for BitFieldCoder that corresponds to one field value. + class BitFieldElement{ public : @@ -95,213 +95,213 @@ namespace DDSegmentation { - /// Helper class for decoding and encoding a bit field of 64bits for convenient declaration - /** and manipulation of sub fields of various widths.<br> - * This is a thread safe re-implementation of the functionality in the deprected BitField64. - * - * Example:<br> - * BitFieldCoder bc("layer:7,system:-3,barrel:3,theta:32:11,phi:11" ) ; <br> - * bc.set( field, "layer" , 123 ); <br> - * bc.set( field, "system" , -4 ); <br> - * bc.set( field, "barrel" , 7 ); <br> - * bc.set( field, "theta" , 180 ); <br> - * bc.set( field, "phi" , 270 ); <br> - * ... <br> - * int theta = bc.get( field, "theta" ) ; <br> - * ... <br> - * unsigned phiIndex = bc.index("phi") ; <br> - * int phi = bc.get( field, phiIndex ) ; <br> - * - * @author F.Gaede, DESY - * @date 2017-09 - */ - class BitFieldCoder{ + /// Helper class for decoding and encoding a bit field of 64bits for convenient declaration + /** and manipulation of sub fields of various widths.<br> + * This is a thread safe re-implementation of the functionality in the deprected BitField64. + * + * Example:<br> + * BitFieldCoder bc("layer:7,system:-3,barrel:3,theta:32:11,phi:11" ) ; <br> + * bc.set( field, "layer" , 123 ); <br> + * bc.set( field, "system" , -4 ); <br> + * bc.set( field, "barrel" , 7 ); <br> + * bc.set( field, "theta" , 180 ); <br> + * bc.set( field, "phi" , 270 ); <br> + * ... <br> + * int theta = bc.get( field, "theta" ) ; <br> + * ... <br> + * unsigned phiIndex = bc.index("phi") ; <br> + * int phi = bc.get( field, phiIndex ) ; <br> + * + * @author F.Gaede, DESY + * @date 2017-09 + */ + class BitFieldCoder{ - public : + public : - typedef std::map<std::string, unsigned int> IndexMap ; - - /// Default constructor - BitFieldCoder() = default ; - /// Copy constructor - BitFieldCoder(const BitFieldCoder&) = default ; - /// Move constructor - BitFieldCoder(BitFieldCoder&&) = default ; - /// Default destructor - ~BitFieldCoder() = default ; - - /// Assignment operator - BitFieldCoder& operator=(const BitFieldCoder&) = default ; + typedef std::map<std::string, unsigned int> IndexMap ; + + /// Default constructor + BitFieldCoder() = default ; + /// Copy constructor + BitFieldCoder(const BitFieldCoder&) = default ; + /// Move constructor + BitFieldCoder(BitFieldCoder&&) = default ; + /// Default destructor + ~BitFieldCoder() = default ; + + /// Assignment operator + BitFieldCoder& operator=(const BitFieldCoder&) = default ; - /** 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" - */ - BitFieldCoder( const std::string& initString ) : _joined(0){ + /** 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" + */ + BitFieldCoder( const std::string& initString ) : _joined(0){ - init( initString ) ; - } + init( initString ) ; + } - /** return a new 64bit value given as high and low 32bit words. - */ - static long64 toLong(unsigned low_Word, unsigned high_Word ) { - return ( ( low_Word & 0xffffffffULL ) | ( ( high_Word & 0xffffffffULL ) << 32 ) ) ; - } + /** return a new 64bit value given as high and low 32bit words. + */ + static long64 toLong(unsigned low_Word, unsigned high_Word ) { + return ( ( low_Word & 0xffffffffULL ) | ( ( high_Word & 0xffffffffULL ) << 32 ) ) ; + } - /** The low word, bits 0-31 - */ - static unsigned lowWord(long64 bitfield) { return unsigned( bitfield & 0xffffFFFFUL ) ; } + /** The low word, bits 0-31 + */ + static unsigned lowWord(long64 bitfield) { return unsigned( bitfield & 0xffffFFFFUL ) ; } - /** The high word, bits 32-63 - */ - static unsigned highWord(long64 bitfield) { return unsigned( bitfield >> 32) ; } + /** The high word, bits 32-63 + */ + static unsigned highWord(long64 bitfield) { return unsigned( bitfield >> 32) ; } - /** get value of sub-field specified by index - */ - long64 get(long64 bitfield, size_t index) const { - return _fields.at(index).value( bitfield ) ; - } + /** get value of sub-field specified by index + */ + long64 get(long64 bitfield, size_t idx) const { + return _fields.at(idx).value( bitfield ) ; + } - /** Access to field through name . - */ - long64 get(long64 bitfield, const std::string& name) const { + /** Access to field through name . + */ + long64 get(long64 bitfield, const std::string& name) const { - return _fields.at( index( name ) ).value( bitfield ) ; - } + return _fields.at( index( name ) ).value( bitfield ) ; + } - /** set value of sub-field specified by index - */ - void set(long64& bitfield, size_t index, ulong64 value) const { - _fields.at(index).set( bitfield , value ) ; - } + /** set value of sub-field specified by index + */ + void set(long64& bitfield, size_t idx, ulong64 value) const { + _fields.at(idx).set( bitfield , value ) ; + } - /** Access to field through name . - */ - void set(long64& bitfield, const std::string& name, ulong64 value) const { + /** Access to field through name . + */ + void set(long64& bitfield, const std::string& name, ulong64 value) const { - _fields.at( index( name ) ).set( bitfield, value ) ; - } + _fields.at( index( name ) ).set( bitfield, value ) ; + } - /** Highest bit used in fields [0-63] - */ - unsigned highestBit() const ; + /** Highest bit used in fields [0-63] + */ + unsigned highestBit() const ; - /** Number of values */ - size_t size() const { return _fields.size() ; } + /** Number of values */ + size_t size() const { return _fields.size() ; } - /** Index for field named 'name' - */ - size_t index( const std::string& name) const ; + /** Index for field named 'name' + */ + size_t index( const std::string& name) const ; - /** Const Access to field through name . - */ - const BitFieldElement& operator[](const std::string& name) const { + /** Const Access to field through name . + */ + const BitFieldElement& operator[](const std::string& name) const { - return _fields[ index( name ) ] ; - } + return _fields[ index( name ) ] ; + } - /** Const Access to field through index . - */ - const BitFieldElement& operator[](unsigned index) const { + /** Const Access to field through index . + */ + const BitFieldElement& operator[](unsigned idx) const { - return _fields[ index ] ; - } + return _fields[ idx ] ; + } - /** Return a valid description string of all fields - */ - std::string fieldDescription() const ; + /** 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(ulong64 bitfield) const ; + /** Return a string with a comma separated list of the current sub field values + */ + std::string valueString(ulong64 bitfield) const ; - const std::vector<BitFieldElement>& fields() const { - return _fields; - } + const std::vector<BitFieldElement>& fields() const { + return _fields; + } - /** the mask of all the bits used in the description */ - ulong64 mask() const { return _joined ; } + /** the mask of all the bits used in the description */ + ulong64 mask() const { return _joined ; } - protected: + protected: - /** Add an additional field to the list - */ - void addField( const std::string& name, unsigned offset, int width ); + /** 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 BitFieldCoder( const std::string& initString ) - */ - void init( const std::string& initString) ; + /** Decode the initialization string as described in the constructor. + * @see BitFieldCoder( const std::string& initString ) + */ + void init( const std::string& initString) ; - public: + public: - protected: + protected: - // -------------- data members:-------------- + // -------------- data members:-------------- - std::vector<BitFieldElement> _fields{} ; - IndexMap _map{} ; - long64 _joined{} ; + std::vector<BitFieldElement> _fields{} ; + IndexMap _map{} ; + long64 _joined{} ; - }; + }; - /// Helper class for string tokenization. - /** Usage:<br> - * std::vector<std::string> tokens ; <br> - * StringTokenizer t( tokens ,',') ; <br> - * std::for_each( aString.begin(), aString.end(), t ) ; <br> - * - * @author F.Gaede, DESY - * @date 2013-06 - */ - class StringTokenizer{ + /// Helper class for string tokenization. + /** Usage:<br> + * std::vector<std::string> tokens ; <br> + * StringTokenizer t( tokens ,',') ; <br> + * std::for_each( aString.begin(), aString.end(), t ) ; <br> + * + * @author F.Gaede, DESY + * @date 2013-06 + */ + class StringTokenizer{ - std::vector< std::string >& _tokens ; - char _del ; - char _last ; + std::vector< std::string >& _tokens ; + char _del ; + char _last ; - public: + public: - /** Only c'tor, give (empty) token vector and delimeter character */ - StringTokenizer( std::vector< std::string >& tokens, char del ) - : _tokens(tokens) - , _del(del), - _last(del) { - } + /** Only c'tor, give (empty) token vector and delimeter character */ + StringTokenizer( 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) { + /** Operator for use with algorithms, e.g. for_each */ + void operator()(const char& c) { - if( c != _del ) { + if( c != _del ) { - if( _last == _del ) { - _tokens.emplace_back("") ; - } - _tokens.back() += c ; - } - _last = c ; - } + if( _last == _del ) { + _tokens.emplace_back("") ; + } + _tokens.back() += c ; + } + _last = c ; + } - }; + }; -} // end namespace + } // end namespace } // end namespace diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp index f4e09f2dd1c0a9b20b1061a54624684e783fc78a..e652c1bdc79cd4faac3a661d0a8f6b4e850f5bd2 100644 --- a/DDG4/src/Geant4Converter.cpp +++ b/DDG4/src/Geant4Converter.cpp @@ -688,7 +688,7 @@ void* Geant4Converter::handleSolid(const string& name, const TGeoShape* shape) c } else if (shape->IsA() == TGeoTrap::Class()) { const TGeoTrap* sh = (const TGeoTrap*) shape; - solid = new G4Trap(name, sh->GetDz() * CM_2_MM, sh->GetTheta(), sh->GetPhi(), + solid = new G4Trap(name, sh->GetDz() * CM_2_MM, sh->GetTheta() * DEGREE_2_RAD, sh->GetPhi() * DEGREE_2_RAD, sh->GetH1() * CM_2_MM, sh->GetBl1() * CM_2_MM, sh->GetTl1() * CM_2_MM, sh->GetAlpha1() * DEGREE_2_RAD, sh->GetH2() * CM_2_MM, sh->GetBl2() * CM_2_MM, sh->GetTl2() * CM_2_MM, sh->GetAlpha2() * DEGREE_2_RAD); } diff --git a/DDParsers/src/Evaluator/string.src b/DDParsers/src/Evaluator/string.src index 7e8cde0a05c2e2404c26155f93f108e4a1cf3603..a449089b94a1a44ede7f4fb0ad501a3ff1ad080b 100644 --- a/DDParsers/src/Evaluator/string.src +++ b/DDParsers/src/Evaluator/string.src @@ -97,7 +97,7 @@ inline string operator+(const char * a, const string & b) { int lenb = strlen(b.c_str()); string s; s.p->s = new char[lena+lenb+1]; - strncpy(s.p->s, a, lena); + strncpy(s.p->s, a, lena+1); strncpy(s.p->s+lena, b.c_str(), lenb+1); return s; } @@ -105,7 +105,7 @@ inline string operator+(const char * a, const string & b) { inline string operator+(const string & a, const char * b) { int lena = strlen(a.c_str()), lenb = strlen(b); string s; s.p->s = new char[lena+lenb+1]; - strncpy(s.p->s, a.c_str(),lena); + strncpy(s.p->s, a.c_str(),lena+1); strncpy(s.p->s+lena, b,lenb+1); return s; } @@ -114,7 +114,7 @@ inline string operator+(const string & a, const string & b) { int lena = strlen(a.c_str()); int lenb = strlen(b.c_str()); string s; s.p->s = new char[lena+lenb+1]; - strncpy(s.p->s, a.c_str(), lena); + strncpy(s.p->s, a.c_str(), lena+1); strncpy(s.p->s+lena, b.c_str(), lenb+1); return s; }