Import Geant4 10.3.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2016-06-30 14:12:05 +02:00
parent a654a7ab1f
commit 4ec577e5c4
2021 changed files with 100995 additions and 78277 deletions
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4CellScoreComposer.cc 67992 2013-03-13 10:59:57Z gcosmo $
// $Id: G4CellScoreComposer.cc 94771 2015-12-09 09:44:05Z gcosmo $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
@@ -45,8 +45,7 @@ G4CellScoreComposer::~G4CellScoreComposer()
void G4CellScoreComposer::EstimatorCalculation(const G4Step &aStep){
G4StepPoint *p = 0;
p = aStep.GetPreStepPoint();
G4StepPoint *p = aStep.GetPreStepPoint();
if (!p) {
G4Exception("G4CellScoreComposer::EstimatorCalculation","Det0191",FatalException," no pointer to pre PreStepPoint!");
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4MultiFunctionalDetector.cc 67992 2013-03-13 10:59:57Z gcosmo $
// $Id: G4MultiFunctionalDetector.cc 94771 2015-12-09 09:44:05Z gcosmo $
//
// G4MultiFunctionalDetector
//
@@ -40,26 +40,25 @@ G4MultiFunctionalDetector::G4MultiFunctionalDetector(G4String name)
{;}
G4MultiFunctionalDetector::~G4MultiFunctionalDetector()
{;}
{
for(auto pr : primitives) delete pr;
primitives.clear();
}
G4bool G4MultiFunctionalDetector::ProcessHits(G4Step* aStep,G4TouchableHistory* aTH)
{
if(aStep->GetStepLength()>0. || aStep->GetTotalEnergyDeposit()>0.){
G4int nPrim = primitives.size();
for(G4int iPrim=0;iPrim<nPrim;iPrim++)
{
primitives[iPrim]->HitPrimitive(aStep,aTH);
}
}
return true;
if(aStep->GetStepLength()>0. || aStep->GetTotalEnergyDeposit()>0.){
for(auto pr : primitives)
{ pr->HitPrimitive(aStep,aTH); }
}
return true;
}
G4bool G4MultiFunctionalDetector::RegisterPrimitive(G4VPrimitiveScorer* aPS)
{
G4int nPrim = primitives.size();
for(G4int iPrim=0;iPrim<nPrim;iPrim++)
for(auto pr : primitives)
{
if(primitives[iPrim]==aPS)
if(pr==aPS)
{
G4ExceptionDescription ED;
ED << "Primitive <" << aPS->GetName() << "> is already defined in <" << SensitiveDetectorName
@@ -83,17 +82,12 @@ G4bool G4MultiFunctionalDetector::RegisterPrimitive(G4VPrimitiveScorer* aPS)
G4bool G4MultiFunctionalDetector::RemovePrimitive(G4VPrimitiveScorer* aPS)
{
std::vector<G4VPrimitiveScorer*>::iterator iterPS;
std::vector<G4String>::iterator iterName = collectionName.begin();
for(iterPS=primitives.begin();iterPS!=primitives.end();iterPS++)
auto pr = std::find(primitives.begin(),primitives.end(),aPS);
if(pr!=primitives.end())
{
if(*iterPS==aPS)
{
primitives.erase(iterPS);
aPS->SetMultiFunctionalDetector(0);
return true;
}
iterName++;
primitives.erase(pr);
aPS->SetMultiFunctionalDetector(nullptr);
return true;
}
G4cerr << "Primitive <" << aPS->GetName() << "> is not defined in <" << SensitiveDetectorName
<< ">." << G4endl << "Method RemovePrimitive() is ignored." << G4endl;
@@ -102,36 +96,31 @@ G4bool G4MultiFunctionalDetector::RemovePrimitive(G4VPrimitiveScorer* aPS)
void G4MultiFunctionalDetector::Initialize(G4HCofThisEvent* HC)
{
G4int nPrim = primitives.size();
for(G4int iPrim=0;iPrim<nPrim;iPrim++)
{ primitives[iPrim]->Initialize(HC); }
for(auto pr : primitives)
{ pr->Initialize(HC); }
}
void G4MultiFunctionalDetector::EndOfEvent(G4HCofThisEvent* HC)
{
G4int nPrim = primitives.size();
for(G4int iPrim=0;iPrim<nPrim;iPrim++)
{ primitives[iPrim]->EndOfEvent(HC); }
for(auto pr : primitives)
{ pr->EndOfEvent(HC); }
}
void G4MultiFunctionalDetector::clear()
{
G4int nPrim = primitives.size();
for(G4int iPrim=0;iPrim<nPrim;iPrim++)
{ primitives[iPrim]->clear(); }
for(auto pr : primitives)
{ pr->clear(); }
}
void G4MultiFunctionalDetector::DrawAll()
{
G4int nPrim = primitives.size();
for(G4int iPrim=0;iPrim<nPrim;iPrim++)
{ primitives[iPrim]->DrawAll(); }
for(auto pr : primitives)
{ pr->DrawAll(); }
}
void G4MultiFunctionalDetector::PrintAll()
{
G4int nPrim = primitives.size();
for(G4int iPrim=0;iPrim<nPrim;iPrim++)
{ primitives[iPrim]->PrintAll(); }
for(auto pr : primitives)
{ pr->PrintAll(); }
}
@@ -26,6 +26,7 @@
// G4MultiSensitiveDetector
#include "G4MultiSensitiveDetector.hh"
#include "G4SDManager.hh"
#include <sstream>
//#define MSDDEBUG
@@ -133,3 +134,9 @@ G4VSensitiveDetector* G4MultiSensitiveDetector::Clone() const
return newInst;
}
void G4MultiSensitiveDetector::AddSD(G4VSensitiveDetector* sd)
{
// making sure this sensitive detector is registered to G4SDManager
G4SDManager::GetSDMpointer()->AddNewDetector(sd);
fSensitiveDetectors.push_back(sd);
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4SDManager.cc 73819 2013-09-12 15:52:52Z gcosmo $
// $Id: G4SDManager.cc 96455 2016-04-15 08:44:06Z gcosmo $
//
#include "G4SDManager.hh"
@@ -35,7 +35,7 @@
#include "G4ios.hh"
G4ThreadLocal G4SDManager* G4SDManager::fSDManager = 0;
G4ThreadLocal G4SDManager* G4SDManager::fSDManager = nullptr;
G4SDManager* G4SDManager::GetSDMpointer()
{
@@ -62,6 +62,10 @@ G4SDManager::~G4SDManager()
delete theMessenger;
delete HCtable;
delete treeTop;
theMessenger = nullptr;
HCtable = nullptr;
treeTop = nullptr;
fSDManager = nullptr;
}
void G4SDManager::AddNewDetector(G4VSensitiveDetector*aSD)
@@ -81,7 +85,7 @@ void G4SDManager::AddNewDetector(G4VSensitiveDetector*aSD)
if( verboseLevel > 0 )
{
G4cout << "New sensitive detector <" << aSD->GetName()
<< "> is registored at " << pathName << G4endl;
<< "> is registered at " << pathName << G4endl;
}
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4SDStructure.cc 74576 2013-10-15 07:20:11Z gcosmo $
// $Id: G4SDStructure.cc 94771 2015-12-09 09:44:05Z gcosmo $
//
// G4SDStructure
@@ -47,12 +47,10 @@ G4SDStructure::G4SDStructure(G4String aPath):verboseLevel(0)
G4SDStructure::~G4SDStructure()
{
size_t nTree = structure.size();
for(size_t iTree=0;iTree<nTree;iTree++)
{ delete structure[iTree]; }
size_t nDet = detector.size();
for(size_t iDet=0;iDet<nDet;iDet++)
{ delete detector[iDet]; }
for(auto st : structure) delete st;
structure.clear();
for(auto dt : detector) delete dt;
detector.clear();
}
G4int G4SDStructure::operator==(const G4SDStructure &right) const
@@ -70,7 +68,7 @@ void G4SDStructure::AddNewDetector(G4VSensitiveDetector*aSD,
// First, check if the subdirectoy exists.
G4String subD = ExtractDirName( remainingPath );
G4SDStructure* tgtSDS = FindSubDirectory(subD);
if( tgtSDS == 0 )
if( tgtSDS == nullptr )
{ // Subdirectory not found. Create a new directory.
subD.prepend(pathName);
tgtSDS = new G4SDStructure(subD);
@@ -100,33 +98,22 @@ void G4SDStructure::AddNewDetector(G4VSensitiveDetector*aSD,
G4SDStructure* G4SDStructure::FindSubDirectory(G4String subD)
{
for( size_t i=0; i<structure.size(); i++ )
{
if( subD == structure[i]->dirName ) return structure[i];
}
return 0;
for(auto st : structure)
{ if( subD == st->dirName ) return st; }
return nullptr;
}
G4VSensitiveDetector* G4SDStructure::GetSD(G4String aSDName)
{
for( size_t i=0; i<detector.size(); i++ )
{
G4VSensitiveDetector* tgtSD = detector[i];
if( aSDName == tgtSD->GetName() ) return tgtSD;
}
return 0;
for(auto det : detector)
{ if(aSDName == det->GetName()) return det; }
return nullptr;
}
void G4SDStructure::RemoveSD(G4VSensitiveDetector* sd)
{
std::vector<G4VSensitiveDetector*>::iterator itr = detector.begin();
for(;itr!=detector.end();itr++)
{
if((*itr)==sd) {
detector.erase(itr);
break;
}
}
auto det = std::find(detector.begin(), detector.end(), sd);
if(det!=detector.end()) detector.erase(det);
}
G4String G4SDStructure::ExtractDirName(G4String aName)
@@ -145,7 +132,7 @@ void G4SDStructure::Activate(G4String aName, G4bool sensitiveFlag)
{ // Command is ordered for a subdirectory.
G4String subD = ExtractDirName(aPath);
G4SDStructure* tgtSDS = FindSubDirectory(subD);
if( tgtSDS == 0 )
if( tgtSDS == nullptr )
{ // The subdirectory is not found
G4cout << subD << " is not found in " << pathName << G4endl;
}
@@ -156,19 +143,13 @@ void G4SDStructure::Activate(G4String aName, G4bool sensitiveFlag)
}
else if( aPath.isNull() )
{ // Command is ordered for all detectors in this directory.
for( size_t i=0; i<detector.size(); i++)
{
detector[i]->Activate(sensitiveFlag);
}
for( size_t j=0;j<structure.size(); j++)
{
structure[j]->Activate(G4String("/"),sensitiveFlag);
}
for(auto det : detector) det->Activate(sensitiveFlag);
for(auto st : structure) st->Activate(G4String("/"),sensitiveFlag);
}
else
{ // Command is ordered to a particular detector.
G4VSensitiveDetector* tgtSD = GetSD(aPath);
if( tgtSD == 0 )
if( tgtSD == nullptr )
{ // The detector is not found.
G4cout << aPath << " is not found in " << pathName << G4endl;
}
@@ -187,11 +168,11 @@ G4VSensitiveDetector* G4SDStructure::FindSensitiveDetector(G4String aName, G4boo
{ // SD exists in sub-directory
G4String subD = ExtractDirName(aPath);
G4SDStructure* tgtSDS = FindSubDirectory(subD);
if( tgtSDS == 0 )
if( tgtSDS == nullptr )
{ // The subdirectory is not found
if (warning)
G4cout << subD << " is not found in " << pathName << G4endl;
return 0;
return nullptr;
}
else
{
@@ -201,7 +182,7 @@ G4VSensitiveDetector* G4SDStructure::FindSensitiveDetector(G4String aName, G4boo
else
{ // SD must exist in this directory
G4VSensitiveDetector* tgtSD = GetSD(aPath);
if( tgtSD == 0 )
if( tgtSD == nullptr )
{ // The detector is not found.
if (warning)
G4cout << aPath << " is not found in " << pathName << G4endl;
@@ -212,40 +193,29 @@ G4VSensitiveDetector* G4SDStructure::FindSensitiveDetector(G4String aName, G4boo
void G4SDStructure::Initialize(G4HCofThisEvent*HCE)
{
size_t i;
// Broadcast to subdirectories.
for( i=0; i<structure.size(); i++ )
{
structure[i]->Initialize(HCE);
}
for(auto st : structure)
{ st->Initialize(HCE); }
// Initialize all detectors in this directory.
for( i=0; i<detector.size(); i++ )
{
if(detector[i]->isActive()) detector[i]->Initialize(HCE);
}
for(auto dt : detector)
{ if(dt->isActive()) dt->Initialize(HCE); }
}
void G4SDStructure::Terminate(G4HCofThisEvent*HCE)
{
size_t i;
// Broadcast to subdirectories.
for( i=0; i<structure.size(); i++ )
{
structure[i]->Terminate(HCE);
}
// Initialize all detectors in this directory.
for( i=0; i<detector.size(); i++ )
{
if(detector[i]->isActive()) detector[i]->EndOfEvent(HCE);
}
for(auto st : structure)
{ st->Terminate(HCE); }
// Terminate all detectors in this directory.
for(auto dt : detector)
{ if(dt->isActive()) dt->EndOfEvent(HCE); }
}
void G4SDStructure::ListTree()
{
G4cout << pathName << G4endl;
for(size_t i=0; i<detector.size(); i++)
for(auto sd : detector)
{
G4VSensitiveDetector* sd = detector[i];
G4cout << pathName << sd->GetName();
if( sd->isActive() )
{ G4cout << " *** Active "; }
@@ -253,8 +223,7 @@ void G4SDStructure::ListTree()
{ G4cout << " XXX Inactive "; }
G4cout << G4endl;
}
for(size_t j=0; j<structure.size(); j++)
{ structure[j]->ListTree(); }
for(auto st : structure) st->ListTree();
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4SensitiveVolumeList.cc 81087 2014-05-20 15:44:27Z gcosmo $
// $Id: G4SensitiveVolumeList.cc 94771 2015-12-09 09:44:05Z gcosmo $
//
// --------------------------------------------------------------
// GEANT 4 class implementation file
@@ -79,19 +79,17 @@
//Other Operations
G4bool G4SensitiveVolumeList::CheckPV(const G4VPhysicalVolume * pvp) const
{
if (thePhysicalVolumeList.size()==0) return false;
for(size_t i=0;i<thePhysicalVolumeList.size();i++)
{ if(thePhysicalVolumeList[i]==pvp) return true; }
for(auto pv : thePhysicalVolumeList)
{ if(pv==pvp) return true; }
return false;
}
G4bool G4SensitiveVolumeList::CheckLV(const G4LogicalVolume * lvp) const
{
if (theLogicalVolumeList.size()==0) return false;
for(size_t i=0;i<theLogicalVolumeList.size();i++)
{ if(theLogicalVolumeList[i]==lvp) return true; }
return false;
for(auto lv : theLogicalVolumeList)
{ if(lv==lvp) return true; }
return false;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VPrimitiveScorer.cc 67992 2013-03-13 10:59:57Z gcosmo $
// $Id: G4VPrimitiveScorer.cc 94771 2015-12-09 09:44:05Z gcosmo $
//
// G4VPrimitiveScorer
#include "G4VPrimitiveScorer.hh"
@@ -35,7 +35,7 @@
#include "G4UnitsTable.hh"
G4VPrimitiveScorer::G4VPrimitiveScorer(G4String name, G4int depth)
:primitiveName(name),detector(0),filter(0),verboseLevel(0),indexDepth(depth),
:primitiveName(name),detector(nullptr),filter(nullptr),verboseLevel(0),indexDepth(depth),
unitName("NoUnit"),unitValue(1.0),fNi(0),fNj(0),fNk(0)
{;}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VReadOutGeometry.cc 81087 2014-05-20 15:44:27Z gcosmo $
// $Id: G4VReadOutGeometry.cc 94771 2015-12-09 09:44:05Z gcosmo $
//
#include "G4VReadOutGeometry.hh"
@@ -32,8 +32,8 @@
G4VReadOutGeometry::G4VReadOutGeometry()
:ROworld(0),fincludeList(0),
fexcludeList(0),touchableHistory(0)
:ROworld(nullptr),fincludeList(nullptr),
fexcludeList(nullptr),touchableHistory(nullptr)
{
name = "unknown";
ROnavigator = new G4Navigator();
@@ -49,21 +49,29 @@ G4VReadOutGeometry::G4VReadOutGeometry()
G4VReadOutGeometry::G4VReadOutGeometry(const G4VReadOutGeometry &right)
{
fincludeList = 0;
fexcludeList = 0;
fincludeList = nullptr;
fexcludeList = nullptr;
name = right.name;
ROworld = right.ROworld;
touchableHistory = 0;
touchableHistory = nullptr;
ROnavigator = new G4Navigator();
// COPY CONSTRUCTOR NOT STRAIGHT FORWARD: need to copy the touchabelHistory
// VALUE, same for navigator and same for the World+Geom hierachy
}
G4VReadOutGeometry::G4VReadOutGeometry(G4String n)
:ROworld(0),fincludeList(0),
fexcludeList(0),name(n),touchableHistory(0)
:ROworld(nullptr),fincludeList(nullptr),
fexcludeList(nullptr),name(n),touchableHistory(nullptr)
{
ROnavigator = new G4Navigator();
G4ExceptionDescription ed;
ed<<"The concept and the functionality of Readout Geometry has been merged\n"
<<"into Parallel World. This G4VReadOutGeometry is kept for the sake of\n"
<<"not breaking the commonly-used interface in the sensitive detector class.\n"
<<"But this functionality of G4VReadOutGeometry class is no longer tested\n"
<<"and thus may not be working well. We strongly recommend our customers to\n"
<<"migrate to Parallel World scheme.";
G4Exception("G4VReadOutGeometry","DIGIHIT1001",JustWarning,ed);
}
G4VReadOutGeometry::~G4VReadOutGeometry()
@@ -78,11 +86,11 @@ G4VReadOutGeometry::~G4VReadOutGeometry()
G4VReadOutGeometry & G4VReadOutGeometry::operator=(const G4VReadOutGeometry &right)
{
if ( this == &right ) return *this;
delete fincludeList; fincludeList = 0;
delete fexcludeList; fexcludeList = 0;
delete fincludeList; fincludeList = nullptr;
delete fexcludeList; fexcludeList = nullptr;
name = right.name;
ROworld = right.ROworld;
delete touchableHistory; touchableHistory = 0;
delete touchableHistory; touchableHistory = nullptr;
delete ROnavigator; ROnavigator = new G4Navigator();
return *this;
}
@@ -101,7 +109,7 @@ void G4VReadOutGeometry::BuildROGeometry()
G4bool G4VReadOutGeometry::CheckROVolume(G4Step*currentStep,G4TouchableHistory*& ROhist)
{
ROhist = 0;
ROhist = nullptr;
G4bool incFlg = true;
G4VPhysicalVolume* PV = currentStep->GetPreStepPoint()->GetPhysicalVolume();
if((fexcludeList)&&(fexcludeList->CheckPV(PV)))
@@ -24,14 +24,15 @@
// ********************************************************************
//
//
// $Id: G4VSensitiveDetector.cc 81087 2014-05-20 15:44:27Z gcosmo $
// $Id: G4VSensitiveDetector.cc 94771 2015-12-09 09:44:05Z gcosmo $
//
// G4VSensitiveDetector
#include "G4VSensitiveDetector.hh"
#include "G4SDManager.hh"
G4VSensitiveDetector::G4VSensitiveDetector(G4String name)
:verboseLevel(0),active(true),ROgeometry(0),filter(0)
:verboseLevel(0),active(true),
ROgeometry(nullptr),filter(nullptr)
{
size_t sLast = name.last('/');
if(sLast==std::string::npos)
@@ -72,7 +73,7 @@ G4VSensitiveDetector* G4VSensitiveDetector::Clone() const
<< "but Clone method called.\n"
<< "Cannot continue;";
G4Exception("G4VSensitiveDetector::Clone","Det0010",FatalException,msg);
return NULL;
return nullptr;
}
G4VSensitiveDetector & G4VSensitiveDetector::operator=(const G4VSensitiveDetector &right)