File indexing completed on 2025-01-18 09:14:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 namespace {
0019 struct UserData {
0020 int dimension ;
0021 };
0022 }
0023
0024
0025 #define SURFACEINSTALLER_DATA UserData
0026 #define DD4HEP_USE_SURFACEINSTALL_HELPER Lhe_SiTrackerBarrelSurfacePlugin
0027 #include "DD4hep/SurfaceInstaller.h"
0028
0029 namespace{
0030 template <> void Installer<UserData>::handle_arguments(int argc, char** argv) {
0031 for(int i=0; i<argc; ++i) {
0032 char* ptr = ::strchr(argv[i],'=');
0033 if ( ptr ) {
0034 std::string name( argv[i] , ptr ) ;
0035 double value = dd4hep::_toDouble(++ptr);
0036 if( name=="dimension" ) data.dimension = value ;
0037 std::cout << "DD4hep_SiTrackerBarrelSurfacePlugin: argument[" << i << "] = " << name
0038 << " = " << value << std::endl;
0039 }
0040 }
0041 }
0042
0043
0044 template <typename UserData>
0045 void Installer<UserData>::install(dd4hep::DetElement component, dd4hep::PlacedVolume pv) {
0046 dd4hep::Volume comp_vol = pv.volume();
0047 if ( comp_vol.isSensitive() ) {
0048 dd4hep::Volume mod_vol = parentVolume(component);
0049 dd4hep::Box mod_shape(mod_vol.solid()), comp_shape(comp_vol.solid());
0050
0051 if ( !comp_shape.isValid() || !mod_shape.isValid() ) {
0052 invalidInstaller("Components and/or modules are not boxes -- invalid shapes");
0053 }
0054 else if ( !handleUsingCache(component,comp_vol) ) {
0055 const double* trans = placementTranslation(component);
0056 double half_module_thickness = mod_shape->GetDZ();
0057 double sensitive_z_position = trans[2];
0058 double outer_thickness = half_module_thickness + sensitive_z_position;
0059 double inner_thickness = half_module_thickness - sensitive_z_position;
0060
0061
0062 Vector3D u(-1.,0.,0.), v(0.,-1.,0.), n(0.,0.,1.), o(0.,0.,0.);
0063
0064 Type type( Type::Sensitive ) ;
0065
0066 if( data.dimension == 1 ) {
0067 type.setProperty( Type::Measurement1D , true ) ;
0068 } else if( data.dimension != 2 ) {
0069 throw std::runtime_error("**** Lhe_SiTrackerBarrelSurfacePlugin: no or wrong "
0070 "'dimension' argument given - has to be 1 or 2") ;
0071 }
0072 VolPlane surf(comp_vol, type, inner_thickness, outer_thickness, u, v, n, o);
0073 addSurface(component,surf);
0074 }
0075 }
0076 }
0077
0078
0079 }