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
CylinderShell_geo.cpp
Go to the documentation of this file.
1 // $Id$
2 //====================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------
5 //
6 // Generic cylindric shell detector to be used to measure
7 // e.g. escape energy from calorimeters.
8 //
9 // Author : M.Frank
10 //
11 //====================================================================
12 
13 /*
14  Example XML:
15 
16  <detector id="2" name="ContainmentShell" type="ZylinderShell" vis="VisibleRed" readout="ContainmentHits" >
17  <comment>Containment shell to measure calorimeter escapes</comment>
18  <material name="Air"/>
19  <module name="Barrel" id="0" vis="VisibleRed">
20  <zplane rmin="HcalBarrel_rmax+20*cm" rmax="HcalBarrel_rmax+22*cm" z="-2*HcalBarrel_zmax"/>
21  <zplane rmin="HcalBarrel_rmax+20*cm" rmax="HcalBarrel_rmax+22*cm" z="2*HcalBarrel_zmax"/>
22  </module>
23  <module name="SideA" id="1" vis="VisibleRed">
24  <zplane rmin="0" rmax="HcalBarrel_rmax+22*cm" z="2*HcalBarrel_zmax+10*cm"/>
25  <zplane rmin="0" rmax="HcalBarrel_rmax+22*cm" z="2*HcalBarrel_zmax+20*cm"/>
26  </module>
27  <module name="SideB" id="2" vis="VisibleRed">
28  <zplane rmin="0" rmax="HcalBarrel_rmax+22*cm" z="-(2*HcalBarrel_zmax+10*cm)"/>
29  <zplane rmin="0" rmax="HcalBarrel_rmax+22*cm" z="-(2*HcalBarrel_zmax+20*cm)"/>
30  </module>
31  </detector>
32  </detectors>
33 
34 to be joined by a sensitive detector:
35  <readouts>
36  <readout name="ContainmentHits">
37  <id>system:8,barrel:3</id>
38  </readout>
39  </readouts>
40 
41 
42 */
44 
45 using namespace std;
46 using namespace DD4hep;
47 using namespace DD4hep::Geometry;
48 
49 static Ref_t create_detector(LCDD& lcdd, xml_h e, SensitiveDetector sensitive) {
50  xml_det_t x_det = e;
51  string name = x_det.nameStr();
52  DetElement sdet (name,x_det.id());
53  Assembly assembly(name+"_assembly");
54  Material mat (lcdd.material(x_det.materialStr()));
55  PlacedVolume pv;
56 
57  sensitive.setType("escape_counter");
58  for(xml_coll_t m(e,_U(module)); m; ++m) {
59  xml_comp_t mod = m;
60  vector<double> rmin,rmax,z;
61  string vis = mod.visStr().empty() ? x_det.visStr() : mod.visStr();
62  int num = 0;
63  for(xml_coll_t c(m,_U(zplane)); c; ++c, ++num) {
64  xml_comp_t dim(c);
65  rmin.push_back(dim.rmin());
66  rmax.push_back(dim.rmax());
67  z.push_back(dim.z()/2);
68  }
69  if ( num < 2 ) {
70  throw runtime_error("ZylinderShell["+name+"]> Not enough Z planes. minimum is 2!");
71  }
72  Polycone cone (0.,2*M_PI,rmin,rmax,z);
73  Volume volume(name, cone, mat);
74  volume.setVisAttributes(lcdd, vis);
75  volume.setSensitiveDetector(sensitive);
76  pv = assembly.placeVolume(volume);
77  pv.addPhysVolID("barrel",mod.id());
78  }
79 
80  pv = lcdd.pickMotherVolume(sdet).placeVolume(assembly);
81  pv.addPhysVolID("system",x_det.id());
82  sdet.setPlacement(pv);
83  return sdet;
84 }
85 
86 DECLARE_DETELEMENT(DD4hep_CylinderShell,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
virtual Volume pickMotherVolume(const DetElement &sd) const =0
Access mother volume by detector element.
double rmax() const
Access min/max parameters: rmax.
double rmin() const
Access min/max parameters: rmin.
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
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
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
const Volume & setVisAttributes(const VisAttr &obj) const
Set Visualization attributes to the volume.
Definition: Volumes.cpp:564
double z() const
Access parameters: z.
int id() const
Access parameters: id.
Definition: XMLDetector.cpp:57
#define DECLARE_DETELEMENT(name, func)
Definition: Factories.h:248
XML Handle class extending the XML handle Dimension.
Definition: XMLDetector.h:39
static Ref_t create_detector(LCDD &lcdd, xml_h e, SensitiveDetector sensitive)
int id() const
Access parameters: id.
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
Class describing a Polycone shape.
Definition: Shapes.h:201
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.
TGeoShape TGeoMedium * m
Definition: Volumes.cpp:294
PlacedVolume placeVolume(const Volume &vol) const
Place daughter volume. The position and rotation are the identity.
Definition: Volumes.cpp:524