DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Solenoid_o1_v01_gep.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 //==========================================================================
11 
12 #include "DDRec/DetectorData.h"
13 
15 
16 #include "XML/Layering.h"
17 #include "XML/Utilities.h"
18 
19 
20 #include "TGeoTrd2.h"
21 
22 using namespace std;
23 using namespace dd4hep;
24 using namespace dd4hep::detail;
25 
26 static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sens) {
27  xml_det_t x_det = e;
28  int det_id = x_det.id();
29  string det_name = x_det.nameStr();
30  DetElement sdet (det_name,det_id);
31 
32 
33  // --- create an envelope volume and position it into the world ---------------------
34 
35  Volume envelope = xml::createPlacedEnvelope( description, e , sdet ) ;
36  xml::setDetectorTypeFlag( e, sdet ) ;
37 
38  if( description.buildType() == BUILD_ENVELOPE ) return sdet ;
39 
40  //-----------------------------------------------------------------------------------
41 
42 
43  Material air = description.air();
44  PlacedVolume pv;
45  int n = 0;
46 
47  //added code by Thorben Quast for event display
49  solenoidData->inner_symmetry = 0;
50  solenoidData->outer_symmetry = 0;
51  solenoidData->layoutType = rec::LayeredCalorimeterData::BarrelLayout ;
52 
53  double inner_radius= std::numeric_limits<double>::max();
54  double outer_radius= 0;
55 
56  double detZ= 0.;
57 
58  for(xml_coll_t i(x_det,_U(layer)); i; ++i, ++n) {
59  xml_comp_t x_layer = i;
60  string l_name = det_name+_toString(n,"_layer%d");
61  double z = x_layer.outer_z();
62  double rmin = x_layer.inner_r();
63  double r = rmin;
64  DetElement layer(sdet,_toString(n,"layer%d"),x_layer.id());
65  Tube l_tub (rmin,2*rmin,z);
66  Volume l_vol(l_name,l_tub,air);
67  int im = 0;
68 
69 
70  for(xml_coll_t j(x_layer,_U(slice)); j; ++j, ++im) {
71  xml_comp_t x_slice = j;
72  Material mat = description.material(x_slice.materialStr());
73  string s_name= l_name+_toString(m,"_slice%d");
74  double thickness = x_slice.thickness();
75 
76  //NN: These probably need to be fixed and ced modified to read the extent, rather than the layer
77  //added code by Thorben Quast for event display
78  rec::LayeredCalorimeterData::Layer solenoidLayer;
79  solenoidLayer.distance = r;
80 
81  solenoidLayer.inner_thickness = thickness/2.;
82  solenoidLayer.outer_thickness = solenoidLayer.inner_thickness ;
83 
84  solenoidLayer.cellSize0 = 0; //equivalent to
85  solenoidLayer.cellSize1 = z; //half extension along z-axis
86  solenoidData->layers.push_back(solenoidLayer);
87 
88  Tube s_tub(r,r+thickness,z,2*M_PI);
89  Volume s_vol(s_name, s_tub, mat);
90 
91  r += thickness;
92  if ( x_slice.isSensitive() ) {
93  sens.setType("tracker");
94  s_vol.setSensitiveDetector(sens);
95  }
96  // Set Attributes
97  s_vol.setAttributes(description,x_slice.regionStr(),x_slice.limitsStr(),x_slice.visStr());
98  pv = l_vol.placeVolume(s_vol);
99  // Slices have no extra id. Take the ID of the layer!
100  pv.addPhysVolID("slice",im);
101  }
102  l_tub.setDimensions(rmin,r,z);
103 
104  if (rmin < inner_radius)
105  inner_radius = rmin;
106 
107  if (z>detZ)
108  detZ = z;
109 
110  if (r>outer_radius)
111  outer_radius = r;
112 
113  l_vol.setVisAttributes(description,x_layer.visStr());
114 
115  pv = envelope.placeVolume(l_vol);
116  pv.addPhysVolID("layer",n);
117  layer.setPlacement(pv);
118  }
119  if ( x_det.hasAttr(_U(combineHits)) ) {
120  sdet.setCombineHits(x_det.combineHits(),sens);
121  }
122 
124  solenoidData->extent[0] = inner_radius ;
125  solenoidData->extent[1] = outer_radius ;
126  solenoidData->extent[2] = 0. ;
127  solenoidData->extent[3] = detZ;
128 
129  //added code by Thorben Quast for event display
130  sdet.addExtension< rec::LayeredCalorimeterData >( solenoidData ) ;
131 
132  return sdet;
133 
134 }
135 
136 DECLARE_DETELEMENT(DD4hep_Solenoid_o1_v01,create_detector)
dd4hep::xml::Collection_t
Class to support the access to collections of XmlNodes (or XmlElements)
Definition: XMLElements.h:636
DetectorData.h
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::PlacedVolume::addPhysVolID
PlacedVolume & addPhysVolID(const std::string &name, int value)
Add identifier.
Definition: Volumes.cpp:485
dd4hep::BUILD_ENVELOPE
@ BUILD_ENVELOPE
Definition: BuildType.h:40
dd4hep::Handle
Handle: a templated class like a shared pointer, which allows specialized access to tgeometry objects...
Definition: Handle.h:84
dd4hep::_toString
std::string _toString(bool value)
String conversions: boolean value to string.
Definition: Handle.cpp:332
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::rec::LayeredCalorimeterData
StructExtension< LayeredCalorimeterStruct > LayeredCalorimeterData
Definition: DetectorData.h:472
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
Layering.h
dd4hep::xml::setDetectorTypeFlag
void setDetectorTypeFlag(dd4hep::xml::Handle_t e, dd4hep::DetElement sdet)
Definition: Utilities.cpp:284
DetFactoryHelper.h
dd4hep::xml::createPlacedEnvelope
Volume createPlacedEnvelope(dd4hep::Detector &description, dd4hep::xml::Handle_t e, dd4hep::DetElement sdet)
Definition: Utilities.cpp:220
dd4hep::Detector::buildType
virtual DetectorBuildType buildType() const =0
Access flag to steer the detail of building of the geometry/detector description.
std
Definition: Plugins.h:30
dd4hep::rec::StructExtension
Definition: DetectorData.h:37
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
Utilities.h
dd4hep::SensitiveDetector::setType
SensitiveDetector & setType(const std::string &typ)
Set detector type (structure, tracker, calorimeter, etc.).
Definition: DetElement.cpp:403