DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BoxSegment_geo.cpp
Go to the documentation of this file.
1 // $Id: $
2 //==========================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------------
5 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6 // All rights reserved.
7 //
8 // For the licensing terms see $DD4hepINSTALL/LICENSE.
9 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10 //
11 // Author : M.Frank
12 //
13 //==========================================================================
14 //
15 // Specialized generic detector constructor
16 //
17 //==========================================================================
19 
20 using namespace std;
21 using namespace DD4hep;
22 using namespace DD4hep::Geometry;
23 
24 static Ref_t create_element(LCDD& lcdd, xml_h e, Ref_t sens) {
25  xml_det_t x_det = e;
26  string name = x_det.nameStr();
27  xml_comp_t box (x_det.child(_U(box)));
28  xml_dim_t pos (x_det.child(_U(position)));
29  xml_dim_t rot (x_det.child(_U(rotation)));
30  Material mat (lcdd.material(x_det.materialStr()));
31  DetElement det (name,x_det.id());
32  Volume det_vol(name+"_vol",Box(box.x(),box.y(),box.z()), mat);
33  Volume mother = lcdd.pickMotherVolume(det);
34  Transform3D transform(Rotation3D(RotationZYX(rot.z(),rot.y(),rot.x())),Position(pos.x(),pos.y(),pos.z()));
35  PlacedVolume phv = mother.placeVolume(det_vol,transform);
36 
37  det_vol.setVisAttributes(lcdd, x_det.visStr());
38  det_vol.setLimitSet(lcdd, x_det.limitsStr());
39  det_vol.setRegion(lcdd, x_det.regionStr());
40  if ( x_det.isSensitive() ) {
41  SensitiveDetector sd = sens;
42  xml_dim_t sd_typ = x_det.child(_U(sensitive));
43  det_vol.setSensitiveDetector(sens);
44  sd.setType(sd_typ.typeStr());
45  }
46  if ( x_det.hasAttr(_U(id)) ) {
47  phv.addPhysVolID("system",x_det.id());
48  }
49  det.setPlacement(phv);
50  return det;
51 }
52 
53 // first argument is the type from the xml file
54 DECLARE_DETELEMENT(DD4hep_BoxSegment,create_element)
Handle class to hold the information of a sensitive detector.
Definition: Detector.h:47
static Ref_t create_element(LCDD &lcdd, xml_h e, Ref_t sens)
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:135
virtual Volume pickMotherVolume(const DetElement &sd) const =0
Access mother volume by detector element.
Handle class describing a material.
Definition: Objects.h:300
Handle_t child(const Strng_t &tag_value, bool except=true) const
Access child by tag name. Thow an exception if required in case the child is not present.
Definition: XMLElements.h:815
std::string typeStr() const
Access "type" attribute as STL string.
std::string regionStr() const
Access region attribute as STL string. If not present empty return empty string.
XML Handle class extending the XML handle Dimension.
Definition: XMLDetector.h:69
#define _U(a)
Definition: XMLTags.h:27
Class describing a box shape.
Definition: Shapes.h:120
return e
Definition: Volumes.cpp:297
SensitiveDetector & setType(const std::string &typ)
Set detector type (structure, tracker, calorimeter, etc.).
Definition: Detector.cpp:434
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:237
std::string visStr() const
Access vis attribute as STL string. If not present empty return empty string.
std::string materialStr() const
Access material attribute as STL string. If not present empty return empty string.
Definition: XMLDetector.cpp:67
std::string limitsStr() const
Access limits attribute as STL string. If not present empty return empty string.
ROOT::Math::RotationZYX RotationZYX
Definition: Objects.h:98
int id() const
Access parameters: id.
Definition: XMLDetector.cpp:57
bool hasAttr(const XmlChar *name) const
Check for the existence of a named attribute.
Definition: XMLElements.h:760
#define DECLARE_DETELEMENT(name, func)
Definition: Factories.h:248
ROOT::Math::Rotation3D Rotation3D
Definition: Objects.h:106
XML Handle class extending the XML handle Dimension.
Definition: XMLDetector.h:39
ROOT::Math::XYZVector Position
Definition: Objects.h:75
#define DECLARE_DEPRECATED_DETELEMENT(name, func)
Definition: Factories.h:249
Handle class describing a detector element.
Definition: Detector.h:172
Handle: a templated class like a shared pointer, which allows specialized access to tgeometry objects...
Definition: Handle.h:87
bool isSensitive() const
Check if xml detector element is sensitive.
Definition: XMLDetector.cpp:61
XML Handle to xml elements with predefined attribute access.
Definition: XMLDimension.h:52
PlacedVolume & addPhysVolID(const std::string &name, int value)
Add identifier.
Definition: Volumes.cpp:377
The main interface to the DD4hep detector description package.
Definition: LCDD.h:82
Class to easily access the properties of single XmlElements.
Definition: XMLElements.h:361
virtual Material material(const std::string &name) const =0
Retrieve a matrial by it's name from the detector description.
std::string nameStr() const
Access "name" attribute as STL string.
ROOT::Math::Transform3D Transform3D
Definition: Objects.h:110
PlacedVolume placeVolume(const Volume &vol) const
Place daughter volume. The position and rotation are the identity.
Definition: Volumes.cpp:524