From 17aa3131beae7603f19c3930cef0af7dba9069f8 Mon Sep 17 00:00:00 2001 From: Frank Gaede <frank.gaede@desy.de> Date: Fri, 7 Feb 2014 15:21:35 +0000 Subject: [PATCH] - added gear to SIT and VXD in ILDExDet - fixed geometry in ILDExVXD_geo.cpp, ILDExTPCSIT_geo.cpp wrt. to position of support ans sensitive ladders - added test_convert_ild_gear - updated release notes --- doc/release.notes | 13 ++++++++ examples/ILDExDet/CMakeLists.txt | 8 +++++ examples/ILDExDet/compact/ILDEx.xml | 8 ++--- examples/ILDExDet/src/DDGear.cpp | 35 ++++++++++++++++----- examples/ILDExDet/src/ILDExSIT_geo.cpp | 39 ++++++++++++++++++------ examples/ILDExDet/src/ILDExVXD_geo.cpp | 42 ++++++++++++++++++-------- examples/ILDExDet/src/convertToGear.cc | 11 ++++--- 7 files changed, 117 insertions(+), 39 deletions(-) diff --git a/doc/release.notes b/doc/release.notes index 0ad9ac86b..9d5b9d84d 100644 --- a/doc/release.notes +++ b/doc/release.notes @@ -2,6 +2,19 @@ DD4hep ---- Release Notes ================================= +2014/02/07 Frank Gaede +----------------------- + - added DDGear, support for interfacing to gear for backward compatibility + - lives currently in ILDExDet ( should become (optional) part of core DD4hep) + - users need to GearParameter objects as extensions to the DetElement + -> see ILDExTPC_geo.cpp, ILDExVXD_geo.cpp, ILDExTPCSIT_geo.cpp as examples + - program convertToGear creates gear xml file from compact file + ( only if GearParameter objects are avialble as extensions) + - added test_convert_ild_gear + - fixed geometry in ILDExVXD_geo.cpp, ILDExTPCSIT_geo.cpp + wrt. to position of support ans sensitive ladders + + -------- | v00-06 | sixth beta release ... -------- diff --git a/examples/ILDExDet/CMakeLists.txt b/examples/ILDExDet/CMakeLists.txt index afcb2366d..ed9792522 100644 --- a/examples/ILDExDet/CMakeLists.txt +++ b/examples/ILDExDet/CMakeLists.txt @@ -161,6 +161,14 @@ ADD_TEST( t_${test_name} "${CMAKE_INSTALL_PREFIX}/bin/run_test_${PackageName}.sh SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES PASS_REGULAR_EXPRESSION " Handled [1-9][0-9][0-9]+ volumes" ) +SET( test_name "test_converter_ild_gear" ) +ADD_TEST( t_${test_name} "${CMAKE_INSTALL_PREFIX}/bin/run_test_${PackageName}.sh" + convertToGear ${CMAKE_CURRENT_SOURCE_DIR}/compact/ILDEx.xml ) +SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES PASS_REGULAR_EXPRESSION "found gear object : SITParameters" ) +SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES PASS_REGULAR_EXPRESSION "found gear object : TPCParameters" ) +SET_TESTS_PROPERTIES( t_${test_name} PROPERTIES PASS_REGULAR_EXPRESSION "found gear object : VXDParameters" ) + + #SET( test_name "test_converter_pandora" ) #ADD_TEST( t_${test_name} "${CMAKE_INSTALL_PREFIX}/bin/run_test_${PackageName}.sh" # geoConverter -compact2pandora -input ${CMAKE_CURRENT_SOURCE_DIR}/compact/ILDEx.xml -output ILDExDet.pandora ) diff --git a/examples/ILDExDet/compact/ILDEx.xml b/examples/ILDExDet/compact/ILDEx.xml index 0216db18f..5cd451e9d 100644 --- a/examples/ILDExDet/compact/ILDEx.xml +++ b/examples/ILDExDet/compact/ILDEx.xml @@ -145,11 +145,11 @@ <detector name="SIT" type="ILDExSIT" vis="SITVis" id="2" limits="Tracker_limits" readout="SITCollection" insideTrackingVolume="true"> <tubs rmin="SIT_inner_radius" rmax="SIT_outer_radius" zhalf="SIT_zhalf"/> <layer id="0" vis="SITLayerVis"> - <support thickness="0.01*mm" material="Carbon" vis="SITSupportVis"/> + <support thickness="1.0*mm" material="Carbon" vis="SITSupportVis"/> <ladder thickness="0.1*mm" zhalf="370*mm" radius="155*mm" material="Silicon" number="10" /> </layer> <layer id="1" vis="SITLayerVis"> - <support thickness="0.01*mm" material="Carbon" vis="SITSupportVis"/> + <support thickness="1.0*mm" material="Carbon" vis="SITSupportVis"/> <ladder thickness="0.1*mm" zhalf="650*mm" radius="300*mm" material="Silicon" number="19" /> </layer> </detector> @@ -196,7 +196,7 @@ </detector> <comment>Calorimeters</comment> - <detector id="7" name="HcalBarrel" type="AhcalBarrelCalorimeter" readout="HcalBarrelHits" vis="HcalBarrelVis" calorimeterType="HAD_BARREL" gap="10.*mm"> + <detector id="7" name="HcalBarrel" type="AhcalBarrelCalorimeter" readout="HcalBarrelRegCollection" vis="HcalBarrelVis" calorimeterType="HAD_BARREL" gap="10.*mm"> <comment>Hadron Calorimeter Barrel</comment> <material name="Steel235"/> @@ -253,7 +253,7 @@ <id>system:5,side:-2,layer:9,module:8,sensor:8</id> </readout> - <readout name="HcalBarrelHits"> + <readout name="HcalBarrelRegCollection"> <segmentation type="CartesianGridXZ" grid_size_x="30.0*mm" grid_size_z="30.0*mm" /> <id>system:6,stave:3,module:4,layer:8,slice:5,x:32:-16,y:-16</id> </readout> diff --git a/examples/ILDExDet/src/DDGear.cpp b/examples/ILDExDet/src/DDGear.cpp index 6500677ad..eedacefa3 100644 --- a/examples/ILDExDet/src/DDGear.cpp +++ b/examples/ILDExDet/src/DDGear.cpp @@ -40,19 +40,38 @@ namespace DD4hep{ //------------------ SubdetectorParamters ---------------------------------- - typedef std::map<std::string, DetElement> DEMap ; - DEMap chMap = world.children() ; - - for ( DEMap::const_iterator it=chMap.begin() ; it != chMap.end() ; ++it ){ + std::vector< DetElement > dets ; + dets.reserve(1024) ; + + DetElement::Children chMap = world.children() ; + + // --- get all DetElements and their children into on vector + // ( expect gear parameters to be only at top two levels ) + for ( DetElement::Children::const_iterator it=chMap.begin() ; it != chMap.end() ; ++it ){ + DetElement subDet = (*it).second ; + dets.push_back( subDet ) ; + // std::cout << " *** subdetector : " << subDet.name() << std::endl ; + + DetElement::Children grCh = subDet.children() ; + + for ( DetElement::Children::const_iterator it=grCh.begin() ; it != grCh.end() ; ++it ){ + DetElement subDet = (*it).second ; + dets.push_back( subDet ) ; + // std::cout << " *** sub-subdetector : " << subDet.name() << std::endl ; + } + } - std::cout << " *** subdetector : " << subDet.name() << std::endl ; - + for( unsigned i=0, N= dets.size() ; i<N ; ++i){ + DD4hep::GearHandle* gearH = 0 ; + try{ - gearH = subDet.extension<DD4hep::GearHandle>() ; + gearH = dets[i].extension<DD4hep::GearHandle>() ; + + std::cout << " *** subdetector " << dets[i].name() << " - found gear object : " << gearH->name() << std::endl ; } catch( std::exception& e) { @@ -64,7 +83,7 @@ namespace DD4hep{ // --- check for canonical names of GearHandle objects : // (fixme: will have to iterate over daughters as well ... ) - if ( gearH->name() == "TPCParameters" ) { gearMgr->setTPCParameters ( dynamic_cast<gear::TPCParameters* >( gearH->takeGearObject() ) ) ; } + if ( gearH->name() == "TPCParameters" ) { gearMgr->setTPCParameters ( dynamic_cast<gear::TPCParameters* >( gearH->takeGearObject() ) ) ; } else if( gearH->name() == "EcalBarrelParameters" ) { gearMgr->setEcalBarrelParameters( dynamic_cast<gear::CalorimeterParameters* >( gearH->takeGearObject() ) ) ; } else if( gearH->name() == "EcalEndcapParameters" ) { gearMgr->setEcalEndcapParameters( dynamic_cast<gear::CalorimeterParameters* >( gearH->takeGearObject() ) ) ; } else if( gearH->name() == "EcalPlugParameters" ) { gearMgr->setEcalPlugParameters ( dynamic_cast<gear::CalorimeterParameters* >( gearH->takeGearObject() ) ) ; } diff --git a/examples/ILDExDet/src/ILDExSIT_geo.cpp b/examples/ILDExDet/src/ILDExSIT_geo.cpp index 16202789f..67d5921a1 100644 --- a/examples/ILDExDet/src/ILDExSIT_geo.cpp +++ b/examples/ILDExDet/src/ILDExSIT_geo.cpp @@ -24,12 +24,10 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) { PlacedVolume pv; - //--------------- create gear::ZPlanarParameters and add them as Extension - gear::ZPlanarParametersImpl* gearZPlanar = new gear::ZPlanarParametersImpl( 0 , 0.0, 0.0, 0.0, 0.0, 0.0 ) ; - + //--------------- gear: create gear::ZPlanarParameters and add them as Extension + gear::ZPlanarParametersImpl* gearZPlanar = new gear::ZPlanarParametersImpl( gear::ZPlanarParameters::HYBRID , 0.0, 0.0, 0.0, 0.0, 0.0 ) ; // ZPlanarParametersImpl( int type, double shellInnerRadius, double shellOuterRadius, double shellHalfLength, double shellGap, double shellRadLength ) ; - - + // -> the SIT has no outer shell - set type to HYPRID to keep gear happy (needs fix in gear) sit.addExtension<GearHandle>( new GearHandle( gearZPlanar, "SITParameters" ) ) ; //-------------------------------------------------------------------- @@ -49,13 +47,21 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) { double supp_thick = x_support.thickness(); double width = 2.*tan(dphi/2.)*(sens_radius-sens_thick/2.); Box ladderbox ((sens_thick+supp_thick)/2.,width/2.,zhalf); - Volume laddervol (layername+"_ladder",ladderbox,lcdd.material(x_ladder.materialStr())); + + Material suppmat = lcdd.material( x_support.materialStr() ) ; + Material sensmat = lcdd.material( x_ladder.materialStr() ); + + Volume laddervol (layername+"_ladder",ladderbox , suppmat ); Box sensbox (sens_thick/2.,width/2.,zhalf); - Volume sensvol (layername+"_sens",sensbox,lcdd.material(x_ladder.materialStr())); + Volume sensvol (layername+"_sens",sensbox, sensmat ); Box suppbox (supp_thick/2.,width/2.,zhalf); Volume suppvol (layername+"_supp",suppbox,lcdd.material(x_support.materialStr())); - 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 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 ! + 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 ); sens.setType("tracker"); sensvol.setSensitiveDetector(sens); @@ -65,10 +71,11 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) { laddervol.placeVolume(suppvol,supppos); sit.setVisAttributes(lcdd, x_det.visStr(),laddervol); + double radius = sens_radius + ((sens_thick+supp_thick)/2. - sens_thick/2.); + for(int j=0; j<nLadders; ++j) { string laddername = layername + _toString(j,"_ladder%d"); - double radius = sens_radius + ((sens_thick+supp_thick)/2. - sens_thick/2.); Position pos(radius*cos(j*dphi),radius*sin(j*dphi),0.); pv = assembly.placeVolume(laddervol,Transform3D(RotationZ(j*dphi),pos)); @@ -76,7 +83,19 @@ 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 ) ; + } + //----------------- gear --------------------------------------------- + double ladderRadLength = suppmat->GetMaterial()->GetRadLen() /tgeo::mm ; + double sensitiveRadLength = sensmat->GetMaterial()->GetRadLen() /tgeo::mm ; + + gearZPlanar->addLayer ( nLadders, 0. , radius/tgeo::mm, 0. , supp_thick/tgeo::mm , 2*zhalf/tgeo::mm, width/tgeo::mm, ladderRadLength, + (radius+supp_thick)/tgeo::mm, 0 , sens_thick/tgeo::mm , 2*zhalf/tgeo::mm , width/tgeo::mm, sensitiveRadLength) ; + + // addLayer (int nLadders, double phi0, double ladderDistance, double ladderOffset, double ladderThickness, double ladderLength, double ladderWidth, double ladderRadLength, + // double sensitiveDistance, double sensitiveOffset, double sensitiveThickness, double sensitiveLength, double sensitiveWidth, double sensitiveRadLength) + //----------------- gear --------------------------------------------- + } diff --git a/examples/ILDExDet/src/ILDExVXD_geo.cpp b/examples/ILDExDet/src/ILDExVXD_geo.cpp index d9b07cfad..ce48bb8e1 100644 --- a/examples/ILDExDet/src/ILDExVXD_geo.cpp +++ b/examples/ILDExDet/src/ILDExVXD_geo.cpp @@ -9,7 +9,8 @@ #include "DD4hep/DetFactoryHelper.h" #include "VXDData.h" -//#include "GearWrapper.h" +#include "DDGear.h" +#include "gearimpl/ZPlanarParametersImpl.h" using namespace std; using namespace DD4hep; @@ -36,10 +37,12 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) { vxd_data->id = x_det.id(); - // //--------------- create gear::ZPlanarParameters and add them as Extension - // GearZPlanarParameters* gearZPlanar = new GearZPlanarParameters ; - // vxd.addExtension<GearZPlanarParameters>( gearZPlanar ) ; - // //-------------------------------------------------------------------- + //--------------- gear: create gear::ZPlanarParameters and add them as Extension + gear::ZPlanarParametersImpl* gearZPlanar = new gear::ZPlanarParametersImpl( gear::ZPlanarParameters::CCD , 0.0, 0.0, 0.0, 0.0, 0.0 ) ; + // ZPlanarParametersImpl( int type, double shellInnerRadius, double shellOuterRadius, double shellHalfLength, double shellGap, double shellRadLength ) ; + // -> this VXD has no outer shell ... + vxd.addExtension<GearHandle>( new GearHandle( gearZPlanar, "VXDParameters" ) ) ; + //-------------------------------------------------------------------- for(xml_coll_t c(e,_U(layer)); c; ++c) { @@ -63,7 +66,11 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) { double sens_radius= x_ladder.radius(); double sens_thick = x_ladder.thickness(); double supp_thick = x_support.thickness(); - double radius = sens_radius + ((sens_thick+supp_thick)/2. - sens_thick/2.); + + // double radius = sens_radius + ((sens_thick+supp_thick)/2. - sens_thick/2.); + //fg: this is the radius(distance) of the support ladder which should be under(inside) the sensitive ladder + double radius = sens_radius - supp_thick ; + double phi0 = x_layer.phi0() ; // double width = 2.*tan(dphi/2.)*(sens_radius-sens_thick/2.); @@ -81,10 +88,9 @@ 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,suppmat); - //Position senspos (0,0,0); - //Position supppos (0,0,0); - 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 ! + 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 ); sens.setType("tracker"); sensvol.setSensitiveDetector(sens); @@ -128,9 +134,6 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) { string laddername = layername + _toString(j,"_ladder%d"); - // Position pos(radius*cos(dj*dphi) - offset*sin(dj*dphi), - // radius*sin(dj*dphi) - offset*cos(dj*dphi),0.); - double lthick = sens_thick + supp_thick ; RotationZYX rot( phi , 0, 0 ) ; @@ -167,6 +170,19 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) { } vxd.setVisAttributes(lcdd, x_det.visStr(),laddervol); + + //----------------- gear --------------------------------------------- + double ladderRadLength = suppmat->GetMaterial()->GetRadLen() /tgeo::mm ; + double sensitiveRadLength = sensmat->GetMaterial()->GetRadLen() /tgeo::mm ; + + gearZPlanar->addLayer ( nLadders, phi0 , radius/tgeo::mm, offset/tgeo::mm , supp_thick/tgeo::mm , 2*zhalf/tgeo::mm, width/tgeo::mm, ladderRadLength, + (radius+supp_thick)/tgeo::mm, offset/tgeo::mm , sens_thick/tgeo::mm , 2*zhalf/tgeo::mm , width/tgeo::mm, sensitiveRadLength) ; + + // addLayer (int nLadders, double phi0, double ladderDistance, double ladderOffset, double ladderThickness, double ladderLength, double ladderWidth, double ladderRadLength, + // double sensitiveDistance, double sensitiveOffset, double sensitiveThickness, double sensitiveLength, double sensitiveWidth, double sensitiveRadLength) + //----------------- gear --------------------------------------------- + + } Volume mother = lcdd.pickMotherVolume(vxd) ; diff --git a/examples/ILDExDet/src/convertToGear.cc b/examples/ILDExDet/src/convertToGear.cc index c1083281c..bf4268bc5 100644 --- a/examples/ILDExDet/src/convertToGear.cc +++ b/examples/ILDExDet/src/convertToGear.cc @@ -43,9 +43,9 @@ int main(int argc, char** argv ){ //---------------------------------------------------------------------------------- - std::cout << " ***************************** GEAR parameters **************************************** " << std::endl ; - std::cout << *gearMgr ; - std::cout << " ************************* End of GEAR parameters ************************************* " << std::endl ; + // std::cout << " ***************************** GEAR parameters **************************************** " << std::endl ; + // std::cout << *gearMgr ; + // std::cout << " ************************* End of GEAR parameters ************************************* " << std::endl ; //---------------------------------------------------------------------------------- @@ -55,9 +55,12 @@ int main(int argc, char** argv ){ outFile = "gear_" + gearMgr->getDetectorName() + ".xml" ; } - gear::GearXML::createXMLFile ( gearMgr, outFile ) ; + std::cout << " ************************************************************** " << std::endl ; + std::cout << " created gear file : " << outFile << std::endl ; + std::cout << " ************************************************************** " << std::endl ; + return 0; } -- GitLab