Import Geant4 11.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2021-12-10 14:46:44 +01:00
committed by Ben Morgan
parent 6399a014b6
commit 80e2389dd8
3932 changed files with 202519 additions and 246221 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ G4int G4HCtable::Registor(G4String SDname, G4String HCname)
G4int G4HCtable::GetCollectionID(G4String HCname) const
{
G4int i = -1;
if(HCname.index("/") == std::string::npos) // HCname only
if(HCname.find("/") == std::string::npos) // HCname only
{
for(size_t j = 0; j < HClist.size(); j++)
{
@@ -71,9 +71,9 @@ void G4SDManager::AddNewDetector(G4VSensitiveDetector* aSD)
{
G4int numberOfCollections = aSD->GetNumberOfCollections();
G4String pathName = aSD->GetPathName();
if(pathName(0) != '/')
pathName.prepend("/");
if(pathName(pathName.length() - 1) != '/')
if(pathName[0] != '/')
pathName.insert(0, "/");
if(pathName.back() != '/')
pathName += "/";
treeTop->AddNewDetector(aSD, pathName);
if(numberOfCollections < 1)
@@ -125,8 +125,8 @@ void G4SDManager::TerminateCurrentEvent(G4HCofThisEvent* HCE)
void G4SDManager::Activate(G4String dName, G4bool activeFlag)
{
G4String pathName = dName;
if(pathName(0) != '/')
pathName.prepend("/");
if(pathName[0] != '/')
pathName.insert(0, "/");
treeTop->Activate(pathName, activeFlag);
}
@@ -134,8 +134,8 @@ G4VSensitiveDetector* G4SDManager::FindSensitiveDetector(G4String dName,
G4bool warning)
{
G4String pathName = dName;
if(pathName(0) != '/')
pathName.prepend("/");
if(pathName[0] != '/')
pathName.insert(0, "/");
return treeTop->FindSensitiveDetector(pathName, warning);
}
@@ -38,9 +38,9 @@ G4SDStructure::G4SDStructure(const G4String& aPath)
G4int i = dirName.length();
if(i > 1)
{
dirName.remove(i - 1);
G4int isl = dirName.last('/');
dirName.remove(0, isl + 1);
dirName.erase(i - 1);
G4int isl = dirName.rfind('/');
dirName.erase(0, isl + 1);
dirName += "/";
}
}
@@ -64,15 +64,15 @@ void G4SDStructure::AddNewDetector(G4VSensitiveDetector* aSD,
const G4String& treeStructure)
{
G4String remainingPath = treeStructure;
remainingPath.remove(0, pathName.length());
if(!remainingPath.isNull())
remainingPath.erase(0, pathName.length());
if(!remainingPath.empty())
{ // The detector should be kept in subdirectory.
// First, check if the subdirectoy exists.
G4String subD = ExtractDirName(remainingPath);
G4SDStructure* tgtSDS = FindSubDirectory(subD);
if(tgtSDS == nullptr)
{ // Subdirectory not found. Create a new directory.
subD.prepend(pathName);
subD.insert(0, pathName);
tgtSDS = new G4SDStructure(subD);
structure.push_back(tgtSDS);
}
@@ -132,17 +132,17 @@ void G4SDStructure::RemoveSD(G4VSensitiveDetector* sd)
G4String G4SDStructure::ExtractDirName(const G4String& aName)
{
G4String subD = aName;
G4int i = aName.first('/');
if(i != G4int(std::string::npos))
subD.remove(i + 1);
auto i = aName.find('/');
if(i != G4String::npos)
subD.erase(i + 1);
return subD;
}
void G4SDStructure::Activate(const G4String& aName, G4bool sensitiveFlag)
{
G4String aPath = aName;
aPath.remove(0, pathName.length());
if(aPath.first('/') != std::string::npos)
aPath.erase(0, pathName.length());
if(aPath.find('/') != std::string::npos)
{ // Command is ordered for a subdirectory.
G4String subD = ExtractDirName(aPath);
G4SDStructure* tgtSDS = FindSubDirectory(subD);
@@ -155,7 +155,7 @@ void G4SDStructure::Activate(const G4String& aName, G4bool sensitiveFlag)
tgtSDS->Activate(aName, sensitiveFlag);
}
}
else if(aPath.isNull())
else if(aPath.empty())
{ // Command is ordered for all detectors in this directory.
for(auto det : detector)
det->Activate(sensitiveFlag);
@@ -180,8 +180,8 @@ G4VSensitiveDetector* G4SDStructure::FindSensitiveDetector(
const G4String& aName, G4bool warning)
{
G4String aPath = aName;
aPath.remove(0, pathName.length());
if(aPath.first('/') != std::string::npos)
aPath.erase(0, pathName.length());
if(aPath.find('/') != std::string::npos)
{ // SD exists in sub-directory
G4String subD = ExtractDirName(aPath);
G4SDStructure* tgtSDS = FindSubDirectory(subD);
@@ -35,7 +35,7 @@ G4VSensitiveDetector::G4VSensitiveDetector(G4String name)
, ROgeometry(nullptr)
, filter(nullptr)
{
size_t sLast = name.last('/');
size_t sLast = name.rfind('/');
if(sLast == std::string::npos)
{ // detector name only
SensitiveDetectorName = name;
@@ -44,11 +44,11 @@ G4VSensitiveDetector::G4VSensitiveDetector(G4String name)
else
{ // name conatin the directory path
SensitiveDetectorName = name;
SensitiveDetectorName.remove(0, sLast + 1);
SensitiveDetectorName.erase(0, sLast + 1);
thePathName = name;
thePathName.remove(sLast + 1, name.length() - sLast);
if(thePathName(0) != '/')
thePathName.prepend("/");
thePathName.erase(sLast + 1);
if(thePathName[0] != '/')
thePathName.insert(0, "/");
}
fullPathName = thePathName + SensitiveDetectorName;
}