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
TubeSegment_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  xml_comp_t x_tube = x_det.tubs();
27  xml_dim_t pos = x_det.position();
28  xml_dim_t rot = x_det.rotation();
29  string name = x_det.nameStr();
30  Tube tub (x_tube.rmin(),x_tube.rmax(),x_tube.zhalf());
31  Volume vol (name,tub,lcdd.material(x_det.materialStr()));
32 
33  vol.setVisAttributes(lcdd, x_det.visStr());
34  vol.setLimitSet(lcdd, x_det.limitsStr());
35  vol.setRegion(lcdd, x_det.regionStr());
36  if ( x_det.isSensitive() ) {
37  SensitiveDetector sd = sens;
38  xml_dim_t sd_typ = x_det.child(_U(sensitive));
39  vol.setSensitiveDetector(sens);
40  sd.setType(sd_typ.typeStr());
41  }
42 
43  DetElement sdet(name,x_det.id());
44  Volume mother = lcdd.pickMotherVolume(sdet);
45  PlacedVolume phv =
46  mother.placeVolume(vol,Transform3D(RotationZYX(rot.z(),rot.y(),rot.x()),Position(-pos.x(),-pos.y(),pos.z())));
47  if ( x_det.hasAttr(_U(id)) ) {
48  phv.addPhysVolID("system",x_det.id());
49  }
50  sdet.setPlacement(phv);
51  return sdet;
52 }
53 
54 DECLARE_DETELEMENT(DD4hep_TubeSegment,create_element)
Handle class to hold the information of a sensitive detector.
Definition: Detector.h:47
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.
double rmax() const
Access min/max parameters: rmax.
Dimension position(bool throw_if_not_present=true) const
Child access: position.
Dimension rotation(bool throw_if_not_present=true) const
Child access: rotation.
double rmin() const
Access min/max parameters: rmin.
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
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.
static Ref_t create_element(LCDD &lcdd, xml_h e, Ref_t sens)
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.
double z() const
Access parameters: z.
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
XML Handle class extending the XML handle Dimension.
Definition: XMLDetector.h:39
ROOT::Math::XYZVector Position
Definition: Objects.h:75
double zhalf() const
Access Tube parameters: zhalf.
Dimension tubs(bool throw_if_not_present=true) const
Child access: tubs.
#define DECLARE_DEPRECATED_DETELEMENT(name, func)
Definition: Factories.h:249
Handle class describing a detector element.
Definition: Detector.h:172
double y() const
Access parameters: y.
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
double x() const
Access parameters: x.
Class describing a tube shape of a section of a tube.
Definition: Shapes.h:277