DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
DiskTracker_geo.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 //==========================================================================
18 
19 using namespace std;
20 using namespace dd4hep;
21 using namespace dd4hep::detail;
22 
23 static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sens) {
24  xml_det_t x_det = e;
25  Material air = description.air();
26  string det_name = x_det.nameStr();
27  bool reflect = x_det.reflect();
28  DetElement sdet(det_name,x_det.id());
29  Assembly assembly(det_name);
30  PlacedVolume pv;
31  int l_num = 0;
32 
33  for(xml_coll_t i(x_det,_U(layer)); i; ++i, ++l_num) {
34  xml_comp_t x_layer = i;
35  string l_nam = det_name+_toString(l_num,"_layer%d");
36  double zmin = x_layer.inner_z();
37  double rmin = x_layer.inner_r();
38  double rmax = x_layer.outer_r();
39  double z = zmin, layerWidth = 0.;
40  int s_num = 0;
41 
42  for(xml_coll_t j(x_layer,_U(slice)); j; ++j) {
43  double thickness = xml_comp_t(j).thickness();
44  layerWidth += thickness;
45  }
46  Tube l_tub(rmin,rmax,layerWidth,2*M_PI);
47  Volume l_vol(l_nam,l_tub,air);
48  l_vol.setVisAttributes(description,x_layer.visStr());
49  for(xml_coll_t j(x_layer,_U(slice)); j; ++j, ++s_num) {
50  xml_comp_t x_slice = j;
51  double thick = x_slice.thickness();
52  Material mat = description.material(x_slice.materialStr());
53  string s_nam = l_nam+_toString(s_num,"_slice%d");
54  Volume s_vol(s_nam, Tube(rmin,rmax,thick), mat);
55 
56  if ( x_slice.isSensitive() ) {
57  sens.setType("tracker");
58  s_vol.setSensitiveDetector(sens);
59  }
60  s_vol.setAttributes(description,x_slice.regionStr(),x_slice.limitsStr(),x_slice.visStr());
61  pv = l_vol.placeVolume(s_vol,Position(0,0,z-zmin-layerWidth/2+thick/2));
62  pv.addPhysVolID("slice",s_num);
63  }
64 
65  DetElement layer(sdet,l_nam+"_pos",l_num);
66  pv = assembly.placeVolume(l_vol,Position(0,0,zmin+layerWidth/2.));
67  pv.addPhysVolID("layer",l_num);
68  pv.addPhysVolID("barrel",1);
69  layer.setPlacement(pv);
70  if ( reflect ) {
71  pv = assembly.placeVolume(l_vol,Transform3D(RotationY(M_PI),Position(0,0,-zmin-layerWidth/2)));
72  pv.addPhysVolID("layer",l_num);
73  pv.addPhysVolID("barrel",2);
74  DetElement layerR = layer.clone(l_nam+"_neg");
75  sdet.add(layerR.setPlacement(pv));
76  }
77  }
78  if ( x_det.hasAttr(_U(combineHits)) ) {
79  sdet.setCombineHits(x_det.attr<bool>(_U(combineHits)),sens);
80  }
81  pv = description.pickMotherVolume(sdet).placeVolume(assembly);
82  pv.addPhysVolID("system", x_det.id()); // Set the subdetector system ID.
83  sdet.setPlacement(pv);
84  return sdet;
85 }
86 
87 DECLARE_DETELEMENT(DD4hep_DiskTracker,create_detector)
dd4hep::xml::Collection_t
Class to support the access to collections of XmlNodes (or XmlElements)
Definition: XMLElements.h:636
dd4hep::SensitiveDetector
Handle class to hold the information of a sensitive detector.
Definition: DetElement.h:44
DECLARE_DETELEMENT
#define DECLARE_DETELEMENT(name, func)
Definition: Factories.h:339
M_PI
#define M_PI
Definition: Handle.h:33
dd4hep::PlacedVolume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:173
dd4hep::DetElement::clone
DetElement clone(int flag) const
Clone (Deep copy) the DetElement structure.
Definition: DetElement.cpp:274
dd4hep::PlacedVolume::addPhysVolID
PlacedVolume & addPhysVolID(const std::string &name, int value)
Add identifier.
Definition: Volumes.cpp:485
dd4hep::Handle< NamedObject >
dd4hep::_toString
std::string _toString(bool value)
String conversions: boolean value to string.
Definition: Handle.cpp:332
dd4hep::Detector::pickMotherVolume
virtual Volume pickMotherVolume(const DetElement &sd) const =0
Access mother volume by detector element.
dd4hep::DetElement::add
DetElement & add(DetElement sub_element)
Add new child to the detector structure.
Definition: DetElement.cpp:258
dd4hep::xml::Handle_t
Class to easily access the properties of single XmlElements.
Definition: XMLElements.h:380
dd4hep::DetElement::setCombineHits
DetElement & setCombineHits(bool value, SensitiveDetector &sens)
Setter: Combine hits attribute.
Definition: DetElement.cpp:177
dd4hep::Assembly
Implementation class extending the ROOT assembly volumes (TGeoVolumeAssembly)
Definition: Volumes.h:762
dd4hep::Volume::placeVolume
PlacedVolume placeVolume(const Volume &volume) const
Place daughter volume. The position and rotation are the identity.
Definition: Volumes.cpp:830
xml_comp_t
dd4hep::xml::Component xml_comp_t
Definition: XML.h:33
dd4hep::Material
Handle class describing a material.
Definition: Objects.h:272
dd4hep::Detector::material
virtual Material material(const std::string &name) const =0
Retrieve a matrial by its name from the detector description.
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:188
dd4hep::Detector::air
virtual Material air() const =0
Return handle to material describing air.
dd4hep::Volume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:378
dd4hep::detail
DD4hep internal namespace.
Definition: Alignments.h:32
xml_det_t
dd4hep::xml::DetElement xml_det_t
Definition: XML.h:32
_U
#define _U(a)
Definition: Tags.h:23
dd4hep::DetElement::setPlacement
DetElement & setPlacement(const PlacedVolume &volume)
Set the physical volumes of the detector element.
Definition: DetElement.cpp:330
dd4hep::Transform3D
ROOT::Math::Transform3D Transform3D
Definition: Objects.h:117
dd4hep::Position
ROOT::Math::XYZVector Position
Definition: Objects.h:81
dd4hep::RotationY
ROOT::Math::RotationY RotationY
Definition: Objects.h:109
DetFactoryHelper.h
std
Definition: Plugins.h:30
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
dd4hep::Tube
Class describing a tube shape of a section of a tube.
Definition: Shapes.h:628
dd4hep::SensitiveDetector::setType
SensitiveDetector & setType(const std::string &typ)
Set detector type (structure, tracker, calorimeter, etc.).
Definition: DetElement.cpp:403