diff --git a/DDCore/include/DD4hep/OpticalSurfaces.h b/DDCore/include/DD4hep/OpticalSurfaces.h index 31eb6f4fae1389123781988b41a72ecbe5d42ef6..77487a67aa4911dc846fafebd3eef46596fed6ce 100644 --- a/DDCore/include/DD4hep/OpticalSurfaces.h +++ b/DDCore/include/DD4hep/OpticalSurfaces.h @@ -27,6 +27,15 @@ namespace dd4hep { /// Class to support the handling of optical surfaces. /** + * Optical surfaces are "global" objects ie. they are attached to the + * TGeoManager of the Detector object. + * + * IF the optical surface is created locally in a detector constructor, + * and registered to the OpticalSurfaceManager, the surfaces are ALSO + * attached to the currently built detector. + * Alternatively the call + * OpticalSurfaceManager::registerSurfaces(DetElement subdetector) + * may be issued to attach then to the subdetector DetElement. * * \author M.Frank * \version 1.0 @@ -55,7 +64,7 @@ namespace dd4hep { template <typename Q> OpticalSurface(const Handle<Q>& e) : Handle<Object>(e) { } /// Initializing constructor. - OpticalSurface(Detector& description, + OpticalSurface(Detector& detector, const std::string& name, EModel model = Model::kMglisur, EFinish finish = Finish::kFpolished, @@ -90,7 +99,7 @@ namespace dd4hep { template <typename Q> SkinSurface(const Handle<Q>& e) : Handle<Object>(e) { } /// Initializing constructor. - SkinSurface(Detector& description, + SkinSurface(Detector& detector, DetElement de, const std::string& nam, OpticalSurface surf, @@ -129,7 +138,7 @@ namespace dd4hep { template <typename Q> BorderSurface(const Handle<Q>& e) : Handle<Object>(e) { } /// Initializing constructor: Creates the object and registers it to the manager - BorderSurface(Detector& description, + BorderSurface(Detector& detector, DetElement de, const std::string& nam, OpticalSurface surf, diff --git a/DDCore/src/OpticalSurfaces.cpp b/DDCore/src/OpticalSurfaces.cpp index 8979412ec60dee96b0ecd5bdc3b1db6f2efeaeab..f459af5c8a9e646c01b18112fc0ae0f252beb058 100644 --- a/DDCore/src/OpticalSurfaces.cpp +++ b/DDCore/src/OpticalSurfaces.cpp @@ -34,7 +34,7 @@ DD4HEP_INSTANTIATE_HANDLE(TGeoBorderSurface); DD4HEP_INSTANTIATE_HANDLE(TGeoOpticalSurface); /// Initializing constructor. -OpticalSurface::OpticalSurface(Detector& description, +OpticalSurface::OpticalSurface(Detector& detector, const string& full_name, EModel model, EFinish finish, @@ -42,17 +42,18 @@ OpticalSurface::OpticalSurface(Detector& description, double value) { unique_ptr<Object> s(new Object(full_name.c_str(), model, finish, type, value)); - description.surfaceManager().addOpticalSurface(m_element=s.release()); + //detector.surfaceManager().addOpticalSurface(m_element=s.release()); + detector.manager().AddOpticalSurface(m_element=s.release()); } /// Initializing constructor: Creates the object and registers it to the manager -SkinSurface::SkinSurface(Detector& description, DetElement de, const string& nam, OpticalSurface surf, Volume vol) +SkinSurface::SkinSurface(Detector& detector, DetElement de, const string& nam, OpticalSurface surf, Volume vol) { if ( de.isValid() ) { if ( vol.isValid() ) { if ( surf.isValid() ) { unique_ptr<Object> s(new Object(nam.c_str(), surf->GetName(), surf.ptr(), vol.ptr())); - description.surfaceManager().addSkinSurface(de, m_element=s.release()); + detector.surfaceManager().addSkinSurface(de, m_element=s.release()); return; } except("SkinSurface","++ Cannot create SkinSurface %s without valid optical surface!",nam.c_str()); @@ -74,7 +75,7 @@ Volume SkinSurface::volume() const { } /// Initializing constructor: Creates the object and registers it to the manager -BorderSurface::BorderSurface(Detector& description, +BorderSurface::BorderSurface(Detector& detector, DetElement de, const string& nam, OpticalSurface surf, @@ -85,7 +86,7 @@ BorderSurface::BorderSurface(Detector& description, if ( lft.isValid() && rht.isValid() ) { if ( surf.isValid() ) { unique_ptr<Object> s(new Object(nam.c_str(), surf->GetName(), surf.ptr(), lft.ptr(), rht.ptr())); - description.surfaceManager().addBorderSurface(de, m_element=s.release()); + detector.surfaceManager().addBorderSurface(de, m_element=s.release()); return; } except("BorderSurface","++ Cannot create BorderSurface %s without valid optical surface!",nam.c_str()); diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp index 7cbb18b4fec9d8b2ee10293d8a3bc983c6e6b3bc..e2ff3f86c8de0e25facff9212b690ab2ff02dccc 100644 --- a/DDCore/src/plugins/Compact2Objects.cpp +++ b/DDCore/src/plugins/Compact2Objects.cpp @@ -95,17 +95,21 @@ namespace { printout(ERROR, "Compact", msg.c_str()); throw runtime_error(msg); } - bool s_debug_readout = false; - bool s_debug_regions = false; - bool s_debug_limits = false; - bool s_debug_visattr = false; - bool s_debug_isotopes = false; - bool s_debug_elements = false; - bool s_debug_materials = false; - bool s_debug_segmentation = false; - bool s_debug_constants = false; - bool s_debug_include = false; - bool s_debug_matrix = false; + class DebugOptions { + public: + bool readout = false; + bool regions = false; + bool limits = false; + bool visattr = false; + bool isotopes = false; + bool elements = false; + bool materials = false; + bool segmentation = false; + bool constants = false; + bool includes = false; + bool matrix = false; + bool surface = false; + } s_debug; } static Ref_t create_ConstantField(Detector& /* description */, xml_h e) { @@ -250,20 +254,21 @@ DECLARE_XML_DOC_READER(compact,load_Compact) */ template <> void Converter<Debug>::operator()(xml_h e) const { for (xml_coll_t coll(e, _U(type)); coll; ++coll) { - string nam = coll.attr<string>(_U(name)); int val = coll.attr<int>(_U(value)); - if ( nam.substr(0,6) == "isotop" ) s_debug_isotopes = (0 != val); - else if ( nam.substr(0,6) == "elemen" ) s_debug_elements = (0 != val); - else if ( nam.substr(0,6) == "materi" ) s_debug_materials = (0 != val); - else if ( nam.substr(0,6) == "visatt" ) s_debug_visattr = (0 != val); - else if ( nam.substr(0,6) == "region" ) s_debug_regions = (0 != val); - else if ( nam.substr(0,6) == "readou" ) s_debug_readout = (0 != val); - else if ( nam.substr(0,6) == "limits" ) s_debug_limits = (0 != val); - else if ( nam.substr(0,6) == "segmen" ) s_debug_segmentation = (0 != val); - else if ( nam.substr(0,6) == "consta" ) s_debug_constants = (0 != val); - else if ( nam.substr(0,6) == "define" ) s_debug_constants = (0 != val); - else if ( nam.substr(0,6) == "includ" ) s_debug_include = (0 != val); - else if ( nam.substr(0,6) == "matrix" ) s_debug_matrix = (0 != val); + string nam = coll.attr<string>(_U(name)); + if ( nam.substr(0,6) == "isotop" ) s_debug.isotopes = (0 != val); + else if ( nam.substr(0,6) == "elemen" ) s_debug.elements = (0 != val); + else if ( nam.substr(0,6) == "materi" ) s_debug.materials = (0 != val); + else if ( nam.substr(0,6) == "visatt" ) s_debug.visattr = (0 != val); + else if ( nam.substr(0,6) == "region" ) s_debug.regions = (0 != val); + else if ( nam.substr(0,6) == "readou" ) s_debug.readout = (0 != val); + else if ( nam.substr(0,6) == "limits" ) s_debug.limits = (0 != val); + else if ( nam.substr(0,6) == "segmen" ) s_debug.segmentation = (0 != val); + else if ( nam.substr(0,6) == "consta" ) s_debug.constants = (0 != val); + else if ( nam.substr(0,6) == "define" ) s_debug.constants = (0 != val); + else if ( nam.substr(0,6) == "includ" ) s_debug.includes = (0 != val); + else if ( nam.substr(0,6) == "matrix" ) s_debug.matrix = (0 != val); + else if ( nam.substr(0,6) == "surfac" ) s_debug.surface = (0 != val); } } @@ -324,14 +329,14 @@ template <> void Converter<Constant>::operator()(xml_h e) const { Constant c(nam, val, typ); _toDictionary(nam, val, typ); description.addConstant(c); - if ( s_debug_constants ) { + if ( s_debug.constants ) { printout(ALWAYS, "Compact", "++ Converting constant %-16s = %-32s [%s]", nam.c_str(), val.c_str(), typ.c_str()); } return; } xml::DocumentHolder doc(xml::DocumentHandler().load(e, e.attr_value(_U(ref)))); - if ( s_debug_include ) { + if ( s_debug.includes ) { printout(ALWAYS, "Compact","++ Processing xml document %s.",doc.uri().c_str()); } xml_h root = doc.root(); @@ -401,7 +406,7 @@ template <> void Converter<Material>::operator()(xml_h e) const { cout << " Density Value raw:" << dens_val << " normalized:" << (dens_val*dens_unit) << endl; dens_val *= dens_unit; } - printout(s_debug_materials ? ALWAYS : DEBUG, "Compact", + printout(s_debug.materials ? ALWAYS : DEBUG, "Compact", "++ Converting material %-16s Density: %.3f.",matname, dens_val); #if 0 cout << "Gev " << xml::_toDouble(_Unicode(GeV)) << endl; @@ -527,12 +532,12 @@ template <> void Converter<Isotope>::operator()(xml_h e) const { string unit = atom.attr<string>(_U(unit)); double a = value * _multiply<double>(unit,"mol/g"); iso = new TGeoIsotope(nam.c_str(), z, n, a); - printout(s_debug_isotopes ? ALWAYS : DEBUG, "Compact", + printout(s_debug.isotopes ? ALWAYS : DEBUG, "Compact", "++ Converting isotope %-16s Z:%3d N:%3d A:%8.4f [g/mol]", iso->GetName(), iso->GetZ(), iso->GetN(), iso->GetA()); } else { - printout(s_debug_isotopes ? WARNING : DEBUG, "Compact", + printout(s_debug.isotopes ? WARNING : DEBUG, "Compact", "++ Isotope %-16s Z:%3d N:%3d A:%8.4f [g/mol] ALREADY defined. [Ignore definition]", iso->GetName(), iso->GetZ(), iso->GetN(), iso->GetA()); } @@ -566,7 +571,7 @@ template <> void Converter<Atom>::operator()(xml_h e) const { string unit = atom.attr<string>(_U(unit)); int z = elem.attr<int>(_U(Z)); double a = value*_multiply<double>(unit,"mol/g"); - printout(s_debug_elements ? ALWAYS : DEBUG, "Compact", + printout(s_debug.elements ? ALWAYS : DEBUG, "Compact", "++ Converting element %-16s [%-3s] Z:%3d A:%8.4f [g/mol]", name.c_str(), formula.c_str(), z, a); tab->AddElement(name.c_str(), formula.c_str(), z, a); @@ -586,12 +591,12 @@ template <> void Converter<Atom>::operator()(xml_h e) const { except("Compact","Element %s cannot be constructed. Isotope '%s' (fraction:%f) missing!", name.c_str(), ref.c_str(), frac); } - printout(s_debug_elements ? ALWAYS : DEBUG, "Compact", + printout(s_debug.elements ? ALWAYS : DEBUG, "Compact", "++ Converting element %-16s Add isotope: %-16s fraction:%.4f.", name.c_str(), ref.c_str(), frac); elt->AddIsotope(iso, frac); } - printout(s_debug_elements ? ALWAYS : DEBUG, "Compact", + printout(s_debug.elements ? ALWAYS : DEBUG, "Compact", "++ Converted element %-16s [%-3s] Z:%3d A:%8.4f [g/mol] with %d isotopes.", name.c_str(), formula.c_str(), elt->Z(), elt->A(), num_isotopes); } @@ -601,7 +606,7 @@ template <> void Converter<Atom>::operator()(xml_h e) const { } } else { - printout(s_debug_elements ? WARNING : DEBUG, "Compact", + printout(s_debug.elements ? WARNING : DEBUG, "Compact", "++ Element %-16s Z:%3d N:%3d A:%8.4f [g/mol] ALREADY defined. [Ignore definition]", elt->GetName(), elt->Z(), elt->N(), elt->A()); } @@ -619,13 +624,21 @@ template <> void Converter<OpticalSurface>::operator()(xml_h element) const { OpticalSurface::EFinish finish = OpticalSurface::Finish::kFpolished; OpticalSurface::EType type = OpticalSurface::Type::kTdielectric_metal; Double_t value = 0; - if ( (attr=e.attr<xml_attr_t>(_U(type))) ) type = OpticalSurface::Type::StringToType(e.attr<string>(attr).c_str()); - if ( (attr=e.attr<xml_attr_t>(_U(model))) ) model = OpticalSurface::Model::StringToModel(e.attr<string>(attr).c_str()); - if ( (attr=e.attr<xml_attr_t>(_U(finish))) ) finish = OpticalSurface::Finish::StringToFinish(e.attr<string>(attr).c_str()); + if ( (attr=e.attr<xml_attr_t>(_U(type))) ) type = (OpticalSurface::EType)e.attr<int>(attr); + if ( (attr=e.attr<xml_attr_t>(_U(model))) ) model = (OpticalSurface::EModel)e.attr<int>(attr); + if ( (attr=e.attr<xml_attr_t>(_U(finish))) ) finish = (OpticalSurface::EFinish)e.attr<int>(attr); if ( (attr=e.attr<xml_attr_t>(_U(value))) ) value = e.attr<double>(attr); OpticalSurface surf(description, e.attr<string>(_U(name)), model, finish, type, value); + if ( s_debug.surface ) { + printout(ALWAYS,"Compact","+++ Reading optical surface %s Typ:%d model:%d finish:%d value:%f", + e.attr<string>(_U(name)).c_str(), int(type), int(model), int(finish), value); + } for (xml_coll_t props(e, _U(property)); props; ++props) { surf->AddProperty(props.attr<string>(_U(name)).c_str(), props.attr<string>(_U(ref)).c_str()); + if ( s_debug.surface ) { + printout(ALWAYS,"Compact","+++ \t\t Property: %s -> %s", + props.attr<string>(_U(name)).c_str(), props.attr<string>(_U(ref)).c_str()); + } } } @@ -640,29 +653,27 @@ template <> void Converter<PropertyTable>::operator()(xml_h e) const { size_t cols = e.attr<long>(_U(coldim)); stringstream str(e.attr<string>(_U(values))); - if ( s_debug_matrix ) { - printout(ALWAYS,"Compact","+++ Reading proeprty table %s with %d columns.", + if ( s_debug.matrix ) { + printout(ALWAYS,"Compact","+++ Reading property table %s with %d columns.", e.attr<string>(_U(name)).c_str(), cols); } values.reserve(1024); while ( !str.eof() ) { str >> val; if ( !str.good() ) break; - if ( s_debug_matrix ) { + if ( s_debug.matrix ) { cout << " state:" << (str.good() ? "OK " : "BAD") << " '" << val << "'"; } values.push_back(_toDouble(val)); if ( 0 == (values.size()%cols) ) cout << endl; } - if ( s_debug_matrix ) { + if ( s_debug.matrix ) { cout << endl; } /// Create table and register table PropertyTable table(description, e.attr<string>(_U(name)), "", values.size()/cols, cols); for (size_t i=0, n=values.size(); i<n; ++i) table->Set(i/cols, i%cols, values[i]); - if ( s_debug_matrix ) - table->Print(); } #endif @@ -680,7 +691,7 @@ template <> void Converter<VisAttr>::operator()(xml_h e) const { float green = e.hasAttr(_U(g)) ? e.attr<float>(_U(g)) : 1.0f; float blue = e.hasAttr(_U(b)) ? e.attr<float>(_U(b)) : 1.0f; - printout(s_debug_visattr ? ALWAYS : DEBUG, "Compact", + printout(s_debug.visattr ? ALWAYS : DEBUG, "Compact", "++ Converting VisAttr structure: %-16s. R=%.3f G=%.3f B=%.3f", attr.name(), red, green, blue); attr.setColor(red, green, blue); @@ -727,7 +738,7 @@ template <> void Converter<Region>::operator()(xml_h elt) const { xml_attr_t store_secondaries = elt.attr_nothrow(_U(store_secondaries)); double ene = e.eunit(1.0), len = e.lunit(1.0); - printout(s_debug_regions ? ALWAYS : DEBUG, "Compact", + printout(s_debug.regions ? ALWAYS : DEBUG, "Compact", "++ Converting region structure: %s.",region.name()); if ( cut ) { region.setCut(elt.attr<double>(cut)*len); @@ -760,7 +771,7 @@ template <> void Converter<Segmentation>::operator()(xml_h seg) const { Segmentation segment(type, name, bitfield); if ( segment.isValid() ) { const DDSegmentation::Parameters& pars = segment.parameters(); - printout(s_debug_segmentation ? ALWAYS : DEBUG, "Compact", + printout(s_debug.segmentation ? ALWAYS : DEBUG, "Compact", "++ Converting segmentation structure: %s of type %s.",name.c_str(),type.c_str()); for(const auto p : pars ) { xml::Strng_t pNam(p->name()); @@ -775,7 +786,7 @@ template <> void Converter<Segmentation>::operator()(xml_h seg) const { } else if ( pType.compare("doublevec") == 0 ) { vector<double> valueVector; string par = seg.attr<string>(pNam); - printout(s_debug_segmentation ? ALWAYS : DEBUG, "Compact", + printout(s_debug.segmentation ? ALWAYS : DEBUG, "Compact", "++ Converting this string structure: %s.",par.c_str()); vector<string> elts = DDSegmentation::splitString(par); for (const string& spar : elts ) { @@ -816,7 +827,7 @@ template <> void Converter<Segmentation>::operator()(xml_h seg) const { xml::dump_tree(sub,tree); throw_print("Nested segmentations: Invalid key specification:"+tree.str()); } - printout(s_debug_segmentation ? ALWAYS : DEBUG,"Compact", + printout(s_debug.segmentation ? ALWAYS : DEBUG,"Compact", "++ Segmentation [%s/%s]: Add sub-segmentation %s [%s]", name.c_str(), type.c_str(), sub_seg->segmentation->name().c_str(), @@ -863,7 +874,7 @@ template <> void Converter<Readout>::operator()(xml_h e) const { ro.setIDDescriptor(opt.second); } - printout(s_debug_readout ? ALWAYS : DEBUG, + printout(s_debug.readout ? ALWAYS : DEBUG, "Compact", "++ Converting readout structure: %-16s. %s%s", ro.name(), id ? "ID: " : "", id ? id.text().c_str() : ""); @@ -891,7 +902,7 @@ template <> void Converter<Readout>::operator()(xml_h e) const { xml::dump_tree(e,tree); throw_print("Reaout: Invalid specificatrion for multiple hit collections."+tree.str()); } - printout(s_debug_readout ? ALWAYS : DEBUG,"Compact", + printout(s_debug.readout ? ALWAYS : DEBUG,"Compact", "++ Readout[%s]: Add hit collection %s [%s] %d-%d", ro.name(), coll_name.c_str(), coll_key.c_str(), key_min, key_max); HitCollection hits(coll_name, coll_key, key_min, key_max); @@ -910,7 +921,7 @@ template <> void Converter<Readout>::operator()(xml_h e) const { template <> void Converter<LimitSet>::operator()(xml_h e) const { Limit limit; LimitSet ls(e.attr<string>(_U(name))); - printout(s_debug_limits ? ALWAYS : DEBUG, "Compact", + printout(s_debug.limits ? ALWAYS : DEBUG, "Compact", "++ Converting LimitSet structure: %s.",ls.name()); for (xml_coll_t c(e, _U(limit)); c; ++c) { limit.name = c.attr<string>(_U(name)); @@ -1179,7 +1190,7 @@ template <> void Converter<DetElement>::operator()(xml_h element) const { template <> void Converter<GdmlFile>::operator()(xml_h element) const { xml::DocumentHolder doc(xml::DocumentHandler().load(element, element.attr_value(_U(ref)))); xml_h root = doc.root(); - if ( s_debug_include ) { + if ( s_debug.includes ) { printout(ALWAYS, "Compact","++ Processing xml document %s.",doc.uri().c_str()); } if ( root.tag() == "materials" || root.tag() == "elements" ) { @@ -1279,7 +1290,7 @@ template <> void Converter<DetElementInclude>::operator()(xml_h element) const { string type = element.hasAttr(_U(type)) ? element.attr<string>(_U(type)) : string("xml"); if ( type == "xml" ) { xml::DocumentHolder doc(xml::DocumentHandler().load(element, element.attr_value(_U(ref)))); - if ( s_debug_include ) { + if ( s_debug.includes ) { printout(ALWAYS, "Compact","++ Processing xml document %s.",doc.uri().c_str()); } xml_h node = doc.root(); diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp index 1610293e41d8f74ccc0202f54ecc578c74e52c55..4583514c365dd617741e6af6afcd3733cb345f7e 100644 --- a/DDCore/src/plugins/StandardPlugins.cpp +++ b/DDCore/src/plugins/StandardPlugins.cpp @@ -272,25 +272,57 @@ DECLARE_APPLY(DD4hep_InteractiveUI,root_ui) * \version 1.0 * \date 01/04/2014 */ -static long root_gdml_tables(Detector& description, int /* argc */, char** /* argv */) { +static long root_dump_gdml_tables(Detector& description, int /* argc */, char** /* argv */) { size_t num_tables = 0; size_t num_elements = 0; #if ROOT_VERSION_CODE > ROOT_VERSION(6,16,0) const TObjArray* c = description.manager().GetListOfGDMLMatrices(); TObjArrayIter arr(c); + printout(INFO,"Dump_GDMLTables","+++ Dumping known GDML tables from TGeoManager."); for(TObject* i = arr.Next(); i; i=arr.Next()) { TGDMLMatrix* m = (TGDMLMatrix*)i; num_elements += (m->GetRows()*m->GetCols()); ++num_tables; m->Print(); } +#else + description.world().isValid(); #endif printout(INFO,"Dump_GDMLTables", "+++ Successfully dumped %ld GDML tables with %ld elements.", num_tables, num_elements); return 1; } -DECLARE_APPLY(DD4hep_Dump_GDMLTables,root_gdml_tables) +DECLARE_APPLY(DD4hep_Dump_GDMLTables,root_dump_gdml_tables) + +/// Basic entry point to dump all known optical surfaces +/** + * + * Factory: DD4hep_Dump_OpticalSurfaces + * + * \author M.Frank + * \version 1.0 + * \date 01/04/2014 + */ +static long root_dump_optical_surfaces(Detector& description, int /* argc */, char** /* argv */) { + size_t num_surfaces = 0; +#if ROOT_VERSION_CODE > ROOT_VERSION(6,16,0) + const TObjArray* c = description.manager().GetListOfOpticalSurfaces(); + TObjArrayIter arr(c); + printout(INFO,"Dump_OpticalSurfaces","+++ Dumping known Optical Surfaces from TGeoManager."); + for(TObject* i = arr.Next(); i; i=arr.Next()) { + TGeoOpticalSurface* m = (TGeoOpticalSurface*)i; + ++num_surfaces; + m->Print(); + } +#else + description.world().isValid(); +#endif + printout(INFO,"Dump_OpticalSurfaces", + "+++ Successfully dumped %ld Optical surfaces.",num_surfaces); + return 1; +} +DECLARE_APPLY(DD4hep_Dump_OpticalSurfaces,root_dump_optical_surfaces) /// Basic entry point to dump the ROOT TGeoElementTable object /** diff --git a/examples/OpticalSurfaces/CMakeLists.txt b/examples/OpticalSurfaces/CMakeLists.txt index 9b83fb740211db30ec3e117ab7f37bd3c2c74e55..3a57a77de056d165c18fc688c3e312222af21e72 100644 --- a/examples/OpticalSurfaces/CMakeLists.txt +++ b/examples/OpticalSurfaces/CMakeLists.txt @@ -26,13 +26,26 @@ dd4hep_configure_scripts( OpticalSurfaces DEFAULT_SETUP WITH_TESTS) # message (STATUS "OpticalSurfaces: ROOT version: ${ROOT_VERSION}") # -#---Testing: Load Telescope geometry and read conditions ------------------ +#---Testing: Load ROOT GDMLMatrix objects from compact +# and register them to the TGeoManager dd4hep_add_test_reg( Surfaces_read_GDMLMatrix COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_OpticalSurfaces.sh" EXEC_ARGS geoPluginRun -volmgr -destroy - -compact file:${OpticalSurfaces_INSTALL}/compact/ReadGDMLMatrix.xml - -plugin DD4hep_DetectorDump + -compact file:${OpticalSurfaces_INSTALL}/compact/ReadGDMLMatrices.xml + -plugin DD4hep_Dump_GDMLTables REGEX_PASS "Successfully dumped 2 GDML tables with 42 elements." REGEX_FAIL " ERROR ;EXCEPTION;Exception" ) # +#---Testing: Load ROOT TGeoOpticalSurface objects from compact +# and register them to the TGeoManager +dd4hep_add_test_reg( Surfaces_read_OpticalSurfaces + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_OpticalSurfaces.sh" + EXEC_ARGS geoPluginRun -volmgr -destroy + -compact file:${OpticalSurfaces_INSTALL}/compact/ReadOpticalSurfaces.xml + -plugin DD4hep_Dump_GDMLTables + -plugin DD4hep_Dump_OpticalSurfaces + REGEX_PASS "Successfully dumped 2 Optical surfaces." + REGEX_FAIL " ERROR ;EXCEPTION;Exception" + ) +# diff --git a/examples/OpticalSurfaces/compact/ReadGDMLMatrices.xml b/examples/OpticalSurfaces/compact/ReadGDMLMatrices.xml index 15e6674867d7530eb07742e2bacba787b8d0b702..21d51841309c427dfe9cd59a165fedaf7933e848 100644 --- a/examples/OpticalSurfaces/compact/ReadGDMLMatrices.xml +++ b/examples/OpticalSurfaces/compact/ReadGDMLMatrices.xml @@ -2,13 +2,13 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> - <info name="TelescopeSensor" - title="Simple emulation of the EU Telescope" - author="Christoph Hombach" - url="https://github.com/AIDASoft/DD4hep/blob/master/examples/AlignDet/compact/Telescope.xml" + <info name="TestGDMLMatrices" + title="Test reading of TGeo's GDML matrices" + author="Markus Frank" + url="None" status="development" version="1.0"> - <comment>Simple emulation of the EU Telescope to test alignment procedures</comment> + <comment>Test reading of TGeo's GDML matrices</comment> </info> <includes> @@ -21,7 +21,6 @@ <constant name="world_x" value="world_side/2"/> <constant name="world_y" value="world_side/2"/> <constant name="world_z" value="world_side/2"/> - <constant name="CrossingAngle" value="0.020"/> <constant name="PhotMomWaveConv" value="1243.125*eV"/> </define> <debug> @@ -29,114 +28,21 @@ <type name="surface" value="1"/> </debug> - <materials> - </materials> - - <limits> - </limits> - - <display> - <vis name="DetVis" alpha="1.0" r="0" g="0.0" b="1.0" showDaughters="true" visible="false"/> - <vis name="ModVis" alpha="0.3" r="0.8" g="0.8" b="1.0" showDaughters="true" visible="true"/> - - <vis name="SensorVis" alpha="1.0" r="1.0" g="0.2" b="0.2" showDaughters="false" visible="true"/> - <vis name="ChipVis" alpha="1.0" r="0.7451" g="0.7451" b="0.7451" showDaughters="false" visible="true"/> - <vis name="PCBVis" alpha="1.0" r="0.0000" g="0.3910" b="0.0000" showDaughters="false" visible="true"/> - </display> - - <properties> - <matrix name= "Someother_property" - coldim = "6" values=" - PhotMomWaveConv/100.0 0.0 1 2 3 4 - PhotMomWaveConv/190.0 0.0 1 2 3 4 - PhotMomWaveConv/200.0 0.0 1 2 3 4 - PhotMomWaveConv/220.0 0.0 1 2 3 4 - PhotMomWaveConv/240.0 0.0 1 2 3 4 - "/> - <matrix name= "Rich1Mirror2SurfaceEfficiencyPT" - coldim = "2" values=" - PhotMomWaveConv/100.0 0.0 - PhotMomWaveConv/190.0 0.0 - PhotMomWaveConv/200.0 0.0 - PhotMomWaveConv/220.0 0.0 - PhotMomWaveConv/240.0 0.0 - PhotMomWaveConv/260.0 0.0 - "/> - + <matrix name= "Someother_property" coldim="6" values=" + PhotMomWaveConv/100.0 0.0 1 2 3 4 + PhotMomWaveConv/190.0 0.0 1 2 3 4 + PhotMomWaveConv/200.0 0.0 1 2 3 4 + PhotMomWaveConv/220.0 0.0 1 2 3 4 + PhotMomWaveConv/240.0 0.0 1 2 3 4 + "/> + <matrix name= "Rich1Mirror2SurfaceEfficiencyPT" coldim="2" values=" + PhotMomWaveConv/100.0 0.0 + PhotMomWaveConv/190.0 0.0 + PhotMomWaveConv/200.0 0.0 + PhotMomWaveConv/220.0 0.0 + PhotMomWaveConv/240.0 0.0 + PhotMomWaveConv/260.0 0.0 + "/> </properties> - - <detectors> - <comment>No comment so far</comment> - - <detector name="Telescope" type="DD4hep_Example_Telescope" vis="DetVis" id ="3" readout="TelescopeHits"> - <!-- Front arm --> - <module z="0.0*cm" id="1" vis="ModVis"> - <sensor thickness="3*mm" pitch="55*micron" NoOfPixY="256" NoOfPixX="256" vis="SensorVis"/> - <chip thickness="7*mm" vis="ChipVis"/> - <PCB thickness="1.4*mm" vis="PCBVis"/> - </module> - - <module z="2.5*cm" id="2" vis="ModVis"> - <sensor thickness="300*micron" pitch="55*micron" NoOfPixY="256" NoOfPixX="256" vis="SensorVis"/> - <chip thickness="700*micron" vis="ChipVis"/> - <PCB thickness="1.4*mm" vis="PCBVis"/> - </module> - - <module z="5.0*cm" id="3" vis="ModVis"> - <sensor thickness="300*micron" pitch="55*micron" NoOfPixY="256" NoOfPixX="256" vis="SensorVis"/> - <chip thickness="700*micron" vis="ChipVis"/> - <PCB thickness="1.4*mm" vis="PCBVis"/> - </module> - - <module z="7.5*cm" id="4" vis="ModVis"> - <sensor thickness="300*micron" pitch="55*micron" NoOfPixY="256" NoOfPixX="256" vis="SensorVis"/> - <chip thickness="700*micron" vis="ChipVis"/> - <PCB thickness="1.4*mm" vis="PCBVis"/> - </module> - - <!-- DuT --> - <module z="25.0*cm" id="5" vis="ModVis"> - <sensor thickness="300*micron" pitch="55*micron" NoOfPixY="256" NoOfPixX="768" vis="SensorVis"/> - <chip thickness="700*micron" vis="ChipVis"/> - <PCB thickness="1.4*mm" vis="PCBVis"/> - </module> - - <!-- Back arm --> - <module z="42.5*cm" id="6" vis="ModVis"> - <sensor thickness="300*micron" pitch="55*micron" NoOfPixY="256" NoOfPixX="256" vis="SensorVis"/> - <chip thickness="700*micron" vis="ChipVis"/> - <PCB thickness="1.4*mm" vis="PCBVis"/> - </module> - - <module z="45.0*cm" id="7" vis="ModVis"> - <sensor thickness="300*micron" pitch="55*micron" NoOfPixY="256" NoOfPixX="256" vis="SensorVis"/> - <chip thickness="700*micron" vis="ChipVis"/> - <PCB thickness="1.4*mm" vis="PCBVis"/> - </module> - - <module z="47.5*cm" id="8" vis="ModVis"> - <sensor thickness="300*micron" pitch="55*micron" NoOfPixY="256" NoOfPixX="256" vis="SensorVis"/> - <chip thickness="700*micron" vis="ChipVis"/> - <PCB thickness="1.4*mm" vis="PCBVis"/> - </module> - - <module z="50.0*cm" id="9" vis="ModVis"> - <sensor thickness="300*micron" pitch="55*micron" NoOfPixY="256" NoOfPixX="256" vis="SensorVis"/> - <chip thickness="700*micron" vis="ChipVis"/> - <PCB thickness="1.4*mm" vis="PCBVis"/> - </module> - </detector> - </detectors> - - <readouts> - <readout name="TelescopeHits"> - <segmentation type="CartesianGridXY" grid_size_x="55*micron" grid_size_y="55*micron" /> - <id>system:8,module:10,sensor:10,x:16,y:16</id> - </readout> - </readouts> - - <fields> - </fields> - </lccdd> diff --git a/examples/OpticalSurfaces/compact/ReadOpticalSurfaces.xml b/examples/OpticalSurfaces/compact/ReadOpticalSurfaces.xml new file mode 100644 index 0000000000000000000000000000000000000000..843f49710e0790c82c06164d367995549191e4e5 --- /dev/null +++ b/examples/OpticalSurfaces/compact/ReadOpticalSurfaces.xml @@ -0,0 +1,61 @@ +<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> + + <info name="TestGDMLMatrices" + title="Test reading of TGeo's GDML matrices" + author="Markus Frank" + url="None" + status="development" + version="1.0"> + <comment>Test reading of TGeo's GDML matrices</comment> + </info> + + <includes> + <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/> + <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/materials.xml"/> + </includes> + + <define> + <constant name="world_side" value="1*m"/> + <constant name="world_x" value="world_side/2"/> + <constant name="world_y" value="world_side/2"/> + <constant name="world_z" value="world_side/2"/> + <constant name="PhotMomWaveConv" value="1243.125*eV"/> + </define> + <debug> + <type name="matrix" value="1"/> + <type name="surface" value="1"/> + </debug> + + <properties> + <matrix name= "REFLECTIVITY0x123aff00" coldim="2" values=" + PhotMomWaveConv/100.0 0.1 + PhotMomWaveConv/190.0 0.2 + PhotMomWaveConv/200.0 0.3 + PhotMomWaveConv/220.0 0.4 + PhotMomWaveConv/240.0 0.2 + PhotMomWaveConv/260.0 0.1 + "/> + <matrix name= "EFFICIENCY0x8b77240" coldim="2" values=" + PhotMomWaveConv/100.0 0.1 + PhotMomWaveConv/190.0 0.2 + PhotMomWaveConv/200.0 0.3 + PhotMomWaveConv/220.0 0.4 + PhotMomWaveConv/240.0 0.2 + PhotMomWaveConv/260.0 0.1 + "/> + </properties> + + <surfaces> + <opticalsurface finish="0" model="0" name="OpticalSurface#1" type="1" value="0"> + <property name="REFLECTIVITY" ref="REFLECTIVITY0x123aff00"/> + <property name="EFFICIENCY" ref="EFFICIENCY0x8b77240"/> + </opticalsurface> + <opticalsurface finish="0" model="0" name="OpticalSurface#2" type="1" value="1"> + <property name="REFLECTIVITY" ref="REFLECTIVITY0x123aff00"/> + <property name="EFFICIENCY" ref="EFFICIENCY0x8b77240"/> + </opticalsurface> + </surfaces> + +</lccdd>