Skip to content
Snippets Groups Projects
Commit 9143f23d authored by Frank Gaede's avatar Frank Gaede
Browse files

- fixed issues in Surface class

    - implemented copy c'tor for DetElements
    - fixed memory handling
 - fixed bug in DetectorSurfaces with 
   multiple adding of the same extensions to 
   a DetElement
 - implement gear for EcalBarrel (using DDRec::Calorimeter)
parent fbf83d93
No related branches found
No related tags found
No related merge requests found
......@@ -199,6 +199,12 @@ namespace DD4hep {
//======================================================================================================
struct VolSurfaceList ;
/** Helper function for accessing the list assigned to a DetElement - attaches
* empty list if needed.
*/
VolSurfaceList* volSurfaceList( Geometry::DetElement& det ) ;
/** std::list of VolSurfaces that takes ownership.
* @author F.Gaede, DESY
* @date Apr, 6 2014
......@@ -210,36 +216,37 @@ namespace DD4hep {
// required c'tor for extension mechanism
VolSurfaceList(Geometry::DetElement& det){
// det.addExtension<VolSurfaceList>( this ) ;
VolSurfaceList* sL = volSurfaceList( det ) ;
std::copy( this->end() , sL->begin() , sL->end() ) ;
}
// required c'tor for extension mechanism
VolSurfaceList(const VolSurfaceList& vsl, Geometry::DetElement& det ){
//fixme: this causes a seg fault ...
// std::cout << " VolSurfaceList(const VolSurfaceList& vsl, Geometry::DetElement& det ) - vsl.size() " << vsl.size()
// << " own size: " << this->size() << " detelem : " ;
// if( det.isValid() )
// std::cout << det.name() << std::endl ; //<< " path : " << det.placementPath() << std::endl ;
// else
// std::cout << " INVALID " << std::endl ;
// VolSurfaceList* nL = new VolSurfaceList ;
// nL->insert( nL->end() , vsl.begin() , vsl.end() ) ;
// det.addExtension<VolSurfaceList>( nL ) ;
this->insert( this->end() , vsl.begin() , vsl.end() ) ;
}
virtual ~VolSurfaceList(){
// delete all surfaces attached to this volume
// fixme: causes seg fault if same surfaces attached to more than one list
// -> how do we deal with this ?
// for( VolSurfaceList::iterator i=begin(), n=end() ; i !=n ; ++i ) {
// delete (*i).ptr() ;
// }
// delete all surfaces attached to this volume
for( VolSurfaceList::iterator i=begin(), n=end() ; i !=n ; ++i ) {
i->clear() ;
}
}
} ;
/** Helper function for accessing the list assigned to a DetElement - attaches
* empty list if needed.
*/
VolSurfaceList* volSurfaceList( Geometry::DetElement& det ) ;
//======================================================================================================
......
......@@ -31,7 +31,7 @@ namespace DD4hep {
_sL = det.addExtension<SurfaceList >( new SurfaceList( true ) ) ;
}
if( ! vsL->empty() ) {
if( ! vsL->empty() && _sL->empty() ) { // only fill surfaces for this DetElement once
// std::cout << " detector " << det.name() << " id: " << det.id() << " has " << vsL->size() << " surfaces " << std::endl ;
......
......@@ -5,8 +5,9 @@
#include "DDRec/DetectorData.h"
#include "DDRec/DDGear.h"
#include "DDRec/MaterialManager.h"
#include "DDSurfaces/Vector3D.h"
#include "DDRec/API/Calorimeter.h"
#include "DDSurfaces/Vector3D.h"
#include "gearimpl/TPCParametersImpl.h"
#include "gearimpl/FixedPadSizeDiskLayout.h"
......@@ -260,11 +261,15 @@ namespace DD4hep{
tubeDE.addExtension< GearHandle >( new GearHandle( gearTUBE, "BeamPipe" ) ) ;
//========= CALO ==============================================================================
//**********************************************************
//* test gear interface w/ LayeredCalorimeterData extension
//**********************************************************
DetElement caloDE = lcdd.detector("HcalBarrel") ;
LayeredCalorimeterData* calo = caloDE.extension<LayeredCalorimeterData>() ;
gear::CalorimeterParametersImpl* gearCalo =
( calo->layoutType == LayeredCalorimeterData::BarrelLayout ?
new gear::CalorimeterParametersImpl( calo->extent[0]/dd4hep::mm, calo->extent[3]/dd4hep::mm, calo->symmetry, calo->phi0 ) :
......@@ -285,9 +290,38 @@ namespace DD4hep{
}
caloDE.addExtension< GearHandle >( new GearHandle( gearCalo, "HcalBarrelParameters" ) ) ;
//**********************************************************
//* test gear interface w/ LayeredExtensionImpl extension
//**********************************************************
DetElement calo2DE = lcdd.detector("EcalBarrel") ;
Calorimeter calo2( calo2DE ) ;
gear::CalorimeterParametersImpl* gearCalo2 =
( calo2.isBarrel() ?
new gear::CalorimeterParametersImpl( calo2.getRMin()/dd4hep::mm, calo2.getZMax()/dd4hep::mm, calo2.getNSides(), 0. ) : // fixme: phi 0 is not defined ??
new gear::CalorimeterParametersImpl( calo2.getRMin()/dd4hep::mm, calo2.getRMax()/dd4hep::mm, calo2.getZMin()/dd4hep::mm, calo2.getNSides(), 0. )
) ;
for( unsigned i=0, nL = calo2.numberOfLayers() ; i <nL ; ++i ){
if( i == 0 ) {
gearCalo2->layerLayout().positionLayer( calo2.getRMin()/dd4hep::mm, calo2.thickness(i)/dd4hep::mm , 0. /dd4hep::mm, 0. /dd4hep::mm, calo2.absorberThickness(i)/dd4hep::mm ) ;
}else{ // fixme: cell sizes not in API !?
gearCalo2->layerLayout().addLayer( calo2.thickness(i)/dd4hep::mm , 0. /dd4hep::mm, 0. /dd4hep::mm, calo2.absorberThickness(i)/dd4hep::mm ) ;
}
}
calo2DE.addExtension< GearHandle >( new GearHandle( gearCalo2, "EcalBarrelParameters" ) ) ;
//============================================================================================
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment