Import Geant4 11.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2022-12-09 14:43:28 +01:00
parent c07cea1fe0
commit 9f34590941
3810 changed files with 200490 additions and 182326 deletions
+13 -2
View File
@@ -1,8 +1,19 @@
# Category param History
See `CONTRIBUTING.rst` for details of **required** info/format for each entry,
which **must** added in reverse chronological order (newest at the top). It must **not**
be used as a substitute for writing good git commit messages!
which **must** added in reverse chronological order (newest at the top).
It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2022-11-23 Gabriele Cosmo (param-V11-00-04)
- Fixed compilation warnings for implicit type conversions on macOS/XCode 14.1.
## 2022-10-27 Makoto Asai (param-V11-00-03)
- G4FastSimHitMaker - making compatible to command-based scorer
## 2022-08-24 Vladimir Ivanchenko (param-V11-00-02)
- G4FastStep - delete copy constructor and operators
## 2022-01-19 Witek Pokorski (param-V11-00-01)
- Adding the 'flush' method to the fast simulation models.
@@ -31,6 +31,9 @@
#include "G4Navigator.hh"
#include "G4FastHit.hh"
#include "G4FastTrack.hh"
class G4Step;
class G4StepPoint;
class G4VProcess;
/**
* @brief Helper class for hit creation
@@ -63,6 +66,7 @@ class G4FastSimHitMaker
{
fWorldWithSdName = aName;
};
inline void SetProcess(G4VProcess* proc) { fpProcess = proc; }
private:
/// Touchable
@@ -74,5 +78,9 @@ class G4FastSimHitMaker
/// Name of the world containing the sensitive detector. If empty, default
/// mass world is used.
G4String fWorldWithSdName;
G4Step* fpSpotS;
G4StepPoint* fpSpotP;
G4VProcess* fpProcess = nullptr;
};
#endif
#endif
@@ -283,14 +283,8 @@ public: // Without description
G4FastStep();
virtual ~G4FastStep();
// equal/unequal operator
G4bool operator==(const G4FastStep &right) const;
G4bool operator!=(const G4FastStep &right) const;
protected:
// hide copy constructor and assignment operator as protected
G4FastStep (const G4FastStep &right);
G4FastStep & operator= (const G4FastStep &right);
G4FastStep (const G4FastStep &right) = delete;
G4FastStep & operator= (const G4FastStep &right) = delete;
public:
// ===============================================
@@ -29,6 +29,8 @@
#include "G4TransportationManager.hh"
#include "G4VSensitiveDetector.hh"
#include "G4TouchableHandle.hh"
#include "G4Step.hh"
#include "G4StepPoint.hh"
#include "G4VFastSimSensitiveDetector.hh"
@@ -38,11 +40,23 @@ G4FastSimHitMaker::G4FastSimHitMaker()
fpNavigator = new G4Navigator();
fNaviSetup = false;
fWorldWithSdName = "";
fpSpotS = new G4Step();
fpSpotP = new G4StepPoint();
// N.B. Pre and Post step points are common.
fpSpotS->SetPreStepPoint(fpSpotP);
fpSpotS->SetPostStepPoint(fpSpotP);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4FastSimHitMaker::~G4FastSimHitMaker() { delete fpNavigator; }
G4FastSimHitMaker::~G4FastSimHitMaker()
{
delete fpNavigator;
delete fpSpotP;
fpSpotS->ResetPreStepPoint();
fpSpotS->ResetPostStepPoint();
delete fpSpotS;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -86,10 +100,9 @@ void G4FastSimHitMaker::make(const G4FastHit& aHit, const G4FastTrack& aTrack)
}
G4VPhysicalVolume* currentVolume = fTouchableHandle()->GetVolume();
G4VSensitiveDetector* sensitive;
if(currentVolume != 0)
{
sensitive = currentVolume->GetLogicalVolume()->GetSensitiveDetector();
G4VSensitiveDetector* sensitive = currentVolume->GetLogicalVolume()->GetSensitiveDetector();
G4VFastSimSensitiveDetector* fastSimSensitive =
dynamic_cast<G4VFastSimSensitiveDetector*>(sensitive);
if(fastSimSensitive)
@@ -99,13 +112,17 @@ void G4FastSimHitMaker::make(const G4FastHit& aHit, const G4FastTrack& aTrack)
else if(sensitive &&
currentVolume->GetLogicalVolume()->GetFastSimulationManager())
{
G4cerr << "ERROR - G4FastSimHitMaker::make()" << G4endl
<< " It is required to derive from the " << G4endl
<< " G4VFastSimSensitiveDetector in " << G4endl
<< " addition to the usual G4VSensitiveDetector class."
<< G4endl;
G4Exception("G4FastSimHitMaker::make()", "InvalidSetup", FatalException,
"G4VFastSimSensitiveDetector interface not implemented.");
fpSpotS->SetTotalEnergyDeposit(aHit.GetEnergy());
fpSpotS->SetTrack(const_cast<G4Track*>(aTrack.GetPrimaryTrack()));
fpSpotP->SetWeight(aTrack.GetPrimaryTrack()->GetWeight());
fpSpotP->SetPosition(aHit.GetPosition());
fpSpotP->SetGlobalTime(aTrack.GetPrimaryTrack()->GetGlobalTime());
fpSpotP->SetLocalTime(aTrack.GetPrimaryTrack()->GetLocalTime());
fpSpotP->SetProperTime(aTrack.GetPrimaryTrack()->GetProperTime());
fpSpotP->SetTouchableHandle(fTouchableHandle);
fpSpotP->SetProcessDefinedStep(fpProcess);
fpSpotP->SetStepStatus(fUserDefinedLimit);
sensitive->Hit(fpSpotS);
}
}
}
@@ -86,16 +86,16 @@ G4FastSimulationManager::~G4FastSimulationManager()
G4bool
G4FastSimulationManager::ActivateFastSimulationModel(const G4String& aName)
{
size_t iModel;
G4int iModel;
// If the model is already active, do nothing.
for (iModel=0; iModel<ModelList.size(); iModel++)
for (iModel=0; iModel<(G4int)ModelList.size(); ++iModel)
if(ModelList[iModel]->GetName() == aName)
return true;
// Look for in the fInactivatedModels list, if found push_back it back to
// the ModelList
for (iModel=0; iModel<fInactivatedModels.size(); iModel++)
for (iModel=0; iModel<(G4int)fInactivatedModels.size(); ++iModel)
if(fInactivatedModels[iModel]->GetName() == aName) {
ModelList.
push_back (fInactivatedModels.removeAt(iModel));
@@ -111,10 +111,9 @@ G4FastSimulationManager::InActivateFastSimulationModel(const G4String& aName)
{
// Look for in the ModelList, if found remove from it and keep the pointer
// on the fInactivatedModels list.
for (size_t iModel=0; iModel<ModelList.size(); iModel++)
for (G4int iModel=0; iModel<(G4int)ModelList.size(); ++iModel)
if(ModelList[iModel]->GetName() == aName) {
fInactivatedModels.
push_back (ModelList.removeAt(iModel));
fInactivatedModels.push_back (ModelList.removeAt(iModel));
// forces the fApplicableModelList to be rebuild
fLastCrossedParticle=0;
return true;
@@ -128,7 +127,7 @@ G4FastSimulationManager::GetFastSimulationModel(const G4String& modelName,
bool &foundPrevious) const
{
G4VFastSimulationModel* model = 0;
for (size_t iModel=0; iModel<ModelList.size(); iModel++)
for (std::size_t iModel=0; iModel<ModelList.size(); ++iModel)
{
if(ModelList[iModel]->GetName() == modelName)
{
@@ -157,7 +156,7 @@ G4FastSimulationManager::GetFastSimulationModel(const G4String& modelName,
void G4FastSimulationManager::FlushModels()
{
for (size_t iModel=0; iModel<ModelList.size(); iModel++)
for (std::size_t iModel=0; iModel<ModelList.size(); ++iModel)
{
ModelList[iModel]->Flush();
}
@@ -192,7 +191,7 @@ G4FastSimulationManager::
PostStepGetFastSimulationManagerTrigger(const G4Track& track,
const G4Navigator* theNavigator)
{
size_t iModel;
std::size_t iModel;
// If particle type changed re-build the fApplicableModelList.
if(fLastCrossedParticle!=track.GetDefinition()) {
@@ -200,7 +199,7 @@ PostStepGetFastSimulationManagerTrigger(const G4Track& track,
fApplicableModelList.clear();
// If Model List is empty, do nothing !
if(ModelList.size()==0) return false;
for (iModel=0; iModel<ModelList.size(); iModel++)
for (iModel=0; iModel<ModelList.size(); ++iModel)
if(ModelList[iModel]->IsApplicable(*(track.GetDefinition())))
fApplicableModelList.push_back (ModelList[iModel]);
}
@@ -216,7 +215,7 @@ PostStepGetFastSimulationManagerTrigger(const G4Track& track,
if(fFastTrack.OnTheBoundaryButExiting()) return false;
// Loops on the ModelTrigger() methods
for (iModel=0; iModel<fApplicableModelList.size(); iModel++)
for (iModel=0; iModel<fApplicableModelList.size(); ++iModel)
//---------------------------------------------------
// Asks the ModelTrigger method if it must be trigged now.
@@ -257,7 +256,7 @@ G4bool
G4FastSimulationManager::AtRestGetFastSimulationManagerTrigger(const G4Track& track,
const G4Navigator* theNavigator)
{
size_t iModel;
std::size_t iModel;
// If particle type changed re-build the fApplicableModelList.
if(fLastCrossedParticle!=track.GetDefinition()) {
@@ -265,7 +264,7 @@ G4FastSimulationManager::AtRestGetFastSimulationManagerTrigger(const G4Track& tr
fApplicableModelList.clear();
// If Model List is empty, do nothing !
if(ModelList.size()==0) return false;
for (iModel=0; iModel<ModelList.size(); iModel++)
for (iModel=0; iModel<ModelList.size(); ++iModel)
if(ModelList[iModel]->IsApplicable(*(track.GetDefinition())))
fApplicableModelList.push_back (ModelList[iModel]);
}
@@ -281,7 +280,7 @@ G4FastSimulationManager::AtRestGetFastSimulationManagerTrigger(const G4Track& tr
// -- is irrelevant here)
// Loops on the models to see if one of them wants to trigger:
for (iModel=0; iModel < fApplicableModelList.size(); iModel++)
for (iModel=0; iModel < fApplicableModelList.size(); ++iModel)
if(fApplicableModelList[iModel]->AtRestModelTrigger(fFastTrack))
{
fFastStep.Initialize(fFastTrack);
@@ -314,28 +313,28 @@ G4FastSimulationManager::ListTitle() const
void
G4FastSimulationManager::ListModels() const
{
size_t iModel;
std::size_t iModel;
G4cout << "Current Models for the ";
ListTitle();
G4cout << " envelope:\n";
for (iModel=0; iModel<ModelList.size(); iModel++)
for (iModel=0; iModel<ModelList.size(); ++iModel)
G4cout << " " << ModelList[iModel]->GetName() << "\n";
for (iModel=0; iModel<fInactivatedModels.size(); iModel++)
for (iModel=0; iModel<fInactivatedModels.size(); ++iModel)
G4cout << " " << fInactivatedModels[iModel]->GetName()
<< "(inactivated)\n";
}
void G4FastSimulationManager::ListModels(const G4String& modelName) const
{
size_t iModel;
std::size_t iModel;
G4int titled = 0;
G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
// Active Models
for ( iModel=0; iModel<ModelList.size(); iModel++ )
for ( iModel=0; iModel<ModelList.size(); ++iModel )
if( ModelList[iModel]->GetName() == modelName || modelName == "all" )
{
if( !(titled++) )
@@ -359,7 +358,7 @@ void G4FastSimulationManager::ListModels(const G4String& modelName) const
}
// Inactive Models
for (iModel=0; iModel<fInactivatedModels.size(); iModel++)
for (iModel=0; iModel<fInactivatedModels.size(); ++iModel)
if(fInactivatedModels[iModel]->GetName() == modelName || modelName == "all" )
{
if( !(titled++) )
@@ -385,11 +384,11 @@ void G4FastSimulationManager::ListModels(const G4String& modelName) const
void G4FastSimulationManager::ListModels(const G4ParticleDefinition* particleDefinition) const
{
size_t iModel;
std::size_t iModel;
G4bool unique = true;
// Active Models
for ( iModel=0; iModel<ModelList.size(); iModel++ )
for ( iModel=0; iModel<ModelList.size(); ++iModel )
if ( ModelList[iModel]->IsApplicable(*particleDefinition) )
{
G4cout << "Envelope ";
@@ -403,7 +402,7 @@ void G4FastSimulationManager::ListModels(const G4ParticleDefinition* particleDef
}
// Inactive Models
for ( iModel=0; iModel<fInactivatedModels.size(); iModel++ )
for ( iModel=0; iModel<fInactivatedModels.size(); ++iModel )
if( fInactivatedModels[iModel]->IsApplicable(*particleDefinition) )
{
G4cout << "Envelope ";
@@ -311,52 +311,6 @@ G4FastStep::~G4FastStep()
}
}
// copy and assignment operators are implemented as "shallow copy"
G4FastStep::G4FastStep(const G4FastStep &right)
: G4VParticleChange()
{
*this = right;
}
G4FastStep & G4FastStep::operator=(const G4FastStep &right)
{
if (this != &right)
{
G4VParticleChange::operator=(right);
theListOfSecondaries = right.theListOfSecondaries;
theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries;
theNumberOfSecondaries = right.theNumberOfSecondaries;
theStatusChange = right.theStatusChange;
theMomentumChange = right.theMomentumChange;
thePolarizationChange = right.thePolarizationChange;
thePositionChange = right.thePositionChange;
theProperTimeChange = right.theProperTimeChange;
theTimeChange = right.theTimeChange;
theEnergyChange = right.theEnergyChange;
theTrueStepLength = right.theTrueStepLength;
theLocalEnergyDeposit = right.theLocalEnergyDeposit;
theSteppingControlFlag = right.theSteppingControlFlag;
theWeightChange = right.theWeightChange;
fFastTrack = right.fFastTrack;
}
return *this;
}
G4bool G4FastStep::operator==(const G4FastStep &right) const
{
return ((G4VParticleChange *)this == (G4VParticleChange *) &right);
}
G4bool G4FastStep::operator!=(const G4FastStep &right) const
{
return ((G4VParticleChange *)this != (G4VParticleChange *) &right);
}
//----------------------------------------------------------------
// methods for updating G4Step
//
@@ -444,7 +398,7 @@ void G4FastStep::DumpInfo() const
G4cout << " Position - z (mm) : " << G4BestUnit( thePositionChange.z(), "Length" ) << G4endl;
G4cout << " Time (ns) : " << G4BestUnit( theTimeChange, "Time" ) << G4endl;
G4cout << " Proper Time (ns) : " << G4BestUnit( theProperTimeChange, "Time" ) << G4endl;
G4int olprc = G4cout.precision(3);
G4long olprc = G4cout.precision(3);
G4cout << " Momentum Direct - x : " << std::setw(20) << theMomentumChange.x() << G4endl;
G4cout << " Momentum Direct - y : " << std::setw(20) << theMomentumChange.y() << G4endl;
G4cout << " Momentum Direct - z : " << std::setw(20) << theMomentumChange.z() << G4endl;
@@ -118,8 +118,8 @@ G4FastTrack::FRecordsAffineTransformation(const G4Navigator* theNavigator)
// must be deleted by G4FastTrack.
//--------------------------------------------------------
const G4Navigator* NavigatorToUse;
if(theNavigator != 0 ) NavigatorToUse = theNavigator;
else NavigatorToUse = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
if(theNavigator != nullptr ) NavigatorToUse = theNavigator;
else NavigatorToUse = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
G4TouchableHistoryHandle history = NavigatorToUse->CreateTouchableHistoryHandle();
@@ -127,9 +127,10 @@ G4FastTrack::FRecordsAffineTransformation(const G4Navigator* theNavigator)
// Run accross the hierarchy to find the physical volume
// associated with the envelope
//-----------------------------------------------------
G4int depth = history->GetHistory()->GetDepth();
G4int idepth, Done = 0;
for (idepth = 0; idepth <= depth; idepth++)
G4int depth = (G4int)history->GetHistory()->GetDepth();
G4int idepth;
G4bool Done = false;
for (idepth = 0; idepth <= depth; ++idepth)
{
G4VPhysicalVolume* currPV = history->GetHistory()->GetVolume(idepth);
G4LogicalVolume* currLV = currPV->GetLogicalVolume();
@@ -138,14 +139,14 @@ G4FastTrack::FRecordsAffineTransformation(const G4Navigator* theNavigator)
fEnvelopePhysicalVolume = currPV;
fEnvelopeLogicalVolume = currLV;
fEnvelopeSolid = currLV->GetSolid();
Done = 1;
Done = true;
break;
}
}
//---------------------------------------------
//-- Verification: should be removed in future:
//---------------------------------------------
if ( !Done )
if ( Done == false )
{
G4ExceptionDescription ed;
ed << "Can't find transformation for `" << fEnvelopePhysicalVolume->GetName() << "'" << G4endl;