DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
SiTrackerBarrel_surfaces.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 //
14 // Specialized generic detector constructor
15 //
16 //==========================================================================
17 
18 namespace {
19  struct UserData {
20  int dimension ;
21  };
22 }
23 
24 // Framework include files
25 #define SURFACEINSTALLER_DATA UserData
26 #define DD4HEP_USE_SURFACEINSTALL_HELPER DD4hep_SiTrackerBarrelSurfacePlugin
28 
29 namespace{
30  template <> void Installer<UserData>::handle_arguments(int argc, char** argv) {
31  for(int i=0; i<argc; ++i) {
32  char* ptr = ::strchr(argv[i],'=');
33  if ( ptr ) {
34  std::string name( argv[i] , ptr ) ;
35  double value = dd4hep::_toDouble(++ptr);
36  if( name=="dimension" ) data.dimension = value ;
37  std::cout << "DD4hep_SiTrackerBarrelSurfacePlugin: argument[" << i << "] = " << name
38  << " = " << value << std::endl;
39  }
40  }
41  }
42 
44  template <typename UserData>
45  void Installer<UserData>::install(dd4hep::DetElement component, dd4hep::PlacedVolume pv) {
46  dd4hep::Volume comp_vol = pv.volume();
47  if ( comp_vol.isSensitive() ) {
48  dd4hep::Volume mod_vol = parentVolume(component);
49  dd4hep::Box mod_shape(mod_vol.solid()), comp_shape(comp_vol.solid());
50 
51  if ( !comp_shape.isValid() || !mod_shape.isValid() ) {
52  invalidInstaller("Components and/or modules are not boxes -- invalid shapes");
53  }
54  else if ( !handleUsingCache(component,comp_vol) ) {
55  const double* trans = placementTranslation(component);
56  double half_module_thickness = mod_shape->GetDZ();
57  double sensitive_z_position = trans[2];
58  double outer_thickness = half_module_thickness + sensitive_z_position;
59  double inner_thickness = half_module_thickness - sensitive_z_position;
60  //Surface is placed at the center of the volume, no need to shift origin
61  //Make sure u,v,n form a right-handed coordinate system, v along the final z
62  Vector3D u(-1.,0.,0.), v(0.,-1.,0.), n(0.,0.,1.), o(0.,0.,0.);
63 
64  Type type( Type::Sensitive ) ;
65 
66  if( data.dimension == 1 ) {
67  type.setProperty( Type::Measurement1D , true ) ;
68  } else if( data.dimension != 2 ) {
69  throw std::runtime_error("**** dd4hep_SiTrackerBarrelSurfacePlugin: no or wrong "
70  "'dimension' argument given - has to be 1 or 2") ;
71  }
72  VolPlane surf(comp_vol, type, inner_thickness, outer_thickness, u, v, n, o);
73  addSurface(component,surf);
74  }
75  }
76  }
77 
78 
79 }// namespace
SurfaceInstaller.h
v
View * v
Definition: MultiView.cpp:28
dd4hep::PlacedVolume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:173
dd4hep::Volume::solid
Solid solid() const
Access to Solid (Shape)
Definition: Volumes.cpp:1223
dd4hep::Handle::isValid
bool isValid() const
Check the validity of the object held by the handle.
Definition: Handle.h:128
dd4hep::Volume::isSensitive
bool isSensitive() const
Accessor if volume is sensitive (ie. is attached to a sensitive detector)
Definition: Volumes.cpp:1293
dd4hep::rec::VolPlane
VolSurfaceHandle< VolPlaneImpl > VolPlane
Definition: Surface.h:474
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:188
dd4hep::Volume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:378
dd4hep::_toDouble
double _toDouble(const std::string &value)
String conversions: string to double value.
Definition: Handle.cpp:116
dd4hep::Box
Class describing a box shape.
Definition: Shapes.h:294
dd4hep::PlacedVolume::volume
Volume volume() const
Logical volume of this placement.
Definition: Volumes.cpp:452
dd4hep::sim::Setup::Sensitive
Geant4Handle< Geant4Sensitive > Sensitive
Definition: Geant4Config.h:73