diff --git a/DDCore/src/Plugins.cpp b/DDCore/src/Plugins.cpp index 8297424ffee7376dab240495b9369e0b1fefd91f..98cbd54a2118195e6a1c1af0903e0b02e3302244 100644 --- a/DDCore/src/Plugins.cpp +++ b/DDCore/src/Plugins.cpp @@ -119,7 +119,11 @@ namespace { plugin_name = "libDD4hepGaudiPluginMgr"; } #if !defined(DD4HEP_PARSERS_NO_ROOT) - gSystem->Load(plugin_name); + if ( 0 != gSystem->Load(plugin_name) ) { + string err = "Failed to load plugin manager library: "; + err += plugin_name; + throw runtime_error(err); + } #else handle = ::dlopen(plugin_name, RTLD_LAZY | RTLD_GLOBAL); #endif diff --git a/DDCore/src/gdml/ImportPlainRoot.cpp b/DDCore/src/gdml/ImportPlainRoot.cpp index fe2480a20c6873b9193de0ba4dcf50ff94540e50..68817d70cb52bdc39e239cd2c1798c7726680238 100644 --- a/DDCore/src/gdml/ImportPlainRoot.cpp +++ b/DDCore/src/gdml/ImportPlainRoot.cpp @@ -126,20 +126,20 @@ static long plain_root_dump(Detector& description, int argc, char** argv) { bool do_import = false; string input, in_obj = "Geometry", air, vacuum; for(int i = 0; i < argc && argv[i]; ++i) { - if ( 0 == ::strncmp("-input",argv[i],5) ) + if ( 0 == ::strncmp("-input",argv[i],5) && (i+1)<argc ) input = argv[++i]; - else if ( 0 == ::strncmp("-object",argv[i],5) ) + else if ( 0 == ::strncmp("-object",argv[i],5) && (i+1)<argc ) in_obj = argv[++i]; - else if ( 0 == ::strncmp("-air",argv[i],5) ) + else if ( 0 == ::strncmp("-air",argv[i],5) && (i+1)<argc ) air = argv[++i]; - else if ( 0 == ::strncmp("-vacuum",argv[i],5) ) + else if ( 0 == ::strncmp("-vacuum",argv[i],5) && (i+1)<argc ) vacuum = argv[++i]; - else if ( 0 == ::strncmp("-level",argv[i],5) ) + else if ( 0 == ::strncmp("-level",argv[i],5) && (i+1)<argc ) level = ::atol(argv[++i]); + else if ( 0 == ::strncmp("-print",argv[i],5) && (i+1)<argc ) + prt = decodePrintLevel(argv[++i]); else if ( 0 == ::strncmp("-import",argv[i],5) ) do_import = true; - else if ( 0 == ::strncmp("-print",argv[i],5) ) - prt = decodePrintLevel(argv[++i]); else goto Error; } diff --git a/DDG4/plugins/Geant4EventReaderHepMC.cpp b/DDG4/plugins/Geant4EventReaderHepMC.cpp index e1d0c75607e365d9b23383ee82ebfdcc828ef551..f3842e9a303d0c7f33f35e9f930acc2b39a0282b 100644 --- a/DDG4/plugins/Geant4EventReaderHepMC.cpp +++ b/DDG4/plugins/Geant4EventReaderHepMC.cpp @@ -309,10 +309,10 @@ void HepMC::fix_particles(EventStream& info) { for(id=v->out.begin(); id!=v->out.end();++id) { EventStream::Particles::iterator ipp = parts.find(*id); Geant4Particle* dau = ipp != parts.end() ? (*ipp).second : 0; - p->daughters.insert(*id); - if ( !p ) { + if ( !dau ) { cout << "ERROR: Invalid daughter particle: " << *id << endl; } + p->daughters.insert(*id); dau->parents.insert(p->id); } } diff --git a/DDG4/plugins/Geant4GDMLWriteAction.cpp b/DDG4/plugins/Geant4GDMLWriteAction.cpp index 5fb30f097f11e6377d3bd6f618a38b6e00dfd877..2c79155d43e151dc392de807c9f290b659c9a5ed 100644 --- a/DDG4/plugins/Geant4GDMLWriteAction.cpp +++ b/DDG4/plugins/Geant4GDMLWriteAction.cpp @@ -128,18 +128,19 @@ void Geant4GDMLWriteAction::installCommandMessenger() { /// Write geometry to GDML void Geant4GDMLWriteAction::writeGDML() { + string fname = m_output; struct stat buff; - if ( m_output.empty() ) { + if ( fname.empty() ) { error("+++ No GDML file name given. Please set the output file (property Output)"); return; } - if ( 0 == ::stat(m_output.c_str(), &buff) && !m_overWrite ) { + if ( 0 == ::stat(fname.c_str(), &buff) && !m_overWrite ) { error("+++ GDML file elready exists. Please set another output file (property Output)"); return; } - if ( 0 == ::stat(m_output.c_str(), &buff) && m_overWrite ) { - warning("+++ GDML file %s already exists. Overwriting existing file.", m_output.c_str()); - ::unlink(m_output.c_str()); + if ( 0 == ::stat(fname.c_str(), &buff) && m_overWrite ) { + warning("+++ GDML file %s already exists. Overwriting existing file.", fname.c_str()); + ::unlink(fname.c_str()); } unique_ptr<G4GDMLParser> parser(new G4GDMLParser()); parser->SetRegionExport(m_exportRegions != 0); @@ -147,8 +148,8 @@ void Geant4GDMLWriteAction::writeGDML() { #if G4VERSION_NUMBER>=1030 parser->SetSDExport(m_exportSensitiveDetectors != 0); #endif - info("+++ Writing GDML file: %s", m_output.c_str()); - parser->Write(m_output, context()->world()); + info("+++ Writing GDML file: %s", fname.c_str()); + parser->Write(fname, context()->world()); } #include "DDG4/Factories.h" diff --git a/DDG4/plugins/Geant4TrackerWeightedSD.cpp b/DDG4/plugins/Geant4TrackerWeightedSD.cpp index 22b408bab7a18f47e6e495e392b860ee1332bc37..0c2a831c2ac3ed36c35e3b04e83f08d57dddd139 100644 --- a/DDG4/plugins/Geant4TrackerWeightedSD.cpp +++ b/DDG4/plugins/Geant4TrackerWeightedSD.cpp @@ -406,24 +406,25 @@ namespace dd4hep { ///dumpStep void dumpStep(const Geant4StepHandler& h, const G4Step* s) { - std::cout << " ----- step in detector " << h.sdName( s->GetPreStepPoint() ) - << " prePos " << h.prePos() - << " postPos " << h.postPos() - << " preStatus " << h.preStepStatus() - << " postStatus " << h.postStepStatus() - << " preVolume " << h.volName( s->GetPreStepPoint() ) - << " postVolume " << h.volName( s->GetPostStepPoint() ) - << std::endl - << " momentum : " << std::scientific - << s->GetPreStepPoint()->GetMomentum()[0] << ", " - << s->GetPreStepPoint()->GetMomentum()[1]<< ", " - << s->GetPreStepPoint()->GetMomentum()[2] - << " / " - << s->GetPostStepPoint()->GetMomentum()[0] << ", " - << s->GetPostStepPoint()->GetMomentum()[1] << ", " - << s->GetPostStepPoint()->GetMomentum()[2] - << ", PDG: " << s->GetTrack()->GetDefinition()->GetPDGEncoding() - << std::endl ; + std::stringstream str; + str << " ----- step in detector " << h.sdName( s->GetPreStepPoint() ) + << " prePos " << h.prePos() + << " postPos " << h.postPos() + << " preStatus " << h.preStepStatus() + << " postStatus " << h.postStepStatus() + << " preVolume " << h.volName( s->GetPreStepPoint() ) + << " postVolume " << h.volName( s->GetPostStepPoint() ) + << std::endl + << " momentum : " << std::scientific + << s->GetPreStepPoint()->GetMomentum()[0] << ", " + << s->GetPreStepPoint()->GetMomentum()[1]<< ", " + << s->GetPreStepPoint()->GetMomentum()[2] + << " / " + << s->GetPostStepPoint()->GetMomentum()[0] << ", " + << s->GetPostStepPoint()->GetMomentum()[1] << ", " + << s->GetPostStepPoint()->GetMomentum()[2] + << ", PDG: " << s->GetTrack()->GetDefinition()->GetPDGEncoding(); + std::cout << str.str() << std::endl; } }; diff --git a/DDTest/src/test_cellDimensionsRPhi2.cc b/DDTest/src/test_cellDimensionsRPhi2.cc index 1565c4d32ea19653e052836a2c036eab093a67e0..7665b9b3f55ced5aa483bb1f6771b822cd82c685 100644 --- a/DDTest/src/test_cellDimensionsRPhi2.cc +++ b/DDTest/src/test_cellDimensionsRPhi2.cc @@ -1,6 +1,7 @@ #include "DDSegmentation/Segmentation.h" #include "DDSegmentation/PolarGridRPhi2.h" #include "DDSegmentation/PolarGridRPhi.h" +#include "DD4hep/Printout.h" #include "DD4hep/DDTest.h" #include <iostream> @@ -31,10 +32,17 @@ void testRPhi2(); void testRPhi(); int main() { - - testRPhi2(); - testRPhi(); - + using namespace dd4hep; + try { + testRPhi2(); + testRPhi(); + } + catch(const std::exception& e) { + printout(ERROR,"CellDimensions","+++ Caught unhandled exception: %s",e.what()); + } + catch(...) { + printout(ERROR,"CellDimensions","+++ Caught UNKNOWN unhandled exception."); + } return 0; } diff --git a/examples/DDDigi/src/DigiTestAction.cpp b/examples/DDDigi/src/DigiTestAction.cpp index 6ba3c8e02a26ba6152ed5e07415ebd8a77d039b7..c821b65d437b947216ab1f19032a8067caadc033 100644 --- a/examples/DDDigi/src/DigiTestAction.cpp +++ b/examples/DDDigi/src/DigiTestAction.cpp @@ -40,13 +40,9 @@ namespace dd4hep { /// Sleep period to fake execution [milliseconds] int m_sleep = 0; protected: - /// Inhibit copy constructor - DigiTestAction() = default; - /// Inhibit copy constructor - DigiTestAction(const DigiTestAction& copy) = delete; - /// Inhibit assignment operator - DigiTestAction& operator=(const DigiTestAction& copy) = delete; - + /// Define standard assignments and constructors + DDDIGI_DEFINE_ACTION_CONSTRUCTORS(DigiTestAction); + public: /// Standard constructor DigiTestAction(const DigiKernel& kernel, const std::string& nam);