/// Callback to output PlacedVolume information of an single Placement int VisMaterialProcessor::operator()(PlacedVolume pv, int /* level */) { Volume vol = pv.volume(); double frac_active = 0.0; VisAttr attr; for ( Atom atom : activeElements ) { frac_active += vol.material().fraction(atom); } //if ( frac_active >= fraction ) printout(DEBUG,name, "++ Volume:%s [%s] active:%s fraction:%.3f active-vis:%s inactive-vis:%s", pv.name(), vol.name(), yes_no(frac_active >= fraction), frac_active, yes_no(activeVis.isValid()), yes_no(inactiveVis.isValid())); if ( activeVis.isValid() ) { if ( frac_active >= fraction ) { attr = activeVis; ++numActive; } if ( !attr.isValid() ) { for ( Material mat : activeMaterials ) { if ( mat.ptr() == vol.material().ptr() ) { attr = activeVis; ++numActive; break; } } } } // If we get here, the material is definitely inactive if ( inactiveVis.isValid() ) { if ( !attr.isValid() && setAllInactive ) { attr = inactiveVis; ++numInactive; } else if ( frac_active<fraction ) { attr = inactiveVis; ++numInactive; } if ( !attr.isValid() && inactiveVis.isValid() ) { for ( Material imat : inactiveMaterials ) { if ( imat.ptr() == vol.material().ptr() ) { attr = inactiveVis; ++numInactive; break; } } } } if ( attr.isValid() ) { set_attr(vol,attr); } return 1; }
static void* create_object(Detector& description, int argc, char** argv) { DetectorHelper helper(description); VisDensityProcessor* proc = new VisDensityProcessor(description); for ( int i=0; i<argc; ++i ) { if ( argv[i] ) { if ( ::strncmp(argv[i],"-vis",6) == 0 ) { VisAttr vis = description.visAttributes(argv[++i]); if ( vis.isValid() ) proc->minVis = vis; continue; } else if ( ::strncmp(argv[i],"-min-vis",6) == 0 ) { VisAttr vis = description.visAttributes(argv[++i]); if ( vis.isValid() ) proc->minVis = vis; continue; } else if ( ::strncmp(argv[i],"-min-density",6) == 0 ) { double density = _toDouble(argv[++i]); proc->minDensity = density; continue; } else if ( ::strncmp(argv[i],"-name",4) == 0 ) { string name = argv[++i]; proc->name = name; continue; } else if ( ::strncmp(argv[i],"-show",4) == 0 ) { proc->show = true; continue; } cout << "Usage: DD4hep_VisDensityProcessor -arg [-arg] \n" " -vis <name> Set the visualization attribute for inactive materials\n" " -min-vis <name> Set the visualization attribute for inactive materials\n" " -min-density <number> Minimal density to show the volume. \n" " -show Print setup to output device (stdout) \n" "\tArguments given: " << arguments(argc,argv) << endl << flush; ::exit(EINVAL); } } proc->_show(); PlacedVolumeProcessor* placement_proc = proc; return (void*)placement_proc; }
static void* create_object(Detector& description, int argc, char** argv) { DetectorHelper helper(description); VisMaterialProcessor* proc = new VisMaterialProcessor(description); for ( int i=0; i<argc; ++i ) { if ( argv[i] ) { if ( ::strncmp(argv[i],"-vis-active",6) == 0 ) { VisAttr vis = description.visAttributes(argv[++i]); if ( vis.isValid() ) proc->activeVis = vis; continue; } else if ( ::strncmp(argv[i],"-vis-inactive",6) == 0 ) { VisAttr vis = description.visAttributes(argv[++i]); if ( vis.isValid() ) proc->inactiveVis = vis; continue; } else if ( ::strncmp(argv[i],"-elt-active",6) == 0 ) { Atom atom = helper.element(argv[++i]); if ( atom.isValid() ) proc->activeElements.push_back(atom); continue; } else if ( ::strncmp(argv[i],"-mat-active",6) == 0 ) { Material mat = helper.material(argv[++i]); if ( mat.isValid() ) proc->activeMaterials.push_back(mat); continue; } else if ( ::strncmp(argv[i],"-mat-inactive",6) == 0 ) { Material mat = helper.material(argv[++i]); if ( mat.isValid() ) proc->inactiveMaterials.push_back(mat); continue; } else if ( ::strncmp(argv[i],"-all-inactive",6) == 0 ) { proc->setAllInactive = true; continue; } else if ( ::strncmp(argv[i],"-fraction",3) == 0 ) { stringstream str(argv[++i]); if ( str.good() ) { str >> proc->fraction; if ( !str.fail() ) continue; } } else if ( ::strncmp(argv[i],"-path",4) == 0 ) {
GeoHandler& GeoHandler::collect(DetElement element, GeometryInfo& info) { m_data->clear(); i_collect(element.placement().ptr(), 0, Region(), LimitSet()); for (Data::const_reverse_iterator i = m_data->rbegin(); i != m_data->rend(); ++i) { const Data::mapped_type& mapped = (*i).second; for (Data::mapped_type::const_iterator j = mapped.begin(); j != mapped.end(); ++j) { const TGeoNode* n = *j; TGeoVolume* v = n->GetVolume(); if (v) { Material m(v->GetMedium()); Volume vol = Ref_t(v); // Note : assemblies and the world do not have a real volume nor a material if (info.volumeSet.find(vol) == info.volumeSet.end()) { info.volumeSet.insert(vol); info.volumes.push_back(vol); } if (m.isValid()) info.materials.insert(m); if (dynamic_cast<Volume::Object*>(v)) { VisAttr vis = vol.visAttributes(); //Region reg = vol.region(); //LimitSet lim = vol.limitSet(); //SensitiveDetector det = vol.sensitiveDetector(); if (vis.isValid()) info.vis.insert(vis); //if ( lim.isValid() ) info.limits[lim.ptr()].insert(v); //if ( reg.isValid() ) info.regions[reg.ptr()].insert(v); //if ( det.isValid() ) info.sensitives[det.ptr()].insert(v); } collectSolid(info, v->GetName(), n->GetName(), v->GetShape(), n->GetMatrix()); } } } return *this; }