diff --git a/DDRec/include/DDRec/Surface.h b/DDRec/include/DDRec/Surface.h index 0d6a30cd202208912b07039ffffadf7689a1e372..e4d366b001d58f544b30fa25b13f80a2d406a8cc 100644 --- a/DDRec/include/DDRec/Surface.h +++ b/DDRec/include/DDRec/Surface.h @@ -185,12 +185,19 @@ namespace DD4hep { struct VolSurfaceList : std::list< VolSurface > { VolSurfaceList() {} + // required c'tors for extension mechanism - VolSurfaceList(const Geometry::DetElement& ){ - // anything to do here ? + VolSurfaceList(Geometry::DetElement& det){ + // det.addExtension<VolSurfaceList>( this ) ; } - VolSurfaceList(const VolSurfaceList& ,const Geometry::DetElement& ){ - // anything to do here ? + + VolSurfaceList(const VolSurfaceList& vsl, Geometry::DetElement& det ){ + + //fixme: this causes a seg fault ... + + // VolSurfaceList* nL = new VolSurfaceList ; + // nL->insert( nL->end() , vsl.begin() , vsl.end() ) ; + // det.addExtension<VolSurfaceList>( nL ) ; } virtual ~VolSurfaceList(){ diff --git a/DDRec/src/DetectorSurfaces.cpp b/DDRec/src/DetectorSurfaces.cpp index 97596e6de6cd589d1d9abec54badaee978f19cfe..cc41ba346c24a620632006e2a3cfa3e5f749fff9 100644 --- a/DDRec/src/DetectorSurfaces.cpp +++ b/DDRec/src/DetectorSurfaces.cpp @@ -45,9 +45,9 @@ namespace DD4hep { Surface* surf = new Surface( det, volSurf ) ; - // std::cout << " ------------------------- " - // << " surface: " << *surf << std::endl - // << " ------------------------- " << std::endl ; + // std::cout << " ------------------------- " + // << " surface: " << *surf << std::endl + // << " ------------------------- " << std::endl ; _sL->push_back( surf ) ; diff --git a/DDRec/src/Surface.cpp b/DDRec/src/Surface.cpp index 777f24ed51e2b09fe22729b6866819fb82e700e2..4466e75d43cb532ca6b0810d2dd87f656e8e9840 100644 --- a/DDRec/src/Surface.cpp +++ b/DDRec/src/Surface.cpp @@ -287,10 +287,10 @@ namespace DD4hep { //=========== compute and cache world transform for surface ========== - const TGeoMatrix* wm = &_det.worldTransformation() ; + const TGeoHMatrix& wm = _det.worldTransformation() ; #if 0 // debug - wm->Print() ; + wm.Print() ; for( std::list<PlacedVolume>::iterator it= pVList.begin(), n = pVList.end() ; it != n ; ++it ){ PlacedVolume pv = *it ; TGeoMatrix* m = pv->GetMatrix(); @@ -300,7 +300,7 @@ namespace DD4hep { #endif // need to get the inverse transformation ( see Detector.cpp ) - std::auto_ptr<TGeoHMatrix> wtI( new TGeoHMatrix( wm->Inverse() ) ) ; + std::auto_ptr<TGeoHMatrix> wtI( new TGeoHMatrix( wm.Inverse() ) ) ; //---- if the volSurface is not in the DetElement's volume, we need to mutliply the path to the volume to the // DetElements world transform @@ -384,7 +384,7 @@ namespace DD4hep { const static double epsilon = 1e-6 ; - std::vector< std::pair<Vector3D, Vector3D> > _vert ; + std::vector< std::pair<Vector3D, Vector3D> > lines ; // get local and global surface vectors @@ -440,17 +440,89 @@ namespace DD4hep { _wtM->LocalToMasterVect( ubl , ub.array() ) ; _wtM->LocalToMasterVect( vbl , vb.array() ) ; - _vert.reserve(4) ; + lines.reserve(4) ; - _vert.push_back( std::make_pair( _o + boxDim[ uidx ] * ub + boxDim[ vidx ] * vb , _o - boxDim[ uidx ] * ub + boxDim[ vidx ] * vb ) ) ; - _vert.push_back( std::make_pair( _o - boxDim[ uidx ] * ub + boxDim[ vidx ] * vb , _o - boxDim[ uidx ] * ub - boxDim[ vidx ] * vb ) ) ; - _vert.push_back( std::make_pair( _o - boxDim[ uidx ] * ub - boxDim[ vidx ] * vb , _o + boxDim[ uidx ] * ub - boxDim[ vidx ] * vb ) ) ; - _vert.push_back( std::make_pair( _o + boxDim[ uidx ] * ub - boxDim[ vidx ] * vb , _o + boxDim[ uidx ] * ub + boxDim[ vidx ] * vb ) ) ; + lines.push_back( std::make_pair( _o + boxDim[ uidx ] * ub + boxDim[ vidx ] * vb , _o - boxDim[ uidx ] * ub + boxDim[ vidx ] * vb ) ) ; + lines.push_back( std::make_pair( _o - boxDim[ uidx ] * ub + boxDim[ vidx ] * vb , _o - boxDim[ uidx ] * ub - boxDim[ vidx ] * vb ) ) ; + lines.push_back( std::make_pair( _o - boxDim[ uidx ] * ub - boxDim[ vidx ] * vb , _o + boxDim[ uidx ] * ub - boxDim[ vidx ] * vb ) ) ; + lines.push_back( std::make_pair( _o + boxDim[ uidx ] * ub - boxDim[ vidx ] * vb , _o + boxDim[ uidx ] * ub + boxDim[ vidx ] * vb ) ) ; - return _vert ; + return lines ; } + + } else if( shape->IsA() == TGeoConeSeg::Class() ) { + + TGeoCone* cone = ( TGeoCone* ) shape ; + + // can only deal with special case of z-disk and origin in center of cone + if( type().isZDisk() && lo.rho() < epsilon ) { + + double zhalf = cone->GetDZ() ; + double rmax1 = cone->GetRmax1() ; + double rmax2 = cone->GetRmax2() ; + double rmin1 = cone->GetRmin1() ; + double rmin2 = cone->GetRmin2() ; + + // two circles around origin + // get radii at position of plane + double r0 = rmin1 + ( rmin2 - rmin1 ) / ( 2. * zhalf ) * ( zhalf + lo.z() ) ; + double r1 = rmax1 + ( rmax2 - rmax1 ) / ( 2. * zhalf ) * ( zhalf + lo.z() ) ; + + + unsigned n = nMax / 4 ; + double dPhi = 2.* ROOT::Math::Pi() / double( n ) ; + + for( unsigned i = 0 ; i < n ; ++i ) { + + Vector3D rv00( r0*sin( i *dPhi ) , r0*cos( i *dPhi ) , 0. ) ; + Vector3D rv01( r0*sin( (i+1)*dPhi ) , r0*cos( (i+1)*dPhi ) , 0. ) ; + + Vector3D rv10( r1*sin( i *dPhi ) , r1*cos( i *dPhi ) , 0. ) ; + Vector3D rv11( r1*sin( (i+1)*dPhi ) , r1*cos( (i+1)*dPhi ) , 0. ) ; + + + Vector3D pl0 = lo + rv00 ; + Vector3D pl1 = lo + rv01 ; + + Vector3D pl2 = lo + rv10 ; + Vector3D pl3 = lo + rv11 ; + + + Vector3D pg0,pg1,pg2,pg3 ; + + _wtM->LocalToMaster( pl0, pg0.array() ) ; + _wtM->LocalToMaster( pl1, pg1.array() ) ; + _wtM->LocalToMaster( pl2, pg2.array() ) ; + _wtM->LocalToMaster( pl3, pg3.array() ) ; + + lines.push_back( std::make_pair( pg0, pg1 ) ) ; + lines.push_back( std::make_pair( pg2, pg3 ) ) ; + } + + //add some vertical and horizontal lines so that the disc is seen in the rho-z projection + + n = 4 ; dPhi = 2.* ROOT::Math::Pi() / double( n ) ; + + for( unsigned i = 0 ; i < n ; ++i ) { + + Vector3D rv0( r0*sin( i * dPhi ) , r0*cos( i * dPhi ) , 0. ) ; + Vector3D rv1( r1*sin( i * dPhi ) , r1*cos( i * dPhi ) , 0. ) ; + + Vector3D pl0 = lo + rv0 ; + Vector3D pl1 = lo + rv1 ; + + Vector3D pg0,pg1 ; + + _wtM->LocalToMaster( pl0, pg0.array() ) ; + _wtM->LocalToMaster( pl1, pg1.array() ) ; + + lines.push_back( std::make_pair( pg0, pg1 ) ) ; + } + + } + + return lines ; } - // ===== default for arbitrary planes in arbitrary shapes ================= // We create nMax vertices by rotating the local u vector around the normal @@ -460,7 +532,7 @@ namespace DD4hep { // The alterative would be to compute the true intersections a plane and the most // common shapes - at least for boxes that should be not too hard. To be done... - _vert.reserve( nMax ) ; + lines.reserve( nMax ) ; double dAlpha = 2.* ROOT::Math::Pi() / double( nMax ) ; @@ -492,16 +564,22 @@ namespace DD4hep { _wtM->LocalToMaster( lp , gp.array() ) ; - // std::cout << " **** normal:" << ln << " lu:" << lu << " alpha:" << alpha << " luRot:" << luRot << " lp :" << lp << " gp:" << gp << std::endl; + // std::cout << " **** normal:" << ln << " lu:" << lu << " alpha:" << alpha << " luRot:" << luRot << " lp :" << lp << " gp:" << gp << " dist : " << dist + // << " is point " << gp << " inside : " << shape->Contains( gp ) + // << " dist from outside for lo,lu " << shape->DistFromOutside( lo , lu , 3 ) + // << " dist from inside for lo,ln " << shape->DistFromInside( lo , ln , 3 ) + // << std::endl; + // shape->Dump() ; + if( i > 0 ) - _vert.push_back( std::make_pair( previous, gp ) ) ; + lines.push_back( std::make_pair( previous, gp ) ) ; else first = gp ; previous = gp ; } - _vert.push_back( std::make_pair( previous, first ) ) ; + lines.push_back( std::make_pair( previous, first ) ) ; } else if( type().isCylinder() ) { @@ -509,7 +587,7 @@ namespace DD4hep { // if( shape->IsA() == TGeoTube::Class() ) { if( shape->IsA() == TGeoConeSeg::Class() ) { - _vert.reserve( nMax ) ; + lines.reserve( nMax ) ; TGeoTube* tube = ( TGeoTube* ) shape ; @@ -543,42 +621,14 @@ namespace DD4hep { _wtM->LocalToMaster( pl2, pg2.array() ) ; _wtM->LocalToMaster( pl3, pg3.array() ) ; - _vert.push_back( std::make_pair( pg0, pg1 ) ) ; - _vert.push_back( std::make_pair( pg1, pg2 ) ) ; - _vert.push_back( std::make_pair( pg2, pg3 ) ) ; - _vert.push_back( std::make_pair( pg3, pg0 ) ) ; + lines.push_back( std::make_pair( pg0, pg1 ) ) ; + lines.push_back( std::make_pair( pg1, pg2 ) ) ; + lines.push_back( std::make_pair( pg2, pg3 ) ) ; + lines.push_back( std::make_pair( pg3, pg0 ) ) ; } - - // unsigned n = nMax / 4 ; - // double dPhi = 2.* ROOT::Math::Pi() / double( n ) ; - - // for( unsigned i = 0 ; i < n ; ++i ) { - - // Vector3D rv0( r*sin( i *dPhi ) , r*cos( i *dPhi ) , 0. ) ; - // Vector3D rv1( r*sin( (i+1)*dPhi ) , r*cos( (i+1)*dPhi ) , 0. ) ; - - // // 4 points on local cylinder - - // Vector3D pl0 = zv + rv0 ; - // Vector3D pl1 = zv + rv1 ; - // Vector3D pl2 = -zv + rv1 ; - // Vector3D pl3 = -zv + rv0 ; - - // Vector3D pg0,pg1,pg2,pg3 ; - - // _wtM->LocalToMaster( pl0, pg0.array() ) ; - // _wtM->LocalToMaster( pl1, pg1.array() ) ; - // _wtM->LocalToMaster( pl2, pg2.array() ) ; - // _wtM->LocalToMaster( pl3, pg3.array() ) ; - - // _vert.push_back( std::make_pair( pg0, pg1 ) ) ; - // _vert.push_back( std::make_pair( pg1, pg2 ) ) ; - // _vert.push_back( std::make_pair( pg2, pg3 ) ) ; - // _vert.push_back( std::make_pair( pg3, pg0 ) ) ; - // } } } - return _vert ; + return lines ; } diff --git a/DDSurfaces/include/DDSurfaces/ISurface.h b/DDSurfaces/include/DDSurfaces/ISurface.h index 779e301c568cc3e504e26c0a835265f61169a122..dc26061d1a1c19e619b15d5d4e1cefd81d77e7f8 100644 --- a/DDSurfaces/include/DDSurfaces/ISurface.h +++ b/DDSurfaces/include/DDSurfaces/ISurface.h @@ -191,7 +191,7 @@ namespace DDSurfaces { os << "sensitive[" << t.isSensitive() << "] helper[" << t.isHelper() << "] plane[" << t.isPlane() << "] cylinder[" << t.isCylinder() << "] parallelToZ[" << t.isParallelToZ() << "] orthogonalToZ[" << t. isOrthogonalToZ() << "] zCylinder[" << t.isZCylinder() - << "] zPlane[" << t.isZPlane() << "]" ; + << "] zPlane[" << t.isZPlane() << "] zDisk[" << t.isZDisk() << "]" ; return os ; } @@ -203,8 +203,8 @@ namespace DDSurfaces { os << " id: " << std::hex << s.id() << std::dec << " type : " << s.type() << std::endl << " u : " << s.u() << " v : " << s.v() << " normal : " << s.normal() << " origin : " << s.origin() << std::endl ; - os << " inner material : " << s.innerMaterial() << std::endl - << " outerMaterial : " << s.outerMaterial() << std::endl ; + os << " inner material : " << s.innerMaterial() << " thickness: " << s.innerThickness() << std::endl + << " outerMaterial : " << s.outerMaterial() << " thickness: " << s.outerThickness() << std::endl ; return os ; } diff --git a/ReadMe.txt b/ReadMe.txt index 1ce3b85c996368e9f22b5cdc983462a7c197ae0d..d8d3ab30791a7252421fed1fbaed04ff98b806bb 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -98,9 +98,11 @@ To build and run the simulation examples Geant4 will be required. * use pyroot to write python geometry drivers ( currently broken !?) -DDD4HEP_USE_PYROOT=ON - - example for building a 'complete' DD4hep: + - examples for building a 'complete' DD4hep: cmake -D DD4HEP_WITH_GEANT4=1 -DDD4HEP_USE_BOOST=ON -DDD4HEP_USE_LCIO=ON -DBOOST_ROOT=/data/ilcsoft/boost/1.55.0 -DBUILD_TESTING=On .. (if geant4 was built with external CLHEP, add: -D CLHEP_DIR=_path_to_CLHEP ) + cmake -D DD4HEP_WITH_GEANT4=1 -DGeant4_DIR=/data/ilcsoft/geant4/9.6.p01/lib/Geant4-9.6.1 -DDD4HEP_USE_BOOST=ON -DDD4HEP_USE_LCIO=ON -DBOOST_ROOT=/data/ilcsoft/boost/1.55.0 -DBUILD_TESTING=On -D CLHEP_DIR=/data/ilcsoft/HEAD/CLHEP/2.1.3.1 .. + - Setup the environment for running diff --git a/UtilityApps/src/teve_display.cpp b/UtilityApps/src/teve_display.cpp index fc7d6c831576721f3e851d2c53ecd1b33cf1c516..25713053a03369e586cae0b97a9fabed26b28d84 100644 --- a/UtilityApps/src/teve_display.cpp +++ b/UtilityApps/src/teve_display.cpp @@ -192,6 +192,8 @@ TEveStraightLineSet* getSurfaces() { const SurfaceList& sL = surfMan.surfaceList() ; + // std::cout << " getSurfaces() - #surfaces : " << sL.size() << std::endl ; + for( SurfaceList::const_iterator it = sL.begin() ; it != sL.end() ; ++it ){ Surface* surf = *it ; @@ -208,6 +210,7 @@ TEveStraightLineSet* getSurfaces() { for( unsigned i=0 ; i<nL ; ++i){ + // std::cout << " **** drawSurfaces() : draw line for surface " << lines[i].first << " - " << lines[i].second << std::endl ; ls->AddLine( lines[i].first.x(), lines[i].first.y(), lines[i].first.z(), lines[i].second.x(), lines[i].second.y(), lines[i].second.z() ) ; diff --git a/examples/ILDExDet/include/VXDData.h b/examples/ILDExDet/include/VXDData.h index 1e4b7589c302518d192a623b63da48e293aaf490..af37f348ba9dbc37a1647fc53ebeea98048576fe 100644 --- a/examples/ILDExDet/include/VXDData.h +++ b/examples/ILDExDet/include/VXDData.h @@ -8,6 +8,10 @@ //==================================================================== #include "DD4hep/Detector.h" + +//fixme: VXDData should not depend on this internal header +#include "DD4hep/objects/DetectorInterna.h" + #include <vector> namespace DD4hep { diff --git a/examples/ILDExDet/src/ILDExTPC_geo.cpp b/examples/ILDExDet/src/ILDExTPC_geo.cpp index d6aed607f3007c6a9155e15ab2241e1d4e206b56..8e2a87cc46915994e6459605ddbb9c8162c7aadc 100644 --- a/examples/ILDExDet/src/ILDExTPC_geo.cpp +++ b/examples/ILDExDet/src/ILDExTPC_geo.cpp @@ -10,6 +10,10 @@ #include "DD4hep/DetFactoryHelper.h" #include "DD4hep/Detector.h" + +//fixme: TPCData should not depend on this internal header +#include "DD4hep/objects/DetectorInterna.h" + #include "DD4hep/TGeoUnits.h" #include "DDRec/Surface.h" @@ -177,6 +181,10 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) { // add a plane to the endcap volume // note: u and v are exchanged: normal is along z ... + // Vector3D u( 0. , 1. , 0. ) ; + // Vector3D v( 0. , 0. , 1. ) ; + // Vector3D n( 1. , 0. , 0. ) ; + VolPlane surf( part_vol , SurfaceType( SurfaceType::Helper ) , px_tube.zhalf() , x_tube.zhalf(), u , n , v ) ; volSurfaceList( part_det )->push_back( surf ) ;