Import Geant4 8.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 14:55:03 +02:00
parent 216a75eeb1
commit fe73f43734
6714 changed files with 118229 additions and 68144 deletions
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4FastSimulationManager.cc,v 1.11 2006/06/29 21:09:26 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
// $Id: G4FastSimulationManager.cc,v 1.12 2006/11/03 17:26:04 mverderi Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
//---------------------------------------------------------------
//
@@ -42,6 +42,7 @@
#include "G4FastSimulationManager.hh"
#include "G4GlobalFastSimulationManager.hh"
#include "G4PVPlacement.hh"
#include "G4TransportationManager.hh"
// --------------------------------------------------
// Constructor with envelope and IsUnique flag :
@@ -154,6 +155,7 @@ G4FastSimulationManager::GetFastSimulationModel(const G4String& modelName,
return model;
}
// ***************************************** TO BE DROPPED ********************************************** >>>> BEGINNING
//----------------------------------------
// Methods to add/remove GhostPlacements
@@ -226,6 +228,7 @@ InsertGhostHereIfNecessary(G4VPhysicalVolume* theClone,
return false;
}
// ***************************************** TO BE DROPPED **************************************** <<<< END
//
//-------------------------------------
@@ -369,7 +372,10 @@ void
G4FastSimulationManager::ListTitle() const
{
G4cout << fFastTrack.GetEnvelope()->GetName();
if(GhostPlacements.size()!=0) G4cout << " (ghost)";
// if(GhostPlacements.size()!=0) G4cout << " (ghost)";
if (fFastTrack.GetEnvelope()->GetWorldPhysical() == G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume()) G4cout << " (mass geom.)";
else G4cout << " (// geom.)";
}
void
@@ -379,7 +385,7 @@ G4FastSimulationManager::ListModels() const
G4cout << "Current Models for the ";
ListTitle();
G4cout << " Envelope:\n";
G4cout << " envelope:\n";
for (iModel=0; iModel<ModelList.size(); iModel++)
G4cout << " " << ModelList[iModel]->GetName() << "\n";
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4FastSimulationManagerProcess.cc,v 1.13 2006/06/29 21:09:28 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
// $Id: G4FastSimulationManagerProcess.cc,v 1.14 2006/11/03 17:26:04 mverderi Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
//
//---------------------------------------------------------------
@@ -148,6 +148,7 @@ G4FastSimulationManagerProcess::PostStepGetPhysicalInteractionLength(
fOutOfGhostWorld = true;
}
}
if (fGhostWorld == 0) fStartTracking = false; // -- case ghost world below
// -------------------------------------------------------
//
@@ -0,0 +1,314 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: G4FastSimulationManagerProcess81.cc,v 1.1 2006/11/10 13:23:07 mverderi Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
//
//---------------------------------------------------------------
//
// G4FastSimulationProcess.cc
//
// Description:
// The process that triggers the parameterised simulations,
// if any.
//
// History:
// August 97: First implementation. Verderi && MoraDeFreitas.
// October 06: move to parallel geometry scheme, M. Verderi
//---------------------------------------------------------------
#include "G4ios.hh"
#include "G4FastSimulationManagerProcess81.hh"
#include "G4GlobalFastSimulationManager.hh"
#include "G4TransportationManager.hh"
#include "G4PathFinder.hh"
#include "G4ParticleChange.hh"
#define PARANOIA
G4FastSimulationManagerProcess81::
G4FastSimulationManagerProcess81(const G4String& processName,
G4ProcessType theType) :
G4VProcess(processName,theType),
fWorldVolume(0),
fIsTrackingTime(false),
fNavigator(0),
fNavigatorIndex(-1),
fFastSimulationManager(0),
fFastSimulationTrigger(false)
{
SetWorldVolume(G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume()->GetName());
if (verboseLevel>0) G4cout << "G4FastSimulationManagerProcess81 `" << GetProcessName()
<< "' is created, and will message geometry with world volume `"
<< fWorldVolume->GetName() << "'." << G4endl;
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->AddFSMP(this);
}
G4FastSimulationManagerProcess81::
G4FastSimulationManagerProcess81(const G4String& processName,
const G4String& worldVolumeName,
G4ProcessType theType) :
G4VProcess(processName,theType),
fWorldVolume(0),
fIsTrackingTime(false),
fNavigator(0),
fNavigatorIndex(-1),
fFastSimulationManager(0),
fFastSimulationTrigger(false)
{
SetWorldVolume(worldVolumeName);
if (verboseLevel>0) G4cout << "G4FastSimulationManagerProcess81 `" << GetProcessName()
<< "' is created, and will message geometry with world volume `"
<< fWorldVolume->GetName() << "'." << G4endl;
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->AddFSMP(this);
}
G4FastSimulationManagerProcess81::
G4FastSimulationManagerProcess81(const G4String& processName,
G4VPhysicalVolume* worldVolume,
G4ProcessType theType) :
G4VProcess(processName,theType),
fWorldVolume(0),
fIsTrackingTime(false),
fNavigator(0),
fNavigatorIndex(-1),
fFastSimulationManager(0),
fFastSimulationTrigger(false)
{
SetWorldVolume(worldVolume);
if (verboseLevel>0) G4cout << "G4FastSimulationManagerProcess81 `" << GetProcessName()
<< "' is created, and will message geometry with world volume `"
<< fWorldVolume->GetName() << "'." << G4endl;
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->AddFSMP(this);
}
G4FastSimulationManagerProcess81::~G4FastSimulationManagerProcess81()
{
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->RemoveFSMP(this);
}
// -----------------------
// User access methods:
// -----------------------
void
G4FastSimulationManagerProcess81::
SetWorldVolume(G4String newWorldName)
{
if (fIsTrackingTime)
G4cout << "!!! G4FastSimulationManagerProcess81 `" << GetProcessName()
<< "': changing world volume at tracking time is not allowed for now. Call ignored !!!" << G4endl;
else
{
G4VPhysicalVolume* newWorld = G4TransportationManager::GetTransportationManager()->IsWorldExisting(newWorldName);
G4String tellWhatIsWrong;
tellWhatIsWrong = "Volume newWorldName = `"; tellWhatIsWrong += newWorldName; tellWhatIsWrong += "' is not a parallel world nor the mass world volume.";
if (newWorld == 0) G4Exception("G4FastSimulationManagerProcess81::SetWorldVolume(const G4String&, G4bool verbose)",
"InvalidWorld",
FatalException,
tellWhatIsWrong);
if (verboseLevel>0)
if (fWorldVolume) G4cout << "G4FastSimulationManagerProcess81 `" << GetProcessName()
<< "': changing world volume from '" << fWorldVolume->GetName()
<< "' to `" << newWorld << "'." << G4endl;
else G4cout << "G4FastSimulationManagerProcess81 `" << GetProcessName()
<< "': setting world volume from to `"<< newWorld->GetName() << "'." << G4endl;
fWorldVolume = newWorld;
}
}
void
G4FastSimulationManagerProcess81::
SetWorldVolume(G4VPhysicalVolume* newWorld)
{
if (newWorld) SetWorldVolume(newWorld->GetName());
else G4cout << "!!! G4FastSimulationManagerProcess81::SetWorldVolume(const G4VPhysicalVolume* newWorld) : null pointer passed. !!! Continuing at your own risks..." << G4endl;
}
// --------------------
// Start/End tracking:
// --------------------
void
G4FastSimulationManagerProcess81::
StartTracking(G4Track*)
{
fIsTrackingTime = true;
fIsFirstStep = true;
// -- fetch the navigator (and its index) and activate it:
G4TransportationManager* transportationManager = G4TransportationManager::GetTransportationManager();
fNavigator = transportationManager->GetNavigator(fWorldVolume);
if (fNavigator != transportationManager->GetNavigatorForTracking())
fNavigatorIndex = transportationManager->ActivateNavigator(fNavigator);
else
fNavigatorIndex = 0;
}
void
G4FastSimulationManagerProcess81::
EndTracking()
{
fIsTrackingTime = false;
}
// ------------------------------------------
// PostStepGetPhysicalInteractionLength():
// ------------------------------------------
G4double
G4FastSimulationManagerProcess81::
PostStepGetPhysicalInteractionLength(const G4Track& track,
G4double,
G4ForceCondition* condition)
{
#ifdef PARANOIA
if ( fNavigator->GetWorldVolume() != fWorldVolume ) G4Exception("!!! ??? INCONSISTENT NAVIGATORS/WORLD VOLUMES ??? !!!");
#endif
// -- Get current volume, and check for presence of fast simulation manager.
// -- For the case of the navigator for tracking (fNavigatorIndex == 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 (fNavigatorIndex == 0) currentVolume = track.GetVolume();
else currentVolume = G4PathFinder::GetInstance()->GetLocatedVolume(fNavigatorIndex);
if ( currentVolume )
{
fFastSimulationManager = currentVolume->GetLogicalVolume()->GetFastSimulationManager();
if( fFastSimulationManager )
{
// Ask for trigger:
fFastSimulationTrigger = fFastSimulationManager->PostStepGetFastSimulationManagerTrigger(track, fNavigator);
if( fFastSimulationTrigger )
{
// Take control over stepping:
*condition = ExclusivelyForced;
return 0.0;
}
}
}
// -- no fast simulation occuring there:
*condition = NotForced;
return DBL_MAX;
}
//------------------------------------
// PostStepDoIt()
//------------------------------------
G4VParticleChange*
G4FastSimulationManagerProcess81::
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;
}
//--------------------------------------------
// At Rest parameterisation:
//--------------------------------------------
// AtRestGetPhysiscalInteractionLength:
//--------------------------------------------
G4double
G4FastSimulationManagerProcess81::
AtRestGetPhysicalInteractionLength(const G4Track& track,
G4ForceCondition* condition)
{
const G4VPhysicalVolume* currentVolume(0);
if (fNavigatorIndex == 0) currentVolume = track.GetVolume();
else currentVolume = G4PathFinder::GetInstance()->GetLocatedVolume(fNavigatorIndex);
fFastSimulationManager = currentVolume->GetLogicalVolume()->GetFastSimulationManager();
if( fFastSimulationManager )
{
// Ask for trigger:
fFastSimulationTrigger = fFastSimulationManager->AtRestGetFastSimulationManagerTrigger(track, fNavigator);
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;
}
//-----------------------------------------------
// AtRestDoIt:
//-----------------------------------------------
G4VParticleChange* G4FastSimulationManagerProcess81::AtRestDoIt(const G4Track&, const G4Step&)
{
return fFastSimulationManager->InvokeAtRestDoIt();
}
void G4FastSimulationManagerProcess81::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;
}*/
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4FastSimulationMessenger.cc,v 1.6 2006/06/29 21:09:30 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
// $Id: G4FastSimulationMessenger.cc,v 1.7 2006/11/03 17:26:04 mverderi Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
#include "G4FastSimulationMessenger.hh"
@@ -42,6 +42,11 @@ G4FastSimulationMessenger(G4GlobalFastSimulationManager* theGFSM)
fFSDirectory = new G4UIdirectory("/param/");
fFSDirectory->SetGuidance("Fast Simulation print/control commands.");
fShowSetupCmd =
new G4UIcmdWithoutParameter("/param/showSetup", this);
fShowSetupCmd->SetGuidance("Show fast simulation setup");
fShowSetupCmd->AvailableForStates(G4State_GeomClosed);
fListEnvelopesCmd =
new G4UIcmdWithAString("/param/listEnvelopes", this);
fListEnvelopesCmd->SetParameterName("ParticleName",true);
@@ -78,6 +83,8 @@ G4FastSimulationMessenger(G4GlobalFastSimulationManager* theGFSM)
G4FastSimulationMessenger::~G4FastSimulationMessenger()
{
delete fShowSetupCmd;
fShowSetupCmd = 0;
delete fListIsApplicableCmd;
fListIsApplicableCmd = 0;
delete fActivateModel;
@@ -94,6 +101,8 @@ G4FastSimulationMessenger::~G4FastSimulationMessenger()
void G4FastSimulationMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
{
if (command == fShowSetupCmd)
fGlobalFastSimulationManager->ShowSetup();
if( command == fListEnvelopesCmd)
if(newValue == "all")
fGlobalFastSimulationManager->ListEnvelopes();
@@ -25,7 +25,7 @@
//
//
// $Id: G4FastStep.cc,v 1.16 2006/06/29 21:09:32 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
// GEANT4 tag $Name: geant4-08-02 $
//
//---------------------------------------------------------------
//
@@ -25,7 +25,7 @@
//
//
// $Id: G4FastTrack.cc,v 1.10 2006/06/29 21:09:34 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
// GEANT4 tag $Name: geant4-08-02 $
//
//---------------------------------------------------------------
//
@@ -0,0 +1,167 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id: G4GFSManager81.cc,v 1.1 2006/11/10 13:23:07 mverderi Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
//
//---------------------------------------------------------------
//
// G4GFSManager81.cc
//
// Description:
// Gathers code to be dropped at the next major release
//
// History:
// November 2006
//
//---------------------------------------------------------------
#include "G4GFSManager81.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4Material.hh"
#include "G4ThreeVector.hh"
#include "G4PVPlacement.hh"
#include "G4TransportationManager.hh"
#include "G4FastSimulationMessenger.hh"
#include "G4GlobalFastSimulationManager.hh"
G4GFSManager81::G4GFSManager81()
{
// It starts closed.
fClosed=true;
}
void G4GFSManager81::FastSimulationNeedsToBeClosed()
{
fClosed=false;
}
void G4GFSManager81::CloseFastSimulation()
{
if(fClosed) return;
G4ParticleTable* theParticleTable;
// Reset the NeededFlavoredWorlds List
NeededFlavoredWorlds.clearAndDestroy();
// We'll look for models for all particle types
theParticleTable=G4ParticleTable::GetParticleTable();
// Creates the first world volume clone.
G4VPhysicalVolume* aClone = GiveMeAWorldVolumeClone();
G4cout << "Closing Fast-Simulation ..." << G4endl;
for (G4int iParticle=0;
iParticle<theParticleTable->entries(); iParticle++) {
G4bool Needed = false;
G4GlobalFastSimulationManager* global = G4GlobalFastSimulationManager::GetGlobalFastSimulationManager();
for (size_t ifsm=0; ifsm< global->ManagedManagers.size(); ifsm++)
Needed = Needed || global->ManagedManagers[ifsm]->
InsertGhostHereIfNecessary(aClone,
*(theParticleTable->
GetParticle(iParticle)));
// if some FSM inserted a ghost, keep this clone.
if(Needed)
{
G4Region* aWorldGhostRegion = new G4Region("Ghost world region for " + theParticleTable->GetParticle(iParticle)->GetParticleName());
aWorldGhostRegion->AddRootLogicalVolume(aClone->GetLogicalVolume());
NeededFlavoredWorlds.push_back(new G4FlavoredParallelWorld(theParticleTable->GetParticle(iParticle), aClone));
// and prepare a new one.
aClone=GiveMeAWorldVolumeClone();
}
}
fClosed=true;
}
G4VFlavoredParallelWorld*
G4GFSManager81::
GetFlavoredWorldForThis(G4ParticleDefinition* particle)
{
for (size_t ipw=0; ipw<NeededFlavoredWorlds.size(); ipw++)
if(NeededFlavoredWorlds[ipw]->GetTheParticleType()==particle)
return NeededFlavoredWorlds[ipw];
return 0;
}
G4VPhysicalVolume*
G4GFSManager81::GiveMeAWorldVolumeClone()
{
G4VPhysicalVolume* theParallelWorldPhysical;
G4TransportationManager *transportationManager=
G4TransportationManager::GetTransportationManager();
G4VSolid *parallelWorldSolid=transportationManager->
GetNavigatorForTracking()->GetWorldVolume()->
GetLogicalVolume()->GetSolid();
G4Material *parallelWorldMaterial=transportationManager->
GetNavigatorForTracking()->GetWorldVolume()->
GetLogicalVolume()->GetMaterial();
G4LogicalVolume *parallelWorldLog =
new G4LogicalVolume(parallelWorldSolid,
parallelWorldMaterial,
"ParallelWorldLogical",
0, 0, 0);
theParallelWorldPhysical= new G4PVPlacement(0,G4ThreeVector(),
"ParallelWorldPhysical",
parallelWorldLog,
0,false,0);
return theParallelWorldPhysical;
}
G4bool
G4GFSManager81::Notify(G4ApplicationState requestedState)
{
G4StateManager * stateManager = G4StateManager::GetStateManager();
if((stateManager->GetPreviousState()==G4State_Idle) &&
(requestedState==G4State_GeomClosed) && (!fClosed) )
{
G4cerr
<< "ERROR - G4GFSManager81::Notify()" << G4endl
<< " 1) you are using ghost volumes;" << G4endl
<< " 2) In this case the G4GFSManager81" << G4endl
<< " MUST be closed BEFORE closing the geometry;" << G4endl
<< " 3) To do this put in your code the call to" << G4endl
<< " GetGlobalFastSimulationManager()->CloseFastSimulation();"
<< G4endl
<< " just before closing the geometry." << G4endl;
G4Exception("G4GFSManager81::Notify()", "InvalidState",
FatalException, "Fast simulation must be closed.");
}
return true;
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4GlobalFastSimulationManager.cc,v 1.16 2006/06/29 21:09:36 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
// $Id: G4GlobalFastSimulationManager.cc,v 1.19 2006/11/10 15:27:17 mverderi Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
//
//---------------------------------------------------------------
@@ -54,6 +54,14 @@
#include "G4PVPlacement.hh"
#include "G4TransportationManager.hh"
#include "G4FastSimulationMessenger.hh"
#include "G4RegionStore.hh"
#include "G4ProcessVector.hh"
#include "G4ProcessManager.hh"
#include "G4PhysicalVolumeStore.hh"
// -- *** to be dropped @ next major release: >>>>
#include "G4GFSManager81.hh"
// -- <<<<<<<<
G4GlobalFastSimulationManager*
G4GlobalFastSimulationManager::fGlobalFastSimulationManager = 0;
@@ -66,6 +74,7 @@ G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()
{
fGlobalFastSimulationManager = new G4GlobalFastSimulationManager;
SetConcreteInstance(fGlobalFastSimulationManager);
}
return fGlobalFastSimulationManager;
}
@@ -73,10 +82,11 @@ G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()
G4GlobalFastSimulationManager::G4GlobalFastSimulationManager()
{
// It starts closed.
fClosed=true;
// Initialises the G4FastSimulationMessenger
fTheFastSimulationMessenger=new G4FastSimulationMessenger(this);
// -- *** to be dropped @ next major release ***:
_deprecated = new G4GFSManager81();
}
G4GlobalFastSimulationManager::~G4GlobalFastSimulationManager()
@@ -87,7 +97,7 @@ G4GlobalFastSimulationManager::~G4GlobalFastSimulationManager()
void G4GlobalFastSimulationManager::FastSimulationNeedsToBeClosed()
{
fClosed=false;
_deprecated->FastSimulationNeedsToBeClosed();
}
void G4GlobalFastSimulationManager::
@@ -102,54 +112,34 @@ RemoveFastSimulationManager(G4FastSimulationManager* fsmanager)
ManagedManagers.remove(fsmanager);
}
void G4GlobalFastSimulationManager::
AddFSMP(G4FastSimulationManagerProcess81* fp)
{
fFSMPVector.push_back(fp);
}
void G4GlobalFastSimulationManager::
RemoveFSMP(G4FastSimulationManagerProcess81* fp)
{
fFSMPVector.remove(fp);
}
void G4GlobalFastSimulationManager::CloseFastSimulation()
{
if(fClosed) return;
G4ParticleTable* theParticleTable;
// Reset the NeededFlavoredWorlds List
NeededFlavoredWorlds.clearAndDestroy();
// We'll look for models for all particle types
theParticleTable=G4ParticleTable::GetParticleTable();
// Creates the first world volume clone.
G4VPhysicalVolume* aClone = GiveMeAWorldVolumeClone();
G4cout << "Closing Fast-Simulation ..." << G4endl;
for (G4int iParticle=0;
iParticle<theParticleTable->entries(); iParticle++) {
G4bool Needed = false;
for (size_t ifsm=0; ifsm<ManagedManagers.size(); ifsm++)
Needed = Needed || ManagedManagers[ifsm]->
InsertGhostHereIfNecessary(aClone,
*(theParticleTable->
GetParticle(iParticle)));
// if some FSM inserted a ghost, keep this clone.
if(Needed)
{
G4Region* aWorldGhostRegion = new G4Region("Ghost world region for " + theParticleTable->GetParticle(iParticle)->GetParticleName());
aWorldGhostRegion->AddRootLogicalVolume(aClone->GetLogicalVolume());
NeededFlavoredWorlds.push_back(new G4FlavoredParallelWorld(theParticleTable->GetParticle(iParticle), aClone));
// and prepare a new one.
aClone=GiveMeAWorldVolumeClone();
}
}
fClosed=true;
static int count(0);
if (count++ < 5)
G4cout << "G4GlobalFastSimulationManager::CloseFastSimulation() : DEPRECATING, will be dropped @ next major release" << G4endl;
_deprecated->CloseFastSimulation();
}
G4VFlavoredParallelWorld*
G4GlobalFastSimulationManager::
GetFlavoredWorldForThis(G4ParticleDefinition* particle)
GetFlavoredWorldForThis(G4ParticleDefinition* definition)
{
for (size_t ipw=0; ipw<NeededFlavoredWorlds.size(); ipw++)
if(NeededFlavoredWorlds[ipw]->GetTheParticleType()==particle)
return NeededFlavoredWorlds[ipw];
return 0;
static int count(0);
if (count++ < 5)
G4cout << "G4GlobalFastSimulationManager::GetFlavoredWorldForThis(...): DEPRECATING, will be dropped @ next major release" << G4endl;
return _deprecated->GetFlavoredWorldForThis(definition);
}
void
@@ -182,37 +172,143 @@ InActivateFastSimulationModel(const G4String& aName)
G4cout << G4endl;
}
void
G4GlobalFastSimulationManager::ShowSetup()
{
std::vector<G4VPhysicalVolume*> worldDone;
G4VPhysicalVolume* world;
G4RegionStore* regions = G4RegionStore::GetInstance();
// ----------------------------------------------------
// -- loop on regions to get the list of world volumes:
// ----------------------------------------------------
G4cout << "\nFast simulation setup:" << G4endl;
for (size_t i=0; i<regions->size(); i++)
{
world = (*regions)[i]->GetWorldPhysical();
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);
}
}
}
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;
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;
}
}
// -- 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);
}
}
}
void
G4GlobalFastSimulationManager::ListEnvelopes(const G4String& aName,
listType theType)
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();
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;
}
}
}
else {
for (size_t ifsm=0; ifsm<ManagedManagers.size(); ifsm++)
if(aName == ManagedManagers[ifsm]->
GetEnvelope()->GetName()){
ManagedManagers[ifsm]->ListModels();
break;
}
}
}
void
@@ -222,56 +318,13 @@ G4GlobalFastSimulationManager::ListEnvelopes(const G4ParticleDefinition* aPD)
ManagedManagers[ifsm]->ListModels(aPD);
}
G4VPhysicalVolume*
G4GlobalFastSimulationManager::GiveMeAWorldVolumeClone()
{
G4VPhysicalVolume* theParallelWorldPhysical;
G4TransportationManager *transportationManager=
G4TransportationManager::GetTransportationManager();
G4VSolid *parallelWorldSolid=transportationManager->
GetNavigatorForTracking()->GetWorldVolume()->
GetLogicalVolume()->GetSolid();
G4Material *parallelWorldMaterial=transportationManager->
GetNavigatorForTracking()->GetWorldVolume()->
GetLogicalVolume()->GetMaterial();
G4LogicalVolume *parallelWorldLog =
new G4LogicalVolume(parallelWorldSolid,
parallelWorldMaterial,
"ParallelWorldLogical",
0, 0, 0);
theParallelWorldPhysical= new G4PVPlacement(0,G4ThreeVector(),
"ParallelWorldPhysical",
parallelWorldLog,
0,false,0);
return theParallelWorldPhysical;
}
G4bool
G4GlobalFastSimulationManager::Notify(G4ApplicationState requestedState)
{
G4StateManager * stateManager = G4StateManager::GetStateManager();
if((stateManager->GetPreviousState()==G4State_Idle) &&
(requestedState==G4State_GeomClosed) && (!fClosed) )
{
G4cerr
<< "ERROR - G4GlobalFastSimulationManager::Notify()" << G4endl
<< " 1) you are using ghost volumes;" << G4endl
<< " 2) In this case the G4GlobalFastSimulationManager" << G4endl
<< " MUST be closed BEFORE closing the geometry;" << G4endl
<< " 3) To do this put in your code the call to" << G4endl
<< " GetGlobalFastSimulationManager()->CloseFastSimulation();"
<< G4endl
<< " just before closing the geometry." << G4endl;
G4Exception("G4GlobalFastSimulationManager::Notify()", "InvalidState",
FatalException, "Fast simulation must be closed.");
}
return true;
static int count(0);
if (count++ < 5)
G4cout << "G4GlobalFastSimulationManager::Notify() : DEPRECATING, will be dropped @ next major release" << G4endl;
return _deprecated->Notify(requestedState);
}
G4VFastSimulationModel*
@@ -25,7 +25,7 @@
//
//
// $Id: G4VFastSimulationModel.cc,v 1.6 2006/06/29 21:09:38 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
// GEANT4 tag $Name: geant4-08-02 $
//
//---------------------------------------------------------------
//