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
DiskTracker_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 
25  xml_det_t x_det = e;
26  Material air = lcdd.air();
27  string det_name = x_det.nameStr();
28  bool reflect = x_det.reflect();
29  DetElement sdet(det_name,x_det.id());
30  Assembly assembly(det_name);
31  PlacedVolume pv;
32  int l_num = 0;
33 
34  for(xml_coll_t i(x_det,_U(layer)); i; ++i, ++l_num) {
35  xml_comp_t x_layer = i;
36  string l_nam = det_name+_toString(l_num,"_layer%d");
37  double zmin = x_layer.inner_z();
38  double rmin = x_layer.inner_r();
39  double rmax = x_layer.outer_r();
40  double z = zmin, layerWidth = 0.;
41  int s_num = 0;
42 
43  for(xml_coll_t j(x_layer,_U(slice)); j; ++j) {
44  double thickness = xml_comp_t(j).thickness();
45  layerWidth += thickness;
46  }
47  Tube l_tub(rmin,rmax,layerWidth,2*M_PI);
48  Volume l_vol(l_nam,l_tub,air);
49  l_vol.setVisAttributes(lcdd,x_layer.visStr());
50  for(xml_coll_t j(x_layer,_U(slice)); j; ++j, ++s_num) {
51  xml_comp_t x_slice = j;
52  double thick = x_slice.thickness();
53  Material mat = lcdd.material(x_slice.materialStr());
54  string s_nam = l_nam+_toString(s_num,"_slice%d");
55  Volume s_vol(s_nam, Tube(rmin,rmax,thick), mat);
56 
57  if ( x_slice.isSensitive() ) {
58  sens.setType("tracker");
59  s_vol.setSensitiveDetector(sens);
60  }
61  s_vol.setAttributes(lcdd,x_slice.regionStr(),x_slice.limitsStr(),x_slice.visStr());
62  pv = l_vol.placeVolume(s_vol,Position(0,0,z-zmin-layerWidth/2+thick/2));
63  pv.addPhysVolID("slice",s_num);
64  }
65 
66  DetElement layer(sdet,l_nam+"_pos",l_num);
67  pv = assembly.placeVolume(l_vol,Position(0,0,zmin+layerWidth/2.));
68  pv.addPhysVolID("layer",l_num);
69  pv.addPhysVolID("barrel",1);
70  layer.setPlacement(pv);
71  if ( reflect ) {
72  pv = assembly.placeVolume(l_vol,Transform3D(RotationY(M_PI),Position(0,0,-zmin-layerWidth/2)));
73  pv.addPhysVolID("layer",l_num);
74  pv.addPhysVolID("barrel",2);
75  DetElement layerR = layer.clone(l_nam+"_neg");
76  sdet.add(layerR.setPlacement(pv));
77  }
78  }
79  if ( x_det.hasAttr(_U(combineHits)) ) {
80  sdet.setCombineHits(x_det.attr<bool>(_U(combineHits)),sens);
81  }
82  pv = lcdd.pickMotherVolume(sdet).placeVolume(assembly);
83  pv.addPhysVolID("system", x_det.id()); // Set the subdetector system ID.
84  sdet.setPlacement(pv);
85  return sdet;
86 }
87 
88 DECLARE_DETELEMENT(DD4hep_DiskTracker,create_detector)
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
static Ref_t create_detector(LCDD &lcdd, xml_h e, SensitiveDetector sens)
virtual Volume pickMotherVolume(const DetElement &sd) const =0
Access mother volume by detector element.
Handle class describing a material.
Definition: Objects.h:300
Implementation class extending the ROOT assembly volumes (TGeoVolumeAsembly)
Definition: Volumes.h:348
#define M_PI
Definition: Handle.h:39
std::string regionStr() const
Access region attribute as STL string. If not present empty return empty string.
Class to support the access to collections of XmlNodes (or XmlElements)
Definition: XMLElements.h:556
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
ROOT::Math::RotationY RotationY
Definition: Objects.h:102
SensitiveDetector & setType(const std::string &typ)
Set detector type (structure, tracker, calorimeter, etc.).
Definition: Detector.cpp:434
double thickness() const
Access attribute values: thickness.
double inner_r() const
Access attribute values: inner_r.
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.
bool isSensitive() const
Check if component is sensitive.
Definition: XMLDetector.cpp:29
std::string limitsStr() const
Access limits attribute as STL string. If not present empty return empty string.
const Volume & setVisAttributes(const VisAttr &obj) const
Set Visualization attributes to the volume.
Definition: Volumes.cpp:564
DetElement & add(DetElement sub_element)
Add new child to the detector structure.
Definition: Detector.cpp:255
int id() const
Access parameters: id.
Definition: XMLDetector.cpp:57
double inner_z() const
Access attribute values: inner_z.
double outer_r() const
Access attribute values: outer_r.
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
bool reflect() const
Access attribute values: reflect.
DetElement & setPlacement(const PlacedVolume &volume)
Set the physical volumes of the detector element.
Definition: Detector.cpp:290
DetElement & setCombineHits(bool value, SensitiveDetector &sens)
Setter: Combine hits attribute.
Definition: Detector.cpp:179
DetElement clone(const std::string &new_name) const
Clone (Deep copy) the DetElement structure with a new name.
Definition: Detector.cpp:268
const Volume & setAttributes(const LCDD &lcdd, const std::string &region, const std::string &limits, const std::string &vis) const
Attach attributes to the volume.
Definition: Volumes.cpp:669
ROOT::Math::XYZVector Position
Definition: Objects.h:75
#define DECLARE_DEPRECATED_DETELEMENT(name, func)
Definition: Factories.h:249
virtual Material air() const =0
Return handle to material describing air.
std::string materialStr() const
Access material attribute as STL string.
Definition: XMLDetector.cpp:25
Handle class describing a detector element.
Definition: Detector.h:172
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.
const Volume & setSensitiveDetector(const SensitiveDetector &obj) const
Assign the sensitive detector structure.
Definition: Volumes.cpp:736
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
T attr(const XmlChar *tag_value) const
Access attribute by type.
Definition: XMLDetector.h:94
static std::string _toString(const DD4hep::XML::XmlChar *value)
std::string conversion of XML strings (e.g. Unicode for Xerces-C)
DD4hep::XML::Component xml_comp_t
Class describing a tube shape of a section of a tube.
Definition: Shapes.h:277