Import Geant4 11.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2024-12-06 11:11:40 +01:00
parent e58e650b32
commit 32390e802b
1984 changed files with 98713 additions and 83996 deletions
+3
View File
@@ -6,6 +6,9 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2024-08-08 Gabriele Cosmo (ascii-V11-02-00)
- Fixed reported Coverity defects for use of const G4String& and std::move().
## 2022-11-18 Gabriele Cosmo (ascii-V11-00-03)
- More compilation warnings fixes for implicit type conversions.
@@ -230,7 +230,7 @@ void G4tgbGeometryDumper::DumpPVPlacement(G4VPhysicalVolume* pv,
*rotMat = (*rotMat).inverse();
pvName += "_refl";
}
G4String rotName = DumpRotationMatrix(rotMat);
const G4String& rotName = DumpRotationMatrix(rotMat);
G4ThreeVector pos = pv->GetTranslation();
if(copyNo == -999) // for parameterisations copy number is provided
@@ -238,8 +238,8 @@ void G4tgbGeometryDumper::DumpPVPlacement(G4VPhysicalVolume* pv,
copyNo = pv->GetCopyNo();
}
G4String fullname = pvName + "#" + G4UIcommand::ConvertToString(copyNo) +
"/" + pv->GetMotherLogical()->GetName();
const G4String& fullname = pvName + "#" + G4UIcommand::ConvertToString(copyNo)
+ "/" + pv->GetMotherLogical()->GetName();
if(!CheckIfPhysVolExists(fullname, pv))
{
@@ -414,7 +414,7 @@ void G4tgbGeometryDumper::DumpPVReplica(G4PVReplica* pv, const G4String& lvName)
break;
}
G4String fullname = lvName + "/" + pv->GetMotherLogical()->GetName();
const G4String& fullname = lvName + "/" + pv->GetMotherLogical()->GetName();
if(!CheckIfPhysVolExists(fullname, pv))
{
@@ -463,14 +463,14 @@ G4String G4tgbGeometryDumper::DumpLogVol(G4LogicalVolume* lv,
}
//---- Dump solid
G4String solidName = DumpSolid(solid, extraName);
const G4String& solidName = DumpSolid(solid, extraName);
//---- Dump material
if(mate == nullptr)
{
mate = lv->GetMaterial();
}
G4String mateName = DumpMaterial(mate);
const G4String& mateName = DumpMaterial(mate);
//---- Dump logical volume (solid + material)
(*theFile) << ":VOLU " << SubstituteRefl(AddQuotes(lvName)) << " "
@@ -485,7 +485,7 @@ G4String G4tgbGeometryDumper::DumpLogVol(G4LogicalVolume* lv,
// --------------------------------------------------------------------
G4String G4tgbGeometryDumper::DumpMaterial(G4Material* mat)
{
G4String mateName = GetObjectName(mat, theMaterials);
const G4String& mateName = GetObjectName(mat, theMaterials);
if(theMaterials.find(mateName) != theMaterials.cend()) // alredy dumped
{
return mateName;
@@ -559,7 +559,7 @@ G4String G4tgbGeometryDumper::DumpMaterial(G4Material* mat)
// --------------------------------------------------------------------
void G4tgbGeometryDumper::DumpElement(G4Element* ele)
{
G4String elemName = GetObjectName(ele, theElements);
const G4String& elemName = GetObjectName(ele, theElements);
if(theElements.find(elemName) != theElements.cend()) // alredy dumped
{
@@ -605,7 +605,7 @@ void G4tgbGeometryDumper::DumpElement(G4Element* ele)
// --------------------------------------------------------------------
void G4tgbGeometryDumper::DumpIsotope(G4Isotope* isot)
{
G4String isotName = GetObjectName(isot, theIsotopes);
const G4String& isotName = GetObjectName(isot, theIsotopes);
if(theIsotopes.find(isotName) != theIsotopes.cend()) // alredy dumped
{
return;
@@ -725,11 +725,10 @@ void G4tgbGeometryDumper::DumpBooleanVolume(const G4String& solidType,
pos = G4ThreeVector();
}
G4String bsoName = GetObjectName(so, theSolids);
if(theSolids.find(bsoName) != theSolids.cend())
return; // alredy dumped
G4String solid0Name = FindSolidName(solid0);
G4String solid1Name = FindSolidName(solid1);
const G4String& bsoName = GetObjectName(so, theSolids);
if(theSolids.find(bsoName) != theSolids.cend()) return; // alredy dumped
const G4String& solid0Name = FindSolidName(solid0);
const G4String& solid1Name = FindSolidName(solid1);
(*theFile) << ":SOLID " << AddQuotes(bsoName) << " " << AddQuotes(solidType)
<< " " << AddQuotes(solid0Name) << " " << AddQuotes(solid1Name)
@@ -750,16 +749,16 @@ void G4tgbGeometryDumper::DumpMultiUnionVolume( G4VSolid* so)
std::vector<G4String> rotList;
for( G4int iso = 0; iso < nSolids; iso++ ) {
G4Transform3D trans = muun->GetTransformation(iso);
G4String rotName = DumpRotationMatrix( new G4RotationMatrix(trans.getRotation()));
const G4String& rotName = DumpRotationMatrix( new G4RotationMatrix(trans.getRotation()));
rotList.push_back(rotName);
G4VSolid* solN = muun->GetSolid(iso);
DumpSolid(solN);
}
G4String bsoName = GetObjectName(const_cast<G4VSolid*>(so), theSolids);
const G4String& bsoName = GetObjectName(const_cast<G4VSolid*>(so), theSolids);
(*theFile) << ":SOLID " << AddQuotes(bsoName) << " MULTIUNION "
<< nSolids;
for( G4int iso = 0; iso < nSolids; iso++ ) {
for( G4int iso = 0; iso < nSolids; ++iso ) {
G4VSolid* solN = muun->GetSolid(iso);
G4Transform3D trans = muun->GetTransformation(iso);
G4ThreeVector pos = trans.getTranslation(); // translation is of mother frame
@@ -1109,7 +1108,7 @@ std::vector<G4double> G4tgbGeometryDumper::GetSolidParams(const G4VSolid* so)
}
else
{
G4String ErrMessage = "Solid type not supported, sorry... " + solidType;
const G4String& ErrMessage = "Solid type not supported, sorry... " + solidType;
G4Exception("G4tgbGeometryDumper::DumpSolidParams()", "NotImplemented",
FatalException, ErrMessage);
}
@@ -1298,7 +1297,7 @@ G4String G4tgbGeometryDumper::GetIsotopeName(G4Isotope* isot)
// with same name
for(;; ++ii)
{
G4String newIsotName =
const G4String& newIsotName =
isotName + "_" + G4UIcommand::ConvertToString(ii);
std::map<G4String, G4Isotope*>::const_iterator ite2 =
theIsotopes.find(newIsotName);
@@ -1354,7 +1353,7 @@ G4String G4tgbGeometryDumper::GetObjectName(
G4int ii = 2;
for(;; ++ii)
{
G4String newObjName = objName + "_" + G4UIcommand::ConvertToString(ii);
const G4String& newObjName = objName + "_" + G4UIcommand::ConvertToString(ii);
typename std::map<G4String, TYP*>::const_iterator ite2 =
objectsDumped.find(newObjName);
if(ite2 == objectsDumped.cend())
+15 -15
View File
@@ -251,10 +251,10 @@ G4int G4tgrFileIn::GetWordsInLine(std::vector<G4String>& wordlist)
else if(comment > 0)
{
stemp = stemp.substr(0, comment);
wordlist.push_back(stemp);
wordlist.push_back(std::move(stemp));
break;
}
wordlist.push_back(stemp);
wordlist.push_back(std::move(stemp));
}
// These two algorithms should be the more STL-like way, but they don't
@@ -294,9 +294,9 @@ G4int G4tgrFileIn::GetWordsInLine(std::vector<G4String>& wordlist)
{
if(imerge != 1)
{
G4String err1 = " word with trailing '\"' while there is no";
G4String err2 = " previous word with leading '\"' in line ";
G4String err = err1 + err2;
const G4String& err1 = " word with trailing '\"' while there is no";
const G4String& err2 = " previous word with leading '\"' in line ";
const G4String& err = err1 + err2;
DumpException(err);
}
imerge = 2;
@@ -334,13 +334,13 @@ G4int G4tgrFileIn::GetWordsInLine(std::vector<G4String>& wordlist)
}
if(imerge == 1)
{
G4String err1 = " word with leading '\"' in line while there is no";
G4String err2 = " later word with trailing '\"' in line ";
G4String err = err1 + err2;
const G4String& err1 = " word with leading '\"' in line while there is no";
const G4String& err2 = " later word with trailing '\"' in line ";
const G4String& err = err1 + err2;
DumpException(err);
}
wordlist = wordlist2;
wordlist = std::move(wordlist2);
// Or why not like this (?):
// typedef std::istream_iterator<G4String, ptrdiff_t> string_iter;
@@ -433,10 +433,10 @@ void G4tgrFileIn::Close()
// --------------------------------------------------------------------
void G4tgrFileIn::DumpException(const G4String& sent)
{
G4String Err1 = sent + " in file " + theName;
G4String Err2 =
" line No: " + G4UIcommand::ConvertToString(theLineNo[theCurrentFile]);
G4String ErrMessage = Err1;
G4Exception("G4tgrFileIn::DumpException()", "FileError", FatalException,
ErrMessage);
const G4String& Err1 = sent + " in file " + theName;
const G4String& Err2 =
", line No: " + G4UIcommand::ConvertToString(theLineNo[theCurrentFile]);
const G4String& ErrMessage = Err1 + Err2;
G4Exception("G4tgrFileIn::DumpException()", "FileError",
FatalException, ErrMessage);
}
+1 -1
View File
@@ -150,7 +150,7 @@ void G4tgrSolid::FillSolidParams(const std::vector<G4String>& wl)
apar.clear();
apar.insert(0);
apar.insert(4);
angleParams["TWISTED_TUBS"] = apar;
angleParams["TWISTED_TUBS"] = std::move(apar);
std::vector<G4double>* vd = new std::vector<G4double>;
theSolidParams.push_back(vd);
@@ -90,7 +90,7 @@ G4tgrSolidMultiUnion::G4tgrSolidMultiUnion(const std::vector<G4String>& wl)
{
wl2[ii] = (char)std::toupper(wl2[ii]);
}
theType = wl2;
theType = std::move(wl2);
#ifdef G4VERBOSE
if(G4tgrMessenger::GetVerboseLevel() >= 1)
@@ -65,7 +65,7 @@ G4tgrSolidScaled::G4tgrSolidScaled(const std::vector<G4String>& wl)
{
wl2[ii] = (char)std::toupper(wl2[ii]);
}
theType = wl2;
theType = std::move(wl2);
#ifdef G4VERBOSE
if(G4tgrMessenger::GetVerboseLevel() >= 1)
+3
View File
@@ -6,6 +6,9 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2024-07-09 Gabriele Cosmo (mctruth-V11-02-00)
- Use G4String type consistently.
## 2022-11-16 Gabriele Cosmo (mctruth-V11-00-03)
- Fixed more compilation warnings for implicit type conversions on
macOS/XCode 14.1 in G4MCTGenEvent source.
@@ -34,7 +34,6 @@
#ifndef G4DCIOENTRYT_HH
#define G4DCIOENTRYT_HH 1
#include <string>
#include "G4Types.hh"
#include "G4VPDigitsCollectionIO.hh"
@@ -46,7 +45,7 @@ class G4DCIOentryT : public G4VDCIOentry
{
public:
G4DCIOentryT<T>(std::string n) : G4VDCIOentry(n)
G4DCIOentryT<T>(const G4String& n) : G4VDCIOentry(n)
{
if(m_verbose > 2)
{
@@ -37,15 +37,6 @@
#include "G4Types.hh"
#include "G4String.hh"
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
class G4FileUtilities
{
public:
@@ -59,10 +50,10 @@ class G4FileUtilities
G4bool FileExists(const G4String& file);
// checks if the "file" exists. returns true if it does
std::string StrErrNo() const { return ::strerror(errno); }
G4String StrErrNo() const;
// returns the error message of the last system call as string
G4int Shell(const G4String& str) { return ::system(str.c_str()); }
G4int Shell(const G4String& str);
// executes the shell command. returns zero if success
G4int CopyFile(const G4String& srcFile, const G4String& dstFile);
@@ -71,9 +62,8 @@ class G4FileUtilities
G4int DeleteFile(const G4String& file, const G4String& option);
// deletes the "file" with the "option". returns zero if success
std::string GetEnv(const G4String& env) { return ::getenv(env.c_str()); }
G4String GetEnv(const G4String& env);
// retuns the value of environment variable as string
};
#endif
@@ -41,10 +41,8 @@
class G4VHCIOentry;
using HCIOmap = std::map<std::string, G4VHCIOentry*, std::less<std::string>>;
using HCIOstore = std::map<G4String, G4VPHitsCollectionIO*,
std::less<G4String>>;
using HCIOmap = std::map<G4String, G4VHCIOentry*, std::less<G4String>>;
using HCIOstore = std::map<G4String, G4VPHitsCollectionIO*, std::less<G4String>>;
class G4HCIOcatalog
{
@@ -34,7 +34,6 @@
#ifndef G4HCIOENTRYT_HH
#define G4HCIOENTRYT_HH 1
#include <string>
#include "G4Types.hh"
#include "G4VPHitsCollectionIO.hh"
@@ -31,7 +31,6 @@
#define G4MCTSIMPARTICLE_HH 1
#include <vector>
#include <string>
#include <iostream>
#include "G4String.hh"
@@ -63,7 +62,7 @@ class G4MCTSimParticle
inline void SetParentParticle(const G4MCTSimParticle* p);
inline G4MCTSimParticle* GetParentParticle() const;
inline void SetParticleName(std::string aname);
inline void SetParticleName(const G4String& aname);
inline const G4String& GetParticleName() const;
inline void SetPdgID(G4int id);
@@ -147,7 +146,7 @@ inline G4MCTSimParticle* G4MCTSimParticle::GetParentParticle() const
return parentParticle;
}
inline void G4MCTSimParticle::SetParticleName(std::string aname)
inline void G4MCTSimParticle::SetParticleName(const G4String& aname)
{
name = aname;
}
@@ -32,7 +32,6 @@
#include <iostream>
#include <vector>
#include <string>
#include "G4Types.hh"
#include "G4ThreeVector.hh"
@@ -34,10 +34,10 @@
#ifndef G4PERSISTENCYCENTER_HH
#define G4PERSISTENCYCENTER_HH 1
#include "G4Types.hh"
#include <string>
#include <vector>
#include <map>
#include "G4Types.hh"
#include "G4HCIOcatalog.hh"
#include "G4DCIOcatalog.hh"
@@ -72,8 +72,8 @@ class G4PersistencyCenterMessenger : public G4UImessenger
G4UIcmdWithAnInteger* verboseCmd = nullptr;
G4UIcmdWithAString* select = nullptr;
G4UIcmdWithAString* regHitIO = nullptr;
std::vector<std::string> wrObj;
std::vector<std::string> rdObj;
std::vector<G4String> wrObj;
std::vector<G4String> rdObj;
std::vector<G4UIcmdWithAString*> storeObj;
std::vector<G4UIcmdWithAString*> setWrFile;
std::vector<G4UIcmdWithAString*> setRdFile;
@@ -36,7 +36,6 @@
#define G4VTRANSACTIONMANAGER_HH 1
#include "G4Types.hh"
#include <string>
class G4VTransactionManager
{
@@ -48,13 +47,15 @@ class G4VTransactionManager
virtual ~G4VTransactionManager() {}
// Destructor
void SetVerboseLevel(int v) { m_verbose = v; }
void SetVerboseLevel(G4int v) { m_verbose = v; }
// Set verbose level
virtual G4bool SelectReadFile(std::string obj, std::string file) = 0;
virtual G4bool SelectReadFile(const G4String& obj,
const G4String& file) = 0;
// Set the input file name and open it for the object type "obj"
virtual G4bool SelectWriteFile(std::string obj, std::string file) = 0;
virtual G4bool SelectWriteFile(const G4String& obj,
const G4String& file) = 0;
// Set the output file name and open it for the object type "obj"
virtual G4bool StartUpdate() = 0;
@@ -32,6 +32,12 @@
#include "G4FileUtilities.hh"
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
// --------------------------------------------------------------------
G4FileUtilities::G4FileUtilities()
{
@@ -60,11 +66,23 @@ G4bool G4FileUtilities::FileExists(const G4String& file)
}
}
// --------------------------------------------------------------------
G4String G4FileUtilities::StrErrNo() const
{
return ::strerror(errno);
}
// --------------------------------------------------------------------
G4int G4FileUtilities::Shell(const G4String& str)
{
return ::system(str.c_str());
}
// --------------------------------------------------------------------
G4int G4FileUtilities::CopyFile(const G4String& srcFile,
const G4String& dstFile)
{
std::string cmd = "cp " + srcFile + " " + dstFile;
G4String cmd = "cp " + srcFile + " " + dstFile;
return Shell(cmd);
}
@@ -72,8 +90,14 @@ G4int G4FileUtilities::CopyFile(const G4String& srcFile,
G4int G4FileUtilities::DeleteFile(const G4String& file,
const G4String& option)
{
std::string cmd = "rm " + option + " " + file;
G4String cmd = "rm " + option + " " + file;
return Shell(cmd);
}
// --------------------------------------------------------------------
G4String G4FileUtilities::GetEnv(const G4String& env)
{
return ::getenv(env.c_str());
}
#endif