/* * Returns the closest detector element in the hierarchy for a given global position */ DetElement IDDecoder::detectorElement(const Position& pos) const { DetElement world = Geometry::LCDD::getInstance().world(); DetElement det = getClosestDaughter(world, pos); if (not det.isValid()) { throw invalid_position("DD4hep::DDRec::IDDecoder::detectorElement", pos); } std::cout << det.name() << std::endl; return det; }
/// Access mother volume by detector element Volume LCDDImp::pickMotherVolume(const DetElement& de) const { if ( de.isValid() ) { string de_name = de.name(); HandleMap::const_iterator i = m_motherVolumes.find(de_name); if (i == m_motherVolumes.end()) { return m_worldVol; } return (*i).second; } throw runtime_error("LCDD: Attempt access mother volume of invalid detector [Invalid-handle]"); }
/// Dump method. virtual int operator()(DetElement de,int level) const { const DetElement::Children& children = de.children(); PlacedVolume place = de.placement(); char sens = place.volume().isSensitive() ? 'S' : ' '; char fmt[128], tmp[32]; ::snprintf(tmp,sizeof(tmp),"%03d/",level+1); ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%s #Dau:%%d VolID:%%08X %%c",level+1,2*level+1); printout(INFO,"DetectorDump",fmt,"",de.path().c_str(),int(children.size()), (unsigned long)de.volumeID(), sens); printer.prefix = string(tmp)+de.name(); (printer)(de, level); return 1; }
/// Given a detector element, access it's sensitive detector (if the sub-detector is sensitive!) SensitiveDetector LCDDHelper::sensitiveDetector(DetElement detector) const { for(DetElement par = detector; par.isValid(); par = par.parent()) { if ( par.ptr() != ptr()->world().ptr() ) { PlacedVolume pv = par.placement(); if ( pv.isValid() ) { const PlacedVolume::VolIDs& ids = pv.volIDs(); for(PlacedVolume::VolIDs::const_iterator i=ids.begin(); i!=ids.end();++i) { if ( (*i).first == "system" ) { return sensitiveDetector(par.name()); } } } } } return SensitiveDetector(0); }
/// Load 'levels' Children into the geometry scene void Display::LoadGeoChildren(TEveElement* start, int levels, bool redraw) { using namespace DD4hep::Geometry; DetElement world = m_lcdd->world(); if ( world.children().size() == 0 ) { MessageBox(INFO,"It looks like there is no\nGeometry loaded.\nNo event display availible.\n"); } else if ( levels > 0 ) { if ( 0 == start ) { TEveElementList& sens = GetGeoTopic("Sensitive"); TEveElementList& struc = GetGeoTopic("Structure"); const DetElement::Children& c = world.children(); printout(INFO,"Display","+++ Load children of %s to %d levels", world.placement().name(), levels); for (DetElement::Children::const_iterator i = c.begin(); i != c.end(); ++i) { DetElement de = (*i).second; SensitiveDetector sd = m_lcdd->sensitiveDetector(de.name()); TEveElementList& parent = sd.isValid() ? sens : struc; pair<bool,TEveElement*> e = Utilities::LoadDetElement(de,levels,&parent); if ( e.second && e.first ) { parent.AddElement(e.second); } } } else { TGeoNode* n = (TGeoNode*)start->GetUserData(); printout(INFO,"Display","+++ Load children of %s to %d levels",Utilities::GetName(start),levels); if ( 0 != n ) { TGeoHMatrix mat; const char* node_name = n->GetName(); int level = Utilities::findNodeWithMatrix(lcdd().world().placement().ptr(),n,&mat); if ( level > 0 ) { pair<bool,TEveElement*> e(false,0); const DetElement::Children& c = world.children(); for (DetElement::Children::const_iterator i = c.begin(); i != c.end(); ++i) { DetElement de = (*i).second; if ( de.placement().ptr() == n ) { e = Utilities::createEveShape(0, levels, start, n, mat, de.name()); break; } } if ( !e.first && !e.second ) { e = Utilities::createEveShape(0, levels, start, n, mat, node_name); } if ( e.first ) { // newly created start->AddElement(e.second); } printout(INFO,"Display","+++ Import geometry node %s with %d levels.",node_name, levels); } else { printout(INFO,"Display","+++ FAILED to import geometry node %s with %d levels.",node_name, levels); } } else { LoadGeoChildren(0,levels,false); } } } if ( redraw ) { manager().Redraw3D(); } }
/// Add skin surface to manager void OpticalSurfaceManager::addSkinSurface(DetElement de, SkinSurface surf) const { if ( access()->skinSurfaces.insert(make_pair(make_pair(de,surf->GetName()), surf)).second ) return; except("OpticalSurfaceManager","++ Skin surface %s already present for DE:%s.", surf->GetName(), de.name()); }