diff --git a/DDCAD/src/ASSIMPWriter.cpp b/DDCAD/src/ASSIMPWriter.cpp index 4b8ddbcba776b1e642c44b5e437d7ce9c32df70b..d098098e4d2352398dd486720a841f492e14961f 100644 --- a/DDCAD/src/ASSIMPWriter.cpp +++ b/DDCAD/src/ASSIMPWriter.cpp @@ -47,14 +47,15 @@ namespace { for(Int_t i=0; i<v->GetNdaughters(); ++i) { PlacedVolume p = v->GetNode(i); Solid sol = p.volume().solid(); + bool use = sol->IsA() != TGeoShapeAssembly::Class(); unique_ptr<TGeoHMatrix> mother(new TGeoHMatrix(to_global)); mother->Multiply(p->GetMatrix()); - if ( sol->IsA() != TGeoShapeAssembly::Class() ) + if ( use ) cont.push_back(make_pair(p, mother.get())); if ( recursive ) _collect(cont, recursive, *mother, p); - if ( sol->IsA() != TGeoShapeAssembly::Class() ) + if ( use ) mother.release(); } } @@ -433,6 +434,7 @@ int ASSIMPWriter::write(const std::string& file_name, if ( mesh->mFaces ) delete [] mesh->mFaces; mesh->mFaces = nullptr; mesh->mNumFaces = 0; + delete mesh; continue; } diff --git a/DDCore/src/AlignmentsCalculator.cpp b/DDCore/src/AlignmentsCalculator.cpp index 6436110b81bc2843af66895bf80a5730bc4e6d58..f9710d840dade2520e661c28832317b7d2f85a67 100644 --- a/DDCore/src/AlignmentsCalculator.cpp +++ b/DDCore/src/AlignmentsCalculator.cpp @@ -66,7 +66,7 @@ namespace dd4hep { DetElement::Object* det = 0; const Delta* delta = 0; AlignmentCondition::Object* cond = 0; - unsigned char key = 0, valid = 0, created = 0, _pad[1]; + unsigned char key = 0, valid = 0, created = 0, _pad[1] { 0 }; Entry(DetElement d, const Delta* del) : det(d.ptr()), delta(del), key(d.key()) {} }; diff --git a/DDDigi/include/DDDigi/DigiDDG4Input.h b/DDDigi/include/DDDigi/DigiDDG4Input.h index 70b290ee977e74a2968ad30680cb660740025510..5c19d3a3874beec277be94a4b967a254087d812c 100644 --- a/DDDigi/include/DDDigi/DigiDDG4Input.h +++ b/DDDigi/include/DDDigi/DigiDDG4Input.h @@ -40,9 +40,9 @@ namespace dd4hep { class DigiDDG4Input : public DigiInputAction { protected: /// Reference to the current ROOT file to be read - TFile* m_current; + TFile* m_current { nullptr }; /// List of input sources to be worked down - std::vector<std::string> m_todo; + std::vector<std::string> m_todo { }; protected: /// Define standard assignments and constructors diff --git a/DDG4/plugins/Geant4ScintillationPhysics.cpp b/DDG4/plugins/Geant4ScintillationPhysics.cpp index b927362bf2b8f6a4919f250bbc5de5196cf4086f..b6692f7ac746df23de06d9a3fd23fef642ce95d2 100644 --- a/DDG4/plugins/Geant4ScintillationPhysics.cpp +++ b/DDG4/plugins/Geant4ScintillationPhysics.cpp @@ -162,35 +162,35 @@ namespace dd4hep { private: /// G4 11 beta, then disappeared.... - double m_scintillationYieldFactor; + double m_scintillationYieldFactor { 1.0 }; /// G4 11 beta, then disappeared.... - double m_scintillationExcitationRatio; + double m_scintillationExcitationRatio { 1.0 }; /// G4OpticalParameters: "VerboseLevel" - int m_verbosity; + int m_verbosity { 0 }; /// G4OpticalParameters: "CerenkovStackPhotons" - bool m_stackPhotons; + bool m_stackPhotons { true }; /// G4OpticalParameters: "ScintFiniteRiseTime" - bool m_finiteRiseTime; + bool m_finiteRiseTime { false }; /// G4OpticalParameters: "ScintTrackSecondariesFirst" - bool m_trackSecondariesFirst; + bool m_trackSecondariesFirst { false }; /// G4OpticalParameters: "ScintByParticleType" - bool m_byParticleType; + bool m_byParticleType { false }; /// G4OpticalParameters: "ScintTrackInfo" - bool m_trackInfo; + bool m_trackInfo { false }; /// G4OpticalParameters: "BoundaryInvokeSD" - bool m_boundaryInvokeSD; + bool m_boundaryInvokeSD { false }; /// G4OpticalParameters: "WLSTimeProfile" - std::string m_WLSTimeProfile; + std::string m_WLSTimeProfile { }; /// G4OpticalParameters: "WLS2TimeProfile"; - std::string m_WLS2TimeProfile; + std::string m_WLS2TimeProfile { }; /// G4OpticalParameters: "CerenkovMaxBetaChange" - double m_CerenkovMaxBetaChange; + double m_CerenkovMaxBetaChange { -1.0 }; /// G4OpticalParameters: "CerenkovMaxPhotonsPerStep" - int m_CerenkovMaxPhotonsPerStep; + int m_CerenkovMaxPhotonsPerStep { -1 }; /// G4OpticalParameters: "ScintEnhancedTimeConstants" - bool m_ScintEnhancedTimeConstants; + bool m_ScintEnhancedTimeConstants { false }; }; } } diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp index 2158a9d2af9c03368f537059725e4c129fe3dd36..3f95a7057def16cd0637491d0892088fca89074c 100644 --- a/DDG4/src/Geant4Converter.cpp +++ b/DDG4/src/Geant4Converter.cpp @@ -771,6 +771,7 @@ void* Geant4Converter::handleAssembly(const string& name, const TGeoNode* node) if ( ia == info.g4AssemblyVolumes.end() ) { printout(FATAL, "Geant4Converter", "+++ Invalid child assembly at %s : %d parent: %s child:%s", __FILE__, __LINE__, name.c_str(), dau->GetName()); + delete g4; return 0; } g4->placeAssembly(dau, (*ia).second, transform); diff --git a/DDRec/include/DDRec/Surface.h b/DDRec/include/DDRec/Surface.h index 741320460990343186dd3f11120e2f102fbae910..ecb55da8d1ca01ba8eeb817f654201720769a43f 100644 --- a/DDRec/include/DDRec/Surface.h +++ b/DDRec/include/DDRec/Surface.h @@ -401,10 +401,10 @@ namespace dd4hep { class VolConeImpl : public VolSurfaceBase { //internal helper variables - double _ztip ; // z position of the tip in the volume coordinate system - double _zt0 ; // z distance of the front face from the tip - double _zt1 ; // z distance of the back face from the tip - double _tanTheta ; // tan of half the openeing angle + double _ztip { 0.0 }; // z position of the tip in the volume coordinate system + double _zt0 { 0.0 }; // z distance of the front face from the tip + double _zt1 { 0.0 }; // z distance of the back face from the tip + double _tanTheta { 0.0 }; // tan of half the openeing angle public: diff --git a/DDTest/src/test_PolarGridRPhi2.cc b/DDTest/src/test_PolarGridRPhi2.cc index 0649cc2a890bb8fdf7839e6ff31c52e5235feebf..eb39796604da89d84d9587cfc702d63e01699aba 100644 --- a/DDTest/src/test_PolarGridRPhi2.cc +++ b/DDTest/src/test_PolarGridRPhi2.cc @@ -97,7 +97,7 @@ int main() { tests.push_back( TestTuple( 160.0, -179*DegToRad, 14, 0 ) ); - dd4hep::DDSegmentation::VolumeID volID = 0; + dd4hep::DDSegmentation::VolumeID volID { 0 }; //Test from position to cellID for(std::vector<TestTuple>::const_iterator it = tests.begin(); it != tests.end(); ++it) { @@ -119,19 +119,19 @@ int main() { test( expectedID , cid , " Test get ID From Position" ); std::cout << std::setw(20) << " " - << std::setw(20) << "rBin " - << std::setw(20) << "pBin " - << std::endl; + << std::setw(20) << "rBin " + << std::setw(20) << "pBin " + << std::endl; std::cout << std::setw(20) << "Expected" - << std::setw(20) << rB - << std::setw(20) << pB - << std::endl; + << std::setw(20) << rB + << std::setw(20) << pB + << std::endl; std::cout << std::setw(20) << "Calculated" - << std::setw(20) << seg.decoder()->get(cid,"r") - << std::setw(20) << seg.decoder()->get(cid,"phi") - << std::endl; + << std::setw(20) << seg.decoder()->get(cid,"r") + << std::setw(20) << seg.decoder()->get(cid,"phi") + << std::endl; } @@ -164,7 +164,7 @@ int main() { const long long rB = (*it)._rB; const long long pB = (*it)._pB; - dd4hep::DDSegmentation::CellID cellID ; + dd4hep::DDSegmentation::CellID cellID { 0 }; seg.decoder()->set(cellID,"r" , rB); seg.decoder()->set(cellID,"phi", pB); @@ -179,24 +179,24 @@ int main() { test( fabs(expectedPosition.z() - calculatedPosition.z()) < 1e-11, " Test get Position from ID: Z" ); std::cout << std::setw(20) << " " - << std::setw(20) << "r " - << std::setw(20) << "phi " - << std::endl; + << std::setw(20) << "r " + << std::setw(20) << "phi " + << std::endl; std::cout << std::setw(20) << "Expected" - << std::setw(20) << r - << std::setw(20) << phi/DegToRad - << std::endl; + << std::setw(20) << r + << std::setw(20) << phi/DegToRad + << std::endl; const double rCalc = - sqrt( calculatedPosition.x() * calculatedPosition.x() + - calculatedPosition.y() * calculatedPosition.y() ); + sqrt( calculatedPosition.x() * calculatedPosition.x() + + calculatedPosition.y() * calculatedPosition.y() ); const double pCalc = atan2( calculatedPosition.y(), calculatedPosition.x() ); std::cout << std::setw(20) << "Calculated" - << std::setw(20) << rCalc - << std::setw(20) << pCalc/DegToRad - << std::endl; + << std::setw(20) << rCalc + << std::setw(20) << pCalc/DegToRad + << std::endl; } @@ -209,5 +209,4 @@ int main() { test.error( "exception occurred" ); } return 0; - } diff --git a/DDTest/src/test_cellDimensionsRPhi2.cc b/DDTest/src/test_cellDimensionsRPhi2.cc index 7665b9b3f55ced5aa483bb1f6771b822cd82c685..ad4b975e97cc489a2ed866f02076ba458e8d7bc1 100644 --- a/DDTest/src/test_cellDimensionsRPhi2.cc +++ b/DDTest/src/test_cellDimensionsRPhi2.cc @@ -108,7 +108,7 @@ Segmentation* createPolarGridRPhi2() { } CellID getCellID(dd4hep::DDSegmentation::Segmentation* seg, long long rB, long long pB){ - CellID cID ; + CellID cID { 0 }; seg->decoder()->set(cID,"r",rB) ; seg->decoder()->set(cID,"phi",pB); return cID; diff --git a/UtilityApps/src/materialBudget.cpp b/UtilityApps/src/materialBudget.cpp index 28c91aa455961c6cf9721dc03b0f354c1ac011d0..f01b936890900520262e15eda05c33e6d435f523 100644 --- a/UtilityApps/src/materialBudget.cpp +++ b/UtilityApps/src/materialBudget.cpp @@ -32,6 +32,7 @@ #include "TFile.h" #include "TH1F.h" +#include <cerrno> #include <fstream> #include "main.h" @@ -44,13 +45,13 @@ void dumpExampleSteering() ; namespace { struct SDetHelper{ - std::string name ; - double r0 ; - double r1 ; - double z0 ; - double z1 ; - TH1F* hx ; - TH1F* hl ; + std::string name { }; + double r0 { 0.0 }; + double r1 { 0.0 }; + double z0 { 0.0 }; + double z1 { 0.0 }; + TH1F* hx { nullptr }; + TH1F* hl { nullptr }; }; /// comput a point on a cylinder (r,z) for a given direction (theta,phi) from the IP @@ -111,11 +112,9 @@ int main_wrapper(int argc, char** argv) { std::ifstream infile(steeringFile ); - std::string line; - while (std::getline(infile, line)) - { + while (std::getline(infile, line)) { // ignore empty lines and comments if( line.empty() || line.find("#") == 0 ) continue ; @@ -138,7 +137,7 @@ int main_wrapper(int argc, char** argv) { phi0 = phi0 / 180. * M_PI ; } else if( token == "subdet" ){ - SDetHelper det ; + SDetHelper det; iss >> det.name >> det.r0 >> det.z0 >> det.r1 >> det.z1 ; subdets.emplace_back( det ); } @@ -146,8 +145,12 @@ int main_wrapper(int argc, char** argv) { if ( !iss.eof() || iss.fail() ){ std::cout << " ERROR parsing line : " << line << std::endl ; exit(1) ; - } - + } + } + + if ( nbins <= 0 ) { + std::cout << "Invalid value for binning (nbins) " << nbins << std::endl; + return EINVAL; } // ================================================================================================= diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 23b87c2a616203edb7549a678a02e428343fab52..c50637a1ed07a9f5c903faf361a0fcabd1f415d1 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -41,7 +41,7 @@ dd4hep_configure_output() #========================================================================== -SET(DD4HEP_EXAMPLES "AlignDet CLICSiD ClientTests Conditions DDCMS DDCodex DDDigi DDG4 DDG4_MySensDet LHeD OpticalSurfaces Persistency DDCAD SimpleDetector" +SET(DD4HEP_EXAMPLES "AlignDet CLICSiD ClientTests Conditions DDCMS DDCodex DDDigi DDG4 DDG4_MySensDet LHeD OpticalSurfaces Persistency DDCAD SimpleDetector DDHMB" CACHE STRING "List of DD4hep Examples to build") SEPARATE_ARGUMENTS(DD4HEP_EXAMPLES)