DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
BoxSegment_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_element(Detector& description, xml_h e, Ref_t sens) {
24  xml_det_t x_det = e;
25  string name = x_det.nameStr();
26  xml_comp_t box (x_det.child(_U(box)));
27  xml_dim_t pos (x_det.child(_U(position), false));
28  xml_dim_t rot (x_det.child(_U(rotation), false));
29  Material mat (description.material(x_det.materialStr()));
30  DetElement det (name,x_det.id());
31  Volume det_vol(name+"_vol",Box(box.x(),box.y(),box.z()), mat);
32  Volume mother = description.pickMotherVolume(det);
33  Transform3D transform;
34 
35  if ( pos && rot ) {
36  transform = Transform3D(Rotation3D(RotationZYX(rot.z(),rot.y(),rot.x())),
37  Position(pos.x(),pos.y(),pos.z()));
38  }
39  else if ( rot ) {
40  transform = Transform3D(Rotation3D(RotationZYX(rot.z(),rot.y(),rot.x())),
41  Position());
42  }
43  else if ( pos ) {
44  transform = Transform3D(Rotation3D(), Position(pos.x(),pos.y(),pos.z()));
45  }
46  PlacedVolume phv = mother.placeVolume(det_vol,transform);
47  det_vol.setVisAttributes(description, x_det.visStr());
48  det_vol.setLimitSet(description, x_det.limitsStr());
49  det_vol.setRegion(description, x_det.regionStr());
50  if ( x_det.isSensitive() ) {
51  SensitiveDetector sd = sens;
52  xml_dim_t sd_typ = x_det.child(_U(sensitive));
53  det_vol.setSensitiveDetector(sens);
54  sd.setType(sd_typ.typeStr());
55  }
56  if ( x_det.hasAttr(_U(id)) ) {
57  phv.addPhysVolID("system",x_det.id());
58  }
59  det.setPlacement(phv);
60  return det;
61 }
62 
63 // first argument is the type from the xml file
64 DECLARE_DETELEMENT(DD4hep_BoxSegment,create_element)
65 
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
dd4hep::PlacedVolume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:173
dd4hep::PlacedVolume::addPhysVolID
PlacedVolume & addPhysVolID(const std::string &name, int value)
Add identifier.
Definition: Volumes.cpp:485
dd4hep::Handle
Handle: a templated class like a shared pointer, which allows specialized access to tgeometry objects...
Definition: Handle.h:84
dd4hep::Rotation3D
ROOT::Math::Rotation3D Rotation3D
Definition: Objects.h:113
dd4hep::Detector::pickMotherVolume
virtual Volume pickMotherVolume(const DetElement &sd) const =0
Access mother volume by detector element.
dd4hep::xml::Handle_t
Class to easily access the properties of single XmlElements.
Definition: XMLElements.h:380
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::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::Transform3D
ROOT::Math::Transform3D Transform3D
Definition: Objects.h:117
dd4hep::Position
ROOT::Math::XYZVector Position
Definition: Objects.h:81
DetFactoryHelper.h
dd4hep::Box
Class describing a box shape.
Definition: Shapes.h:294
std
Definition: Plugins.h:30
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
det
DetElement::Object * det
Definition: AlignmentsCalculator.cpp:66
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
dd4hep::RotationZYX
ROOT::Math::RotationZYX RotationZYX
Definition: Objects.h:105
xml_dim_t
dd4hep::xml::Dimension xml_dim_t
Definition: XML.h:31
dd4hep::SensitiveDetector::setType
SensitiveDetector & setType(const std::string &typ)
Set detector type (structure, tracker, calorimeter, etc.).
Definition: DetElement.cpp:403