diff --git a/DDRec/include/DDRec/DDGear.h b/DDRec/include/DDRec/DDGear.h index c84aabfe2533d2668232ed1ad9412ab93973c6fd..124dc9e776d5471f53ab7d00c35147912b24d63b 100644 --- a/DDRec/include/DDRec/DDGear.h +++ b/DDRec/include/DDRec/DDGear.h @@ -3,9 +3,10 @@ #include "DD4hep/Detector.h" -// #include "gear/GEAR.h" -// #include "gearimpl/GearParametersImpl.h" -// #include "gear/GearMgr.h" +#include "gear/GEAR.h" +#include "gearimpl/GearParametersImpl.h" +#include "gearimpl/SimpleMaterialImpl.h" +#include "gear/GearMgr.h" namespace gear{ class GearParametersImpl ; @@ -27,6 +28,7 @@ namespace DD4hep { protected: gear::GearParametersImpl* _gObj ; std::string _name ; + std::vector< gear::SimpleMaterialImpl > _materials ; public : /** Default c'tor - only used by DD4hep extenbsion mechanism.*/ @@ -55,6 +57,17 @@ namespace DD4hep { return obj ; } + + /// add a SimpleMaterial object + void addMaterial(const std::string name, double A, double Z, double density, double radLen, double intLen){ + + _materials.push_back( gear::SimpleMaterialImpl (name, A, Z, density, radLen, intLen) ) ; + } + + /// get all materials assigned to this wrapper + const std::vector< gear::SimpleMaterialImpl >& materials() { return _materials ; } + + /** dummy implementation of required c'tors to allow using the extension mechanism */ GearHandle(const Geometry::DetElement& d) : _gObj(0) {} GearHandle(const GearHandle& c,const Geometry::DetElement& det) : _gObj(0) {} diff --git a/DDRec/src/gear/DDGear.cpp b/DDRec/src/gear/DDGear.cpp index dbdeee2b8a23b3c374e82ff517bb870b6d3f68a3..69e2b1fdb2393f52f8089b3f54944920444a6612 100644 --- a/DDRec/src/gear/DDGear.cpp +++ b/DDRec/src/gear/DDGear.cpp @@ -109,6 +109,15 @@ namespace DD4hep{ gearMgr->setGearParameters( gearH->name() , gearH->takeGearObject() ) ; } + + /// register any materials assigned to the handle: + + for( unsigned j=0, M=gearH->materials().size() ; j<M ; ++j) { + + gearMgr->registerSimpleMaterial( &gearH->materials()[j] ) ; + } + + } std::cout << std::endl ; diff --git a/DDRec/src/gear/createGearForILD.cpp b/DDRec/src/gear/createGearForILD.cpp index 13c6c1507f26f4f8eeb90dd854bd063afeb22130..04450ddb4601ed9455a9f910ca6df1a74762636d 100644 --- a/DDRec/src/gear/createGearForILD.cpp +++ b/DDRec/src/gear/createGearForILD.cpp @@ -4,6 +4,9 @@ #include "DDRec/DetectorData.h" #include "DDRec/DDGear.h" +#include "DDRec/MaterialManager.h" +#include "DDSurfaces/Vector3D.h" + #include "gearimpl/TPCParametersImpl.h" #include "gearimpl/FixedPadSizeDiskLayout.h" @@ -17,6 +20,7 @@ namespace DD4hep{ using namespace Geometry ; // using namespace gear ; + using DDSurfaces::Vector3D ; /** Plugin that creates Gear objects for DetElements and attaches them * as extensions. Called from DDGear::createGearMgr(). @@ -68,12 +72,39 @@ namespace DD4hep{ // FIXME set rad lengths to 0 -> need to get from DD4hep .... gearVXD->addLayer( l.ladderNumber, l.phi0, - l.distanceSupport/dd4hep::mm, l.offsetSupport/dd4hep::mm, l. thicknessSupport/dd4hep::mm, l.zHalfSupport/dd4hep::mm, l.widthSupport/dd4hep::mm, 0. , - l.distanceSensitive/dd4hep::mm, l.offsetSensitive/dd4hep::mm, l. thicknessSensitive/dd4hep::mm, l.zHalfSensitive/dd4hep::mm, l.widthSensitive/dd4hep::mm, 0. ) ; + l.distanceSupport/dd4hep::mm, l.offsetSupport/dd4hep::mm, l.thicknessSupport/dd4hep::mm, l.zHalfSupport/dd4hep::mm, l.widthSupport/dd4hep::mm, 0. , + l.distanceSensitive/dd4hep::mm, l.offsetSensitive/dd4hep::mm, l.thicknessSensitive/dd4hep::mm, l.zHalfSensitive/dd4hep::mm, l.widthSensitive/dd4hep::mm, 0. ) ; } - vxdDE.addExtension< GearHandle >( new GearHandle( gearVXD, "VXDParameters" ) ) ; + GearHandle* handle = new GearHandle( gearVXD, "VXDParameters" ) ; + + // quick hack for now: add the one material that is needed by KalDet : + // handle->addMaterial( "VXDSupportMaterial", 2.075865162e+01, 1.039383117e+01, 2.765900000e+02, 1.014262421e+03, 3.341388059e+03) ; + + // -------- better: get right averaged material from first ladder: ------------------ + MaterialManager matMgr ; + + const DDRec::ZPlanarData::LayerLayout& l = vxd->layers[0] ; + + Vector3D a( l.distanceSupport , l.phi0 , 0. , Vector3D::cylindrical ) ; + Vector3D b( l.distanceSupport + l.thicknessSupport , l.phi0 , 0. , Vector3D::cylindrical ) ; + + const MaterialVec& materials = matMgr.materialsBetween( a , b ) ; + + MaterialData mat = ( materials.size() > 1 ? matMgr.createAveragedMaterial( materials ) : materials[0].first ) ; + + // std::cout << " ####### found materials between points : " << a << " and " << b << " : " ; + // 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 << " averaged material : " << mat << std::endl ; + + handle->addMaterial( "VXDSupportMaterial", mat.A(), mat.Z() , mat.density()/(dd4hep::kg/(dd4hep::g*dd4hep::m3)) , mat.radiationLength()/dd4hep::mm , mat.interactionLength()/dd4hep::mm ) ; + + + vxdDE.addExtension< GearHandle >( handle ) ; //========= SIT ============================================================================== diff --git a/DDSurfaces/include/DDSurfaces/IMaterial.h b/DDSurfaces/include/DDSurfaces/IMaterial.h index c946008736b5af9d119edb62c2cd6f5b38f33df0..ade46aba515f5d0908b00e24c694b3f67e3827a0 100644 --- a/DDSurfaces/include/DDSurfaces/IMaterial.h +++ b/DDSurfaces/include/DDSurfaces/IMaterial.h @@ -23,11 +23,11 @@ namespace DDSurfaces { /// material name virtual std::string name() const =0 ; - /// averaged proton number - virtual double Z() const =0 ; - /// averaged atomic number virtual double A() const =0 ; + + /// averaged proton number + virtual double Z() const =0 ; /// density - units ? virtual double density() const =0 ; @@ -43,7 +43,7 @@ namespace DDSurfaces { /// dump IMaterial operator inline std::ostream& operator<<( std::ostream& os , const IMaterial& m ) { - os << " " << m.name() << ", Z: " << m.Z() << ", A: " << m.A() << ", densitiy: " << m.density() << ", radiationLength: " << m.radiationLength() + os << " " << m.name() << ", A: " << m.A() << ", Z: " << m.Z() << ", density: " << m.density() << ", radiationLength: " << m.radiationLength() << ", interactionLength: " << m.interactionLength() ; return os ;