DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
CylinderShell_geo.cpp
Go to the documentation of this file.
1 //====================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------
4 //
5 // Generic cylindric shell detector to be used to measure
6 // e.g. escape energy from calorimeters.
7 //
8 // Author : M.Frank
9 //
10 //====================================================================
11 
12 /*
13  Example XML:
14 
15  <detector id="2" name="ContainmentShell" type="ZylinderShell" vis="VisibleRed" readout="ContainmentHits" >
16  <comment>Containment shell to measure calorimeter escapes</comment>
17  <material name="Air"/>
18  <module name="Barrel" id="0" vis="VisibleRed">
19  <zplane rmin="HcalBarrel_rmax+20*cm" rmax="HcalBarrel_rmax+22*cm" z="-2*HcalBarrel_zmax"/>
20  <zplane rmin="HcalBarrel_rmax+20*cm" rmax="HcalBarrel_rmax+22*cm" z="2*HcalBarrel_zmax"/>
21  </module>
22  <module name="SideA" id="1" vis="VisibleRed">
23  <zplane rmin="0" rmax="HcalBarrel_rmax+22*cm" z="2*HcalBarrel_zmax+10*cm"/>
24  <zplane rmin="0" rmax="HcalBarrel_rmax+22*cm" z="2*HcalBarrel_zmax+20*cm"/>
25  </module>
26  <module name="SideB" id="2" vis="VisibleRed">
27  <zplane rmin="0" rmax="HcalBarrel_rmax+22*cm" z="-(2*HcalBarrel_zmax+10*cm)"/>
28  <zplane rmin="0" rmax="HcalBarrel_rmax+22*cm" z="-(2*HcalBarrel_zmax+20*cm)"/>
29  </module>
30  </detector>
31  </detectors>
32 
33 to be joined by a sensitive detector:
34  <readouts>
35  <readout name="ContainmentHits">
36  <id>system:8,barrel:3</id>
37  </readout>
38  </readouts>
39 
40 
41 */
43 
44 using namespace std;
45 using namespace dd4hep;
46 using namespace dd4hep::detail;
47 
48 static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sensitive) {
49  xml_det_t x_det = e;
50  string name = x_det.nameStr();
51  DetElement sdet (name,x_det.id());
52  Assembly assembly(name+"_assembly");
53  Material mat (description.material(x_det.materialStr()));
54  PlacedVolume pv;
55 
56  sensitive.setType("escape_counter");
57  for(xml_coll_t xm(e,_U(module)); xm; ++xm) {
58  xml_comp_t mod = xm;
59  vector<double> rmin,rmax,z;
60  string vis = mod.visStr().empty() ? x_det.visStr() : mod.visStr();
61  int num = 0;
62  for(xml_coll_t c(mod,_U(zplane)); c; ++c, ++num) {
63  xml_comp_t dim(c);
64  rmin.push_back(dim.rmin());
65  rmax.push_back(dim.rmax());
66  z.push_back(dim.z()/2);
67  }
68  if ( num < 2 ) {
69  throw runtime_error("ZylinderShell["+name+"]> Not enough Z planes. minimum is 2!");
70  }
71  Polycone cone (0.,2*M_PI,rmin,rmax,z);
72  Volume volume(name, cone, mat);
73  volume.setVisAttributes(description, vis);
74  volume.setSensitiveDetector(sensitive);
75  pv = assembly.placeVolume(volume);
76  pv.addPhysVolID("barrel",mod.id());
77  }
78 
79  pv = description.pickMotherVolume(sdet).placeVolume(assembly);
80  pv.addPhysVolID("system",x_det.id());
81  sdet.setPlacement(pv);
82  return sdet;
83 }
84 
85 DECLARE_DETELEMENT(DD4hep_CylinderShell,create_detector)
dd4hep::xml::Collection_t
Class to support the access to collections of XmlNodes (or XmlElements)
Definition: XMLElements.h:636
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::Handle
Handle: a templated class like a shared pointer, which allows specialized access to tgeometry objects...
Definition: Handle.h:84
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::Assembly
Implementation class extending the ROOT assembly volumes (TGeoVolumeAssembly)
Definition: Volumes.h:762
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::Polycone
Class describing a Polycone shape.
Definition: Shapes.h:471
DetFactoryHelper.h
std
Definition: Plugins.h:30
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::SensitiveDetector::setType
SensitiveDetector & setType(const std::string &typ)
Set detector type (structure, tracker, calorimeter, etc.).
Definition: DetElement.cpp:403