Import Geant4 11.2.0 source tree
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
#include "G4FastHit.hh"
|
||||
|
||||
G4FastHit::G4FastHit()
|
||||
: fEnergy()
|
||||
, fPosition(G4ThreeVector())
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4FastHit::G4FastHit(const G4ThreeVector& aPosition, G4double aEnergy)
|
||||
: fEnergy(aEnergy)
|
||||
, fPosition(aPosition)
|
||||
{}
|
||||
@@ -26,19 +26,18 @@
|
||||
|
||||
#include "G4FastSimHitMaker.hh"
|
||||
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4VSensitiveDetector.hh"
|
||||
#include "G4TouchableHandle.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4StepPoint.hh"
|
||||
|
||||
#include "G4TouchableHandle.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4VFastSimSensitiveDetector.hh"
|
||||
#include "G4VSensitiveDetector.hh"
|
||||
|
||||
G4FastSimHitMaker::G4FastSimHitMaker()
|
||||
{
|
||||
fTouchableHandle = new G4TouchableHistory();
|
||||
fpNavigator = new G4Navigator();
|
||||
fNaviSetup = false;
|
||||
fpNavigator = new G4Navigator();
|
||||
fNaviSetup = false;
|
||||
fWorldWithSdName = "";
|
||||
fpSpotS = new G4Step();
|
||||
fpSpotP = new G4StepPoint();
|
||||
@@ -49,9 +48,9 @@ G4FastSimHitMaker::G4FastSimHitMaker()
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4FastSimHitMaker::~G4FastSimHitMaker()
|
||||
G4FastSimHitMaker::~G4FastSimHitMaker()
|
||||
{
|
||||
delete fpNavigator;
|
||||
delete fpNavigator;
|
||||
delete fpSpotP;
|
||||
fpSpotS->ResetPreStepPoint();
|
||||
fpSpotS->ResetPostStepPoint();
|
||||
@@ -63,54 +62,44 @@ G4FastSimHitMaker::~G4FastSimHitMaker()
|
||||
void G4FastSimHitMaker::make(const G4FastHit& aHit, const G4FastTrack& aTrack)
|
||||
{
|
||||
// do not make empty deposit
|
||||
if(aHit.GetEnergy() <= 0)
|
||||
return;
|
||||
if (aHit.GetEnergy() <= 0) return;
|
||||
// Locate the spot
|
||||
if(!fNaviSetup)
|
||||
{
|
||||
if (!fNaviSetup) {
|
||||
// Choose the world volume that contains the sensitive detector based on its
|
||||
// name (empty name for mass geometry)
|
||||
G4VPhysicalVolume* worldWithSD = nullptr;
|
||||
if(fWorldWithSdName.empty())
|
||||
{
|
||||
if (fWorldWithSdName.empty()) {
|
||||
worldWithSD = G4TransportationManager::GetTransportationManager()
|
||||
->GetNavigatorForTracking()
|
||||
->GetWorldVolume();
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
worldWithSD =
|
||||
G4TransportationManager::GetTransportationManager()->GetParallelWorld(
|
||||
fWorldWithSdName);
|
||||
G4TransportationManager::GetTransportationManager()->GetParallelWorld(fWorldWithSdName);
|
||||
}
|
||||
fpNavigator->SetWorldVolume(worldWithSD);
|
||||
// use track global position
|
||||
fpNavigator->LocateGlobalPointAndUpdateTouchable(
|
||||
aTrack.GetPrimaryTrack()->GetPosition(), fTouchableHandle(), false);
|
||||
fpNavigator->LocateGlobalPointAndUpdateTouchable(aTrack.GetPrimaryTrack()->GetPosition(),
|
||||
fTouchableHandle(), false);
|
||||
fNaviSetup = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
// for further deposits use hit (local) position and local->global
|
||||
// transformation
|
||||
fpNavigator->LocateGlobalPointAndUpdateTouchable(
|
||||
aTrack.GetInverseAffineTransformation()->TransformPoint(
|
||||
aHit.GetPosition()),
|
||||
aTrack.GetInverseAffineTransformation()->TransformPoint(aHit.GetPosition()),
|
||||
fTouchableHandle());
|
||||
}
|
||||
G4VPhysicalVolume* currentVolume = fTouchableHandle()->GetVolume();
|
||||
|
||||
if(currentVolume != 0)
|
||||
{
|
||||
if (currentVolume != nullptr) {
|
||||
G4VSensitiveDetector* sensitive = currentVolume->GetLogicalVolume()->GetSensitiveDetector();
|
||||
G4VFastSimSensitiveDetector* fastSimSensitive =
|
||||
dynamic_cast<G4VFastSimSensitiveDetector*>(sensitive);
|
||||
if(fastSimSensitive)
|
||||
{
|
||||
auto fastSimSensitive = dynamic_cast<G4VFastSimSensitiveDetector*>(sensitive);
|
||||
if (fastSimSensitive != nullptr) {
|
||||
fastSimSensitive->Hit(&aHit, &aTrack, &fTouchableHandle);
|
||||
}
|
||||
else if(sensitive &&
|
||||
currentVolume->GetLogicalVolume()->GetFastSimulationManager())
|
||||
else if ((sensitive != nullptr)
|
||||
&& (currentVolume->GetLogicalVolume()->GetFastSimulationManager() != nullptr))
|
||||
{
|
||||
fpSpotS->SetTotalEnergyDeposit(aHit.GetEnergy());
|
||||
fpSpotS->SetTrack(const_cast<G4Track*>(aTrack.GetPrimaryTrack()));
|
||||
|
||||
@@ -25,31 +25,34 @@
|
||||
//
|
||||
#include "G4FastSimulationHelper.hh"
|
||||
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4FastSimulationManagerProcess.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
|
||||
void G4FastSimulationHelper::ActivateFastSimulation(G4ProcessManager* pmanager, G4String parallelGeometryName )
|
||||
void G4FastSimulationHelper::ActivateFastSimulation(G4ProcessManager* pmanager,
|
||||
G4String parallelGeometryName)
|
||||
{
|
||||
G4FastSimulationManagerProcess* fastSimProcess;
|
||||
if ( parallelGeometryName.empty() ) {
|
||||
if (parallelGeometryName.empty()) {
|
||||
fastSimProcess = new G4FastSimulationManagerProcess("fastSimProcess_massGeom");
|
||||
// -- For the parametrisation envelope belonging to the mass geometry case, the G4FastSimulationManagerProcess
|
||||
// -- For the parametrisation envelope belonging to the mass geometry case, the
|
||||
// G4FastSimulationManagerProcess
|
||||
// -- is a PostStep process, and ordering does not matter:
|
||||
pmanager-> AddDiscreteProcess(fastSimProcess);
|
||||
pmanager->AddDiscreteProcess(fastSimProcess);
|
||||
}
|
||||
else {
|
||||
fastSimProcess = new G4FastSimulationManagerProcess("fastSimProcess_parallelGeom",parallelGeometryName);
|
||||
// -- For the parallel geometry case, the G4FastSimulationManagerProcessz
|
||||
// -- is an Along+PostStep process, and ordering matters:
|
||||
pmanager->AddProcess(fastSimProcess);
|
||||
pmanager->SetProcessOrdering(fastSimProcess, idxAlongStep, 1);
|
||||
fastSimProcess =
|
||||
new G4FastSimulationManagerProcess("fastSimProcess_parallelGeom", parallelGeometryName);
|
||||
// -- For the parallel geometry case, the G4FastSimulationManagerProcessz
|
||||
// -- is an Along+PostStep process, and ordering matters:
|
||||
pmanager->AddProcess(fastSimProcess);
|
||||
pmanager->SetProcessOrdering(fastSimProcess, idxAlongStep, 1);
|
||||
}
|
||||
// If the parallel world
|
||||
// exists (with parallel world physics), e.g. for the sensitive detector.
|
||||
// In that case make sure fast simulation is the first process to be checked by the steppping manager
|
||||
// (highest ordering) so that user can kill the particle and/or deposit energy, ignoring other processes.
|
||||
// Otherwise the parallel world physics (which is a StronglyFroced process) will invoke a PostStepDoIt
|
||||
// on the same step, leading to e.g. duplicated energy deposits.
|
||||
// In that case make sure fast simulation is the first process to be checked by the steppping
|
||||
// manager (highest ordering) so that user can kill the particle and/or deposit energy, ignoring
|
||||
// other processes. Otherwise the parallel world physics (which is a StronglyFroced process) will
|
||||
// invoke a PostStepDoIt on the same step, leading to e.g. duplicated energy deposits.
|
||||
|
||||
// Register as the process with highest ordering so it is checked as the first one,
|
||||
// and since it is exclusively forced no other process will be considered (to be invoked).
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#include "G4FastSimulationManager.hh"
|
||||
|
||||
#include "G4GlobalFastSimulationManager.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
@@ -48,19 +49,15 @@
|
||||
// Constructor with envelope and IsUnique flag :
|
||||
// --------------------------------------------------
|
||||
//
|
||||
G4FastSimulationManager::
|
||||
G4FastSimulationManager(G4Envelope *anEnvelope,
|
||||
G4bool IsUnique) :
|
||||
fFastTrack(anEnvelope,IsUnique),fTriggedFastSimulationModel(0),
|
||||
fLastCrossedParticle(0)
|
||||
G4FastSimulationManager::G4FastSimulationManager(G4Envelope* anEnvelope, G4bool IsUnique)
|
||||
: fFastTrack(anEnvelope, IsUnique)
|
||||
{
|
||||
// Communicates to the region that it becomes a
|
||||
// envelope and with this fast simulation manager.
|
||||
anEnvelope->SetFastSimulationManager(this);
|
||||
|
||||
// Add itself to the GlobalFastSimulationManager
|
||||
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->
|
||||
AddFastSimulationManager(this);
|
||||
// Add itself to the GlobalFastSimulationManager
|
||||
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->AddFastSimulationManager(this);
|
||||
}
|
||||
|
||||
// -----------
|
||||
@@ -69,108 +66,93 @@ G4FastSimulationManager(G4Envelope *anEnvelope,
|
||||
G4FastSimulationManager::~G4FastSimulationManager()
|
||||
{
|
||||
//
|
||||
// Check out the Envelope about this pointer. If in use,
|
||||
// Check out the Envelope about this pointer. If in use,
|
||||
// resets the Logical Volume IsEnvelope flag to avoid clash.
|
||||
//
|
||||
if(fFastTrack.GetEnvelope()->GetFastSimulationManager()==this)
|
||||
if (fFastTrack.GetEnvelope()->GetFastSimulationManager() == this)
|
||||
fFastTrack.GetEnvelope()->ClearFastSimulationManager();
|
||||
// Remove itself from the GlobalFastSimulationManager
|
||||
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->
|
||||
RemoveFastSimulationManager(this);
|
||||
// Remove itself from the GlobalFastSimulationManager
|
||||
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->RemoveFastSimulationManager(
|
||||
this);
|
||||
}
|
||||
|
||||
// ---------------------------------------
|
||||
// Methods to activate/inactivate models
|
||||
//----------------------------------------
|
||||
|
||||
G4bool
|
||||
G4FastSimulationManager::ActivateFastSimulationModel(const G4String& aName)
|
||||
G4bool G4FastSimulationManager::ActivateFastSimulationModel(const G4String& aName)
|
||||
{
|
||||
G4int iModel;
|
||||
|
||||
// If the model is already active, do nothing.
|
||||
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
|
||||
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<(G4int)fInactivatedModels.size(); ++iModel)
|
||||
if(fInactivatedModels[iModel]->GetName() == aName) {
|
||||
ModelList.
|
||||
push_back (fInactivatedModels.removeAt(iModel));
|
||||
for (iModel = 0; iModel < (G4int)fInactivatedModels.size(); ++iModel)
|
||||
if (fInactivatedModels[iModel]->GetName() == aName) {
|
||||
ModelList.push_back(fInactivatedModels.removeAt(iModel));
|
||||
// forces the fApplicableModelList to be rebuild
|
||||
fLastCrossedParticle=0;
|
||||
fLastCrossedParticle = nullptr;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
G4bool
|
||||
G4FastSimulationManager::InActivateFastSimulationModel(const G4String& aName)
|
||||
G4bool G4FastSimulationManager::InActivateFastSimulationModel(const G4String& aName)
|
||||
{
|
||||
// Look for in the ModelList, if found remove from it and keep the pointer
|
||||
// Look for in the ModelList, if found remove from it and keep the pointer
|
||||
// on the fInactivatedModels list.
|
||||
for (G4int iModel=0; iModel<(G4int)ModelList.size(); ++iModel)
|
||||
if(ModelList[iModel]->GetName() == aName) {
|
||||
fInactivatedModels.push_back (ModelList.removeAt(iModel));
|
||||
for (G4int iModel = 0; iModel < (G4int)ModelList.size(); ++iModel)
|
||||
if (ModelList[iModel]->GetName() == aName) {
|
||||
fInactivatedModels.push_back(ModelList.removeAt(iModel));
|
||||
// forces the fApplicableModelList to be rebuild
|
||||
fLastCrossedParticle=0;
|
||||
fLastCrossedParticle = nullptr;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
G4VFastSimulationModel*
|
||||
G4VFastSimulationModel*
|
||||
G4FastSimulationManager::GetFastSimulationModel(const G4String& modelName,
|
||||
const G4VFastSimulationModel* previousFound,
|
||||
bool &foundPrevious) const
|
||||
const G4VFastSimulationModel* previousFound,
|
||||
G4bool& foundPrevious) const
|
||||
{
|
||||
G4VFastSimulationModel* model = 0;
|
||||
for (std::size_t iModel=0; iModel<ModelList.size(); ++iModel)
|
||||
{
|
||||
if(ModelList[iModel]->GetName() == modelName)
|
||||
{
|
||||
if (previousFound == 0)
|
||||
{
|
||||
model = ModelList[iModel];
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ModelList[iModel] == previousFound)
|
||||
{
|
||||
foundPrevious = true;
|
||||
continue;
|
||||
}
|
||||
if (foundPrevious)
|
||||
{
|
||||
model = ModelList[iModel];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
G4VFastSimulationModel* model = nullptr;
|
||||
for (auto iModel : ModelList) {
|
||||
if (iModel->GetName() == modelName) {
|
||||
if (previousFound == nullptr) {
|
||||
model = iModel;
|
||||
break;
|
||||
}
|
||||
if (iModel == previousFound) {
|
||||
foundPrevious = true;
|
||||
continue;
|
||||
}
|
||||
if (foundPrevious) {
|
||||
model = iModel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
void G4FastSimulationManager::FlushModels()
|
||||
{
|
||||
for (std::size_t iModel=0; iModel<ModelList.size(); ++iModel)
|
||||
{
|
||||
ModelList[iModel]->Flush();
|
||||
}
|
||||
for (auto& iModel : ModelList) {
|
||||
iModel->Flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Interface trigger method for the G4ParameterisationManagerProcess
|
||||
//------------------------------------------------------------------
|
||||
// G4bool GetFastSimulationManagerTrigger(const G4Track &);
|
||||
//
|
||||
// This method is used to interface the G4FastSimulationManagerProcess
|
||||
// with the user Fast Simulation Models. It's called when the particle
|
||||
// with the user Fast Simulation Models. It's called when the particle
|
||||
// is inside the envelope.
|
||||
//
|
||||
// It :
|
||||
@@ -179,60 +161,59 @@ void G4FastSimulationManager::FlushModels()
|
||||
// on);
|
||||
// 2) loops on the IsApplicable() methods to find out the
|
||||
// ones should be applied.
|
||||
// 2) for these, loops on the ModelTrigger() methods to find out
|
||||
// 2) for these, loops on the ModelTrigger() methods to find out
|
||||
// perhaps one that must be applied just now.
|
||||
//
|
||||
// If the a Fast Simulation Model is triggered then it returns
|
||||
// If the a Fast Simulation Model is triggered then it returns
|
||||
// true, false otherwise.
|
||||
//
|
||||
//-----------------------------------------------------------
|
||||
G4bool
|
||||
G4FastSimulationManager::
|
||||
PostStepGetFastSimulationManagerTrigger(const G4Track& track,
|
||||
const G4Navigator* theNavigator)
|
||||
G4bool
|
||||
G4FastSimulationManager::PostStepGetFastSimulationManagerTrigger(const G4Track& track,
|
||||
const G4Navigator* theNavigator)
|
||||
{
|
||||
std::size_t iModel;
|
||||
|
||||
// If particle type changed re-build the fApplicableModelList.
|
||||
if(fLastCrossedParticle!=track.GetDefinition()) {
|
||||
fLastCrossedParticle=track.GetDefinition();
|
||||
if (fLastCrossedParticle != track.GetDefinition()) {
|
||||
fLastCrossedParticle = track.GetDefinition();
|
||||
fApplicableModelList.clear();
|
||||
// If Model List is empty, do nothing !
|
||||
if(ModelList.size()==0) return false;
|
||||
for (iModel=0; iModel<ModelList.size(); ++iModel)
|
||||
if(ModelList[iModel]->IsApplicable(*(track.GetDefinition())))
|
||||
fApplicableModelList.push_back (ModelList[iModel]);
|
||||
if (ModelList.empty()) return false;
|
||||
|
||||
for (auto iModel : ModelList) {
|
||||
if (iModel->IsApplicable(*(track.GetDefinition()))) {
|
||||
fApplicableModelList.push_back(iModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If Applicable Model List is empty, do nothing !
|
||||
if(fApplicableModelList.size()==0) return false;
|
||||
if (fApplicableModelList.empty()) return false;
|
||||
|
||||
// -- Register current track
|
||||
fFastTrack.SetCurrentTrack(track,theNavigator);
|
||||
fFastTrack.SetCurrentTrack(track, theNavigator);
|
||||
|
||||
// tests if particle are on the boundary and leaving,
|
||||
// in this case do nothing !
|
||||
if(fFastTrack.OnTheBoundaryButExiting()) return false;
|
||||
|
||||
if (fFastTrack.OnTheBoundaryButExiting()) return false;
|
||||
|
||||
// Loops on the ModelTrigger() methods
|
||||
for (iModel=0; iModel<fApplicableModelList.size(); ++iModel)
|
||||
|
||||
for (auto iModel : fApplicableModelList)
|
||||
//---------------------------------------------------
|
||||
// Asks the ModelTrigger method if it must be trigged now.
|
||||
//---------------------------------------------------
|
||||
|
||||
if(fApplicableModelList[iModel]->ModelTrigger(fFastTrack)) {
|
||||
|
||||
if (iModel->ModelTrigger(fFastTrack)) {
|
||||
//--------------------------------------------------
|
||||
// The model will be applied. Initializes the G4FastStep
|
||||
// with the current state of the G4Track and
|
||||
// The model will be applied. Initializes the G4FastStep
|
||||
// with the current state of the G4Track and
|
||||
// same usefull parameters.
|
||||
// In particular it does SetLocalEnergyDeposit(0.0).
|
||||
//--------------------------------------------------
|
||||
//--------------------------------------------------
|
||||
fFastStep.Initialize(fFastTrack);
|
||||
|
||||
|
||||
// Keeps the FastSimulationModel pointer to call the
|
||||
// DoIt() method.
|
||||
fTriggedFastSimulationModel=fApplicableModelList[iModel];
|
||||
fTriggedFastSimulationModel = iModel;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -242,89 +223,86 @@ PostStepGetFastSimulationManagerTrigger(const G4Track& track,
|
||||
return false;
|
||||
}
|
||||
|
||||
G4VParticleChange* G4FastSimulationManager::InvokePostStepDoIt()
|
||||
G4VParticleChange* G4FastSimulationManager::InvokePostStepDoIt()
|
||||
{
|
||||
// const G4FastTrack& parFastTrack=fFastTrack;
|
||||
fTriggedFastSimulationModel->DoIt(fFastTrack,fFastStep);
|
||||
fTriggedFastSimulationModel->DoIt(fFastTrack, fFastStep);
|
||||
return &fFastStep;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// -- Mostly the same as above, in the case of AtRest particles:
|
||||
// -------------------------------------------------------------
|
||||
G4bool
|
||||
G4bool
|
||||
G4FastSimulationManager::AtRestGetFastSimulationManagerTrigger(const G4Track& track,
|
||||
const G4Navigator* theNavigator)
|
||||
const G4Navigator* theNavigator)
|
||||
{
|
||||
std::size_t iModel;
|
||||
|
||||
// If particle type changed re-build the fApplicableModelList.
|
||||
if(fLastCrossedParticle!=track.GetDefinition()) {
|
||||
fLastCrossedParticle=track.GetDefinition();
|
||||
if (fLastCrossedParticle != track.GetDefinition()) {
|
||||
fLastCrossedParticle = track.GetDefinition();
|
||||
fApplicableModelList.clear();
|
||||
// If Model List is empty, do nothing !
|
||||
if(ModelList.size()==0) return false;
|
||||
for (iModel=0; iModel<ModelList.size(); ++iModel)
|
||||
if(ModelList[iModel]->IsApplicable(*(track.GetDefinition())))
|
||||
fApplicableModelList.push_back (ModelList[iModel]);
|
||||
if (ModelList.empty()) return false;
|
||||
|
||||
for (auto iModel : ModelList) {
|
||||
if (iModel->IsApplicable(*(track.GetDefinition()))) {
|
||||
fApplicableModelList.push_back(iModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If Applicable Model List is empty, do nothing !
|
||||
if(fApplicableModelList.size()==0) return false;
|
||||
if (fApplicableModelList.empty()) return false;
|
||||
|
||||
// -- Register current track
|
||||
fFastTrack.SetCurrentTrack(track,theNavigator);
|
||||
|
||||
fFastTrack.SetCurrentTrack(track, theNavigator);
|
||||
|
||||
// -- (note: compared to the PostStepGetFastSimulationManagerTrigger,
|
||||
// -- the test to see if the particle is on the boundary but leaving
|
||||
// -- is irrelevant here)
|
||||
|
||||
|
||||
// Loops on the models to see if one of them wants to trigger:
|
||||
for (iModel=0; iModel < fApplicableModelList.size(); ++iModel)
|
||||
if(fApplicableModelList[iModel]->AtRestModelTrigger(fFastTrack))
|
||||
{
|
||||
fFastStep.Initialize(fFastTrack);
|
||||
fTriggedFastSimulationModel=fApplicableModelList[iModel];
|
||||
return true;
|
||||
}
|
||||
|
||||
for (auto iModel : fApplicableModelList) {
|
||||
if (iModel->AtRestModelTrigger(fFastTrack)) {
|
||||
fFastStep.Initialize(fFastTrack);
|
||||
fTriggedFastSimulationModel = iModel;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//--------------------------------------------
|
||||
// Nobody asks to gain control, returns false
|
||||
//--------------------------------------------
|
||||
return false;
|
||||
}
|
||||
|
||||
G4VParticleChange* G4FastSimulationManager::InvokeAtRestDoIt()
|
||||
G4VParticleChange* G4FastSimulationManager::InvokeAtRestDoIt()
|
||||
{
|
||||
fTriggedFastSimulationModel->AtRestDoIt(fFastTrack,fFastStep);
|
||||
fTriggedFastSimulationModel->AtRestDoIt(fFastTrack, fFastStep);
|
||||
return &fFastStep;
|
||||
}
|
||||
|
||||
void
|
||||
G4FastSimulationManager::ListTitle() const
|
||||
void G4FastSimulationManager::ListTitle() const
|
||||
{
|
||||
G4cout << fFastTrack.GetEnvelope()->GetName();
|
||||
// if(GhostPlacements.size()!=0) G4cout << " (ghost)";
|
||||
if (fFastTrack.GetEnvelope()->GetWorldPhysical() == G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume()) G4cout << " (mass geom.)";
|
||||
else G4cout << " (// geom.)";
|
||||
|
||||
if (fFastTrack.GetEnvelope()->GetWorldPhysical()
|
||||
== G4TransportationManager::GetTransportationManager()
|
||||
->GetNavigatorForTracking()
|
||||
->GetWorldVolume())
|
||||
G4cout << " (mass geom.)";
|
||||
else
|
||||
G4cout << " (// geom.)";
|
||||
}
|
||||
|
||||
void
|
||||
G4FastSimulationManager::ListModels() const
|
||||
void G4FastSimulationManager::ListModels() const
|
||||
{
|
||||
std::size_t iModel;
|
||||
|
||||
G4cout << "Current Models for the ";
|
||||
ListTitle();
|
||||
G4cout << " envelope:\n";
|
||||
|
||||
for (iModel=0; iModel<ModelList.size(); ++iModel)
|
||||
G4cout << " " << ModelList[iModel]->GetName() << "\n";
|
||||
for (auto iModel : ModelList)
|
||||
G4cout << " " << iModel->GetName() << "\n";
|
||||
|
||||
for (iModel=0; iModel<fInactivatedModels.size(); ++iModel)
|
||||
G4cout << " " << fInactivatedModels[iModel]->GetName()
|
||||
<< "(inactivated)\n";
|
||||
for (auto iModel : fInactivatedModels)
|
||||
G4cout << " " << iModel->GetName() << "(inactivated)\n";
|
||||
}
|
||||
|
||||
void G4FastSimulationManager::ListModels(const G4String& modelName) const
|
||||
@@ -332,94 +310,79 @@ void G4FastSimulationManager::ListModels(const G4String& modelName) const
|
||||
std::size_t iModel;
|
||||
G4int titled = 0;
|
||||
G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
|
||||
|
||||
|
||||
// Active Models
|
||||
for ( iModel=0; iModel<ModelList.size(); ++iModel )
|
||||
if( ModelList[iModel]->GetName() == modelName || modelName == "all" )
|
||||
{
|
||||
if( !(titled++) )
|
||||
{
|
||||
G4cout << "In the envelope ";
|
||||
ListTitle();
|
||||
G4cout << ",\n";
|
||||
}
|
||||
G4cout << " the model " << ModelList[iModel]->GetName()
|
||||
<< " is applicable for :\n ";
|
||||
|
||||
G4int list_started=0;
|
||||
for ( G4int iParticle = 0; iParticle<theParticleTable->entries(); iParticle++)
|
||||
if( ModelList[iModel] -> IsApplicable( *(theParticleTable->GetParticle(iParticle))) )
|
||||
{
|
||||
if(list_started++) G4cout << ", ";
|
||||
G4cout << theParticleTable->
|
||||
GetParticle(iParticle)->GetParticleName();
|
||||
}
|
||||
G4cout <<G4endl;
|
||||
for (iModel = 0; iModel < ModelList.size(); ++iModel)
|
||||
if (ModelList[iModel]->GetName() == modelName || modelName == "all") {
|
||||
if ((titled++) == 0) {
|
||||
G4cout << "In the envelope ";
|
||||
ListTitle();
|
||||
G4cout << ",\n";
|
||||
}
|
||||
|
||||
G4cout << " the model " << ModelList[iModel]->GetName() << " is applicable for :\n ";
|
||||
|
||||
G4int list_started = 0;
|
||||
for (G4int iParticle = 0; iParticle < theParticleTable->entries(); iParticle++)
|
||||
if (ModelList[iModel]->IsApplicable(*(theParticleTable->GetParticle(iParticle)))) {
|
||||
if ((list_started++) != 0) G4cout << ", ";
|
||||
G4cout << theParticleTable->GetParticle(iParticle)->GetParticleName();
|
||||
}
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
// Inactive Models
|
||||
for (iModel=0; iModel<fInactivatedModels.size(); ++iModel)
|
||||
if(fInactivatedModels[iModel]->GetName() == modelName || modelName == "all" )
|
||||
{
|
||||
if( !(titled++) )
|
||||
{
|
||||
G4cout << "In the envelope ";
|
||||
ListTitle();
|
||||
G4cout << ",\n";
|
||||
}
|
||||
G4cout << " the model " << fInactivatedModels[iModel]->GetName()
|
||||
<< " (inactivated) is applicable for :\n ";
|
||||
|
||||
G4int list_started=0;
|
||||
for ( G4int iParticle=0; iParticle<theParticleTable->entries(); iParticle++ )
|
||||
if( fInactivatedModels[iModel] -> IsApplicable( *(theParticleTable->GetParticle(iParticle))) )
|
||||
{
|
||||
if(list_started++) G4cout << ", ";
|
||||
G4cout << theParticleTable->
|
||||
GetParticle(iParticle)->GetParticleName();
|
||||
}
|
||||
G4cout <<G4endl;
|
||||
for (iModel = 0; iModel < fInactivatedModels.size(); ++iModel)
|
||||
if (fInactivatedModels[iModel]->GetName() == modelName || modelName == "all") {
|
||||
if ((titled++) == 0) {
|
||||
G4cout << "In the envelope ";
|
||||
ListTitle();
|
||||
G4cout << ",\n";
|
||||
}
|
||||
G4cout << " the model " << fInactivatedModels[iModel]->GetName()
|
||||
<< " (inactivated) is applicable for :\n ";
|
||||
|
||||
G4int list_started = 0;
|
||||
for (G4int iParticle = 0; iParticle < theParticleTable->entries(); iParticle++)
|
||||
if (fInactivatedModels[iModel]->IsApplicable(*(theParticleTable->GetParticle(iParticle)))) {
|
||||
if ((list_started++) != 0) G4cout << ", ";
|
||||
G4cout << theParticleTable->GetParticle(iParticle)->GetParticleName();
|
||||
}
|
||||
G4cout << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
void G4FastSimulationManager::ListModels(const G4ParticleDefinition* particleDefinition) const
|
||||
{
|
||||
std::size_t iModel;
|
||||
G4bool unique = true;
|
||||
|
||||
|
||||
// Active Models
|
||||
for ( iModel=0; iModel<ModelList.size(); ++iModel )
|
||||
if ( ModelList[iModel]->IsApplicable(*particleDefinition) )
|
||||
{
|
||||
G4cout << "Envelope ";
|
||||
ListTitle();
|
||||
G4cout << ", Model "
|
||||
<< ModelList[iModel]->GetName()
|
||||
<< "." << G4endl;
|
||||
// -- Verify unicity of model attached to particleDefinition:
|
||||
for ( auto jModel = iModel + 1; jModel < ModelList.size(); jModel++ )
|
||||
if ( ModelList[jModel]->IsApplicable(*particleDefinition) ) unique = false;
|
||||
}
|
||||
|
||||
// Inactive Models
|
||||
for ( iModel=0; iModel<fInactivatedModels.size(); ++iModel )
|
||||
if( fInactivatedModels[iModel]->IsApplicable(*particleDefinition) )
|
||||
{
|
||||
G4cout << "Envelope ";
|
||||
ListTitle();
|
||||
G4cout << ", Model "
|
||||
<< fInactivatedModels[iModel]->GetName()
|
||||
<< " (inactivated)." << G4endl;
|
||||
}
|
||||
|
||||
if( !unique )
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "Two or more active Models are available for the same particle type, in the same envelope/region." << G4endl;
|
||||
G4Exception("G4FastSimulationManager::ListModels(const G4ParticleDefinition* particleDefinition) const",
|
||||
"FastSim001",
|
||||
JustWarning, ed,
|
||||
"Models risk to exclude each other.");
|
||||
for (iModel = 0; iModel < ModelList.size(); ++iModel)
|
||||
if (ModelList[iModel]->IsApplicable(*particleDefinition)) {
|
||||
G4cout << "Envelope ";
|
||||
ListTitle();
|
||||
G4cout << ", Model " << ModelList[iModel]->GetName() << "." << G4endl;
|
||||
// -- Verify unicity of model attached to particleDefinition:
|
||||
for (auto jModel = iModel + 1; jModel < ModelList.size(); jModel++)
|
||||
if (ModelList[jModel]->IsApplicable(*particleDefinition)) unique = false;
|
||||
}
|
||||
unique=false;
|
||||
|
||||
// Inactive Models
|
||||
for (iModel = 0; iModel < fInactivatedModels.size(); ++iModel)
|
||||
if (fInactivatedModels[iModel]->IsApplicable(*particleDefinition)) {
|
||||
G4cout << "Envelope ";
|
||||
ListTitle();
|
||||
G4cout << ", Model " << fInactivatedModels[iModel]->GetName() << " (inactivated)." << G4endl;
|
||||
}
|
||||
|
||||
if (!unique) {
|
||||
G4ExceptionDescription ed;
|
||||
ed << "Two or more active Models are available for the same particle type, in the same "
|
||||
"envelope/region."
|
||||
<< G4endl;
|
||||
G4Exception(
|
||||
"G4FastSimulationManager::ListModels(const G4ParticleDefinition* particleDefinition) const",
|
||||
"FastSim001", JustWarning, ed, "Models risk to exclude each other.");
|
||||
}
|
||||
unique = false;
|
||||
}
|
||||
|
||||
@@ -39,233 +39,211 @@
|
||||
// October 06: move to parallel geometry scheme, M. Verderi
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#include "G4ios.hh"
|
||||
#include "G4FastSimulationManagerProcess.hh"
|
||||
#include "G4GlobalFastSimulationManager.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4PathFinder.hh"
|
||||
#include "G4ParticleChange.hh"
|
||||
|
||||
#include "G4FieldTrackUpdator.hh"
|
||||
#include "G4GlobalFastSimulationManager.hh"
|
||||
#include "G4ParticleChange.hh"
|
||||
#include "G4PathFinder.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
#define PARANOIA
|
||||
|
||||
G4FastSimulationManagerProcess::
|
||||
G4FastSimulationManagerProcess(const G4String& processName,
|
||||
G4ProcessType theType) :
|
||||
G4VProcess(processName,theType),
|
||||
fWorldVolume ( nullptr ),
|
||||
fIsTrackingTime ( false ),
|
||||
fIsFirstStep ( false ),
|
||||
fGhostNavigator ( nullptr ),
|
||||
fGhostNavigatorIndex ( -1 ),
|
||||
fIsGhostGeometry ( false ),
|
||||
fGhostSafety ( -1.0 ),
|
||||
fFieldTrack ( '0' ),
|
||||
fFastSimulationManager( nullptr ),
|
||||
fFastSimulationTrigger( false )
|
||||
G4FastSimulationManagerProcess::G4FastSimulationManagerProcess(const G4String& processName,
|
||||
G4ProcessType theType)
|
||||
: G4VProcess(processName, theType),
|
||||
fWorldVolume(nullptr),
|
||||
fIsTrackingTime(false),
|
||||
fIsFirstStep(false),
|
||||
fGhostNavigator(nullptr),
|
||||
fGhostNavigatorIndex(-1),
|
||||
fIsGhostGeometry(false),
|
||||
fGhostSafety(-1.0),
|
||||
fFieldTrack('0'),
|
||||
fFastSimulationManager(nullptr),
|
||||
fFastSimulationTrigger(false)
|
||||
{
|
||||
// -- set Process Sub Type
|
||||
SetProcessSubType(static_cast<int>(FASTSIM_ManagerProcess));
|
||||
|
||||
|
||||
fPathFinder = G4PathFinder::GetInstance();
|
||||
fPathFinder = G4PathFinder::GetInstance();
|
||||
fTransportationManager = G4TransportationManager::GetTransportationManager();
|
||||
|
||||
|
||||
SetWorldVolume(fTransportationManager->GetNavigatorForTracking()->GetWorldVolume()->GetName());
|
||||
if (verboseLevel>0) G4cout << "G4FastSimulationManagerProcess `" << GetProcessName()
|
||||
<< "' is created, and will message geometry with world volume `"
|
||||
<< fWorldVolume->GetName() << "'." << G4endl;
|
||||
if (verboseLevel > 0)
|
||||
G4cout << "G4FastSimulationManagerProcess `" << GetProcessName()
|
||||
<< "' is created, and will message geometry with world volume `"
|
||||
<< fWorldVolume->GetName() << "'." << G4endl;
|
||||
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->AddFSMP(this);
|
||||
}
|
||||
|
||||
|
||||
G4FastSimulationManagerProcess::
|
||||
G4FastSimulationManagerProcess(const G4String& processName,
|
||||
const G4String& worldVolumeName,
|
||||
G4ProcessType theType) :
|
||||
G4VProcess(processName,theType),
|
||||
fWorldVolume ( nullptr ),
|
||||
fIsTrackingTime ( false ),
|
||||
fIsFirstStep ( false ),
|
||||
fGhostNavigator ( nullptr ),
|
||||
fGhostNavigatorIndex ( -1 ),
|
||||
fIsGhostGeometry ( false ),
|
||||
fGhostSafety ( -1.0 ),
|
||||
fFieldTrack ( '0' ),
|
||||
fFastSimulationManager( nullptr ),
|
||||
fFastSimulationTrigger( false )
|
||||
G4FastSimulationManagerProcess::G4FastSimulationManagerProcess(const G4String& processName,
|
||||
const G4String& worldVolumeName,
|
||||
G4ProcessType theType)
|
||||
: G4VProcess(processName, theType),
|
||||
fWorldVolume(nullptr),
|
||||
fIsTrackingTime(false),
|
||||
fIsFirstStep(false),
|
||||
fGhostNavigator(nullptr),
|
||||
fGhostNavigatorIndex(-1),
|
||||
fIsGhostGeometry(false),
|
||||
fGhostSafety(-1.0),
|
||||
fFieldTrack('0'),
|
||||
fFastSimulationManager(nullptr),
|
||||
fFastSimulationTrigger(false)
|
||||
{
|
||||
// -- set Process Sub Type
|
||||
SetProcessSubType(static_cast<int>(FASTSIM_ManagerProcess));
|
||||
|
||||
|
||||
fPathFinder = G4PathFinder::GetInstance();
|
||||
fPathFinder = G4PathFinder::GetInstance();
|
||||
fTransportationManager = G4TransportationManager::GetTransportationManager();
|
||||
|
||||
SetWorldVolume(worldVolumeName);
|
||||
if (verboseLevel>0) G4cout << "G4FastSimulationManagerProcess `" << GetProcessName()
|
||||
<< "' is created, and will message geometry with world volume `"
|
||||
<< fWorldVolume->GetName() << "'." << G4endl;
|
||||
if (verboseLevel > 0)
|
||||
G4cout << "G4FastSimulationManagerProcess `" << GetProcessName()
|
||||
<< "' is created, and will message geometry with world volume `"
|
||||
<< fWorldVolume->GetName() << "'." << G4endl;
|
||||
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->AddFSMP(this);
|
||||
}
|
||||
|
||||
|
||||
G4FastSimulationManagerProcess::
|
||||
G4FastSimulationManagerProcess(const G4String& processName,
|
||||
G4VPhysicalVolume* worldVolume,
|
||||
G4ProcessType theType) :
|
||||
G4VProcess(processName,theType),
|
||||
fWorldVolume ( nullptr ),
|
||||
fIsTrackingTime ( false ),
|
||||
fIsFirstStep ( false ),
|
||||
fGhostNavigator ( nullptr ),
|
||||
fGhostNavigatorIndex ( -1 ),
|
||||
fIsGhostGeometry ( false ),
|
||||
fGhostSafety ( -1.0 ),
|
||||
fFieldTrack ( '0' ),
|
||||
fFastSimulationManager( nullptr ),
|
||||
fFastSimulationTrigger( false )
|
||||
G4FastSimulationManagerProcess::G4FastSimulationManagerProcess(const G4String& processName,
|
||||
G4VPhysicalVolume* worldVolume,
|
||||
G4ProcessType theType)
|
||||
: G4VProcess(processName, theType),
|
||||
fWorldVolume(nullptr),
|
||||
fIsTrackingTime(false),
|
||||
fIsFirstStep(false),
|
||||
fGhostNavigator(nullptr),
|
||||
fGhostNavigatorIndex(-1),
|
||||
fIsGhostGeometry(false),
|
||||
fGhostSafety(-1.0),
|
||||
fFieldTrack('0'),
|
||||
fFastSimulationManager(nullptr),
|
||||
fFastSimulationTrigger(false)
|
||||
{
|
||||
// -- set Process Sub Type
|
||||
SetProcessSubType(static_cast<int>(FASTSIM_ManagerProcess));
|
||||
|
||||
|
||||
fPathFinder = G4PathFinder::GetInstance();
|
||||
fPathFinder = G4PathFinder::GetInstance();
|
||||
fTransportationManager = G4TransportationManager::GetTransportationManager();
|
||||
|
||||
SetWorldVolume(worldVolume);
|
||||
if (verboseLevel>0) G4cout << "G4FastSimulationManagerProcess `" << GetProcessName()
|
||||
<< "' is created, and will message geometry with world volume `"
|
||||
<< fWorldVolume->GetName() << "'." << G4endl;
|
||||
if (verboseLevel > 0)
|
||||
G4cout << "G4FastSimulationManagerProcess `" << GetProcessName()
|
||||
<< "' is created, and will message geometry with world volume `"
|
||||
<< fWorldVolume->GetName() << "'." << G4endl;
|
||||
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->AddFSMP(this);
|
||||
}
|
||||
|
||||
|
||||
G4FastSimulationManagerProcess::~G4FastSimulationManagerProcess()
|
||||
{
|
||||
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->RemoveFSMP(this);
|
||||
}
|
||||
|
||||
|
||||
// -----------------------
|
||||
// User access methods:
|
||||
// -----------------------
|
||||
void G4FastSimulationManagerProcess::SetWorldVolume(G4String newWorldName)
|
||||
{
|
||||
if (fIsTrackingTime)
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "G4FastSimulationManagerProcess `" << GetProcessName()
|
||||
<< "': changing of world volume at tracking time is not allowed." << G4endl;
|
||||
G4Exception("G4FastSimulationManagerProcess::SetWorldVolume(const G4String)",
|
||||
"FastSim002",
|
||||
JustWarning, ed,
|
||||
"Call ignored.");
|
||||
if (fIsTrackingTime) {
|
||||
G4ExceptionDescription ed;
|
||||
ed << "G4FastSimulationManagerProcess `" << GetProcessName()
|
||||
<< "': changing of world volume at tracking time is not allowed." << G4endl;
|
||||
G4Exception("G4FastSimulationManagerProcess::SetWorldVolume(const G4String)", "FastSim002",
|
||||
JustWarning, ed, "Call ignored.");
|
||||
}
|
||||
else {
|
||||
G4VPhysicalVolume* newWorld = fTransportationManager->IsWorldExisting(newWorldName);
|
||||
if (newWorld == nullptr) {
|
||||
G4ExceptionDescription tellWhatIsWrong;
|
||||
tellWhatIsWrong << "Volume newWorldName = `" << newWorldName
|
||||
<< "' is not a parallel world nor the mass world volume." << G4endl;
|
||||
G4Exception("G4FastSimulationManagerProcess::SetWorldVolume(const G4String)", "FastSim003",
|
||||
FatalException, tellWhatIsWrong);
|
||||
}
|
||||
else
|
||||
{
|
||||
G4VPhysicalVolume* newWorld = fTransportationManager->IsWorldExisting(newWorldName);
|
||||
if (newWorld == 0)
|
||||
{
|
||||
G4ExceptionDescription tellWhatIsWrong;
|
||||
tellWhatIsWrong << "Volume newWorldName = `" << newWorldName
|
||||
<< "' is not a parallel world nor the mass world volume."
|
||||
<< G4endl;
|
||||
G4Exception("G4FastSimulationManagerProcess::SetWorldVolume(const G4String)",
|
||||
"FastSim003",
|
||||
FatalException,
|
||||
tellWhatIsWrong);
|
||||
}
|
||||
if (verboseLevel>0)
|
||||
{
|
||||
if (fWorldVolume) G4cout << "G4FastSimulationManagerProcess `" << GetProcessName()
|
||||
<< "': changing world volume from '" << fWorldVolume->GetName()
|
||||
<< "' to `" << newWorld << "'." << G4endl;
|
||||
else G4cout << "G4FastSimulationManagerProcess `" << GetProcessName()
|
||||
<< "': setting world volume from to `"<< newWorld->GetName() << "'." << G4endl;
|
||||
}
|
||||
fWorldVolume = newWorld;
|
||||
if (verboseLevel > 0) {
|
||||
if (fWorldVolume != nullptr)
|
||||
G4cout << "G4FastSimulationManagerProcess `" << GetProcessName()
|
||||
<< "': changing world volume from '" << fWorldVolume->GetName() << "' to `"
|
||||
<< newWorld << "'." << G4endl;
|
||||
else
|
||||
G4cout << "G4FastSimulationManagerProcess `" << GetProcessName()
|
||||
<< "': setting world volume from to `" << newWorld->GetName() << "'." << G4endl;
|
||||
}
|
||||
fWorldVolume = newWorld;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void G4FastSimulationManagerProcess::SetWorldVolume(G4VPhysicalVolume* newWorld)
|
||||
{
|
||||
if (newWorld) SetWorldVolume(newWorld->GetName());
|
||||
else
|
||||
{
|
||||
G4ExceptionDescription tellWhatIsWrong;
|
||||
tellWhatIsWrong << "Null pointer passed for world volume." << G4endl;
|
||||
G4Exception("G4FastSimulationManagerProcess::SetWorldVolume(const G4VPhysicalVolume* newWorld)",
|
||||
"FastSim004",
|
||||
FatalException,
|
||||
tellWhatIsWrong);
|
||||
}
|
||||
if (newWorld != nullptr)
|
||||
SetWorldVolume(newWorld->GetName());
|
||||
else {
|
||||
G4ExceptionDescription tellWhatIsWrong;
|
||||
tellWhatIsWrong << "Null pointer passed for world volume." << G4endl;
|
||||
G4Exception("G4FastSimulationManagerProcess::SetWorldVolume(const G4VPhysicalVolume* newWorld)",
|
||||
"FastSim004", FatalException, tellWhatIsWrong);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --------------------
|
||||
// Start/End tracking:
|
||||
// --------------------
|
||||
void G4FastSimulationManagerProcess::StartTracking(G4Track* track)
|
||||
{
|
||||
fIsTrackingTime = true;
|
||||
fIsFirstStep = true;
|
||||
|
||||
fIsFirstStep = true;
|
||||
|
||||
// -- fetch the navigator (and its index) and activate it:
|
||||
G4TransportationManager* transportationManager = G4TransportationManager::GetTransportationManager();
|
||||
fGhostNavigator = transportationManager->GetNavigator(fWorldVolume);
|
||||
fIsGhostGeometry = (fGhostNavigator != transportationManager->GetNavigatorForTracking());
|
||||
if (fIsGhostGeometry) fGhostNavigatorIndex = transportationManager->ActivateNavigator(fGhostNavigator);
|
||||
else fGhostNavigatorIndex = -1;
|
||||
G4TransportationManager* transportationManager =
|
||||
G4TransportationManager::GetTransportationManager();
|
||||
fGhostNavigator = transportationManager->GetNavigator(fWorldVolume);
|
||||
fIsGhostGeometry = (fGhostNavigator != transportationManager->GetNavigatorForTracking());
|
||||
if (fIsGhostGeometry)
|
||||
fGhostNavigatorIndex = transportationManager->ActivateNavigator(fGhostNavigator);
|
||||
else
|
||||
fGhostNavigatorIndex = -1;
|
||||
|
||||
fPathFinder->PrepareNewTrack(track->GetPosition(), track->GetMomentumDirection());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
G4FastSimulationManagerProcess::
|
||||
EndTracking()
|
||||
void G4FastSimulationManagerProcess::EndTracking()
|
||||
{
|
||||
fIsTrackingTime = false;
|
||||
if ( fIsGhostGeometry ) fTransportationManager->DeActivateNavigator(fGhostNavigator);
|
||||
if (fIsGhostGeometry) fTransportationManager->DeActivateNavigator(fGhostNavigator);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------
|
||||
// PostStepGetPhysicalInteractionLength():
|
||||
// ------------------------------------------
|
||||
G4double
|
||||
G4FastSimulationManagerProcess::
|
||||
PostStepGetPhysicalInteractionLength(const G4Track& track,
|
||||
G4double,
|
||||
G4ForceCondition* condition)
|
||||
G4double
|
||||
G4FastSimulationManagerProcess::PostStepGetPhysicalInteractionLength(const G4Track& track, G4double,
|
||||
G4ForceCondition* condition)
|
||||
{
|
||||
// -- Get current volume, and check for presence of fast simulation manager.
|
||||
// -- For the case of the navigator for tracking (fGhostNavigatorIndex == 0)
|
||||
// -- we use the track volume. This allows the code to be valid for both
|
||||
// -- cases where the PathFinder is used (G4CoupledTranportation) or not
|
||||
// -- (G4Transportation).
|
||||
const G4VPhysicalVolume* currentVolume(0);
|
||||
if ( fIsGhostGeometry ) currentVolume = fPathFinder->GetLocatedVolume(fGhostNavigatorIndex);
|
||||
else currentVolume = track.GetVolume();
|
||||
const G4VPhysicalVolume* currentVolume(nullptr);
|
||||
if (fIsGhostGeometry)
|
||||
currentVolume = fPathFinder->GetLocatedVolume(fGhostNavigatorIndex);
|
||||
else
|
||||
currentVolume = track.GetVolume();
|
||||
|
||||
if ( currentVolume )
|
||||
{
|
||||
fFastSimulationManager = currentVolume->GetLogicalVolume()->GetFastSimulationManager();
|
||||
if( fFastSimulationManager )
|
||||
{
|
||||
// Ask for trigger:
|
||||
fFastSimulationTrigger = fFastSimulationManager->PostStepGetFastSimulationManagerTrigger(track, fGhostNavigator);
|
||||
if( fFastSimulationTrigger )
|
||||
{
|
||||
// Take control over stepping:
|
||||
*condition = ExclusivelyForced;
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
if (currentVolume != nullptr) {
|
||||
fFastSimulationManager = currentVolume->GetLogicalVolume()->GetFastSimulationManager();
|
||||
if (fFastSimulationManager != nullptr) {
|
||||
// Ask for trigger:
|
||||
fFastSimulationTrigger =
|
||||
fFastSimulationManager->PostStepGetFastSimulationManagerTrigger(track, fGhostNavigator);
|
||||
if (fFastSimulationTrigger) {
|
||||
// Take control over stepping:
|
||||
*condition = ExclusivelyForced;
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// -- no fast simulation occuring there:
|
||||
*condition = NotForced;
|
||||
return DBL_MAX;
|
||||
@@ -274,80 +252,67 @@ PostStepGetPhysicalInteractionLength(const G4Track& track,
|
||||
//------------------------------------
|
||||
// PostStepDoIt()
|
||||
//------------------------------------
|
||||
G4VParticleChange*
|
||||
G4FastSimulationManagerProcess::
|
||||
PostStepDoIt(const G4Track&,
|
||||
const G4Step&)
|
||||
G4VParticleChange* G4FastSimulationManagerProcess::PostStepDoIt(const G4Track&, const G4Step&)
|
||||
{
|
||||
G4VParticleChange* finalState = fFastSimulationManager->InvokePostStepDoIt();
|
||||
|
||||
|
||||
// If the particle is still alive, suspend it to force physics re-initialisation:
|
||||
if (finalState->GetTrackStatus() != fStopAndKill) finalState->ProposeTrackStatus(fSuspend);
|
||||
|
||||
|
||||
return finalState;
|
||||
}
|
||||
|
||||
|
||||
G4double
|
||||
G4FastSimulationManagerProcess::
|
||||
AlongStepGetPhysicalInteractionLength(const G4Track& track,
|
||||
G4double previousStepSize,
|
||||
G4double currentMinimumStep,
|
||||
G4double& proposedSafety,
|
||||
G4GPILSelection* selection)
|
||||
G4double G4FastSimulationManagerProcess::AlongStepGetPhysicalInteractionLength(
|
||||
const G4Track& track, G4double previousStepSize, G4double currentMinimumStep,
|
||||
G4double& proposedSafety, G4GPILSelection* selection)
|
||||
{
|
||||
|
||||
*selection = NotCandidateForSelection;
|
||||
*selection = NotCandidateForSelection;
|
||||
G4double returnedStep = DBL_MAX;
|
||||
|
||||
// ---------------------------------------------------
|
||||
// -- Below code valid for ghost geometry, otherwise
|
||||
// -- useless for fast simulation attached to mass
|
||||
// -- geometry. Warn user in case along used for
|
||||
// -- geometry. Warn user in case along used for
|
||||
// -- mass geometry ?
|
||||
// --------------------------------------------------
|
||||
if ( fIsGhostGeometry )
|
||||
{
|
||||
static G4ThreadLocal G4FieldTrack *endTrack_G4MT_TLS_ = 0 ;
|
||||
if (!endTrack_G4MT_TLS_) endTrack_G4MT_TLS_ = new G4FieldTrack ('0') ;
|
||||
G4FieldTrack &endTrack = *endTrack_G4MT_TLS_;
|
||||
|
||||
static G4ThreadLocal ELimited *eLimited_G4MT_TLS_ = 0 ;
|
||||
if (!eLimited_G4MT_TLS_) eLimited_G4MT_TLS_ = new ELimited ;
|
||||
ELimited &eLimited = *eLimited_G4MT_TLS_;
|
||||
|
||||
if (previousStepSize > 0.) fGhostSafety -= previousStepSize;
|
||||
if (fGhostSafety < 0.) fGhostSafety = 0.0;
|
||||
|
||||
// ------------------------------------------
|
||||
// Determination of the proposed step length:
|
||||
// ------------------------------------------
|
||||
if (currentMinimumStep <= fGhostSafety && currentMinimumStep > 0.)
|
||||
{
|
||||
// -- No chance to limit the step, as proposed move inside safety
|
||||
returnedStep = currentMinimumStep;
|
||||
proposedSafety = fGhostSafety - currentMinimumStep;
|
||||
}
|
||||
else
|
||||
{
|
||||
// -- Proposed move exceeds safety, need to state
|
||||
G4FieldTrackUpdator::Update(&fFieldTrack, &track);
|
||||
returnedStep = fPathFinder->ComputeStep(fFieldTrack,
|
||||
currentMinimumStep,
|
||||
fGhostNavigatorIndex,
|
||||
track.GetCurrentStepNumber(),
|
||||
fGhostSafety,
|
||||
eLimited,
|
||||
endTrack,
|
||||
track.GetVolume());
|
||||
|
||||
if(eLimited == kDoNot) fGhostSafety = fGhostNavigator->ComputeSafety(endTrack.GetPosition()); // -- step no limited by ghost
|
||||
proposedSafety = fGhostSafety;
|
||||
if (eLimited == kUnique || eLimited == kSharedOther) *selection = CandidateForSelection;
|
||||
else if (eLimited == kSharedTransport) returnedStep *= (1.0 + 1.0e-9); // -- Expand to disable its selection in Step Manager comparison
|
||||
}
|
||||
if (fIsGhostGeometry) {
|
||||
static G4ThreadLocal G4FieldTrack* endTrack_G4MT_TLS_ = nullptr;
|
||||
if (endTrack_G4MT_TLS_ == nullptr) endTrack_G4MT_TLS_ = new G4FieldTrack('0');
|
||||
G4FieldTrack& endTrack = *endTrack_G4MT_TLS_;
|
||||
|
||||
static G4ThreadLocal ELimited* eLimited_G4MT_TLS_ = nullptr;
|
||||
if (eLimited_G4MT_TLS_ == nullptr) eLimited_G4MT_TLS_ = new ELimited;
|
||||
ELimited& eLimited = *eLimited_G4MT_TLS_;
|
||||
|
||||
if (previousStepSize > 0.) fGhostSafety -= previousStepSize;
|
||||
if (fGhostSafety < 0.) fGhostSafety = 0.0;
|
||||
|
||||
// ------------------------------------------
|
||||
// Determination of the proposed step length:
|
||||
// ------------------------------------------
|
||||
if (currentMinimumStep <= fGhostSafety && currentMinimumStep > 0.) {
|
||||
// -- No chance to limit the step, as proposed move inside safety
|
||||
returnedStep = currentMinimumStep;
|
||||
proposedSafety = fGhostSafety - currentMinimumStep;
|
||||
}
|
||||
|
||||
else {
|
||||
// -- Proposed move exceeds safety, need to state
|
||||
G4FieldTrackUpdator::Update(&fFieldTrack, &track);
|
||||
returnedStep = fPathFinder->ComputeStep(fFieldTrack, currentMinimumStep, fGhostNavigatorIndex,
|
||||
track.GetCurrentStepNumber(), fGhostSafety, eLimited,
|
||||
endTrack, track.GetVolume());
|
||||
|
||||
if (eLimited == kDoNot)
|
||||
fGhostSafety =
|
||||
fGhostNavigator->ComputeSafety(endTrack.GetPosition()); // -- step no limited by ghost
|
||||
proposedSafety = fGhostSafety;
|
||||
if (eLimited == kUnique || eLimited == kSharedOther)
|
||||
*selection = CandidateForSelection;
|
||||
else if (eLimited == kSharedTransport)
|
||||
returnedStep *=
|
||||
(1.0 + 1.0e-9); // -- Expand to disable its selection in Step Manager comparison
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
// Returns the fGhostSafety as the proposedSafety
|
||||
@@ -357,42 +322,39 @@ AlongStepGetPhysicalInteractionLength(const G4Track& track,
|
||||
return returnedStep;
|
||||
}
|
||||
|
||||
G4VParticleChange*
|
||||
G4FastSimulationManagerProcess::
|
||||
AlongStepDoIt(const G4Track& track,
|
||||
const G4Step&)
|
||||
G4VParticleChange* G4FastSimulationManagerProcess::AlongStepDoIt(const G4Track& track,
|
||||
const G4Step&)
|
||||
{
|
||||
fDummyParticleChange.Initialize(track);
|
||||
return &fDummyParticleChange;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
// At Rest parameterisation:
|
||||
//--------------------------------------------
|
||||
// AtRestGetPhysiscalInteractionLength:
|
||||
//--------------------------------------------
|
||||
G4double
|
||||
G4FastSimulationManagerProcess::
|
||||
AtRestGetPhysicalInteractionLength(const G4Track& track,
|
||||
G4ForceCondition* condition)
|
||||
G4double
|
||||
G4FastSimulationManagerProcess::AtRestGetPhysicalInteractionLength(const G4Track& track,
|
||||
G4ForceCondition* condition)
|
||||
{
|
||||
const G4VPhysicalVolume* currentVolume(0);
|
||||
if ( fIsGhostGeometry ) currentVolume = fPathFinder->GetLocatedVolume(fGhostNavigatorIndex);
|
||||
else currentVolume = track.GetVolume();
|
||||
const G4VPhysicalVolume* currentVolume(nullptr);
|
||||
if (fIsGhostGeometry)
|
||||
currentVolume = fPathFinder->GetLocatedVolume(fGhostNavigatorIndex);
|
||||
else
|
||||
currentVolume = track.GetVolume();
|
||||
fFastSimulationManager = currentVolume->GetLogicalVolume()->GetFastSimulationManager();
|
||||
if( fFastSimulationManager )
|
||||
{
|
||||
// Ask for trigger:
|
||||
fFastSimulationTrigger = fFastSimulationManager->AtRestGetFastSimulationManagerTrigger(track, fGhostNavigator);
|
||||
if( fFastSimulationTrigger )
|
||||
{
|
||||
// Dirty trick to take control over stepping. Does anyone will ever use that ?
|
||||
*condition = NotForced;
|
||||
return -1.0;
|
||||
}
|
||||
if (fFastSimulationManager != nullptr) {
|
||||
// Ask for trigger:
|
||||
fFastSimulationTrigger =
|
||||
fFastSimulationManager->AtRestGetFastSimulationManagerTrigger(track, fGhostNavigator);
|
||||
if (fFastSimulationTrigger) {
|
||||
// Dirty trick to take control over stepping. Does anyone will ever use that ?
|
||||
*condition = NotForced;
|
||||
return -1.0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// -- no fast simulation occuring there:
|
||||
*condition = NotForced;
|
||||
return DBL_MAX;
|
||||
@@ -405,32 +367,3 @@ G4VParticleChange* G4FastSimulationManagerProcess::AtRestDoIt(const G4Track&, co
|
||||
{
|
||||
return fFastSimulationManager->InvokeAtRestDoIt();
|
||||
}
|
||||
|
||||
|
||||
void G4FastSimulationManagerProcess::Verbose() const
|
||||
{
|
||||
/* G4cout << " >>>>> Trigger Status : ";
|
||||
switch(fFastSimulationManager->GetTriggerStatus())
|
||||
{
|
||||
case NoModel:
|
||||
G4cout << "NoModel" << G4endl;
|
||||
break;
|
||||
case OnBoundaryButLeaving:
|
||||
G4cout << "OnBoundaryButLeaving" << G4endl;
|
||||
break;
|
||||
case OneModelTrigger:
|
||||
G4cout << "OneModelTrigger" << G4endl;
|
||||
break;
|
||||
case NoModelTrigger:
|
||||
G4cout << "NoModelTrigger" << G4endl;
|
||||
break;
|
||||
case Undefined:
|
||||
G4cout << "Undefined" << G4endl;
|
||||
break;
|
||||
default:
|
||||
G4cout << " Bizarre..." << G4endl;
|
||||
break;
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,21 +27,19 @@
|
||||
//
|
||||
|
||||
#include "G4FastSimulationMessenger.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
G4FastSimulationMessenger::
|
||||
G4FastSimulationMessenger(G4GlobalFastSimulationManager* theGFSM)
|
||||
G4FastSimulationMessenger::G4FastSimulationMessenger(G4GlobalFastSimulationManager* theGFSM)
|
||||
: fGlobalFastSimulationManager(theGFSM)
|
||||
{
|
||||
fFSDirectory = new G4UIdirectory("/param/");
|
||||
fFSDirectory->SetGuidance("Fast Simulation print/control commands.");
|
||||
|
||||
fShowSetupCmd =
|
||||
new G4UIcmdWithoutParameter("/param/showSetup", this);
|
||||
fShowSetupCmd = new G4UIcmdWithoutParameter("/param/showSetup", this);
|
||||
fShowSetupCmd->SetGuidance("Show fast simulation setup:");
|
||||
fShowSetupCmd->SetGuidance(" - for each world region:");
|
||||
fShowSetupCmd->SetGuidance(" 1) fast simulation manager process attached;");
|
||||
@@ -50,77 +48,61 @@ G4FastSimulationMessenger(G4GlobalFastSimulationManager* theGFSM)
|
||||
fShowSetupCmd->SetGuidance(" - with for each the fast simulation models attached;");
|
||||
fShowSetupCmd->AvailableForStates(G4State_Idle, G4State_GeomClosed);
|
||||
|
||||
fListEnvelopesCmd =
|
||||
new G4UIcmdWithAString("/param/listEnvelopes", this);
|
||||
fListEnvelopesCmd->SetParameterName("ParticleName",true);
|
||||
fListEnvelopesCmd = new G4UIcmdWithAString("/param/listEnvelopes", this);
|
||||
fListEnvelopesCmd->SetParameterName("ParticleName", true);
|
||||
fListEnvelopesCmd->SetDefaultValue("all");
|
||||
fListEnvelopesCmd->SetGuidance("List all the envelope names for a given Particle");
|
||||
fListEnvelopesCmd->SetGuidance("(or for all particles if without parameters).");
|
||||
fListEnvelopesCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
fListModelsCmd =
|
||||
new G4UIcmdWithAString("/param/listModels", this);
|
||||
fListModelsCmd->SetParameterName("EnvelopeName",true);
|
||||
fListEnvelopesCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
fListModelsCmd = new G4UIcmdWithAString("/param/listModels", this);
|
||||
fListModelsCmd->SetParameterName("EnvelopeName", true);
|
||||
fListModelsCmd->SetDefaultValue("all");
|
||||
fListModelsCmd->SetGuidance("List all the Model names for a given Envelope");
|
||||
fListModelsCmd->SetGuidance("(or for all envelopes if without parameters).");
|
||||
fListModelsCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
fListIsApplicableCmd =
|
||||
new G4UIcmdWithAString("/param/listIsApplicable", this);
|
||||
fListIsApplicableCmd->SetParameterName("ModelName",true);
|
||||
fListModelsCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
fListIsApplicableCmd = new G4UIcmdWithAString("/param/listIsApplicable", this);
|
||||
fListIsApplicableCmd->SetParameterName("ModelName", true);
|
||||
fListIsApplicableCmd->SetDefaultValue("all");
|
||||
fListIsApplicableCmd->SetGuidance("List all the Particle names a given Model is applicable");
|
||||
fListIsApplicableCmd->SetGuidance("(or for all Models if without parameters).");
|
||||
|
||||
fActivateModel =
|
||||
new G4UIcmdWithAString("/param/ActivateModel", this);
|
||||
fActivateModel->SetParameterName("ModelName",false);
|
||||
fActivateModel = new G4UIcmdWithAString("/param/ActivateModel", this);
|
||||
fActivateModel->SetParameterName("ModelName", false);
|
||||
fActivateModel->SetGuidance("Activate a given Model.");
|
||||
|
||||
fInActivateModel =
|
||||
new G4UIcmdWithAString("/param/InActivateModel", this);
|
||||
fInActivateModel->SetParameterName("ModelName",false);
|
||||
fInActivateModel = new G4UIcmdWithAString("/param/InActivateModel", this);
|
||||
fInActivateModel->SetParameterName("ModelName", false);
|
||||
fInActivateModel->SetGuidance("InActivate a given Model.");
|
||||
}
|
||||
|
||||
G4FastSimulationMessenger::~G4FastSimulationMessenger()
|
||||
{
|
||||
delete fShowSetupCmd;
|
||||
fShowSetupCmd = 0;
|
||||
delete fListIsApplicableCmd;
|
||||
fListIsApplicableCmd = 0;
|
||||
delete fActivateModel;
|
||||
fActivateModel = 0;
|
||||
delete fInActivateModel;
|
||||
fInActivateModel = 0;
|
||||
delete fListModelsCmd;
|
||||
fListModelsCmd = 0;
|
||||
delete fListEnvelopesCmd;
|
||||
fListEnvelopesCmd = 0;
|
||||
delete fFSDirectory;
|
||||
fFSDirectory = 0;
|
||||
}
|
||||
|
||||
void G4FastSimulationMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
|
||||
void G4FastSimulationMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
{
|
||||
if (command == fShowSetupCmd)
|
||||
fGlobalFastSimulationManager->ShowSetup();
|
||||
if( command == fListEnvelopesCmd)
|
||||
{
|
||||
if(newValue == "all")
|
||||
if (command == fShowSetupCmd) fGlobalFastSimulationManager->ShowSetup();
|
||||
if (command == fListEnvelopesCmd) {
|
||||
if (newValue == "all")
|
||||
fGlobalFastSimulationManager->ListEnvelopes();
|
||||
else
|
||||
fGlobalFastSimulationManager->
|
||||
ListEnvelopes(G4ParticleTable::GetParticleTable()->
|
||||
FindParticle(newValue));
|
||||
else
|
||||
fGlobalFastSimulationManager->ListEnvelopes(
|
||||
G4ParticleTable::GetParticleTable()->FindParticle(newValue));
|
||||
}
|
||||
if( command == fListModelsCmd)
|
||||
fGlobalFastSimulationManager->ListEnvelopes(newValue, MODELS);
|
||||
if( command == fListIsApplicableCmd)
|
||||
if (command == fListModelsCmd) fGlobalFastSimulationManager->ListEnvelopes(newValue, MODELS);
|
||||
if (command == fListIsApplicableCmd)
|
||||
fGlobalFastSimulationManager->ListEnvelopes(newValue, ISAPPLICABLE);
|
||||
if( command == fActivateModel)
|
||||
if (command == fActivateModel)
|
||||
fGlobalFastSimulationManager->ActivateFastSimulationModel(newValue);
|
||||
if( command == fInActivateModel)
|
||||
if (command == fInActivateModel)
|
||||
fGlobalFastSimulationManager->InActivateFastSimulationModel(newValue);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
//
|
||||
// Description:
|
||||
// Encapsulates a G4ParticleChange and insure friendly interface
|
||||
// methods to manage the primary/secondaries final state for
|
||||
// methods to manage the primary/secondaries final state for
|
||||
// Fast Simulation Models.
|
||||
//
|
||||
// History:
|
||||
@@ -43,17 +43,17 @@
|
||||
|
||||
#include "G4FastStep.hh"
|
||||
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4TrackFastVector.hh"
|
||||
#include "G4DynamicParticle.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4TrackFastVector.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
void G4FastStep::Initialize(const G4FastTrack& fastTrack)
|
||||
{
|
||||
// keeps the fastTrack reference
|
||||
fFastTrack=&fastTrack;
|
||||
fFastTrack = &fastTrack;
|
||||
|
||||
// currentTrack will be used to Initialize the other data members
|
||||
const G4Track& currentTrack = *(fFastTrack->GetPrimaryTrack());
|
||||
@@ -62,22 +62,22 @@ void G4FastStep::Initialize(const G4FastTrack& fastTrack)
|
||||
G4VParticleChange::Initialize(currentTrack);
|
||||
|
||||
// set Energy/Momentum etc. equal to those of the parent particle
|
||||
const G4DynamicParticle* pParticle = currentTrack.GetDynamicParticle();
|
||||
theEnergyChange = pParticle->GetKineticEnergy();
|
||||
theMomentumChange = pParticle->GetMomentumDirection();
|
||||
thePolarizationChange = pParticle->GetPolarization();
|
||||
theProperTimeChange = pParticle->GetProperTime();
|
||||
const G4DynamicParticle* pParticle = currentTrack.GetDynamicParticle();
|
||||
theEnergyChange = pParticle->GetKineticEnergy();
|
||||
theMomentumChange = pParticle->GetMomentumDirection();
|
||||
thePolarizationChange = pParticle->GetPolarization();
|
||||
theProperTimeChange = pParticle->GetProperTime();
|
||||
|
||||
// set Position/Time etc. equal to those of the parent track
|
||||
thePositionChange = currentTrack.GetPosition();
|
||||
theTimeChange = currentTrack.GetGlobalTime();
|
||||
thePositionChange = currentTrack.GetPosition();
|
||||
theTimeChange = currentTrack.GetGlobalTime();
|
||||
|
||||
// switch off stepping hit invokation by default:
|
||||
theSteppingControlFlag = AvoidHitInvocation;
|
||||
|
||||
// event biasing weigth:
|
||||
theWeightChange = currentTrack.GetWeight();
|
||||
}
|
||||
theWeightChange = currentTrack.GetWeight();
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
// -- Set the StopAndKilled signal
|
||||
@@ -86,32 +86,27 @@ void G4FastStep::Initialize(const G4FastTrack& fastTrack)
|
||||
//----------------------------------------
|
||||
void G4FastStep::KillPrimaryTrack()
|
||||
{
|
||||
SetPrimaryTrackFinalKineticEnergy(0.) ;
|
||||
ProposeTrackStatus(fStopAndKill) ;
|
||||
ProposePrimaryTrackFinalKineticEnergy(0.);
|
||||
ProposeTrackStatus(fStopAndKill);
|
||||
}
|
||||
|
||||
//--------------------
|
||||
//
|
||||
//--------------------
|
||||
void
|
||||
G4FastStep::
|
||||
ProposePrimaryTrackFinalPosition(const G4ThreeVector &position,
|
||||
G4bool localCoordinates)
|
||||
void G4FastStep::ProposePrimaryTrackFinalPosition(const G4ThreeVector& position,
|
||||
G4bool localCoordinates)
|
||||
{
|
||||
// Compute the position coordinate in global
|
||||
// reference system if needed ...
|
||||
G4ThreeVector globalPosition = position;
|
||||
if (localCoordinates)
|
||||
globalPosition = fFastTrack->GetInverseAffineTransformation()->
|
||||
TransformPoint(position);
|
||||
if (localCoordinates)
|
||||
globalPosition = fFastTrack->GetInverseAffineTransformation()->TransformPoint(position);
|
||||
// ...and feed the globalPosition:
|
||||
thePositionChange = globalPosition;
|
||||
}
|
||||
|
||||
void
|
||||
G4FastStep::
|
||||
SetPrimaryTrackFinalPosition(const G4ThreeVector &position,
|
||||
G4bool localCoordinates)
|
||||
void G4FastStep::SetPrimaryTrackFinalPosition(const G4ThreeVector& position,
|
||||
G4bool localCoordinates)
|
||||
{
|
||||
ProposePrimaryTrackFinalPosition(position, localCoordinates);
|
||||
}
|
||||
@@ -119,25 +114,20 @@ SetPrimaryTrackFinalPosition(const G4ThreeVector &position,
|
||||
//--------------------
|
||||
//
|
||||
//--------------------
|
||||
void
|
||||
G4FastStep::
|
||||
ProposePrimaryTrackFinalMomentumDirection(const G4ThreeVector &momentum,
|
||||
G4bool localCoordinates)
|
||||
void G4FastStep::ProposePrimaryTrackFinalMomentumDirection(const G4ThreeVector& momentum,
|
||||
G4bool localCoordinates)
|
||||
{
|
||||
// Compute the momentum in global reference
|
||||
// system if needed ...
|
||||
G4ThreeVector globalMomentum = momentum;
|
||||
if (localCoordinates)
|
||||
globalMomentum = fFastTrack->GetInverseAffineTransformation()->
|
||||
TransformAxis(momentum);
|
||||
globalMomentum = fFastTrack->GetInverseAffineTransformation()->TransformAxis(momentum);
|
||||
// ...and feed the globalMomentum (ensuring unitarity)
|
||||
SetMomentumChange(globalMomentum.unit());
|
||||
}
|
||||
|
||||
void
|
||||
G4FastStep::
|
||||
SetPrimaryTrackFinalMomentum(const G4ThreeVector &momentum,
|
||||
G4bool localCoordinates)
|
||||
void G4FastStep::SetPrimaryTrackFinalMomentum(const G4ThreeVector& momentum,
|
||||
G4bool localCoordinates)
|
||||
{
|
||||
ProposePrimaryTrackFinalMomentumDirection(momentum, localCoordinates);
|
||||
}
|
||||
@@ -145,27 +135,22 @@ SetPrimaryTrackFinalMomentum(const G4ThreeVector &momentum,
|
||||
//--------------------
|
||||
//
|
||||
//--------------------
|
||||
void
|
||||
G4FastStep::
|
||||
ProposePrimaryTrackFinalKineticEnergyAndDirection(G4double kineticEnergy,
|
||||
const G4ThreeVector &direction,
|
||||
G4bool localCoordinates)
|
||||
void G4FastStep::ProposePrimaryTrackFinalKineticEnergyAndDirection(G4double kineticEnergy,
|
||||
const G4ThreeVector& direction,
|
||||
G4bool localCoordinates)
|
||||
{
|
||||
// Compute global direction if needed...
|
||||
G4ThreeVector globalDirection = direction;
|
||||
if (localCoordinates)
|
||||
globalDirection =fFastTrack->GetInverseAffineTransformation()->
|
||||
TransformAxis(direction);
|
||||
globalDirection = fFastTrack->GetInverseAffineTransformation()->TransformAxis(direction);
|
||||
// ...and feed the globalMomentum (ensuring unitarity)
|
||||
SetMomentumChange(globalDirection.unit());
|
||||
SetPrimaryTrackFinalKineticEnergy(kineticEnergy);
|
||||
ProposePrimaryTrackFinalKineticEnergy(kineticEnergy);
|
||||
}
|
||||
|
||||
void
|
||||
G4FastStep::
|
||||
SetPrimaryTrackFinalKineticEnergyAndDirection(G4double kineticEnergy,
|
||||
const G4ThreeVector &direction,
|
||||
G4bool localCoordinates)
|
||||
void G4FastStep::SetPrimaryTrackFinalKineticEnergyAndDirection(G4double kineticEnergy,
|
||||
const G4ThreeVector& direction,
|
||||
G4bool localCoordinates)
|
||||
{
|
||||
ProposePrimaryTrackFinalKineticEnergyAndDirection(kineticEnergy, direction, localCoordinates);
|
||||
}
|
||||
@@ -173,24 +158,20 @@ SetPrimaryTrackFinalKineticEnergyAndDirection(G4double kineticEnergy,
|
||||
//--------------------
|
||||
//
|
||||
//--------------------
|
||||
void
|
||||
G4FastStep::
|
||||
ProposePrimaryTrackFinalPolarization(const G4ThreeVector &polarization,
|
||||
G4bool localCoordinates)
|
||||
void G4FastStep::ProposePrimaryTrackFinalPolarization(const G4ThreeVector& polarization,
|
||||
G4bool localCoordinates)
|
||||
{
|
||||
// Compute polarization in global system if needed:
|
||||
G4ThreeVector globalPolarization(polarization);
|
||||
if (localCoordinates)
|
||||
globalPolarization = fFastTrack->GetInverseAffineTransformation()->
|
||||
TransformAxis(globalPolarization);
|
||||
globalPolarization =
|
||||
fFastTrack->GetInverseAffineTransformation()->TransformAxis(globalPolarization);
|
||||
// Feed the particle globalPolarization:
|
||||
thePolarizationChange = globalPolarization;
|
||||
}
|
||||
|
||||
void
|
||||
G4FastStep::
|
||||
SetPrimaryTrackFinalPolarization(const G4ThreeVector &polarization,
|
||||
G4bool localCoordinates)
|
||||
void G4FastStep::SetPrimaryTrackFinalPolarization(const G4ThreeVector& polarization,
|
||||
G4bool localCoordinates)
|
||||
{
|
||||
ProposePrimaryTrackFinalPolarization(polarization, localCoordinates);
|
||||
}
|
||||
@@ -198,83 +179,64 @@ SetPrimaryTrackFinalPolarization(const G4ThreeVector &polarization,
|
||||
//--------------------
|
||||
//
|
||||
//--------------------
|
||||
G4Track* G4FastStep::
|
||||
CreateSecondaryTrack(const G4DynamicParticle& dynamics,
|
||||
G4ThreeVector polarization,
|
||||
G4ThreeVector position,
|
||||
G4double time,
|
||||
G4bool localCoordinates )
|
||||
G4Track* G4FastStep::CreateSecondaryTrack(const G4DynamicParticle& dynamics,
|
||||
G4ThreeVector polarization, G4ThreeVector position,
|
||||
G4double time, G4bool localCoordinates)
|
||||
{
|
||||
G4DynamicParticle dummyDynamics(dynamics);
|
||||
|
||||
|
||||
// ------------------------------------------
|
||||
// Add the polarization to the dummyDynamics:
|
||||
// ------------------------------------------
|
||||
dummyDynamics.SetPolarization(polarization.x(),
|
||||
polarization.y(),
|
||||
polarization.z());
|
||||
|
||||
dummyDynamics.SetPolarization(polarization.x(), polarization.y(), polarization.z());
|
||||
|
||||
return CreateSecondaryTrack(dummyDynamics, position, time, localCoordinates);
|
||||
}
|
||||
|
||||
//--------------------
|
||||
//
|
||||
//--------------------
|
||||
G4Track* G4FastStep::
|
||||
CreateSecondaryTrack(const G4DynamicParticle& dynamics,
|
||||
G4ThreeVector position,
|
||||
G4double time,
|
||||
G4bool localCoordinates )
|
||||
G4Track* G4FastStep::CreateSecondaryTrack(const G4DynamicParticle& dynamics, G4ThreeVector position,
|
||||
G4double time, G4bool localCoordinates)
|
||||
{
|
||||
// ----------------------------------------
|
||||
// Quantities in global coordinates system.
|
||||
//
|
||||
//
|
||||
// The allocated globalDynamics is deleted
|
||||
// by the destructor of the G4Track.
|
||||
// ----------------------------------------
|
||||
G4DynamicParticle* globalDynamics =
|
||||
new G4DynamicParticle(dynamics);
|
||||
auto globalDynamics = new G4DynamicParticle(dynamics);
|
||||
G4ThreeVector globalPosition(position);
|
||||
|
||||
|
||||
// -----------------------------------
|
||||
// Convert to global system if needed:
|
||||
// -----------------------------------
|
||||
if (localCoordinates)
|
||||
{
|
||||
// -- Momentum Direction:
|
||||
globalDynamics->SetMomentumDirection(fFastTrack->
|
||||
GetInverseAffineTransformation()->
|
||||
TransformAxis(globalDynamics->
|
||||
GetMomentumDirection()));
|
||||
// -- Polarization:
|
||||
G4ThreeVector globalPolarization;
|
||||
globalPolarization = fFastTrack->GetInverseAffineTransformation()->
|
||||
TransformAxis(globalDynamics->GetPolarization());
|
||||
globalDynamics->SetPolarization(
|
||||
globalPolarization.x(),
|
||||
globalPolarization.y(),
|
||||
globalPolarization.z()
|
||||
);
|
||||
|
||||
// -- Position:
|
||||
globalPosition = fFastTrack->GetInverseAffineTransformation()->
|
||||
TransformPoint(globalPosition);
|
||||
}
|
||||
|
||||
if (localCoordinates) {
|
||||
// -- Momentum Direction:
|
||||
globalDynamics->SetMomentumDirection(
|
||||
fFastTrack->GetInverseAffineTransformation()->TransformAxis(
|
||||
globalDynamics->GetMomentumDirection()));
|
||||
// -- Polarization:
|
||||
G4ThreeVector globalPolarization;
|
||||
globalPolarization = fFastTrack->GetInverseAffineTransformation()->TransformAxis(
|
||||
globalDynamics->GetPolarization());
|
||||
globalDynamics->SetPolarization(globalPolarization.x(), globalPolarization.y(),
|
||||
globalPolarization.z());
|
||||
|
||||
// -- Position:
|
||||
globalPosition = fFastTrack->GetInverseAffineTransformation()->TransformPoint(globalPosition);
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
// Create the G4Track of the secondary:
|
||||
//-------------------------------------
|
||||
G4Track* secondary = new G4Track(
|
||||
globalDynamics,
|
||||
time,
|
||||
globalPosition
|
||||
);
|
||||
|
||||
auto secondary = new G4Track(globalDynamics, time, globalPosition);
|
||||
|
||||
//-------------------------------
|
||||
// and feed the changes:
|
||||
//-------------------------------
|
||||
AddSecondary(secondary);
|
||||
|
||||
|
||||
//--------------------------------------
|
||||
// returns the pointer on the secondary:
|
||||
//--------------------------------------
|
||||
@@ -285,129 +247,112 @@ CreateSecondaryTrack(const G4DynamicParticle& dynamics,
|
||||
// but we must define it to avoid warnings.
|
||||
void G4FastStep::Initialize(const G4Track&)
|
||||
{
|
||||
G4ExceptionDescription tellWhatIsWrong;
|
||||
tellWhatIsWrong << "G4FastStep can be initialised only through G4FastTrack."
|
||||
<< G4endl;
|
||||
G4Exception("G4FastStep::Initialize(const G4Track&)",
|
||||
"FastSim005",
|
||||
FatalException,
|
||||
tellWhatIsWrong);
|
||||
}
|
||||
|
||||
G4FastStep::G4FastStep()
|
||||
: G4VParticleChange()
|
||||
{
|
||||
if (verboseLevel>2)
|
||||
{
|
||||
G4cerr << "G4FastStep::G4FastStep()" << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
G4FastStep::~G4FastStep()
|
||||
{
|
||||
if (verboseLevel>2)
|
||||
{
|
||||
G4cerr << "G4FastStep::~G4FastStep()" << G4endl;
|
||||
}
|
||||
G4ExceptionDescription tellWhatIsWrong;
|
||||
tellWhatIsWrong << "G4FastStep can be initialised only through G4FastTrack." << G4endl;
|
||||
G4Exception("G4FastStep::Initialize(const G4Track&)", "FastSim005", FatalException,
|
||||
tellWhatIsWrong);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// methods for updating G4Step
|
||||
// methods for updating G4Step
|
||||
//
|
||||
|
||||
G4Step* G4FastStep::UpdateStepForPostStep(G4Step* pStep)
|
||||
{
|
||||
{
|
||||
// A physics process always calculates the final state of the particle
|
||||
|
||||
// Take note that the return type of GetMomentumChange is a
|
||||
// pointer to G4ParticleMometum. Also it is a normalized
|
||||
// pointer to G4ParticleMometum. Also it is a normalized
|
||||
// momentum vector.
|
||||
|
||||
// G4StepPoint* pPreStepPoint = pStep->GetPreStepPoint();
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
G4Track* aTrack = pStep->GetTrack();
|
||||
// G4StepPoint* pPreStepPoint = pStep->GetPreStepPoint();
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
G4Track* aTrack = pStep->GetTrack();
|
||||
// G4double mass = aTrack->GetDynamicParticle()->GetMass();
|
||||
|
||||
|
||||
// update kinetic energy and momentum direction
|
||||
pPostStepPoint->SetMomentumDirection(theMomentumChange);
|
||||
pPostStepPoint->SetKineticEnergy( theEnergyChange );
|
||||
pPostStepPoint->SetKineticEnergy(theEnergyChange);
|
||||
|
||||
// update polarization
|
||||
pPostStepPoint->SetPolarization(thePolarizationChange);
|
||||
|
||||
// update polarization
|
||||
pPostStepPoint->SetPolarization( thePolarizationChange );
|
||||
|
||||
// update position and time
|
||||
pPostStepPoint->SetPosition( thePositionChange );
|
||||
pPostStepPoint->SetGlobalTime( theTimeChange );
|
||||
pPostStepPoint->AddLocalTime( theTimeChange
|
||||
- aTrack->GetGlobalTime());
|
||||
pPostStepPoint->SetProperTime( theProperTimeChange );
|
||||
pPostStepPoint->SetPosition(thePositionChange);
|
||||
pPostStepPoint->SetGlobalTime(theTimeChange);
|
||||
pPostStepPoint->AddLocalTime(theTimeChange - aTrack->GetGlobalTime());
|
||||
pPostStepPoint->SetProperTime(theProperTimeChange);
|
||||
|
||||
// update weight
|
||||
pPostStepPoint->SetWeight( theWeightChange );
|
||||
pPostStepPoint->SetWeight(theWeightChange);
|
||||
|
||||
if (debugFlag) CheckIt(*aTrack);
|
||||
|
||||
|
||||
// Update the G4Step specific attributes
|
||||
// Update the G4Step specific attributes
|
||||
return UpdateStepInfo(pStep);
|
||||
}
|
||||
|
||||
G4Step* G4FastStep::UpdateStepForAtRest(G4Step* pStep)
|
||||
{
|
||||
{
|
||||
// A physics process always calculates the final state of the particle
|
||||
|
||||
// G4StepPoint* pPreStepPoint = pStep->GetPreStepPoint();
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
G4Track* aTrack = pStep->GetTrack();
|
||||
// G4StepPoint* pPreStepPoint = pStep->GetPreStepPoint();
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
G4Track* aTrack = pStep->GetTrack();
|
||||
// G4double mass = aTrack->GetDynamicParticle()->GetMass();
|
||||
|
||||
|
||||
// update kinetic energy and momentum direction
|
||||
pPostStepPoint->SetMomentumDirection(theMomentumChange);
|
||||
pPostStepPoint->SetKineticEnergy( theEnergyChange );
|
||||
pPostStepPoint->SetKineticEnergy(theEnergyChange);
|
||||
|
||||
// update polarization
|
||||
pPostStepPoint->SetPolarization( thePolarizationChange );
|
||||
|
||||
pPostStepPoint->SetPolarization(thePolarizationChange);
|
||||
|
||||
// update position and time
|
||||
pPostStepPoint->SetPosition( thePositionChange );
|
||||
pPostStepPoint->SetGlobalTime( theTimeChange );
|
||||
pPostStepPoint->AddLocalTime( theTimeChange
|
||||
- aTrack->GetGlobalTime());
|
||||
pPostStepPoint->SetProperTime( theProperTimeChange );
|
||||
pPostStepPoint->SetPosition(thePositionChange);
|
||||
pPostStepPoint->SetGlobalTime(theTimeChange);
|
||||
pPostStepPoint->AddLocalTime(theTimeChange - aTrack->GetGlobalTime());
|
||||
pPostStepPoint->SetProperTime(theProperTimeChange);
|
||||
|
||||
// update weight
|
||||
pPostStepPoint->SetWeight( theWeightChange );
|
||||
pPostStepPoint->SetWeight(theWeightChange);
|
||||
|
||||
if (debugFlag) CheckIt(*aTrack);
|
||||
|
||||
// Update the G4Step specific attributes
|
||||
// Update the G4Step specific attributes
|
||||
return UpdateStepInfo(pStep);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// methods for printing messages
|
||||
// methods for printing messages
|
||||
//
|
||||
|
||||
void G4FastStep::DumpInfo() const
|
||||
{
|
||||
// use base-class DumpInfo
|
||||
// use base-class DumpInfo
|
||||
G4VParticleChange::DumpInfo();
|
||||
|
||||
G4cout << " Position - x (mm) : " << G4BestUnit( thePositionChange.x(), "Length" ) << G4endl;
|
||||
G4cout << " Position - y (mm) : " << G4BestUnit( thePositionChange.y(), "Length" ) << G4endl;
|
||||
G4cout << " Position - z (mm) : " << G4BestUnit( thePositionChange.z(), "Length" ) << G4endl;
|
||||
G4cout << " Time (ns) : " << G4BestUnit( theTimeChange, "Time" ) << G4endl;
|
||||
G4cout << " Proper Time (ns) : " << G4BestUnit( theProperTimeChange, "Time" ) << G4endl;
|
||||
|
||||
G4cout << " Position - x (mm) : " << G4BestUnit(thePositionChange.x(), "Length")
|
||||
<< G4endl;
|
||||
G4cout << " Position - y (mm) : " << G4BestUnit(thePositionChange.y(), "Length")
|
||||
<< G4endl;
|
||||
G4cout << " Position - z (mm) : " << G4BestUnit(thePositionChange.z(), "Length")
|
||||
<< G4endl;
|
||||
G4cout << " Time (ns) : " << G4BestUnit(theTimeChange, "Time") << G4endl;
|
||||
G4cout << " Proper Time (ns) : " << G4BestUnit(theProperTimeChange, "Time") << G4endl;
|
||||
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;
|
||||
G4cout.precision(olprc);
|
||||
G4cout << " Kinetic Energy (MeV): " << G4BestUnit( theEnergyChange, "Energy" ) << G4endl;
|
||||
G4cout << " Kinetic Energy (MeV): " << G4BestUnit(theEnergyChange, "Energy") << G4endl;
|
||||
G4cout.precision(3);
|
||||
G4cout << " Polarization - x : " << std::setw(20) << thePolarizationChange.x() << G4endl;
|
||||
G4cout << " Polarization - y : " << std::setw(20) << thePolarizationChange.y() << G4endl;
|
||||
G4cout << " Polarization - z : " << std::setw(20) << thePolarizationChange.z() << G4endl;
|
||||
G4cout << " Polarization - x : " << std::setw(20) << thePolarizationChange.x()
|
||||
<< G4endl;
|
||||
G4cout << " Polarization - y : " << std::setw(20) << thePolarizationChange.y()
|
||||
<< G4endl;
|
||||
G4cout << " Polarization - z : " << std::setw(20) << thePolarizationChange.z()
|
||||
<< G4endl;
|
||||
G4cout.precision(olprc);
|
||||
}
|
||||
|
||||
@@ -416,7 +361,7 @@ G4bool G4FastStep::CheckIt(const G4Track& aTrack)
|
||||
//
|
||||
// In the G4FastStep::CheckIt
|
||||
// We only check a bit
|
||||
//
|
||||
//
|
||||
// If the user violates the energy,
|
||||
// We don't care, we agree.
|
||||
//
|
||||
@@ -431,84 +376,72 @@ G4bool G4FastStep::CheckIt(const G4Track& aTrack)
|
||||
// and it corrects it because it could cause problems for the ulterior
|
||||
// tracking.For the rest, only warning are issued.
|
||||
|
||||
G4bool itsOK = true;
|
||||
G4bool exitWithError = false;
|
||||
G4double accuracy;
|
||||
|
||||
G4bool itsOK = true;
|
||||
G4bool exitWithError = false;
|
||||
G4double accuracy;
|
||||
|
||||
// Energy should not be larger than the initial value
|
||||
accuracy = ( theEnergyChange - aTrack.GetKineticEnergy())/MeV;
|
||||
if (accuracy > GetAccuracyForWarning())
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "The energy becomes larger than the initial value, difference = " << accuracy << " MeV" << G4endl;
|
||||
G4Exception("G4FastStep::CheckIt(const G4Track& aTrack)",
|
||||
"FastSim006",
|
||||
JustWarning, ed);
|
||||
itsOK = false;
|
||||
if (accuracy > GetAccuracyForException()) {exitWithError = true;}
|
||||
accuracy = (theEnergyChange - aTrack.GetKineticEnergy()) / MeV;
|
||||
if (accuracy > GetAccuracyForWarning()) {
|
||||
G4ExceptionDescription ed;
|
||||
ed << "The energy becomes larger than the initial value, difference = " << accuracy << " MeV"
|
||||
<< G4endl;
|
||||
G4Exception("G4FastStep::CheckIt(const G4Track& aTrack)", "FastSim006", JustWarning, ed);
|
||||
itsOK = false;
|
||||
if (accuracy > GetAccuracyForException()) {
|
||||
exitWithError = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
G4bool itsOKforMomentum = true;
|
||||
if ( theEnergyChange >0.)
|
||||
{
|
||||
accuracy = std::abs(theMomentumChange.mag2()-1.0);
|
||||
if (accuracy > GetAccuracyForWarning())
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "The Momentum Change is not a unit vector, difference = " << accuracy << G4endl;
|
||||
G4Exception("G4FastStep::CheckIt(const G4Track& aTrack)",
|
||||
"FastSim007",
|
||||
JustWarning, ed);
|
||||
itsOK = itsOKforMomentum = false;
|
||||
if (accuracy > GetAccuracyForException()) {exitWithError = true;}
|
||||
}
|
||||
}
|
||||
|
||||
accuracy = (aTrack.GetGlobalTime()- theTimeChange)/ns;
|
||||
if (accuracy > GetAccuracyForWarning())
|
||||
{
|
||||
if (theEnergyChange > 0.) {
|
||||
accuracy = std::abs(theMomentumChange.mag2() - 1.0);
|
||||
if (accuracy > GetAccuracyForWarning()) {
|
||||
G4ExceptionDescription ed;
|
||||
ed << "The global time is getting backward, difference = " << accuracy << " ns" << G4endl;
|
||||
G4Exception("G4FastStep::CheckIt(const G4Track& aTrack)",
|
||||
"FastSim008",
|
||||
JustWarning, ed);
|
||||
itsOK = false;
|
||||
ed << "The Momentum Change is not a unit vector, difference = " << accuracy << G4endl;
|
||||
G4Exception("G4FastStep::CheckIt(const G4Track& aTrack)", "FastSim007", JustWarning, ed);
|
||||
itsOK = itsOKforMomentum = false;
|
||||
if (accuracy > GetAccuracyForException()) {
|
||||
exitWithError = true;
|
||||
}
|
||||
}
|
||||
|
||||
accuracy = (aTrack.GetProperTime() - theProperTimeChange )/ns;
|
||||
if (accuracy > GetAccuracyForWarning())
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "The proper time is getting backward, difference = " << accuracy << " ns" << G4endl;
|
||||
G4Exception("G4FastStep::CheckIt(const G4Track& aTrack)",
|
||||
"FastSim009",
|
||||
JustWarning, ed);
|
||||
itsOK = false;
|
||||
}
|
||||
|
||||
if (!itsOK)
|
||||
{
|
||||
G4cout << "ERROR - G4FastStep::CheckIt() " << G4endl;
|
||||
G4cout << " Pointer : " << this << G4endl ;
|
||||
DumpInfo();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
accuracy = (aTrack.GetGlobalTime() - theTimeChange) / ns;
|
||||
if (accuracy > GetAccuracyForWarning()) {
|
||||
G4ExceptionDescription ed;
|
||||
ed << "The global time is getting backward, difference = " << accuracy << " ns" << G4endl;
|
||||
G4Exception("G4FastStep::CheckIt(const G4Track& aTrack)", "FastSim008", JustWarning, ed);
|
||||
itsOK = false;
|
||||
}
|
||||
|
||||
accuracy = (aTrack.GetProperTime() - theProperTimeChange) / ns;
|
||||
if (accuracy > GetAccuracyForWarning()) {
|
||||
G4ExceptionDescription ed;
|
||||
ed << "The proper time is getting backward, difference = " << accuracy << " ns" << G4endl;
|
||||
G4Exception("G4FastStep::CheckIt(const G4Track& aTrack)", "FastSim009", JustWarning, ed);
|
||||
itsOK = false;
|
||||
}
|
||||
|
||||
if (!itsOK) {
|
||||
G4cout << "ERROR - G4FastStep::CheckIt() " << G4endl;
|
||||
G4cout << " Pointer : " << this << G4endl;
|
||||
DumpInfo();
|
||||
}
|
||||
|
||||
// Exit with error
|
||||
if (exitWithError)
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "An inaccuracy in G4FastStep is beyond tolerance." << G4endl;
|
||||
G4Exception("G4FastStep::CheckIt(const G4Track& aTrack)",
|
||||
"FastSim010",
|
||||
FatalException, ed);
|
||||
}
|
||||
|
||||
//correction for Momentum only.
|
||||
if (exitWithError) {
|
||||
G4ExceptionDescription ed;
|
||||
ed << "An inaccuracy in G4FastStep is beyond tolerance." << G4endl;
|
||||
G4Exception("G4FastStep::CheckIt(const G4Track& aTrack)", "FastSim010", FatalException, ed);
|
||||
}
|
||||
|
||||
// correction for Momentum only.
|
||||
if (!itsOKforMomentum) {
|
||||
G4double vmag = theMomentumChange.mag();
|
||||
theMomentumChange = (1./vmag)*theMomentumChange;
|
||||
theMomentumChange = (1. / vmag) * theMomentumChange;
|
||||
}
|
||||
|
||||
itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
|
||||
|
||||
itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
|
||||
return itsOK;
|
||||
}
|
||||
|
||||
@@ -38,52 +38,39 @@
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#include "G4ios.hh"
|
||||
#include "G4FastTrack.hh"
|
||||
|
||||
#include "G4TouchableHandle.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4TouchableHistoryHandle.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
// -----------
|
||||
// Constructor
|
||||
// -----------
|
||||
//
|
||||
G4FastTrack::G4FastTrack(G4Envelope *anEnvelope, G4bool IsUnique)
|
||||
: fTrack ( nullptr ),
|
||||
fAffineTransformationDefined( false ),
|
||||
fEnvelope ( anEnvelope ),
|
||||
fIsUnique ( IsUnique ),
|
||||
fEnvelopeLogicalVolume ( nullptr ),
|
||||
fEnvelopePhysicalVolume ( nullptr ),
|
||||
fEnvelopeSolid ( nullptr )
|
||||
{}
|
||||
|
||||
// -----------
|
||||
// Destructor:
|
||||
// -----------
|
||||
G4FastTrack::~G4FastTrack()
|
||||
G4FastTrack::G4FastTrack(G4Envelope* anEnvelope, G4bool IsUnique)
|
||||
: fEnvelope(anEnvelope), fIsUnique(IsUnique)
|
||||
{}
|
||||
|
||||
//------------------------------------------------------------
|
||||
// The parameterised simulation manager uses the SetCurrentTrack
|
||||
// method to setup the current G4FastTrack object
|
||||
// method to setup the current G4FastTrack object
|
||||
//------------------------------------------------------------
|
||||
void G4FastTrack::SetCurrentTrack(const G4Track& track,
|
||||
const G4Navigator* theNavigator)
|
||||
void G4FastTrack::SetCurrentTrack(const G4Track& track, const G4Navigator* theNavigator)
|
||||
{
|
||||
|
||||
// -- Register track pointer (used everywhere):
|
||||
fTrack = &track;
|
||||
|
||||
//-----------------------------------------------------
|
||||
// First time the track enters the volume or if the
|
||||
// Logical Volume was placed n-Times in the geometry :
|
||||
//
|
||||
//
|
||||
// Records the Rotation+Translation for the Envelope !
|
||||
// When the particle is inside or on the boundary, the
|
||||
// When the particle is inside or on the boundary, the
|
||||
// NavigationHistory IS UP TO DATE.
|
||||
//------------------------------------------------------
|
||||
if (!fAffineTransformationDefined || !fIsUnique) FRecordsAffineTransformation(theNavigator);
|
||||
|
||||
|
||||
//-------------------------------------------
|
||||
// Records local position/momentum/direction
|
||||
// of the Track.
|
||||
@@ -107,10 +94,8 @@ void G4FastTrack::SetCurrentTrack(const G4Track& track,
|
||||
// This is Done only one time.
|
||||
//
|
||||
//------------------------------------
|
||||
void
|
||||
G4FastTrack::FRecordsAffineTransformation(const G4Navigator* theNavigator)
|
||||
void G4FastTrack::FRecordsAffineTransformation(const G4Navigator* theNavigator)
|
||||
{
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Get the touchable history which represents the current
|
||||
// volume hierachy the particle is in.
|
||||
@@ -118,27 +103,27 @@ G4FastTrack::FRecordsAffineTransformation(const G4Navigator* theNavigator)
|
||||
// must be deleted by G4FastTrack.
|
||||
//--------------------------------------------------------
|
||||
const G4Navigator* NavigatorToUse;
|
||||
if(theNavigator != nullptr ) NavigatorToUse = theNavigator;
|
||||
else NavigatorToUse = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
|
||||
|
||||
G4TouchableHistoryHandle history = NavigatorToUse->CreateTouchableHistoryHandle();
|
||||
|
||||
if (theNavigator != nullptr)
|
||||
NavigatorToUse = theNavigator;
|
||||
else
|
||||
NavigatorToUse = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
|
||||
|
||||
G4TouchableHandle history = NavigatorToUse->CreateTouchableHistoryHandle();
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Run accross the hierarchy to find the physical volume
|
||||
// associated with the envelope
|
||||
//-----------------------------------------------------
|
||||
G4int depth = (G4int)history->GetHistory()->GetDepth();
|
||||
auto depth = (G4int)history->GetHistory()->GetDepth();
|
||||
G4int idepth;
|
||||
G4bool Done = false;
|
||||
for (idepth = 0; idepth <= depth; ++idepth)
|
||||
{
|
||||
for (idepth = 0; idepth <= depth; ++idepth) {
|
||||
G4VPhysicalVolume* currPV = history->GetHistory()->GetVolume(idepth);
|
||||
G4LogicalVolume* currLV = currPV->GetLogicalVolume();
|
||||
if ( (currLV->GetRegion() == fEnvelope) && (currLV->IsRootRegion()) )
|
||||
{
|
||||
G4LogicalVolume* currLV = currPV->GetLogicalVolume();
|
||||
if ((currLV->GetRegion() == fEnvelope) && (currLV->IsRootRegion())) {
|
||||
fEnvelopePhysicalVolume = currPV;
|
||||
fEnvelopeLogicalVolume = currLV;
|
||||
fEnvelopeSolid = currLV->GetSolid();
|
||||
fEnvelopeLogicalVolume = currLV;
|
||||
fEnvelopeSolid = currLV->GetSolid();
|
||||
Done = true;
|
||||
break;
|
||||
}
|
||||
@@ -146,22 +131,18 @@ G4FastTrack::FRecordsAffineTransformation(const G4Navigator* theNavigator)
|
||||
//---------------------------------------------
|
||||
//-- Verification: should be removed in future:
|
||||
//---------------------------------------------
|
||||
if ( Done == false )
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "Can't find transformation for `" << fEnvelopePhysicalVolume->GetName() << "'" << G4endl;
|
||||
G4Exception("G4FastTrack::FRecordsAffineTransformation()",
|
||||
"FastSim011",
|
||||
JustWarning, ed);
|
||||
}
|
||||
else
|
||||
{
|
||||
//-------------------------------------------------------
|
||||
// Records the transformation and inverse transformation:
|
||||
//-------------------------------------------------------
|
||||
fAffineTransformation = history->GetHistory()->GetTransform(idepth);
|
||||
fInverseAffineTransformation = fAffineTransformation.Inverse();
|
||||
|
||||
fAffineTransformationDefined = true;
|
||||
}
|
||||
if (!Done) {
|
||||
G4ExceptionDescription ed;
|
||||
ed << "Can't find transformation for `" << fEnvelopePhysicalVolume->GetName() << "'" << G4endl;
|
||||
G4Exception("G4FastTrack::FRecordsAffineTransformation()", "FastSim011", JustWarning, ed);
|
||||
}
|
||||
else {
|
||||
//-------------------------------------------------------
|
||||
// Records the transformation and inverse transformation:
|
||||
//-------------------------------------------------------
|
||||
fAffineTransformation = history->GetHistory()->GetTransform(idepth);
|
||||
fInverseAffineTransformation = fAffineTransformation.Inverse();
|
||||
|
||||
fAffineTransformationDefined = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,19 +25,19 @@
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4GlobalFastSimulationManager.cc
|
||||
//
|
||||
// Description:
|
||||
// A singleton class which manages the Fast Simulation managers
|
||||
// A singleton class which manages the Fast Simulation managers
|
||||
// attached to envelopes. Implementation.
|
||||
//
|
||||
// History:
|
||||
// June 98: Verderi && MoraDeFreitas - "G4ParallelWorld" becomes
|
||||
// "G4FlavoredParallelWorld"; some method name changes;
|
||||
// GetFlavoredWorldForThis now returns a
|
||||
// GetFlavoredWorldForThis now returns a
|
||||
// G4FlavoredParallelWorld pointer.
|
||||
// Feb 98: Verderi && MoraDeFreitas - First Implementation.
|
||||
// March 98: correction to instanciate dynamically the manager
|
||||
@@ -46,36 +46,29 @@
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#include "G4GlobalFastSimulationManager.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
|
||||
#include "G4FastSimulationMessenger.hh"
|
||||
#include "G4RegionStore.hh"
|
||||
#include "G4ProcessVector.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
|
||||
|
||||
// ------------------------------------------
|
||||
// -- static instance pointer initialisation:
|
||||
// ------------------------------------------
|
||||
G4ThreadLocal G4GlobalFastSimulationManager* G4GlobalFastSimulationManager::fGlobalFastSimulationManager = 0;
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4ProcessVector.hh"
|
||||
#include "G4RegionStore.hh"
|
||||
#include "G4ThreadLocalSingleton.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
|
||||
// --------------------------------------------------
|
||||
// -- static methods to retrieve the manager pointer:
|
||||
// --------------------------------------------------
|
||||
G4GlobalFastSimulationManager* G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()
|
||||
{
|
||||
if(!fGlobalFastSimulationManager)
|
||||
fGlobalFastSimulationManager = new G4GlobalFastSimulationManager;
|
||||
|
||||
return fGlobalFastSimulationManager;
|
||||
static G4ThreadLocalSingleton<G4GlobalFastSimulationManager> instance;
|
||||
return instance.Instance();
|
||||
}
|
||||
|
||||
|
||||
G4GlobalFastSimulationManager* G4GlobalFastSimulationManager::GetInstance()
|
||||
{
|
||||
return G4GlobalFastSimulationManager::GetGlobalFastSimulationManager();
|
||||
@@ -95,20 +88,17 @@ G4GlobalFastSimulationManager::G4GlobalFastSimulationManager()
|
||||
G4GlobalFastSimulationManager::~G4GlobalFastSimulationManager()
|
||||
{
|
||||
delete fTheFastSimulationMessenger;
|
||||
fTheFastSimulationMessenger = 0;
|
||||
}
|
||||
|
||||
// ----------------------
|
||||
// -- management methods:
|
||||
// ----------------------
|
||||
void G4GlobalFastSimulationManager::
|
||||
AddFastSimulationManager(G4FastSimulationManager* fsmanager)
|
||||
void G4GlobalFastSimulationManager::AddFastSimulationManager(G4FastSimulationManager* fsmanager)
|
||||
{
|
||||
ManagedManagers.push_back(fsmanager);
|
||||
}
|
||||
|
||||
void G4GlobalFastSimulationManager::
|
||||
RemoveFastSimulationManager(G4FastSimulationManager* fsmanager)
|
||||
void G4GlobalFastSimulationManager::RemoveFastSimulationManager(G4FastSimulationManager* fsmanager)
|
||||
{
|
||||
ManagedManagers.remove(fsmanager);
|
||||
}
|
||||
@@ -126,32 +116,26 @@ void G4GlobalFastSimulationManager::RemoveFSMP(G4FastSimulationManagerProcess* f
|
||||
void G4GlobalFastSimulationManager::ActivateFastSimulationModel(const G4String& aName)
|
||||
{
|
||||
G4bool result = false;
|
||||
for (size_t ifsm=0; ifsm<ManagedManagers.size(); ifsm++)
|
||||
result = result || ManagedManagers[ifsm]->
|
||||
ActivateFastSimulationModel(aName);
|
||||
if(result)
|
||||
G4cout << "Model " << aName << " activated.";
|
||||
else
|
||||
G4cout << "Model " << aName << " not found.";
|
||||
G4cout << G4endl;
|
||||
for (auto& ManagedManager : ManagedManagers)
|
||||
result = result || ManagedManager->ActivateFastSimulationModel(aName);
|
||||
|
||||
G4cout << "Model " << aName << (result ? " activated." : " not found.") << G4endl;
|
||||
}
|
||||
|
||||
void G4GlobalFastSimulationManager::InActivateFastSimulationModel(const G4String& aName)
|
||||
{
|
||||
G4bool result = false;
|
||||
for (size_t ifsm=0; ifsm<ManagedManagers.size(); ifsm++)
|
||||
result = result || ManagedManagers[ifsm]->
|
||||
InActivateFastSimulationModel(aName);
|
||||
if (result) G4cout << "Model " << aName << " inactivated.";
|
||||
else G4cout << "Model " << aName << " not found.";
|
||||
G4cout << G4endl;
|
||||
for (auto& ManagedManager : ManagedManagers)
|
||||
result = result || ManagedManager->InActivateFastSimulationModel(aName);
|
||||
|
||||
G4cout << "Model " << aName << (result ? " inactivated." : " not found.") << G4endl;
|
||||
}
|
||||
|
||||
void G4GlobalFastSimulationManager::Flush()
|
||||
{
|
||||
// loop over all models (that need flushing?) and flush
|
||||
for (size_t ifsm=0; ifsm<ManagedManagers.size(); ifsm++)
|
||||
ManagedManagers[ifsm]->FlushModels();
|
||||
for (auto& ManagedManager : ManagedManagers)
|
||||
ManagedManager->FlushModels();
|
||||
}
|
||||
|
||||
// ---------------------------------
|
||||
@@ -166,156 +150,153 @@ void G4GlobalFastSimulationManager::ShowSetup()
|
||||
// -- loop on regions to get the list of world volumes:
|
||||
// ----------------------------------------------------
|
||||
G4cout << "\nFast simulation setup:" << G4endl;
|
||||
for (size_t i=0; i<regions->size(); i++)
|
||||
for (auto& region : *regions) {
|
||||
world = region->GetWorldPhysical();
|
||||
if (world == nullptr) // region does not belong to any (existing) world
|
||||
{
|
||||
world = (*regions)[i]->GetWorldPhysical();
|
||||
if (world == nullptr) // region does not belong to any (existing) world
|
||||
{
|
||||
continue;
|
||||
}
|
||||
G4bool newWorld = true;
|
||||
for (size_t ii=0; ii<worldDone.size(); ii++) if (worldDone[ii] == world) {newWorld = false; break;}
|
||||
if (newWorld)
|
||||
{
|
||||
worldDone.push_back(world);
|
||||
G4Region* worldRegion = world->GetLogicalVolume()->GetRegion();
|
||||
// -- preambule: print physical volume and region names...
|
||||
if (world == G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume())
|
||||
G4cout << "\n * Mass Geometry with ";
|
||||
else
|
||||
G4cout << "\n * Parallel Geometry with ";
|
||||
G4cout << "world volume: `" << world->GetName() << "' [region : `" << worldRegion->GetName() << "']" << G4endl;
|
||||
// -- ... and print G4FSMP(s) attached to this world volume:
|
||||
G4bool findG4FSMP(false);
|
||||
// -- show to what particles this G4FSMP is attached to:
|
||||
std::vector<G4ParticleDefinition*> particlesKnown;
|
||||
for (size_t ip=0; ip<fFSMPVector.size(); ip++)
|
||||
if (fFSMPVector[ip]->GetWorldVolume() == world)
|
||||
{
|
||||
G4cout << " o G4FastSimulationProcess: '" << fFSMPVector[ip]->GetProcessName() << "'" << G4endl;
|
||||
G4cout << " Attached to:";
|
||||
G4ParticleTable* particles = G4ParticleTable::GetParticleTable();
|
||||
for (G4int iParticle=0; iParticle<particles->entries(); iParticle++)
|
||||
{
|
||||
G4ParticleDefinition* particle = particles->GetParticle(iParticle);
|
||||
G4ProcessVector* processes = particle->GetProcessManager()->GetProcessList();
|
||||
if (processes->contains(fFSMPVector[ip])) {G4cout << " " << particle->GetParticleName(); findG4FSMP = true; particlesKnown.push_back(particle);}
|
||||
}
|
||||
G4cout << G4endl;
|
||||
}
|
||||
if (!findG4FSMP) G4cout << " o G4FastSimulationProcess: (none)" << G4endl;
|
||||
// -- now display the regions in this world volume, with mother<->daughter link shown by indentation:
|
||||
G4cout << " o Region(s) and model(s) setup:" << G4endl;
|
||||
DisplayRegion(worldRegion, 1, particlesKnown);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
G4bool newWorld = true;
|
||||
for (auto& ii : worldDone)
|
||||
if (ii == world) {
|
||||
newWorld = false;
|
||||
break;
|
||||
}
|
||||
if (newWorld) {
|
||||
worldDone.push_back(world);
|
||||
G4Region* worldRegion = world->GetLogicalVolume()->GetRegion();
|
||||
// -- preambule: print physical volume and region names...
|
||||
if (world
|
||||
== G4TransportationManager::GetTransportationManager()
|
||||
->GetNavigatorForTracking()
|
||||
->GetWorldVolume())
|
||||
G4cout << "\n * Mass Geometry with ";
|
||||
else
|
||||
G4cout << "\n * Parallel Geometry with ";
|
||||
G4cout << "world volume: `" << world->GetName() << "' [region : `" << worldRegion->GetName()
|
||||
<< "']" << G4endl;
|
||||
// -- ... and print G4FSMP(s) attached to this world volume:
|
||||
G4bool findG4FSMP(false);
|
||||
// -- show to what particles this G4FSMP is attached to:
|
||||
std::vector<G4ParticleDefinition*> particlesKnown;
|
||||
for (auto& ip : fFSMPVector)
|
||||
if (ip->GetWorldVolume() == world) {
|
||||
G4cout << " o G4FastSimulationProcess: '" << ip->GetProcessName() << "'" << G4endl;
|
||||
G4cout << " Attached to:";
|
||||
G4ParticleTable* particles = G4ParticleTable::GetParticleTable();
|
||||
for (G4int iParticle = 0; iParticle < particles->entries(); iParticle++) {
|
||||
G4ParticleDefinition* particle = particles->GetParticle(iParticle);
|
||||
G4ProcessVector* processes = particle->GetProcessManager()->GetProcessList();
|
||||
if (processes->contains(ip)) {
|
||||
G4cout << " " << particle->GetParticleName();
|
||||
findG4FSMP = true;
|
||||
particlesKnown.push_back(particle);
|
||||
}
|
||||
}
|
||||
G4cout << G4endl;
|
||||
}
|
||||
if (!findG4FSMP) G4cout << " o G4FastSimulationProcess: (none)" << G4endl;
|
||||
// -- now display the regions in this world volume, with mother<->daughter link shown by
|
||||
// indentation:
|
||||
G4cout << " o Region(s) and model(s) setup:" << G4endl;
|
||||
DisplayRegion(worldRegion, 1, particlesKnown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void G4GlobalFastSimulationManager::DisplayRegion(G4Region* region, G4int depth, std::vector<G4ParticleDefinition*>& particlesKnown) const
|
||||
void G4GlobalFastSimulationManager::DisplayRegion(
|
||||
G4Region* region, G4int depth, std::vector<G4ParticleDefinition*>& particlesKnown) const
|
||||
{
|
||||
G4String indent = " ";
|
||||
for (G4int I=0; I<depth; I++) indent += " ";
|
||||
G4cout << indent << "Region: `" << region->GetName() <<"'" << G4endl;
|
||||
for (G4int I = 0; I < depth; I++)
|
||||
indent += " ";
|
||||
G4cout << indent << "Region: `" << region->GetName() << "'" << G4endl;
|
||||
G4FastSimulationManager* fastSimManager = region->GetFastSimulationManager();
|
||||
if (fastSimManager)
|
||||
{
|
||||
indent += " ";
|
||||
G4cout << indent << "Model(s):" << G4endl;
|
||||
indent += " ";
|
||||
for (size_t im=0; im<fastSimManager->GetFastSimulationModelList().size(); im++)
|
||||
{
|
||||
G4cout << indent << "`" << (fastSimManager->GetFastSimulationModelList())[im]->GetName() << "'";
|
||||
G4cout << " ; applicable to:";
|
||||
G4ParticleTable* particles = G4ParticleTable::GetParticleTable();
|
||||
for (G4int iParticle=0; iParticle<particles->entries(); iParticle++)
|
||||
{
|
||||
if ((fastSimManager->GetFastSimulationModelList())[im]->IsApplicable(*(particles->GetParticle(iParticle))))
|
||||
{
|
||||
G4cout << " " << particles->GetParticle(iParticle)->GetParticleName();
|
||||
G4bool known(false);
|
||||
for (size_t l=0; l<particlesKnown.size();l++) if(particlesKnown[l] == particles->GetParticle(iParticle)) {known = true; break;}
|
||||
if (!known) G4cout << "[!!]";
|
||||
}
|
||||
}
|
||||
G4cout << G4endl;
|
||||
}
|
||||
if (fastSimManager != nullptr) {
|
||||
indent += " ";
|
||||
G4cout << indent << "Model(s):" << G4endl;
|
||||
indent += " ";
|
||||
for (auto im : fastSimManager->GetFastSimulationModelList()) {
|
||||
G4cout << indent << "`" << im->GetName() << "'";
|
||||
G4cout << " ; applicable to:";
|
||||
G4ParticleTable* particles = G4ParticleTable::GetParticleTable();
|
||||
for (G4int iParticle = 0; iParticle < particles->entries(); iParticle++) {
|
||||
if (im->IsApplicable(*(particles->GetParticle(iParticle)))) {
|
||||
G4cout << " " << particles->GetParticle(iParticle)->GetParticleName();
|
||||
G4bool known(false);
|
||||
for (auto& l : particlesKnown)
|
||||
if (l == particles->GetParticle(iParticle)) {
|
||||
known = true;
|
||||
break;
|
||||
}
|
||||
if (!known) G4cout << "[!!]";
|
||||
}
|
||||
}
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// -- all that to check mothership of "region"
|
||||
G4PhysicalVolumeStore* physVolStore = G4PhysicalVolumeStore::GetInstance();
|
||||
for (size_t ip=0; ip<physVolStore->size(); ip++)
|
||||
{
|
||||
G4VPhysicalVolume* physVol = (*physVolStore)[ip];
|
||||
if (physVol->GetLogicalVolume()->IsRootRegion())
|
||||
if (physVol->GetMotherLogical())
|
||||
{
|
||||
G4Region* thisVolMotherRegion = physVol->GetMotherLogical()->GetRegion();
|
||||
if (thisVolMotherRegion == region)
|
||||
DisplayRegion(physVol->GetLogicalVolume()->GetRegion(), depth+1, particlesKnown);
|
||||
}
|
||||
}
|
||||
for (auto physVol : *physVolStore) {
|
||||
if (physVol->GetLogicalVolume()->IsRootRegion())
|
||||
if (physVol->GetMotherLogical() != nullptr) {
|
||||
G4Region* thisVolMotherRegion = physVol->GetMotherLogical()->GetRegion();
|
||||
if (thisVolMotherRegion == region)
|
||||
DisplayRegion(physVol->GetLogicalVolume()->GetRegion(), depth + 1, particlesKnown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------
|
||||
// -- management methods : list
|
||||
// ----------------------------
|
||||
|
||||
void G4GlobalFastSimulationManager::ListEnvelopes(const G4String& aName,
|
||||
listType theType)
|
||||
void G4GlobalFastSimulationManager::ListEnvelopes(const G4String& aName, listType theType)
|
||||
{
|
||||
if (theType == ISAPPLICABLE)
|
||||
{
|
||||
for (size_t ifsm=0; ifsm<ManagedManagers.size(); ifsm++) ManagedManagers[ifsm]->ListModels(aName);
|
||||
return;
|
||||
}
|
||||
|
||||
if(aName == "all")
|
||||
{
|
||||
G4int titled = 0;
|
||||
for (size_t ifsm=0; ifsm<ManagedManagers.size(); ifsm++)
|
||||
{
|
||||
if(theType == NAMES_ONLY)
|
||||
{
|
||||
if(!(titled++))
|
||||
G4cout << "Current Envelopes for Fast Simulation:\n";
|
||||
G4cout << " ";
|
||||
ManagedManagers[ifsm]->ListTitle();
|
||||
G4cout << G4endl;
|
||||
}
|
||||
else ManagedManagers[ifsm]->ListModels();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t ifsm=0; ifsm<ManagedManagers.size(); ifsm++)
|
||||
if(aName == ManagedManagers[ifsm]-> GetEnvelope()->GetName())
|
||||
{
|
||||
ManagedManagers[ifsm]->ListModels();
|
||||
break;
|
||||
}
|
||||
if (theType == ISAPPLICABLE) {
|
||||
for (auto& ManagedManager : ManagedManagers)
|
||||
ManagedManager->ListModels(aName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (aName == "all") {
|
||||
G4int titled = 0;
|
||||
for (auto& ManagedManager : ManagedManagers) {
|
||||
if (theType == NAMES_ONLY) {
|
||||
if ((titled++) == 0) G4cout << "Current Envelopes for Fast Simulation:\n";
|
||||
G4cout << " ";
|
||||
ManagedManager->ListTitle();
|
||||
G4cout << G4endl;
|
||||
}
|
||||
else
|
||||
ManagedManager->ListModels();
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (auto& ManagedManager : ManagedManagers)
|
||||
if (aName == ManagedManager->GetEnvelope()->GetName()) {
|
||||
ManagedManager->ListModels();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void G4GlobalFastSimulationManager::ListEnvelopes(const G4ParticleDefinition* aPD)
|
||||
{
|
||||
for (size_t ifsm=0; ifsm<ManagedManagers.size(); ifsm++)
|
||||
ManagedManagers[ifsm]->ListModels(aPD);
|
||||
for (auto& ManagedManager : ManagedManagers)
|
||||
ManagedManager->ListModels(aPD);
|
||||
}
|
||||
|
||||
|
||||
G4VFastSimulationModel* G4GlobalFastSimulationManager::GetFastSimulationModel(const G4String& modelName,
|
||||
const G4VFastSimulationModel* previousFound) const
|
||||
G4VFastSimulationModel* G4GlobalFastSimulationManager::GetFastSimulationModel(
|
||||
const G4String& modelName, const G4VFastSimulationModel* previousFound) const
|
||||
{
|
||||
G4VFastSimulationModel* model = 0;
|
||||
G4VFastSimulationModel* model = nullptr;
|
||||
// -- flag used to navigate accross the various managers;
|
||||
bool foundPrevious(false);
|
||||
for (size_t ifsm=0; ifsm<ManagedManagers.size(); ifsm++)
|
||||
{
|
||||
model = ManagedManagers[ifsm]->
|
||||
GetFastSimulationModel(modelName, previousFound, foundPrevious);
|
||||
if (model) break;
|
||||
}
|
||||
for (auto ManagedManager : ManagedManagers) {
|
||||
model = ManagedManager->GetFastSimulationModel(modelName, previousFound, foundPrevious);
|
||||
if (model != nullptr) break;
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
@@ -37,28 +37,26 @@
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
|
||||
#include "G4VFastSimulationModel.hh"
|
||||
|
||||
#include "G4FastSimulationManager.hh"
|
||||
|
||||
// ----------------------
|
||||
// -- Simple constructor:
|
||||
// ----------------------
|
||||
G4VFastSimulationModel::G4VFastSimulationModel(const G4String& aName)
|
||||
: theModelName(aName) {}
|
||||
G4VFastSimulationModel::G4VFastSimulationModel(const G4String& aName) : theModelName(aName) {}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------
|
||||
// -- Constructor with automatic G4FastSimulationManager constructed if needed fo given envelope:
|
||||
// ----------------------------------------------------------------------------------------------
|
||||
G4VFastSimulationModel::G4VFastSimulationModel(const G4String& aName,
|
||||
G4Envelope* anEnvelope,
|
||||
G4bool IsUnique)
|
||||
: theModelName(aName)
|
||||
G4VFastSimulationModel::G4VFastSimulationModel(const G4String& aName, G4Envelope* anEnvelope,
|
||||
G4bool IsUnique)
|
||||
: theModelName(aName)
|
||||
{
|
||||
// Retrieves the Fast Simulation Manager ou creates one if needed.
|
||||
G4FastSimulationManager* theFastSimulationManager;
|
||||
if ((theFastSimulationManager = anEnvelope->GetFastSimulationManager()) == 0)
|
||||
theFastSimulationManager = new G4FastSimulationManager(anEnvelope,IsUnique);
|
||||
if ((theFastSimulationManager = anEnvelope->GetFastSimulationManager()) == nullptr)
|
||||
theFastSimulationManager = new G4FastSimulationManager(anEnvelope, IsUnique);
|
||||
// adds this model to the Fast Simulation Manager.
|
||||
theFastSimulationManager->AddFastSimulationModel(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user