DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
VolumeAssembly_geo.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 // Author : M.Frank
11 //
12 //==========================================================================
13 //
14 // Specialized generic detector constructor
15 //
16 //==========================================================================
18 #include "DD4hep/Printout.h"
19 #include "XML/VolumeBuilder.h"
20 #include "XML/Utilities.h"
21 #include <memory>
22 
23 using namespace std;
24 using namespace dd4hep;
25 using namespace dd4hep::detail;
26 
27 static Ref_t create_element(Detector& description, xml_h e, SensitiveDetector sens) {
28  //Builder b(description);
29  //return b.create(e, sens);
30  xml_comp_t x_det(e);
31  xml_comp_t x_env = e.child(_U(envelope));
32  xml_comp_t x_shp = x_env.child(_U(shape),false);
33  xml_h x_dbg = e.child(_U(debug),false);
34  xml_h x_pos, x_rot, x_tr;
35  Volume assembly;
36  xml::tools::VolumeBuilder builder(description, e, sens);
37 
38  builder.debug = x_dbg != 0;
39  builder.load(x_det, "include");
40  builder.buildShapes(x_det);
41  builder.buildShapes(x_env);
42  builder.buildVolumes(x_det);
43  builder.buildVolumes(x_env);
44 
45  // Now we build the envelope
46  if ( !x_shp ) x_shp = x_env;
47  if ( x_shp.typeStr() == "Assembly" ) {
48  assembly = Assembly("lv"+builder.name);
49  }
50  else {
51  Material mat = description.material(x_env.materialStr());
52  Solid solid = xml::createShape(description, x_shp.typeStr(), x_shp);
53  assembly = Volume("lv"+builder.name, solid, mat);
54  }
56  assembly.setAttributes(description,x_det.regionStr(),x_det.limitsStr(),x_det.visStr());
58  if ( x_env.hasAttr(_U(vis)) )
59  assembly.setVisAttributes(description, x_env.visStr());
60 
61  if ( x_env.hasAttr(_U(region)) )
62  assembly.setRegion(description, x_env.regionStr());
63 
64  if ( x_env.hasAttr(_U(limits)) )
65  assembly.setLimitSet(description, x_env.limitsStr());
66 
67  if ( x_det.hasAttr(_U(sensitive)) )
68  sens.setType(x_det.attr<string>(_U(sensitive)));
69  else
70  builder.detector.setType("compound");
71 
72  if ( x_env.hasAttr(_U(name)) )
73  assembly->SetName(x_env.nameStr().c_str());
74 
75  builder.placeDaughters(builder.detector, assembly, x_env);
76  builder.placeDaughters(builder.detector, assembly, x_det);
77  x_pos = x_env.child(_U(position),false);
78  x_rot = x_env.child(_U(rotation),false);
79  x_tr = x_env.child(_U(transformation),false);
80  builder.placeDetector(assembly, (x_pos || x_rot || x_tr) ? x_env : x_det);
81  printout(builder.debug ? ALWAYS : DEBUG, "VolumeBuilder",
82  "+++ Created subdetector instance %s vis:",
83  builder.name.c_str(), x_det.visStr().c_str());
84  return builder.detector;
85 }
86 DECLARE_DETELEMENT(DD4hep_VolumeAssembly,create_element)
dd4hep::Volume::setLimitSet
const Volume & setLimitSet(const Detector &description, const std::string &name) const
Set the limits to the volume. Note: If the name string is empty, the action is ignored.
Definition: Volumes.cpp:1261
dd4hep::xml::tools::VolumeBuilder
Helper class to build volume and shapes according to ertain patterns in the XML tree.
Definition: VolumeBuilder.h:140
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
dd4hep::debug
std::size_t debug(const std::string &src, const std::string &msg)
Definition: RootDictionary.h:64
dd4hep::Handle< NamedObject >
dd4hep::Volume::setRegion
const Volume & setRegion(const Detector &description, const std::string &name) const
Set the regional attributes to the volume. Note: If the name string is empty, the action is ignored.
Definition: Volumes.cpp:1242
dd4hep::Solid_type< TGeoShape >
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
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::Volume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:378
dd4hep::detail
DD4hep internal namespace.
Definition: Alignments.h:32
dd4hep::xml::createShape
Solid createShape(Detector &description, const std::string &shape_type, xml::Element element)
Create a solid shape using the plugin mechanism from the attributes of the XML element.
Definition: Utilities.cpp:84
_U
#define _U(a)
Definition: Tags.h:23
VolumeBuilder.h
dd4hep::xml::Handle_t::child
Handle_t child(const XmlChar *tag, bool throw_exception=true) const
Access a single child by its tag name (unicode)
Definition: XMLElements.cpp:710
DetFactoryHelper.h
std
Definition: Plugins.h:30
dd4hep::Volume::setVisAttributes
const Volume & setVisAttributes(const VisAttr &obj) const
Set Visualization attributes to the volume.
Definition: Volumes.cpp:1127
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::Volume::setAttributes
const Volume & setAttributes(const Detector &description, const std::string &region, const std::string &limits, const std::string &vis) const
Attach attributes to the volume.
Definition: Volumes.cpp:1200
Printout.h
Utilities.h
dd4hep::SensitiveDetector::setType
SensitiveDetector & setType(const std::string &typ)
Set detector type (structure, tracker, calorimeter, etc.).
Definition: DetElement.cpp:403