diff --git a/DDRec/include/DDRec/Material.h b/DDRec/include/DDRec/Material.h new file mode 100644 index 0000000000000000000000000000000000000000..01215ad0d43b4112b7d2e887acbb1fc7390cbacd --- /dev/null +++ b/DDRec/include/DDRec/Material.h @@ -0,0 +1,99 @@ +#ifndef DDRec_Material_H +#define DDRec_Material_H + +#include "DD4hep/Objects.h" +#include "DDSurfaces/IMaterial.h" + +#include <list> + +namespace DD4hep { + namespace DDRec { + + + /** Simple data class that implements the DDSurfaces::IMaterial interface. + * + * @author F.Gaede, DESY + * @date May, 20 2014 + * @version $Id$ + */ + class MaterialData : public DDSurfaces::IMaterial{ + + protected: + std::string _name ; + double _Z ; + double _A ; + double _rho ; + double _x0 ; + double _lambda ; + + public: + + /** Instantiate from Geometry::Material handle */ + MaterialData( Geometry::Material m ) { + // handle data can only be accessed if the handle is valid + if( m.isValid() ) { + _name= m.name() ; + _Z= m.Z() ; + _A= m.A() ; + _rho= m.density() ; + _x0= m.radLength() ; + _lambda= m.intLength() ; + } + } + + /** Default c'tor .*/ + MaterialData() : _name("unknown"), + _Z( -1. ), + _A( 0. ), + _rho( 0. ), + _x0( 0. ), + _lambda( 0.) {} + + /** C'tor setting all attributes .*/ + MaterialData( const std::string& name, double Z, double A, double density, double radLength, double intLength ) : _name( name ), + _Z( Z ), + _A( A ), + _rho( density ), + _x0( radLength ), + _lambda( intLength ) {} + + /** Copy c'tor .*/ + MaterialData( const MaterialData& m ) : _name( m.name() ), + _Z( m.Z() ), + _A( m.A() ), + _rho( m.density() ), + _x0( m.radiationLength() ), + _lambda( m.interactionLength() ) {} + + + /// true if initialized + bool isValid() const { return true ; } //( _Z > 0. ) ; } + + /** D'tor.*/ + virtual ~MaterialData() {} + + /// material name + virtual std::string name() const { return _name ; } + + /// averaged proton number + virtual double Z() const { return _Z ; } + + /// averaged atomic number + virtual double A() const { return _A ; } + + /// density + virtual double density() const { return _rho ; } + + /// radiation length - tgeo units + virtual double radiationLength() const { return _x0 ; } + + /// interaction length - tgeo units + virtual double interactionLength() const { return _lambda ; } + + }; + + + } /* namespace */ +} /* namespace */ + +#endif /* DDRec_Material_H */ diff --git a/DDRec/include/DDRec/MaterialManager.h b/DDRec/include/DDRec/MaterialManager.h index 5626dd2d182071f73359fa127357ea8932b0d808..a115997dff6c4bcd3bad8a88bdd6780ff301d8ba 100644 --- a/DDRec/include/DDRec/MaterialManager.h +++ b/DDRec/include/DDRec/MaterialManager.h @@ -3,6 +3,7 @@ #include "DD4hep/Objects.h" #include "DDSurfaces/Vector3D.h" +#include "DDRec/Material.h" #include <vector> @@ -41,6 +42,9 @@ namespace DD4hep { */ const Material& material(const DDSurfaces::Vector3D& pos ); + + void createAveragedMaterial( const MaterialVec& materials, MaterialData& mData ) ; + protected : //cached materials diff --git a/DDRec/include/DDRec/Surface.h b/DDRec/include/DDRec/Surface.h index 7db071762bca5f1f1a305e33870b9e3464570d9d..c105ef82ce632866055d148feefd1057e6ef27d0 100644 --- a/DDRec/include/DDRec/Surface.h +++ b/DDRec/include/DDRec/Surface.h @@ -6,6 +6,7 @@ #include "DD4hep/Detector.h" #include "DDSurfaces/ISurface.h" +#include "DDRec/Material.h" #include <list> @@ -16,44 +17,47 @@ namespace DD4hep { using namespace DDSurfaces ; +#if 1 + typedef MaterialData SurfaceMaterial ; - // typedef DDRec::Material SurfaceMaterial ; - +#else /** Wrapper class to Geometry::Material that implements the DDSurfaces::IMaterial interface. - * - * @author F.Gaede, DESY - * @date Apr, 6 2014 - * @version $Id$ - */ - struct SurfaceMaterial : public virtual Geometry::Material , public IMaterial{ - - /** Copy c'tor - copies handle */ - SurfaceMaterial( Geometry::Material m ) : Geometry::Material( m ) {} - - SurfaceMaterial( const SurfaceMaterial& sm ) : Geometry::Material( sm ) {} - - virtual ~SurfaceMaterial() {} - - /// material name - virtual std::string name() const { return Geometry::Material::name() ; } - - /// averaged proton number - virtual double Z() const { return Geometry::Material::Z() ; } - - /// averaged atomic number - virtual double A() const { return Geometry::Material::A() ; } - - /// density - units ? - virtual double density() const { return Geometry::Material::density() ; } - - /// radiation length - tgeo units - virtual double radiationLength() const { return Geometry::Material::radLength() ; } - - /// interaction length - tgeo units - virtual double interactionLength() const { return Geometry::Material::intLength() ; } - - }; + * + * @author F.Gaede, DESY + * @date Apr, 6 2014 + * @version $Id$ + */ + struct SurfaceMaterial : public virtual Geometry::Material , public IMaterial{ + + /** Copy c'tor - copies handle */ + SurfaceMaterial( Geometry::Material m ) : Geometry::Material( m ) {} + + SurfaceMaterial( const SurfaceMaterial& sm ) : Geometry::Material( sm ) {} + + virtual ~SurfaceMaterial() {} + + /// material name + virtual std::string name() const { return Geometry::Material::name() ; } + + /// averaged proton number + virtual double Z() const { return Geometry::Material::Z() ; } + + /// averaged atomic number + virtual double A() const { return Geometry::Material::A() ; } + + /// density - units ? + virtual double density() const { return Geometry::Material::density() ; } + + /// radiation length - tgeo units + virtual double radiationLength() const { return Geometry::Material::radLength() ; } + + /// interaction length - tgeo units + virtual double interactionLength() const { return Geometry::Material::intLength() ; } + + }; +#endif + /** Helper class for holding surface data. * @author F.Gaede, DESY * @date Apr, 6 2014 diff --git a/DDRec/src/Surface.cpp b/DDRec/src/Surface.cpp index 2c72979f2316a82a97af89228b740bbd97d4846d..facff75633e6b4825a309718b2f2b90eb49d85e4 100644 --- a/DDRec/src/Surface.cpp +++ b/DDRec/src/Surface.cpp @@ -231,16 +231,17 @@ namespace DD4hep { const MaterialVec& materials = matMgr.materials( _o , p ) ; - // std::cout << " ####### found materials between points : " << _o << " and " << p << " : " ; - // for( unsigned i=0,n=materials.size();i<n;++i){ - // std::cout << materials[i].first.name() << "[" << materials[i].second << "], " ; - // } - // std::cout << std::endl ; - //std::cout << " #### material at origin : " << matMgr.material( _o ).name() << " material at endpoint : " << matMgr.material( p ).name() << std::endl ; + std::cout << " ####### found materials between points : " << _o << " and " << p << " : " ; + for( unsigned i=0,n=materials.size();i<n;++i){ + std::cout << materials[i].first.name() << "[" << materials[i].second << "], " ; + } + std::cout << std::endl ; + std::cout << " #### material at origin : " << matMgr.material( _o ).name() << " material at endpoint : " << matMgr.material( p ).name() << std::endl ; + mat = _volSurf.volume().material() ; - // std::cout << " **** Surface::innerMaterial() - assigning volume material to surface : " << mat.name() << std::endl ; + std::cout << " **** Surface::innerMaterial() - assigning volume material to surface : " << mat.name() << std::endl ; } return _volSurf.innerMaterial() ; } diff --git a/examples/ILDExDet/src/ILDExVXD_geo.cpp b/examples/ILDExDet/src/ILDExVXD_geo.cpp index 66ad3a608cbb3b5acaa13edb3671ee963a404ab5..1c49a227024f43014439b41901bbc9d1a05974ba 100644 --- a/examples/ILDExDet/src/ILDExVXD_geo.cpp +++ b/examples/ILDExDet/src/ILDExVXD_geo.cpp @@ -65,7 +65,7 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) { /// ======== test layer assembly -> results in assembly in assembly and -#define use_layer_assembly 1 // crashes ild_exsimu +#define use_layer_assembly 0 // crashes ild_exsimu #if use_layer_assembly // --- create an assembly and DetElement for the layer @@ -129,7 +129,7 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) { Vector3D v( 0. , 0. , 1. ) ; Vector3D n( 1. , 0. , 0. ) ; // Vector3D o( 0. , 0. , 0. ) ; - VolPlane surf( sensvol , SurfaceType(SurfaceType::Sensitive) , sens_thick/2 + supp_thick/2 , sens_thick/2 , u,v,n ) ; //,o ) ; + VolPlane surf( sensvol , SurfaceType(SurfaceType::Sensitive) , sens_thick/2 + supp_thick , sens_thick/2 , u,v,n ) ; //,o ) ; Material suppmat = lcdd.material(x_support.materialStr()); Box suppbox (supp_thick/2.,width/2.,zhalf); @@ -262,6 +262,9 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) { //----------------- gear --------------------------------------------- + layer_assembly->GetShape()->ComputeBBox() ; + + } Volume mother = lcdd.pickMotherVolume(vxd) ; @@ -270,6 +273,12 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) { pv.addPhysVolID( "system", x_det.id() ).addPhysVolID("side",0 ) ; vxd.setPlacement(pv); + + assembly->GetShape()->ComputeBBox() ; + // TGeoBBox* bbox = assembly->GetShape()->GetBBox() ; + + + return vxd; } diff --git a/examples/ILDExSimu/src/test_surfaces.cc b/examples/ILDExSimu/src/test_surfaces.cc index c98e6da1716bb1ea77ff837e810651688dbaaffa..8ebd76d139c96e3993131066c046c6639b6c3b08 100644 --- a/examples/ILDExSimu/src/test_surfaces.cc +++ b/examples/ILDExSimu/src/test_surfaces.cc @@ -118,7 +118,7 @@ int main(int argc, char** argv ){ if( surf != 0 ){ - // std::cout << " found surface " << *surf << std::endl ; + std::cout << " found surface " << *surf << std::endl ; Vector3D point( sHit->getPosition()[0]* tgeo::mm , sHit->getPosition()[1]* tgeo::mm , sHit->getPosition()[2]* tgeo::mm ) ;