diff --git a/DDSurfaces/include/DDSurfaces/Vector3D.h b/DDSurfaces/include/DDSurfaces/Vector3D.h
index 0e3e4ab74779962455271cf9c3d4701639b325aa..530d7363481e7437f29875b67b42e0d7ab9c6a65 100644
--- a/DDSurfaces/include/DDSurfaces/Vector3D.h
+++ b/DDSurfaces/include/DDSurfaces/Vector3D.h
@@ -61,6 +61,11 @@ namespace DDSurfaces {
return *this ;
}
+ inline const Vector3D& fill( double x, double y, double z) {
+
+ _x = x ; _y = y ; _z = z ;
+ return *this ;
+ }
/** Cartesian x coordinate */
inline double x() const { return _x ; }
diff --git a/examples/ILDExDet/src/ILDExSIT_geo.cpp b/examples/ILDExDet/src/ILDExSIT_geo.cpp
index 1c03a0dce047f5ab6dab5de6f9530dc950df32ee..22a74713c01861123717baa43a618072d9923bb7 100644
--- a/examples/ILDExDet/src/ILDExSIT_geo.cpp
+++ b/examples/ILDExDet/src/ILDExSIT_geo.cpp
@@ -12,9 +12,13 @@
#include "DDRec/DDGear.h"
#include "gearimpl/ZPlanarParametersImpl.h"
+#include "DDRec/Surface.h"
+
using namespace std;
using namespace DD4hep;
using namespace DD4hep::Geometry;
+using namespace DDRec ;
+using namespace DDSurfaces ;
static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) {
xml_det_t x_det = e;
@@ -31,6 +35,8 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) {
sit.addExtension<GearHandle>( new GearHandle( gearZPlanar, "SITParameters" ) ) ;
//--------------------------------------------------------------------
+
+
for(xml_coll_t c(e,_U(layer)); c; ++c) {
@@ -57,6 +63,27 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) {
Box suppbox (supp_thick/2.,width/2.,zhalf);
Volume suppvol (layername+"_supp",suppbox,lcdd.material(x_support.materialStr()));
+
+ // create a measurement plane for the tracking surface attched to the sensitive volume
+ Vector3D u( 0. , 1. , 0. ) ;
+ Vector3D v( 0. , 0. , 1. ) ;
+
+ // implement 7 deg stereo angle
+ if( layer_id % 2 ){
+
+ u.fill( 0. , cos( 3.5/180.*M_PI ) , sin( 3.5/180.*M_PI ) ) ;
+ v.fill( 0. , -sin( 3.5/180.*M_PI ) , cos( 3.5/180.*M_PI ) ) ;
+
+ } else {
+
+ u.fill( 0. , cos( 3.5/180.*M_PI ) , -sin( 3.5/180.*M_PI ) ) ;
+ v.fill( 0. , sin( 3.5/180.*M_PI ) , cos( 3.5/180.*M_PI ) ) ;
+ }
+
+ Vector3D n( 1. , 0. , 0. ) ;
+ VolPlane surf( sensvol , SurfaceType(SurfaceType::Sensitive) , sens_thick/2 + supp_thick/2 , sens_thick/2 , u,v,n ) ;
+
+
// Position senspos (-(sens_thick+supp_thick)/2.+sens_thick/2.,0,0);
// Position supppos (-(sens_thick+supp_thick)/2.+sens_thick+supp_thick/2.,0,0);
// --- position the sensitive on top of the support !
@@ -83,6 +110,10 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) {
// this will result int the correct cellID to be set...
pv.addPhysVolID("layer",layer_id).addPhysVolID("module",j).addPhysVolID("sensor",0 ) ;
+ // create a DetElement for the ladder and assign the meassurment surface to it
+ DetElement ladderDE( sit , laddername , x_det.id() );
+ ladderDE.setPlacement( pv ) ;
+ volSurfaceList( ladderDE )->push_back( surf ) ;
}
//----------------- gear ---------------------------------------------
diff --git a/examples/ILDExDet/src/ILDExVXD_geo.cpp b/examples/ILDExDet/src/ILDExVXD_geo.cpp
index 8939905d66edb60660623cb3e9ebc1e9d374068e..822cd4598a17b27788f01c8ef8ac28b8a7c97489 100644
--- a/examples/ILDExDet/src/ILDExVXD_geo.cpp
+++ b/examples/ILDExDet/src/ILDExVXD_geo.cpp
@@ -194,9 +194,7 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) {
DetElement ladderDEposZ( vxd , laddername+"_posZ" , x_det.id() );
ladderDEposZ.setPlacement( pv ) ;
-
- // if( j == 0 || j == 1 )
- volSurfaceList( ladderDEposZ)->push_back( surf ) ;
+ volSurfaceList( ladderDEposZ )->push_back( surf ) ;
pv = layer_assembly.placeVolume( laddervol, Transform3D( rot , Position( (radius + lthick/2.)*cos(phi) - offset * sin( phi ) ,
diff --git a/examples/ILDExSimu/src/test_surfaces.cc b/examples/ILDExSimu/src/test_surfaces.cc
index 7d3d3f48525a0ef09001f55ef6eb8a986cb34f59..ff94f0b9c43b3ca18965c6c4bd5dbf962d7b9e8c 100644
--- a/examples/ILDExSimu/src/test_surfaces.cc
+++ b/examples/ILDExSimu/src/test_surfaces.cc
@@ -81,82 +81,93 @@ int main(int argc, char** argv ){
UTIL::BitField64 idDecoder( ILDCellID0::encoder_string ) ;
- while( ( evt = rdr->readNextEvent() ) != 0 ){
-
- LCCollection* col = evt->getCollection("VXDCollection" ) ;
-
- int nHit = col->getNumberOfElements() ;
-
- for(int i=0 ; i< nHit ; ++i){
- SimTrackerHit* sHit = (SimTrackerHit*) col->getElementAt(i) ;
+ std::vector< std::string > colNames ;
+ colNames.push_back( "VXDCollection" ) ;
+ colNames.push_back( "SITCollection" ) ;
- long64 id = sHit->getCellID0() ;
-
- idDecoder.setValue( id ) ;
- // std::cout << " simhit with cellid : " << idDecoder << std::endl ;
-
- Surface* surf = surfMap[ id ] ;
+ while( ( evt = rdr->readNextEvent() ) != 0 ){
- std::stringstream sst ;
- sst << " surface found for id : " << std::hex << id << std::dec ;
+ for(unsigned icol=0, ncol = colNames.size() ; icol < ncol ; ++icol ){
- // ===== test that we have a surface with the correct ID for every hit ======================
+ LCCollection* col = evt->getCollection( colNames[ icol ] ) ;
- test( surf != 0 , true , sst.str() ) ;
+ int nHit = col->getNumberOfElements() ;
- if( surf != 0 ){
-
- Vector3D point( sHit->getPosition()[0]* tgeo::mm , sHit->getPosition()[1]* tgeo::mm , sHit->getPosition()[2]* tgeo::mm ) ;
-
- double dist = surf->distance( point ) ;
-
- bool isInside = surf->insideBounds( point ) ;
-
-
- sst.str("") ;
- sst << " point " << point << " is on surface " ;
-
- // ====== test that hit points are inside their surface ================================
-
- test( isInside , true , sst.str() ) ;
-
- // std::cout << " found surface with same id " << *surf << std::endl
- // << " point : " << point
- // << " is inside : " << isInside
- // << " distance from surface : " << dist/tgeo::mm << std::endl
- // << std::endl ;
-
- // ====== test that slightly moved hit points are inside their surface ================================
-
- Vector3D point2 = point + 1e-5 * surf->normal() ;
- sst.str("") ;
- sst << " point2 " << point2 << " is on surface " ;
- isInside = surf->insideBounds( point2 ) ;
- test( isInside , true , sst.str() ) ;
-
- // ====== test that moved hit points are outside their surface ================================
-
- Vector3D point3 = point + 1e-3 * surf->normal() ;
- sst.str("") ;
- sst << " point3 " << point3 << " is not on surface " ;
- isInside = surf->insideBounds( point3) ;
- test( isInside , false , sst.str() ) ;
-
-
-
- } else {
-
- std::cout << "ERROR: no surface found for id: " << idDecoder << std::endl ;
+ for(int i=0 ; i< nHit ; ++i){
+
+ SimTrackerHit* sHit = (SimTrackerHit*) col->getElementAt(i) ;
+
+ long64 id = sHit->getCellID0() ;
+
+ idDecoder.setValue( id ) ;
+ // std::cout << " simhit with cellid : " << idDecoder << std::endl ;
+
+ Surface* surf = surfMap[ id ] ;
+
+ std::stringstream sst ;
+ sst << " surface found for id : " << std::hex << id << std::dec ;
+
+
+ // ===== test that we have a surface with the correct ID for every hit ======================
+
+ test( surf != 0 , true , sst.str() ) ;
+
+
+ if( surf != 0 ){
+
+ Vector3D point( sHit->getPosition()[0]* tgeo::mm , sHit->getPosition()[1]* tgeo::mm , sHit->getPosition()[2]* tgeo::mm ) ;
+
+ double dist = surf->distance( point ) ;
+
+ bool isInside = surf->insideBounds( point ) ;
+
+
+ sst.str("") ;
+ sst << " point " << point << " is on surface " ;
+
+ // ====== test that hit points are inside their surface ================================
+
+ test( isInside , true , sst.str() ) ;
+
+ // std::cout << " found surface with same id " << *surf << std::endl
+ // << " point : " << point
+ // << " is inside : " << isInside
+ // << " distance from surface : " << dist/tgeo::mm << std::endl
+ // << std::endl ;
+
+ // ====== test that slightly moved hit points are inside their surface ================================
+
+ Vector3D point2 = point + 1e-5 * surf->normal() ;
+ sst.str("") ;
+ sst << " point2 " << point2 << " is on surface " ;
+ isInside = surf->insideBounds( point2 ) ;
+ test( isInside , true , sst.str() ) ;
+
+ // ====== test that moved hit points are outside their surface ================================
+
+ Vector3D point3 = point + 1e-3 * surf->normal() ;
+ sst.str("") ;
+ sst << " point3 " << point3 << " is not on surface " ;
+ isInside = surf->insideBounds( point3) ;
+ test( isInside , false , sst.str() ) ;
+
+
+
+ } else {
+
+ std::cout << "ERROR: no surface found for id: " << idDecoder << std::endl ;
+ }
+
}
-
+
}
-
+
}
-
+
return 0;
}