diff --git a/DDCore/include/DD4hep/ComponentProperties.h b/DDCore/include/DD4hep/ComponentProperties.h index c4cc87b6263f6a8f4f606ae71c58aeb794849ab5..aefcbf4e74d9c7432b9a14217870d824b7496d70 100644 --- a/DDCore/include/DD4hep/ComponentProperties.h +++ b/DDCore/include/DD4hep/ComponentProperties.h @@ -184,7 +184,7 @@ namespace dd4hep { */ template <class TYPE> class PropertyValue : private Property { public: - TYPE data; + TYPE data {}; /// Default constructor PropertyValue() : Property(data) {} /// Copy constructor diff --git a/DDCore/include/DD4hep/PluginTester.h b/DDCore/include/DD4hep/PluginTester.h index f1c83f91e9ddd83886176907beadd3f933273d29..1beed1f74059607c1da7b1ba457a31702ced5597 100644 --- a/DDCore/include/DD4hep/PluginTester.h +++ b/DDCore/include/DD4hep/PluginTester.h @@ -38,8 +38,8 @@ namespace dd4hep { /// Defintiion of the extension entry struct Entry { - destruct_t destruct; - int id; + destruct_t destruct = nullptr; + int id = -1; }; typedef std::map<const std::type_info*, Entry> ExtensionMap; diff --git a/DDCore/src/DetectorImp.cpp b/DDCore/src/DetectorImp.cpp index 16a2e0317e9a6eb43dcf8535b7b85d7d50fdfe85..2f4adc73cd7fd0636b026ff69f08a20b78551bd9 100644 --- a/DDCore/src/DetectorImp.cpp +++ b/DDCore/src/DetectorImp.cpp @@ -158,6 +158,9 @@ void Detector::destroyInstance(const std::string& name) { DetectorImp::DetectorImp() : TNamed(), DetectorData(), DetectorLoad(this), m_buildType(BUILD_NONE) { + m_std_conditions.convention = STD_Conditions::NTP; + m_std_conditions.pressure = Pressure_NTP; + m_std_conditions.temperature = Temperature_NTP; } /// Initializing constructor diff --git a/DDCore/src/PluginTester.cpp b/DDCore/src/PluginTester.cpp index 8607486f5112f62179b892784ffd58bb1842e5c8..f3df7da4512621b2626f6fcec88043e037f68723 100644 --- a/DDCore/src/PluginTester.cpp +++ b/DDCore/src/PluginTester.cpp @@ -25,13 +25,14 @@ namespace { static int s_extensionID = 0; PluginTester::ExtensionMap* extensionContainer(const std::type_info& typ) { static std::map<const std::type_info*, PluginTester::ExtensionMap> s_map; - return &s_map[&typ]; + PluginTester::ExtensionMap& m = s_map[&typ]; + return &m; } } /// Default constructor PluginTester::PluginTester() { - extensionMap = extensionContainer(typeid(*this)); + extensionMap = extensionContainer(typeid(PluginTester)); InstanceCount::increment(this); } diff --git a/DDCore/src/Volumes.cpp b/DDCore/src/Volumes.cpp index c2add7a18d94f9c652edc4760ccd0312ab9ad6f6..4041afc6acda82a6088cceae6937551be846c7f4 100644 --- a/DDCore/src/Volumes.cpp +++ b/DDCore/src/Volumes.cpp @@ -817,51 +817,56 @@ const Volume& Volume::setVisAttributes(const VisAttr& attr) const { if ( attr.isValid() ) { VisAttr::Object* vis = attr.data<VisAttr::Object>(); TColor* col = vis->color; - int draw_style = vis->drawingStyle; - int line_style = vis->lineStyle; - int col_num = col->GetNumber(); - int col_tr_num = vis->colortr->GetNumber(); - m_element->SetVisibility(vis->visible ? kTRUE : kFALSE); - m_element->SetVisContainers(kTRUE); - m_element->SetVisDaughters(vis->showDaughters ? kTRUE : kFALSE); - printout(DEBUG,"setVisAttributes", - "Set color %3d transparent(alpha:%.3f): %3d [%02X,%02X,%02X] DrawingStyle:%9s LineStyle:%6s for volume %s", - col_num, vis->alpha, col_tr_num, - col ? int(255*col->GetRed()) : 0xFF, - col ? int(255*col->GetGreen()) : 0xFF, - col ? int(255*col->GetBlue()) : 0xFF, - draw_style == VisAttr::SOLID ? "Solid" : "Wireframe", - line_style == VisAttr::SOLID ? "Solid" : "Dashed", - name() - ); - m_element->SetLineWidth(10); - m_element->SetLineColor(col_num); - m_element->SetFillColor(col_tr_num); - if (draw_style == VisAttr::SOLID) { - m_element->SetFillStyle(1001); // Root: solid + if ( col ) { + int draw_style = vis->drawingStyle; + int line_style = vis->lineStyle; + int col_num = col->GetNumber(); + int col_tr_num = vis->colortr->GetNumber(); + m_element->SetVisibility(vis->visible ? kTRUE : kFALSE); + m_element->SetVisContainers(kTRUE); + m_element->SetVisDaughters(vis->showDaughters ? kTRUE : kFALSE); + printout(DEBUG,"setVisAttributes", + "Set color %3d transparent(alpha:%.3f): %3d [%02X,%02X,%02X] DrawingStyle:%9s LineStyle:%6s for volume %s", + col_num, vis->alpha, col_tr_num, + int(255*col->GetRed()), + int(255*col->GetGreen()), + int(255*col->GetBlue()), + draw_style == VisAttr::SOLID ? "Solid" : "Wireframe", + line_style == VisAttr::SOLID ? "Solid" : "Dashed", + name() + ); + m_element->SetLineWidth(10); + m_element->SetLineColor(col_num); + m_element->SetFillColor(col_tr_num); + if (draw_style == VisAttr::SOLID) { + m_element->SetFillStyle(1001); // Root: solid #if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0) - // As suggested by Valentin Volkl https://sft.its.cern.ch/jira/browse/DDFORHEP-20 - // - // According to https://root.cern.ch/phpBB3/viewtopic.php?t=2309#p66013 - // a transparency>50 will make a volume invisible in the normal pad. - // Hence: possibly restrict transparency to a maximum of 50. - // but let's see first how this behaves. - m_element->SetTransparency((1.0-vis->alpha)*100); + // As suggested by Valentin Volkl https://sft.its.cern.ch/jira/browse/DDFORHEP-20 + // + // According to https://root.cern.ch/phpBB3/viewtopic.php?t=2309#p66013 + // a transparency>50 will make a volume invisible in the normal pad. + // Hence: possibly restrict transparency to a maximum of 50. + // but let's see first how this behaves. + m_element->SetTransparency((1.0-vis->alpha)*100); #endif + } + else { + printout(DEBUG,"setVisAttributes","Set to wireframe vis:%s",name()); + m_element->SetLineColor(kBlack); + m_element->SetFillColor(0); + m_element->SetFillStyle(0); // Root: hollow + } + if (line_style == VisAttr::SOLID) // Root line style: 1=solid, 2=dash, 3=dot, 4=dash-dot. + m_element->SetLineStyle(1); + else if (line_style == VisAttr::DASHED) + m_element->SetLineStyle(2); + else + m_element->SetLineStyle(line_style); } - else { - printout(DEBUG,"setVisAttributes","Set to wireframe vis:%s",name()); - m_element->SetLineColor(kBlack); - m_element->SetFillColor(0); - m_element->SetFillStyle(0); // Root: hollow + else { + except("Volume","setVisAttributes: encountered valid, but badly initialized visattr: %s",attr.name()); } - if (line_style == VisAttr::SOLID) // Root line style: 1=solid, 2=dash, 3=dot, 4=dash-dot. - m_element->SetLineStyle(1); - else if (line_style == VisAttr::DASHED) - m_element->SetLineStyle(2); - else - m_element->SetLineStyle(line_style); } Volume::Object* o = _userExtension(*this); if ( o ) o->vis = attr; diff --git a/DDCore/src/gdml/DetElementCreator.cpp b/DDCore/src/gdml/DetElementCreator.cpp index 2edefa2c1132bc6cb648fe5366c883d5321b775f..f339514d921f2094b32d233824e336d230859bab 100644 --- a/DDCore/src/gdml/DetElementCreator.cpp +++ b/DDCore/src/gdml/DetElementCreator.cpp @@ -226,13 +226,21 @@ DetElementCreator::~DetElementCreator() { printout(INFO,"",str.str().c_str()); char volid[32]; for(auto& p : all_placements ) { - PlacedVolume place = p.first; - Volume vol = place.volume(); - ::snprintf(volid,sizeof(volid),"Lv%d", p.second.first); - printout(DEBUG,pref, "DetElementCreator: ++ Set volid (%-24s): %-6s = %3d -> %s (%p)", - vol.isSensitive() ? vol.sensitiveDetector().name() : "Not Sensitive", - volid, p.second.second, place.name(), place.ptr()); - place.addPhysVolID(volid, p.second.second); + try { + PlacedVolume place = p.first; + Volume vol = place.volume(); + ::snprintf(volid,sizeof(volid),"Lv%d", p.second.first); + printout(DEBUG,pref, "DetElementCreator: ++ Set volid (%-24s): %-6s = %3d -> %s (%p)", + vol.isSensitive() ? vol.sensitiveDetector().name() : "Not Sensitive", + volid, p.second.second, place.name(), place.ptr()); + place.addPhysVolID(volid, p.second.second); + } + catch(const exception& e) { + except(pref, "DetElementCreator: Exception on destruction: %s", e.what()); + } + catch(...) { + except(pref, "DetElementCreator: UNKNOWN Exception on destruction."); + } } printout(ALWAYS, pref, "DetElementCreator: ++ Instrumented %ld subdetectors with %d " "DetElements %d sensitives out of %d volumes and %ld sensitive placements.", diff --git a/DDCore/src/plugins/ShapePlugins.cpp b/DDCore/src/plugins/ShapePlugins.cpp index af394f5d7edef4fea4b26664205d5a1d0a19661c..bc8d79ce4384449dade78c8a68b94eb21d13fe0d 100644 --- a/DDCore/src/plugins/ShapePlugins.cpp +++ b/DDCore/src/plugins/ShapePlugins.cpp @@ -405,9 +405,11 @@ static Handle<TObject> create_TessellatedSolid(Detector&, xml_h element) { if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); for ( xml_coll_t facet(element, _U(facet)); facet; ++facet ) { xml_dim_t f(facet); - int i0 = f.attr<int>(_U(v0)), i1 = f.attr<int>(_U(v1)), i2 = f.attr<int>(_U(v2)); + unsigned int i0 = f.attr<unsigned int>(_U(v0)); + unsigned int i1 = f.attr<unsigned int>(_U(v1)); + unsigned int i2 = f.attr<unsigned int>(_U(v2)); if ( f.hasAttr(_U(v3)) ) { - int i3 = f.attr<int>(_U(v3)); + unsigned int i3 = f.attr<unsigned int>(_U(v3)); solid.addFacet(vertices[i0], vertices[i1], vertices[i2], vertices[i3]); } else { diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp index 630ae7f130a3bfc297dc2828745686dfb3e9c4d5..3b22c1b4814468630cc95dddab4f1870934656e9 100644 --- a/DDCore/src/plugins/StandardPlugins.cpp +++ b/DDCore/src/plugins/StandardPlugins.cpp @@ -1125,7 +1125,8 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { } TGeoVolume* volume = ideal ? ideal->GetVolume() : 0; if ( !m_printSensitivesOnly || (m_printSensitivesOnly && sensitive) ) { - char sens = pv.volume().isSensitive() ? 'S' : ' '; + Volume vol = pv.volume(); + char sens = vol.isSensitive() ? 'S' : ' '; if ( m_printPointers ) { if ( ideal == aligned ) { ::snprintf(fmt,sizeof(fmt),"%03d %%s [Ideal:%p] %%-%ds %%-16s Vol:%%s shape:%%s \t %c %%s", @@ -1146,10 +1147,11 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { level+1,(void*)ideal,(void*)aligned,2*level+1,sens); } } + const auto* sh = volume ? volume->GetShape() : nullptr; printout(INFO,"VolumeDump",fmt,pref.c_str(),"", aligned->GetName(), - volume->GetName(), - volume ? volume->GetShape()->IsA()->GetName() : "[Invalid Volume]", + vol.name(), + sh ? sh->IsA()->GetName() : "[Invalid Shape]", opt_info.c_str()); if ( sens == 'S' ) ++m_numSensitive; } diff --git a/DDG4/include/DDG4/Geant4Action.h b/DDG4/include/DDG4/Geant4Action.h index 6fb9b6e3e9f396408d5820b638d6ce07ef18af55..29e074bcf919eef3da40ec0083ebeb3ac042fef6 100644 --- a/DDG4/include/DDG4/Geant4Action.h +++ b/DDG4/include/DDG4/Geant4Action.h @@ -329,6 +329,8 @@ namespace dd4hep { /// Support for messages with variable output level using output level+2 void printP2(const char* fmt, ...) const; + /// Support of always printed messages. + void always(const char* fmt, ...) const; /// Support of debug messages. void debug(const char* fmt, ...) const; /// Support of info messages. diff --git a/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp b/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp index 17c28d7ec52a506491629bdd2a60c4735c203ca7..ddfaead020c252031d87e4e4a409e9ff79f6937c 100644 --- a/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp +++ b/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp @@ -211,18 +211,19 @@ int Geant4DetectorGeometryConstruction::printMaterial(const char* mat_name) { for ( auto it = g4map.begin(); it != g4map.end(); ++it ) { const auto* mat = (*it).second; if ( mat->GetName() == mat_name ) { + stringstream output; const auto* ion = mat->GetIonisation(); printP2("+++ Dump of GEANT4 material: %s", mat_name); - cout << mat; + output << mat; if ( ion ) { - cout << " MEE: "; - cout << setprecision(12); - cout << ion->GetMeanExcitationEnergy()/CLHEP::eV; - cout << " [eV]"; + output << " MEE: "; + output << setprecision(12); + output << ion->GetMeanExcitationEnergy()/CLHEP::eV; + output << " [eV]"; } else - cout << " MEE: UNKNOWN"; - cout << endl << endl; + output << " MEE: UNKNOWN"; + always("+++ printMaterial: \n%s\n", output.str().c_str()); return 1; } } diff --git a/DDG4/src/Geant4Action.cpp b/DDG4/src/Geant4Action.cpp index 5f0195c43dcd528368a6acf93f63c6d6990e2a86..b1a810adbbd1ea74a4e461c89d9c46db35a2dd26 100644 --- a/DDG4/src/Geant4Action.cpp +++ b/DDG4/src/Geant4Action.cpp @@ -204,6 +204,14 @@ void Geant4Action::printP2(const char* fmt, ...) const { } } +/// Support of always printed messages. +void Geant4Action::always(const char* fmt, ...) const { + va_list args; + va_start(args, fmt); + dd4hep::printout(dd4hep::ALWAYS, m_name, fmt, args); + va_end(args); +} + /// Support of debug messages. void Geant4Action::debug(const char* fmt, ...) const { va_list args;