21 #include "TGeoManager.h"
22 #include "TGeoCompositeShape.h"
23 #include "TGeoBoolNode.h"
29 using namespace DD4hep::Geometry;
30 using namespace DD4hep;
34 void collectSolid(GeoHandler::GeometryInfo& geo,
const string& name,
const string& node, TGeoShape* shape,
36 if (0 == ::strncmp(shape->GetName(),
"TGeo", 4)) {
37 shape->SetName(name.c_str());
39 if (shape->IsA() == TGeoCompositeShape::Class()) {
40 const TGeoCompositeShape*
s = (
const TGeoCompositeShape*) shape;
41 const TGeoBoolNode*
boolean = s->GetBoolNode();
42 collectSolid(geo, name +
"_left", name +
"_left", boolean->GetLeftShape(),
boolean->GetLeftMatrix());
43 collectSolid(geo, name +
"_right", name +
"_right", boolean->GetRightShape(),
boolean->GetRightMatrix());
45 geo.solids.insert(shape);
46 geo.trafos.push_back(make_pair(node, matrix));
57 : m_propagateRegions(false), m_data(ptr) {
88 for (Data::const_reverse_iterator i =
m_data->rbegin(); i !=
m_data->rend(); ++i) {
89 const Data::mapped_type& mapped = (*i).second;
90 for (Data::mapped_type::const_iterator j = mapped.begin(); j != mapped.end(); ++j) {
91 const TGeoNode* n = *j;
92 TGeoVolume*
v = n->GetVolume();
103 if (dynamic_cast<Volume::Object*>(v)) {
104 VisAttr vis = vol.visAttributes();
110 info.
vis.insert(vis);
115 collectSolid(info, v->GetName(), n->GetName(), v->GetShape(), n->GetMatrix());
123 TGeoVolume* volume = current->GetVolume();
124 TObjArray* nodes = volume->GetNodes();
125 int num_children = nodes ? nodes->GetEntriesFast() : 0;
140 (*m_data)[level].insert(current);
142 if (num_children > 0) {
143 for (
int i = 0; i < num_children; ++i) {
144 TGeoNode* node = (TGeoNode*) nodes->At(i);
145 i_collect(node, level + 1, region, limits);
const Volume & setLimitSet(const LCDD &lcdd, const std::string &name) const
Set the limits to the volume. Note: If the name string is empty, the action is ignored.
bool setPropagateRegions(bool value)
Propagate regions. Returns the previous value.
Handle class describing a material.
bool isValid() const
Check the validity of the object held by the handle.
LimitSet limitSet() const
Access to the limit set.
GeoScan(DetElement e)
Initializing constructor.
GeoHandler()
Default constructor.
GeoHandler & i_collect(const TGeoNode *node, int level, Region rg, LimitSet ls)
Internal helper to collect geometry information from traversal.
T * ptr() const
Access to the held object.
Handle class holding a placed volume (also called physical volume)
GeoHandler & collect(DetElement top)
Collect geometry information from traversal.
virtual ~GeoScan()
Default destructor.
The base class for all DD4hep geometry crawlers.
virtual ~GeoHandler()
Default destructor.
Data * release()
Access to collected node list.
virtual GeoScan & operator()()
Work callback.
GeoHandler::Data * m_data
Data holder.
PlacedVolume placement() const
Access to the physical volume of this detector element.
Region region() const
Access to the handle to the region structure.
Handle< NamedObject > Ref_t
Default Ref_t definition describing named objects.
Geometry scanner (handle object)
std::map< int, std::set< const TGeoNode * > > Data
Handle class describing visualization attributes.
Handle class describing a detector element.
Handle class describing a set of limits as they are used for simulation.
Handle class describing a region as used in simulation.
const Volume & setRegion(const LCDD &lcdd, const std::string &name) const
Set the regional attributes to the volume. Note: If the name string is empty, the action is ignored...