File indexing completed on 2025-01-18 09:55:25
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef DDREC_MATERIAL_H
0014 #define DDREC_MATERIAL_H
0015
0016 #include "DD4hep/Detector.h"
0017 #include "DDRec/IMaterial.h"
0018 #include "DD4hep/Objects.h"
0019
0020 #include <list>
0021
0022 namespace dd4hep {
0023 namespace rec {
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 class MaterialData : public IMaterial{
0034
0035 protected:
0036 std::string _name ;
0037 double _Z ;
0038 double _A ;
0039 double _rho ;
0040 double _x0 ;
0041 double _lambda ;
0042
0043 public:
0044
0045
0046 MaterialData( Material m ) :
0047
0048 _name("unknown"),
0049 _Z( -1. ),
0050 _A( 0. ),
0051 _rho( 0. ),
0052 _x0( 0. ),
0053 _lambda( 0.) {
0054
0055 if( m.isValid() ) {
0056
0057 _name= m.name() ;
0058 _Z = m.Z() ;
0059 _A = m.A() ;
0060 _rho = m.density() ;
0061 _x0 = m.radLength() ;
0062 _lambda = m.intLength() ;
0063
0064 }
0065 }
0066
0067
0068 MaterialData() : _name("unknown"),
0069 _Z( -1. ),
0070 _A( 0. ),
0071 _rho( 0. ),
0072 _x0( 0. ),
0073 _lambda( 0.) {}
0074
0075
0076 MaterialData( const std::string& nam, double Z_val, double A_val, double density_val, double radLength, double intLength )
0077 : _name( nam ),
0078 _Z( Z_val ),
0079 _A( A_val ),
0080 _rho( density_val ),
0081 _x0( radLength ),
0082 _lambda( intLength ) {}
0083
0084
0085 MaterialData( const MaterialData& m ) : _name( m.name() ),
0086 _Z( m.Z() ),
0087 _A( m.A() ),
0088 _rho( m.density() ),
0089 _x0( m.radiationLength() ),
0090 _lambda( m.interactionLength() ) {}
0091
0092
0093 MaterialData( const IMaterial& m ) : _name( m.name() ),
0094 _Z( m.Z() ),
0095 _A( m.A() ),
0096 _rho( m.density() ),
0097 _x0( m.radiationLength() ),
0098 _lambda( m.interactionLength() ) {}
0099
0100
0101 MaterialData& operator=(const MaterialData& m){
0102 if ( this != &m ) {
0103 _name = m._name ;
0104 _Z = m._Z ;
0105 _A = m._A ;
0106 _rho = m._rho ;
0107 _x0 = m._x0 ;
0108 _lambda = m._lambda ;
0109 }
0110 return *this ;
0111 }
0112
0113
0114 MaterialData& operator=(const IMaterial& m){
0115 if ( this != &m ) {
0116 _name = m.name() ;
0117 _Z = m.Z() ;
0118 _A = m.A() ;
0119 _rho = m.density() ;
0120 _x0 = m.radiationLength() ;
0121 _lambda = m.interactionLength() ;
0122 }
0123 return *this ;
0124 }
0125
0126
0127 MaterialData& operator=(const Material& m){
0128
0129 if( m.isValid() ) {
0130
0131 _name = m.name() ;
0132 _Z = m.Z() ;
0133 _A = m.A() ;
0134 _rho = m.density() ;
0135 _x0 = m.radLength() ;
0136 _lambda = m.intLength() ;
0137
0138 } else {
0139
0140 _name= "unknown";
0141 _Z = -1. ;
0142 _A = 0. ;
0143 _rho = 0. ;
0144 _x0 = 0. ;
0145 _lambda = 0. ;
0146 }
0147
0148 return *this ;
0149 }
0150
0151
0152 bool isValid() const { return ( _Z > 0. ) ; }
0153
0154
0155 virtual ~MaterialData() {}
0156
0157
0158 virtual std::string name() const { return _name ; }
0159
0160
0161 virtual double Z() const { return _Z ; }
0162
0163
0164 virtual double A() const { return _A ; }
0165
0166
0167 virtual double density() const { return _rho ; }
0168
0169
0170 virtual double radiationLength() const { return _x0 ; }
0171
0172
0173 virtual double interactionLength() const { return _lambda ; }
0174
0175 };
0176
0177
0178 }
0179 }
0180
0181
0182
0183 #endif