Import Geant4 0.0.0 source tree
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4Run.cc,v 2.0 1998/07/02 17:28:15 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
|
||||
#include "G4Run.hh"
|
||||
|
||||
G4Allocator<G4Run> aRunAllocator;
|
||||
|
||||
G4Run::G4Run()
|
||||
:runID(0),numberOfEvent(0),HCtable(NULL),DCtable(NULL)
|
||||
{;}
|
||||
|
||||
G4Run::~G4Run()
|
||||
{;}
|
||||
|
||||
@@ -0,0 +1,381 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RunManager.cc,v 2.10 1998/10/01 17:01:42 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunMessenger.hh"
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
#include "G4UserRunAction.hh"
|
||||
#include "G4VUserPrimaryGeneratorAction.hh"
|
||||
#include "G4GeometryManager.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4ApplicationState.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4VPersistencyManager.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ProcessTable.hh"
|
||||
#include "G4Timer.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
|
||||
#include "G4ios.hh"
|
||||
|
||||
G4RunManager* G4RunManager::fRunManager = NULL;
|
||||
|
||||
G4RunManager* G4RunManager::GetRunManager()
|
||||
{ return fRunManager; }
|
||||
|
||||
G4RunManager::G4RunManager()
|
||||
:userDetector(NULL),physicsList(NULL),
|
||||
userRunAction(NULL),userPrimaryGeneratorAction(NULL),
|
||||
currentRun(NULL),currentEvent(NULL),n_perviousEventsToBeStored(0),
|
||||
geometryInitialized(false),physicsInitialized(false),cutoffInitialized(false),
|
||||
geometryNeedsToBeClosed(true),initializedAtLeastOnce(false),
|
||||
runAborted(false),pauseAtBeginOfEvent(false),pauseAtEndOfEvent(false),
|
||||
geometryToBeOptimized(true),verboseLevel(0),DCtable(NULL)
|
||||
{
|
||||
if(fRunManager)
|
||||
{ G4Exception("G4RunManager constructed twice."); }
|
||||
//G4UnitDefinition::BuildUnitsTable();
|
||||
fRunManager = this;
|
||||
eventManager = new G4EventManager();
|
||||
timer = new G4Timer();
|
||||
runMessenger = new G4RunMessenger(this);
|
||||
previousEvents = new RWTPtrOrderedVector<G4Event>;
|
||||
G4ParticleTable::GetParticleTable()->CreateMessenger();
|
||||
G4ProcessTable::GetProcessTable()->CreateMessenger();
|
||||
}
|
||||
|
||||
G4RunManager::~G4RunManager()
|
||||
{
|
||||
if(verboseLevel>0) G4cout << "G4 kernel has come to Quit state." << endl;
|
||||
G4StateManager* pStateManager = G4StateManager::GetStateManager();
|
||||
pStateManager->SetNewState(Quit);
|
||||
|
||||
if(verboseLevel>1) G4cout << "Deletion of G4 kernel class start." << endl;
|
||||
delete timer;
|
||||
delete runMessenger;
|
||||
G4ParticleTable::GetParticleTable()->DeleteMessenger();
|
||||
G4ProcessTable::GetProcessTable()->DeleteMessenger();
|
||||
delete previousEvents;
|
||||
if(userDetector)
|
||||
{
|
||||
delete userDetector;
|
||||
if(verboseLevel>1) G4cout << "UserDetectorConstruction deleted." << endl;
|
||||
}
|
||||
if(physicsList)
|
||||
{
|
||||
delete physicsList;
|
||||
if(verboseLevel>1) G4cout << "UserPhysicsList deleted." << endl;
|
||||
}
|
||||
if(userRunAction)
|
||||
{
|
||||
delete userRunAction;
|
||||
if(verboseLevel>1) G4cout << "UserRunAction deleted." << endl;
|
||||
}
|
||||
if(userPrimaryGeneratorAction)
|
||||
{
|
||||
delete userPrimaryGeneratorAction;
|
||||
if(verboseLevel>1) G4cout << "UserPrimaryGenerator deleted." << endl;
|
||||
}
|
||||
G4SDManager* fSDM = G4SDManager::GetSDMpointerIfExist();
|
||||
if(fSDM)
|
||||
{
|
||||
delete fSDM;
|
||||
if(verboseLevel>1) G4cout << "G4SDManager deleted." << endl;
|
||||
}
|
||||
delete eventManager;
|
||||
if(verboseLevel>1) G4cout << "EventManager deleted." << endl;
|
||||
G4UImanager* pUImanager = G4UImanager::GetUIpointer();
|
||||
{
|
||||
if(pUImanager) delete pUImanager;
|
||||
if(verboseLevel>1) G4cout << "UImanager deleted." << endl;
|
||||
}
|
||||
if(pStateManager)
|
||||
{
|
||||
delete pStateManager;
|
||||
if(verboseLevel>1) G4cout << "StateManager deleted." << endl;
|
||||
}
|
||||
if(verboseLevel>1) G4cout << "RunManager is deleting." << endl;
|
||||
}
|
||||
|
||||
void G4RunManager::BeamOn(G4int n_event,const char* macroFile,G4int n_select)
|
||||
{
|
||||
G4bool cond = ConfirmBeamOnCondition();
|
||||
if(cond)
|
||||
{
|
||||
RunInitialization();
|
||||
DoEventLoop(n_event,macroFile,n_select);
|
||||
RunTermination();
|
||||
}
|
||||
}
|
||||
|
||||
G4bool G4RunManager::ConfirmBeamOnCondition()
|
||||
{
|
||||
G4StateManager* stateManager = G4StateManager::GetStateManager();
|
||||
|
||||
G4ApplicationState currentState = stateManager->GetCurrentState();
|
||||
if(currentState!=PreInit && currentState!=Idle)
|
||||
{
|
||||
G4cerr << "Illegal application state - BeamOn() ignored." << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!initializedAtLeastOnce)
|
||||
{
|
||||
G4cerr << " Geant4 kernel should be initialized" << endl;
|
||||
G4cerr << "before the first BeamOn(). - BeamOn ignored." << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!(geometryInitialized && physicsInitialized && cutoffInitialized))
|
||||
{
|
||||
if(verboseLevel>0)
|
||||
{
|
||||
G4cout << "Start re-initialization because " << endl;
|
||||
if(!geometryInitialized) G4cout << " Geometry" << endl;
|
||||
if(!physicsInitialized) G4cout << " Physics processes" << endl;
|
||||
if(!cutoffInitialized) G4cout << " Cutoff" << endl;
|
||||
G4cout << "has been modified since last Run." << endl;
|
||||
}
|
||||
Initialize();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void G4RunManager::RunInitialization()
|
||||
{
|
||||
currentRun = new G4Run();
|
||||
currentRun->SetDCtable(DCtable);
|
||||
G4SDManager* fSDM = G4SDManager::GetSDMpointerIfExist();
|
||||
if(fSDM)
|
||||
{ currentRun->SetHCtable(fSDM->GetHCtable()); }
|
||||
|
||||
if(userRunAction) userRunAction->BeginOfRunAction(currentRun);
|
||||
if(geometryNeedsToBeClosed)
|
||||
{
|
||||
if(verboseLevel>1) G4cout << "Start closing geometry." << endl;
|
||||
G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
|
||||
geomManager->OpenGeometry();
|
||||
geomManager->CloseGeometry(geometryToBeOptimized);
|
||||
geometryNeedsToBeClosed = false;
|
||||
}
|
||||
G4StateManager* stateManager = G4StateManager::GetStateManager();
|
||||
stateManager->SetNewState(GeomClosed);
|
||||
|
||||
previousEvents->clearAndDestroy();
|
||||
for(G4int i_prev=0;i_prev<n_perviousEventsToBeStored;i_prev++)
|
||||
{ previousEvents->insert((G4Event*)NULL); }
|
||||
|
||||
runAborted = false;
|
||||
if(verboseLevel>0) G4cout << "Start Run processing." << endl;
|
||||
}
|
||||
|
||||
void G4RunManager::DoEventLoop(G4int n_event,const char* macroFile,G4int n_select)
|
||||
{
|
||||
G4StateManager* stateManager = G4StateManager::GetStateManager();
|
||||
|
||||
if(verboseLevel>0)
|
||||
{ timer->Start(); }
|
||||
|
||||
G4String msg;
|
||||
if(macroFile!=NULL)
|
||||
{
|
||||
if(n_select<0) n_select = n_event;
|
||||
msg = "/control/execute ";
|
||||
msg += macroFile;
|
||||
}
|
||||
else
|
||||
{ n_select = -1; }
|
||||
|
||||
G4int i_event;
|
||||
for( i_event=0; i_event<n_event; i_event++ )
|
||||
{
|
||||
stateManager->SetNewState(EventProc);
|
||||
if(pauseAtBeginOfEvent) stateManager->Pause("BeginOfEvent");
|
||||
|
||||
currentEvent = GenerateEvent(i_event);
|
||||
|
||||
eventManager->ProcessOneEvent(currentEvent);
|
||||
|
||||
AnalyzeEvent(currentEvent);
|
||||
|
||||
if(i_event<n_select) G4UImanager::GetUIpointer()->ApplyCommand(msg);
|
||||
if(pauseAtEndOfEvent) stateManager->Pause("EndOfEvent");
|
||||
stateManager->SetNewState(GeomClosed);
|
||||
StackPreviousEvent(currentEvent);
|
||||
currentEvent = NULL;
|
||||
if(runAborted) break;
|
||||
}
|
||||
|
||||
if(verboseLevel>0)
|
||||
{
|
||||
timer->Stop();
|
||||
G4cout << "Run terminated." << endl;
|
||||
G4cout << "Run Summary" << endl;
|
||||
if(runAborted)
|
||||
{ G4cout << " Run Aborted after " << i_event << " events processed." << endl; }
|
||||
else
|
||||
{ G4cout << " Number of events processed : " << n_event << endl; }
|
||||
G4cout << " " << *timer << endl;
|
||||
}
|
||||
}
|
||||
|
||||
G4Event* G4RunManager::GenerateEvent(G4int i_event)
|
||||
{
|
||||
if(!userPrimaryGeneratorAction)
|
||||
{
|
||||
G4Exception
|
||||
("G4RunManager::BeamOn - G4VUserPrimaryGeneratorAction is not defined.");
|
||||
}
|
||||
G4Event* anEvent = new G4Event(i_event);
|
||||
userPrimaryGeneratorAction->GeneratePrimaries(anEvent);
|
||||
return anEvent;
|
||||
}
|
||||
|
||||
void G4RunManager::AnalyzeEvent(G4Event* anEvent)
|
||||
{
|
||||
G4VPersistencyManager* fPersM = G4VPersistencyManager::GetPersistencyManager();
|
||||
if(fPersM) fPersM->Store(currentEvent);
|
||||
currentRun->RecordEvent(currentEvent);
|
||||
}
|
||||
|
||||
void G4RunManager::RunTermination()
|
||||
{
|
||||
G4StateManager* stateManager = G4StateManager::GetStateManager();
|
||||
|
||||
previousEvents->clearAndDestroy();
|
||||
|
||||
if(userRunAction) userRunAction->EndOfRunAction(currentRun);
|
||||
|
||||
G4VPersistencyManager* fPersM = G4VPersistencyManager::GetPersistencyManager();
|
||||
if(fPersM) fPersM->Store(currentRun);
|
||||
delete currentRun;
|
||||
currentRun = NULL;
|
||||
|
||||
stateManager->SetNewState(Idle);
|
||||
}
|
||||
|
||||
void G4RunManager::StackPreviousEvent(G4Event* anEvent)
|
||||
{
|
||||
G4Event* evt;
|
||||
if(n_perviousEventsToBeStored==0)
|
||||
{ evt = anEvent; }
|
||||
else
|
||||
{
|
||||
previousEvents->prepend(anEvent);
|
||||
evt = previousEvents->removeLast();
|
||||
}
|
||||
delete evt;
|
||||
}
|
||||
|
||||
void G4RunManager::Initialize()
|
||||
{
|
||||
G4StateManager* stateManager = G4StateManager::GetStateManager();
|
||||
G4ApplicationState currentState = stateManager->GetCurrentState();
|
||||
if(currentState!=PreInit && currentState!=Idle)
|
||||
{
|
||||
G4cerr << "Illegal application state - "
|
||||
<< "G4RunManager::Initialize() ignored." << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
stateManager->SetNewState(Init);
|
||||
if(!geometryInitialized) InitializeGeometry();
|
||||
if(!physicsInitialized) InitializePhysics();
|
||||
if(!cutoffInitialized) InitializeCutOff();
|
||||
stateManager->SetNewState(Idle);
|
||||
if(!initializedAtLeastOnce) initializedAtLeastOnce = true;
|
||||
}
|
||||
|
||||
void G4RunManager::InitializeGeometry()
|
||||
{
|
||||
if(!userDetector)
|
||||
{
|
||||
G4Exception
|
||||
("G4RunManager::InitializeGeometry - G4VUserDetectorConstruction is not defined.");
|
||||
}
|
||||
|
||||
if(verboseLevel>1) G4cout << "userDetector->Construct() start." << endl;
|
||||
DefineWorldVolume(userDetector->Construct());
|
||||
geometryInitialized = true;
|
||||
}
|
||||
|
||||
void G4RunManager::InitializePhysics()
|
||||
{
|
||||
if(physicsList)
|
||||
{
|
||||
if(verboseLevel>1) G4cout << "physicsList->Construct() start." << endl;
|
||||
physicsList->Construct();
|
||||
}
|
||||
else
|
||||
{
|
||||
G4Exception("G4VUserPhysicsList is not defined");
|
||||
}
|
||||
physicsInitialized = true;
|
||||
}
|
||||
|
||||
void G4RunManager::InitializeCutOff()
|
||||
{
|
||||
if(physicsList)
|
||||
{
|
||||
if(verboseLevel>1) G4cout << "physicsList->setCut() start." << endl;
|
||||
physicsList->SetCutsWithDefault();
|
||||
}
|
||||
cutoffInitialized = true;
|
||||
}
|
||||
|
||||
void G4RunManager::AbortRun()
|
||||
{
|
||||
// This method is valid only for GeomClosed or EventProc state
|
||||
G4ApplicationState currentState =
|
||||
G4StateManager::GetStateManager()->GetCurrentState();
|
||||
if(currentState==GeomClosed || currentState==EventProc)
|
||||
{
|
||||
runAborted = true;
|
||||
if(currentState==EventProc) eventManager->AbortCurrentEvent();
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cerr << "Run is not in progress. AbortRun() ignored." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void G4RunManager::DefineWorldVolume(G4VPhysicalVolume* worldVol)
|
||||
{
|
||||
// set the world volume to the Navigator
|
||||
G4TransportationManager::GetTransportationManager()
|
||||
->GetNavigatorForTracking()
|
||||
->SetWorldVolume(worldVol);
|
||||
|
||||
// Let VisManager know it
|
||||
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
|
||||
if(pVVisManager) pVVisManager->GeometryHasChanged();
|
||||
|
||||
geometryNeedsToBeClosed = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4RunMessenger.cc,v 2.6 1998/10/01 17:01:43 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
|
||||
#include "G4RunMessenger.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UIcmdWithABool.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIparameter.hh"
|
||||
#include "G4ios.hh"
|
||||
#ifdef WIN32
|
||||
# include <Strstrea.h>
|
||||
#else
|
||||
# include <strstream.h>
|
||||
#endif
|
||||
|
||||
G4RunMessenger::G4RunMessenger(G4RunManager * runMgr)
|
||||
:runManager(runMgr)
|
||||
{
|
||||
runDirectory = new G4UIdirectory("/run/");
|
||||
runDirectory->SetGuidance("Run control commands.");
|
||||
|
||||
initCmd = new G4UIcmdWithoutParameter("/run/initialize",this);
|
||||
initCmd->SetGuidance("Initialize G4 kernel.");
|
||||
initCmd->AvailableForStates(PreInit,Idle),
|
||||
|
||||
beamOnCmd = new G4UIcommand("/run/beamOn",this);
|
||||
beamOnCmd->SetGuidance("Start a Run.");
|
||||
beamOnCmd->SetGuidance("If G4 kernel is not initialized, it will be initialized.");
|
||||
beamOnCmd->SetGuidance("Default number of events to be processed is 1.");
|
||||
beamOnCmd->SetGuidance("The second and third arguments can be used for");
|
||||
beamOnCmd->SetGuidance("executing a macro file at the end of each event.");
|
||||
beamOnCmd->SetGuidance("If the second argument, i.e. name of the macro");
|
||||
beamOnCmd->SetGuidance("file, is given but the third argument is not,");
|
||||
beamOnCmd->SetGuidance("the macro file will be executed for all of the");
|
||||
beamOnCmd->SetGuidance("event.");
|
||||
beamOnCmd->SetGuidance("If the third argument (nSelect) is given, the");
|
||||
beamOnCmd->SetGuidance("macro file will be executed only for the first");
|
||||
beamOnCmd->SetGuidance("nSelect events.");
|
||||
beamOnCmd->AvailableForStates(PreInit,Idle);
|
||||
G4UIparameter* p1 = new G4UIparameter("numberOfEvent",'i',true);
|
||||
p1->SetDefaultValue(1);
|
||||
p1->SetParameterRange("numberOfEvent > 0");
|
||||
beamOnCmd->SetParameter(p1);
|
||||
G4UIparameter* p2 = new G4UIparameter("macroFile",'s',true);
|
||||
p2->SetDefaultValue("***NULL***");
|
||||
beamOnCmd->SetParameter(p2);
|
||||
G4UIparameter* p3 = new G4UIparameter("nSelect",'i',true);
|
||||
p3->SetDefaultValue(-1);
|
||||
p3->SetParameterRange("nSelect>=-1");
|
||||
beamOnCmd->SetParameter(p3);
|
||||
|
||||
verboseCmd = new G4UIcmdWithAnInteger("/run/verbose",this);
|
||||
verboseCmd->SetGuidance("Set the Verbose level of G4RunManager.");
|
||||
verboseCmd->SetGuidance(" 0 : Silent (default)");
|
||||
verboseCmd->SetGuidance(" 1 : Display main topics");
|
||||
verboseCmd->SetGuidance(" 2 : Display main topics and run summary");
|
||||
verboseCmd->SetParameterName("level",true);
|
||||
verboseCmd->SetDefaultValue(0);
|
||||
verboseCmd->SetRange("level >=0 && level <=2");
|
||||
|
||||
optCmd = new G4UIcmdWithABool("/run/optimizeGeometry",this);
|
||||
optCmd->SetGuidance("Set the optimization flag for geometry.");
|
||||
optCmd->SetGuidance("If it is set to TRUE, G4GeometryManager will optimize");
|
||||
optCmd->SetGuidance("the geometry definitions.");
|
||||
optCmd->SetGuidance("GEANT4 is initialized with this flag as TRUE.");
|
||||
optCmd->SetParameterName("optimizeFlag",true);
|
||||
optCmd->SetDefaultValue(true);
|
||||
optCmd->AvailableForStates(PreInit,Idle);
|
||||
|
||||
brkBoECmd = new G4UIcmdWithABool("/run/breakAtBeginOfEvent",this);
|
||||
brkBoECmd->SetGuidance("Set a break point at the begining of every event.");
|
||||
brkBoECmd->SetParameterName("flag",true);
|
||||
brkBoECmd->SetDefaultValue(true);
|
||||
|
||||
brkEoECmd = new G4UIcmdWithABool("/run/breakAtEndOfEvent",this);
|
||||
brkEoECmd->SetGuidance("Set a break point at the end of every event.");
|
||||
brkEoECmd->SetParameterName("flag",true);
|
||||
brkEoECmd->SetDefaultValue(true);
|
||||
|
||||
abortCmd = new G4UIcmdWithoutParameter("/run/abort",this);
|
||||
abortCmd->SetGuidance("Abort current run processing.");
|
||||
abortCmd->AvailableForStates(GeomClosed,EventProc);
|
||||
|
||||
geomCmd = new G4UIcmdWithoutParameter("/run/geometryModified",this);
|
||||
geomCmd->SetGuidance("Force geometry to be closed again.");
|
||||
geomCmd->SetGuidance("This command must be applied");
|
||||
geomCmd->SetGuidance(" if geometry has been modified after the");
|
||||
geomCmd->SetGuidance(" first initialization (or BeamOn).");
|
||||
geomCmd->AvailableForStates(PreInit,Idle),
|
||||
|
||||
cutCmd = new G4UIcmdWithoutParameter("/run/cutoffModified",this);
|
||||
cutCmd->SetGuidance("Force closssection tables to be calculated again.");
|
||||
cutCmd->SetGuidance("This command must be applied");
|
||||
cutCmd->SetGuidance(" if cutoff value(s) have been modified after the");
|
||||
cutCmd->SetGuidance(" first initialization (or BeamOn).");
|
||||
cutCmd->AvailableForStates(PreInit,Idle);
|
||||
}
|
||||
|
||||
G4RunMessenger::~G4RunMessenger()
|
||||
{
|
||||
delete beamOnCmd;
|
||||
delete verboseCmd;
|
||||
delete optCmd;
|
||||
delete brkBoECmd;
|
||||
delete brkEoECmd;
|
||||
delete abortCmd;
|
||||
delete initCmd;
|
||||
delete geomCmd;
|
||||
delete cutCmd;
|
||||
delete runDirectory;
|
||||
}
|
||||
|
||||
void G4RunMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
|
||||
{
|
||||
if( command==beamOnCmd )
|
||||
{
|
||||
G4int nev;
|
||||
G4int ns;
|
||||
const char* nv = (const char*)newValue;
|
||||
istrstream is((char*)nv);
|
||||
is >> nev >> macroFileName >> ns;
|
||||
if(macroFileName=="***NULL***")
|
||||
{ runManager->BeamOn(nev); }
|
||||
else
|
||||
{ runManager->BeamOn(nev,macroFileName,ns); }
|
||||
}
|
||||
else if( command==verboseCmd )
|
||||
{ runManager->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue)); }
|
||||
else if( command==optCmd )
|
||||
{ runManager->SetGeometryToBeOptimized(optCmd->GetNewBoolValue(newValue)); }
|
||||
else if( command==brkBoECmd )
|
||||
{ runManager->SetPauseAtBeginOfEvent(brkBoECmd->GetNewBoolValue(newValue)); }
|
||||
else if( command==brkEoECmd )
|
||||
{ runManager->SetPauseAtEndOfEvent(brkEoECmd->GetNewBoolValue(newValue)); }
|
||||
else if( command==abortCmd )
|
||||
{ runManager->AbortRun(); }
|
||||
else if( command==initCmd )
|
||||
{ runManager->Initialize(); }
|
||||
else if( command==geomCmd )
|
||||
{ runManager->GeometryHasBeenModified(); }
|
||||
else if( command==cutCmd )
|
||||
{ runManager->CutOffHasBeenModified(); }
|
||||
}
|
||||
|
||||
G4String G4RunMessenger::GetCurrentValue(G4UIcommand * command)
|
||||
{
|
||||
G4String cv;
|
||||
|
||||
if( command==verboseCmd )
|
||||
{ cv = verboseCmd->ConvertToString(runManager->GetVerboseLevel()); }
|
||||
|
||||
return cv;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4UserPhysicsListMessenger.cc,v 2.5 1998/07/17 06:12:52 kurasige Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4UserPhysicsListMessenger.cc
|
||||
// ------------------------------------------------------------
|
||||
// History
|
||||
// first version 09 Jan. 1998 by H.Kurashige
|
||||
// ------------------------------------------------------------
|
||||
|
||||
#include "G4UserPhysicsListMessenger.hh"
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
G4UserPhysicsListMessenger::G4UserPhysicsListMessenger(G4VUserPhysicsList* pParticleList):theParticleList(pParticleList)
|
||||
{
|
||||
// /run/particle directory
|
||||
theDirectory = new G4UIdirectory("/run/particle/");
|
||||
theDirectory->SetGuidance("Commands for G4VUserPhysicsList.");
|
||||
|
||||
// /run/particle/Verbose command
|
||||
verboseCmd = new G4UIcmdWithAnInteger("/run/particle/verbose",this);
|
||||
verboseCmd->SetGuidance("Set the Verbose level of G4VUserPhysicsList.");
|
||||
verboseCmd->SetGuidance(" 0 : Silent (default)");
|
||||
verboseCmd->SetGuidance(" 1 : Display warning messages");
|
||||
verboseCmd->SetGuidance(" 2 : Display more");
|
||||
verboseCmd->SetParameterName("level",true);
|
||||
verboseCmd->SetDefaultValue(0);
|
||||
verboseCmd->SetRange("level >=0 && level <=2");
|
||||
|
||||
// /run/particle/setCut command
|
||||
setCutCmd = new G4UIcmdWithADoubleAndUnit("/run/particle/setCut",this);
|
||||
setCutCmd->SetGuidance("Set default cut value ");
|
||||
setCutCmd->SetParameterName("cut",false);
|
||||
setCutCmd->SetDefaultValue(1.0);
|
||||
setCutCmd->SetRange("cut >0.0");
|
||||
setCutCmd->SetUnitCandidates("m cm mm microm");
|
||||
setCutCmd->SetDefaultUnit("mm");
|
||||
setCutCmd->AvailableForStates(PreInit,Idle);
|
||||
|
||||
// /run/particle/DumpList command
|
||||
dumpListCmd = new G4UIcmdWithoutParameter("/run/particle/dumpList",this);
|
||||
dumpListCmd->SetGuidance("Dump List of particles in G4VUserPhysicsList. ");
|
||||
|
||||
|
||||
// /run/particle/DumpCutValues command
|
||||
dumpCutValuesCmd = new G4UIcmdWithAString("/run/particle/dumpCutValues",this);
|
||||
dumpCutValuesCmd->SetGuidance("Dump cut value information ");
|
||||
dumpCutValuesCmd->SetGuidance("Enter particle name ");
|
||||
dumpCutValuesCmd->SetGuidance(" enter all for all particles");
|
||||
dumpCutValuesCmd->SetParameterName("particle", true);
|
||||
dumpCutValuesCmd->SetDefaultValue("table");
|
||||
dumpCutValuesCmd->AvailableForStates(Idle,GeomClosed,EventProc);
|
||||
|
||||
// /run/particle/addProcManager command
|
||||
addProcManCmd = new G4UIcmdWithAString("/run/particle/addProcManager", this);
|
||||
addProcManCmd->SetGuidance("add process manager");
|
||||
addProcManCmd->SetParameterName("particleType", true);
|
||||
addProcManCmd->SetDefaultValue("");
|
||||
addProcManCmd->AvailableForStates(Init,Idle,GeomClosed,EventProc);
|
||||
}
|
||||
|
||||
G4UserPhysicsListMessenger::~G4UserPhysicsListMessenger()
|
||||
{
|
||||
delete setCutCmd;
|
||||
delete verboseCmd;
|
||||
delete dumpListCmd;
|
||||
delete dumpCutValuesCmd;
|
||||
delete addProcManCmd;
|
||||
delete theDirectory;
|
||||
}
|
||||
|
||||
void G4UserPhysicsListMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
|
||||
{
|
||||
if( command==setCutCmd ){
|
||||
G4double newCut = setCutCmd->GetNewDoubleValue(newValue);
|
||||
theParticleList->SetDefaultCutValue(newCut);
|
||||
} else if( command==verboseCmd ) {
|
||||
theParticleList->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue));
|
||||
|
||||
} else if( command==dumpListCmd ){
|
||||
theParticleList->DumpList();
|
||||
} else if( command==dumpCutValuesCmd ){
|
||||
if (newValue == "table") {
|
||||
theParticleList->DumpCutValuesTable();
|
||||
} else {
|
||||
theParticleList->DumpCutValues(newValue);
|
||||
}
|
||||
} else if( command == addProcManCmd ){
|
||||
G4ParticleDefinition* particle = (G4ParticleTable::GetParticleTable())->FindParticle(newValue);
|
||||
if (particle == NULL) return;
|
||||
if (particle->GetProcessManager() != NULL) return;
|
||||
theParticleList->AddProcessManager(particle);
|
||||
}
|
||||
}
|
||||
|
||||
G4String G4UserPhysicsListMessenger::GetCurrentValue(G4UIcommand * command)
|
||||
{
|
||||
G4String cv;
|
||||
|
||||
if( command==setCutCmd ){
|
||||
cv = setCutCmd->ConvertToString( theParticleList->GetDefaultCutValue(), "mm" );
|
||||
|
||||
} else if( command==verboseCmd ){
|
||||
cv = verboseCmd->ConvertToString(theParticleList->GetVerboseLevel());
|
||||
|
||||
} else if( command== addProcManCmd ){
|
||||
// set candidate list
|
||||
G4String candidates("none");
|
||||
G4ParticleTable::G4PTblDicIterator *piter = (G4ParticleTable::GetParticleTable())->GetIterator();
|
||||
piter -> reset();
|
||||
while( (*piter)() ){
|
||||
G4ParticleDefinition *particle = piter->value();
|
||||
candidates += " " + particle->GetParticleName();
|
||||
}
|
||||
addProcManCmd->SetCandidates(candidates);
|
||||
cv = "";
|
||||
}
|
||||
|
||||
return cv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4UserRunAction.cc,v 2.1 1998/07/12 03:08:39 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
|
||||
#include "G4UserRunAction.hh"
|
||||
|
||||
G4UserRunAction::G4UserRunAction()
|
||||
{;}
|
||||
|
||||
G4UserRunAction::~G4UserRunAction()
|
||||
{;}
|
||||
|
||||
void G4UserRunAction::BeginOfRunAction(G4Run* aRun)
|
||||
{;}
|
||||
|
||||
void G4UserRunAction::EndOfRunAction(G4Run* aRun)
|
||||
{;}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4VPersistencyManager.cc,v 2.1 1998/07/12 03:08:40 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
|
||||
#include "G4VPersistencyManager.hh"
|
||||
|
||||
G4VPersistencyManager* G4VPersistencyManager::fPersistencyManager = 0;
|
||||
|
||||
G4VPersistencyManager* G4VPersistencyManager::GetPersistencyManager()
|
||||
{
|
||||
return fPersistencyManager;
|
||||
}
|
||||
|
||||
G4VPersistencyManager::G4VPersistencyManager()
|
||||
{
|
||||
fPersistencyManager = this;
|
||||
}
|
||||
|
||||
G4VPersistencyManager::~G4VPersistencyManager()
|
||||
{
|
||||
fPersistencyManager = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4VUserDetectorConstruction.cc,v 2.0 1998/07/02 17:28:07 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
|
||||
G4VUserDetectorConstruction::G4VUserDetectorConstruction()
|
||||
{;}
|
||||
|
||||
G4VUserDetectorConstruction::~G4VUserDetectorConstruction()
|
||||
{;}
|
||||
|
||||
@@ -0,0 +1,603 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4VUserPhysicsList.cc,v 2.16 1998/12/07 01:16:55 kurasige Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// History
|
||||
// first version 09 Jan. 1998 by H.Kurashige
|
||||
// modified 24 Jan. 1998 by H.Kurashige
|
||||
// modified 06 June 1998 by H.Kurashige
|
||||
// add G4ParticleWithCuts::SetEnergyRange
|
||||
// 18 June 1998 by H.Kurashige
|
||||
// modifeid for short lived particles 27 June 1998 by H.Kurashige
|
||||
// G4BestUnit on output 12 nov. 1998 mma
|
||||
// ------------------------------------------------------------
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
#include "G4ParticleWithCuts.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleWithCuts.hh"
|
||||
#include "G4BosonConstructor.hh"
|
||||
#include "G4LeptonConstructor.hh"
|
||||
#include "G4MesonConstructor.hh"
|
||||
#include "G4BarionConstructor.hh"
|
||||
#include "G4IonConstructor.hh"
|
||||
#include "G4ShortLivedConstructor.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4UserPhysicsListMessenger.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include <iomanip.h>
|
||||
|
||||
|
||||
G4VUserPhysicsList::G4VUserPhysicsList()
|
||||
:verboseLevel(1)
|
||||
{
|
||||
// default cut value (1.0mm)
|
||||
defaultCutValue = 1.0*mm;
|
||||
|
||||
// set energy range for SetCut calcuration
|
||||
G4ParticleWithCuts::SetEnergyRange(0.99*keV, 100*TeV);
|
||||
|
||||
// pointer to the particle table
|
||||
theParticleTable = G4ParticleTable::GetParticleTable();
|
||||
theParticleIterator = theParticleTable->GetIterator();
|
||||
|
||||
// UI Messenger
|
||||
theMessenger = new G4UserPhysicsListMessenger(this);
|
||||
}
|
||||
|
||||
G4VUserPhysicsList::~G4VUserPhysicsList()
|
||||
{
|
||||
if (theMessenger != NULL) {
|
||||
delete theMessenger;
|
||||
theMessenger = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void G4VUserPhysicsList::AddProcessManager(G4ParticleDefinition* newParticle,
|
||||
G4ProcessManager* newManager)
|
||||
{
|
||||
if (newParticle == NULL) return;
|
||||
if (newManager == NULL){
|
||||
newManager = new G4ProcessManager(newParticle);
|
||||
if (newParticle->GetParticleType() == "nucleus") {
|
||||
G4ParticleDefinition* genericIon =
|
||||
(G4ParticleTable::GetParticleTable())->FindParticle("GenericIon");
|
||||
if (genericIon != NULL) {
|
||||
G4ProcessManager* ionMan = genericIon->GetProcessManager();
|
||||
if (ionMan != NULL) {
|
||||
delete newManager;
|
||||
newManager = new G4ProcessManager(*ionMan);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (verboseLevel >2){
|
||||
G4cerr << "G4VUserPhysicsList::AddProcessManager: ";
|
||||
G4cerr << "adds ProcessManager to ";
|
||||
G4cerr << newParticle->GetParticleName() << endl;
|
||||
newManager->DumpInfo();
|
||||
}
|
||||
newManager->SetParticleType(newParticle);
|
||||
if (newParticle->GetProcessManager() == NULL) {
|
||||
newParticle->SetProcessManager(newManager);
|
||||
} else {
|
||||
if (verboseLevel >0){
|
||||
G4cerr << "G4VUserPhysicsList::AddProcessManager: ";
|
||||
G4cerr << newParticle->GetParticleName();
|
||||
G4cerr << " already has ProcessManager " << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void G4VUserPhysicsList::InitializeProcessManager()
|
||||
{
|
||||
// loop over all particles in G4ParticleTable
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
G4ProcessManager* pmanager = particle->GetProcessManager();
|
||||
if (pmanager==NULL) {
|
||||
pmanager = new G4ProcessManager(particle);
|
||||
particle->SetProcessManager(pmanager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "G4Transportation.hh"
|
||||
void G4VUserPhysicsList::AddTransportation()
|
||||
{
|
||||
G4Transportation* theTransportationProcess= new G4Transportation();
|
||||
|
||||
// loop over all particles in G4ParticleTable
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
G4ProcessManager* pmanager = particle->GetProcessManager();
|
||||
if (!particle->IsShortLived()) {
|
||||
pmanager ->AddProcess(theTransportationProcess);
|
||||
pmanager ->SetProcessOrderingToFirst(theTransportationProcess, idxAlongStep);
|
||||
pmanager ->SetProcessOrderingToFirst(theTransportationProcess, idxPostStep);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void G4VUserPhysicsList::SetDefaultCutValue(G4double value)
|
||||
{
|
||||
if (value<=0.0) {
|
||||
if (verboseLevel >0){
|
||||
G4cerr << "G4VUserPhysicsList::SetDefaultCutValue: negative cut values";
|
||||
G4cerr << " :" << value/mm << "[mm]" << endl;
|
||||
}
|
||||
} else {
|
||||
if (verboseLevel >1){
|
||||
G4cout << "G4VUserPhysicsList::SetDefaultCutValue:";
|
||||
G4cout << "default cut value is changed to :" ;
|
||||
G4cout << value/mm << "[mm]" << endl;
|
||||
}
|
||||
defaultCutValue = value;
|
||||
ResetCuts();
|
||||
}
|
||||
}
|
||||
|
||||
void G4VUserPhysicsList::ResetCuts()
|
||||
{
|
||||
if (verboseLevel >1) {
|
||||
G4cout << "G4VUserPhysicsList::ResetCuts()" << endl;
|
||||
G4cout << " cut values in energy will be calculated later" << endl;
|
||||
}
|
||||
|
||||
// Reset cut values for other particles
|
||||
// loop over all particles in G4ParticleTable
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
if (!particle->IsShortLived()) particle->ResetCuts();
|
||||
}
|
||||
|
||||
// inform that cut values are modified to the run manager
|
||||
// i.e state will be changed and SetCuts will be invoked
|
||||
// just before event loop
|
||||
G4UImanager::GetUIpointer()->ApplyCommand("/run/cutoffModified");
|
||||
}
|
||||
|
||||
void G4VUserPhysicsList::SetCutValueForOtherThan(G4double cutValue,
|
||||
G4ParticleDefinition* first,
|
||||
G4ParticleDefinition* second,
|
||||
G4ParticleDefinition* third,
|
||||
G4ParticleDefinition* fourth,
|
||||
G4ParticleDefinition* fifth,
|
||||
G4ParticleDefinition* sixth,
|
||||
G4ParticleDefinition* seventh,
|
||||
G4ParticleDefinition* eighth,
|
||||
G4ParticleDefinition* nineth,
|
||||
G4ParticleDefinition* tenth )
|
||||
{
|
||||
// check cut value is positive
|
||||
if (cutValue <= 0.0) {
|
||||
if (verboseLevel >0){
|
||||
G4cerr << "G4VUserPhysicsList::SetCutValueForOtherThan: negative cut values";
|
||||
G4cerr << " :" << cutValue/mm << "[mm]" << endl;
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
if (verboseLevel >1) {
|
||||
G4cout << "G4VUserPhysicsList::SetCutValueForOtherThan ";
|
||||
G4cout << " :" << cutValue/mm << "[mm]" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// check specified particle types in arguments
|
||||
G4ParticleDefinition* specifiedParticles[10];
|
||||
G4int numberOfSpecifiedParticles = 0;
|
||||
if (first != 0) {
|
||||
specifiedParticles[numberOfSpecifiedParticles] = first;
|
||||
numberOfSpecifiedParticles +=1;
|
||||
}
|
||||
if (second != 0) {
|
||||
specifiedParticles[numberOfSpecifiedParticles] = second;
|
||||
numberOfSpecifiedParticles +=1;
|
||||
}
|
||||
if (third != 0) {
|
||||
specifiedParticles[numberOfSpecifiedParticles] = third;
|
||||
numberOfSpecifiedParticles +=1;
|
||||
}
|
||||
if (fourth != 0) {
|
||||
specifiedParticles[numberOfSpecifiedParticles] = fourth;
|
||||
numberOfSpecifiedParticles +=1;
|
||||
}
|
||||
if (fifth != 0) {
|
||||
specifiedParticles[numberOfSpecifiedParticles] = fifth;
|
||||
numberOfSpecifiedParticles +=1;
|
||||
}
|
||||
if (sixth != 0) {
|
||||
specifiedParticles[numberOfSpecifiedParticles] = sixth;
|
||||
numberOfSpecifiedParticles +=1;
|
||||
}
|
||||
if (seventh != 0) {
|
||||
specifiedParticles[numberOfSpecifiedParticles] = seventh;
|
||||
numberOfSpecifiedParticles +=1;
|
||||
}
|
||||
if (eighth != 0) {
|
||||
specifiedParticles[numberOfSpecifiedParticles] = eighth;
|
||||
numberOfSpecifiedParticles +=1;
|
||||
}
|
||||
if (nineth != 0) {
|
||||
specifiedParticles[numberOfSpecifiedParticles] = nineth;
|
||||
numberOfSpecifiedParticles +=1;
|
||||
}
|
||||
if (tenth != 0) {
|
||||
specifiedParticles[numberOfSpecifiedParticles] = tenth;
|
||||
numberOfSpecifiedParticles +=1;
|
||||
}
|
||||
|
||||
// Set cut values for other particles
|
||||
G4bool isSpecified;
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
isSpecified = false;
|
||||
for (G4int index = 0; index <numberOfSpecifiedParticles; index++) {
|
||||
isSpecified = isSpecified || (particle == specifiedParticles[index]);
|
||||
}
|
||||
if (!isSpecified) {
|
||||
if (!particle->IsShortLived()) {
|
||||
particle->SetCuts(cutValue);
|
||||
if (verboseLevel >1)
|
||||
G4cout << "Set cuts for " << particle->GetParticleName() << endl;
|
||||
BuildPhysicsTable(particle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void G4VUserPhysicsList::SetCutValue(G4double aCut, const G4String& name)
|
||||
{
|
||||
G4ParticleDefinition* particle;
|
||||
if (particle = theParticleTable->FindParticle(name)){
|
||||
if (!particle->IsShortLived()) {
|
||||
particle->SetCuts( aCut );
|
||||
if (verboseLevel >1) G4cout << "Set cuts for " << name << endl;
|
||||
BuildPhysicsTable(particle);
|
||||
}
|
||||
} else {
|
||||
if (verboseLevel >0)
|
||||
G4cout << name << " is not found in ParticleTable" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void G4VUserPhysicsList::SetCutValueForOthers(G4double cutValue)
|
||||
{
|
||||
// check cut value is positive
|
||||
if (cutValue <= 0.0) {
|
||||
if (verboseLevel >0){
|
||||
G4cerr << "G4VUserPhysicsList::SetCutValueForOthers: negative cut values";
|
||||
G4cerr << " :" << cutValue/mm << "[mm]" << endl;
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
if (verboseLevel >1) {
|
||||
G4cout << "G4VUserPhysicsList::SetCutValueForOthers ";
|
||||
G4cout << " :" << cutValue/mm << "[mm]" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// Sets a cut value to particle types which have not be called SetCuts()
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
if (!particle->IsShortLived()) {
|
||||
if ((particle->GetLengthCuts()<0.0) ||(particle->GetEnergyCuts()==NULL)) {
|
||||
particle->SetCuts(cutValue);
|
||||
if (verboseLevel >1)
|
||||
G4cout << "Set cuts for " << particle->GetParticleName() << endl;
|
||||
BuildPhysicsTable(particle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void G4VUserPhysicsList::ReCalcCutValue(const G4String& name)
|
||||
{
|
||||
G4ParticleDefinition* particle;
|
||||
if (particle = theParticleTable->FindParticle(name)){
|
||||
if (!particle->IsShortLived()) {
|
||||
particle->ReCalcCuts();
|
||||
if (verboseLevel >1) G4cout << "Recalc cuts for " << name << endl;
|
||||
BuildPhysicsTable(particle);
|
||||
}
|
||||
} else {
|
||||
if (verboseLevel >0)
|
||||
G4cout << name << " is not found in ParticleTable" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void G4VUserPhysicsList::ReCalcCutValueForOthers()
|
||||
{
|
||||
if (verboseLevel >1) {
|
||||
G4cout << "G4VUserPhysicsList::ReCalcCutValueForOthers ";
|
||||
}
|
||||
|
||||
// Sets a cut value to particle types which have not be called SetCuts()
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
if (!particle->IsShortLived()) {
|
||||
if (particle->GetEnergyCuts()==NULL) {
|
||||
if (verboseLevel >1)
|
||||
G4cout << "ReCalc cuts for " << particle->GetParticleName() << endl;
|
||||
particle->ReCalcCuts();
|
||||
BuildPhysicsTable(particle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void G4VUserPhysicsList::BuildPhysicsTable(G4ParticleDefinition* particle)
|
||||
{
|
||||
G4int j;
|
||||
|
||||
// Rebuild the physics tables for every process for this particle type
|
||||
G4ProcessVector* pVector = (particle->GetProcessManager())->GetProcessList();
|
||||
for ( j=0; j < pVector->length(); ++j) {
|
||||
(*pVector)[j]->BuildPhysicsTable(*particle);
|
||||
}
|
||||
for ( j=0; j < pVector->length(); ++j) {
|
||||
|
||||
//*********************************************************************
|
||||
// temporary addition to make the integral schema of electromagnetic
|
||||
// processes work.
|
||||
//
|
||||
if((*pVector)[j]->GetProcessName() == "Imsc")
|
||||
{
|
||||
(*pVector)[j]->BuildPhysicsTable(*particle);
|
||||
}
|
||||
if((*pVector)[j]->GetProcessName() == "IeIoni")
|
||||
{
|
||||
(*pVector)[j]->BuildPhysicsTable(*particle);
|
||||
}
|
||||
if((*pVector)[j]->GetProcessName() == "IeBrems")
|
||||
{
|
||||
(*pVector)[j]->BuildPhysicsTable(*particle);
|
||||
}
|
||||
if((*pVector)[j]->GetProcessName() == "Iannihil")
|
||||
{
|
||||
(*pVector)[j]->BuildPhysicsTable(*particle);
|
||||
}
|
||||
if((*pVector)[j]->GetProcessName() == "IhIoni")
|
||||
{
|
||||
(*pVector)[j]->BuildPhysicsTable(*particle);
|
||||
}
|
||||
if((*pVector)[j]->GetProcessName() == "IMuIoni")
|
||||
{
|
||||
(*pVector)[j]->BuildPhysicsTable(*particle);
|
||||
}
|
||||
if((*pVector)[j]->GetProcessName() == "IMuBrems")
|
||||
{
|
||||
(*pVector)[j]->BuildPhysicsTable(*particle);
|
||||
}
|
||||
if((*pVector)[j]->GetProcessName() == "IMuPairProd")
|
||||
{
|
||||
(*pVector)[j]->BuildPhysicsTable(*particle);
|
||||
}
|
||||
//*********************************************************************
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void G4VUserPhysicsList::ConstructAllParticles()
|
||||
{
|
||||
ConstructAllBosons();
|
||||
ConstructAllLeptons();
|
||||
ConstructAllMesons();
|
||||
ConstructAllBarions();
|
||||
ConstructAllIons();
|
||||
ConstructAllShortLiveds();
|
||||
}
|
||||
|
||||
void G4VUserPhysicsList::ConstructAllBosons()
|
||||
{
|
||||
// Construct all bosons
|
||||
G4BosonConstructor pConstructor;
|
||||
pConstructor.ConstructParticle();
|
||||
}
|
||||
|
||||
void G4VUserPhysicsList::ConstructAllLeptons()
|
||||
{
|
||||
// Construct all leptons
|
||||
G4LeptonConstructor pConstructor;
|
||||
pConstructor.ConstructParticle();
|
||||
}
|
||||
|
||||
void G4VUserPhysicsList::ConstructAllMesons()
|
||||
{
|
||||
// Construct all mesons
|
||||
G4MesonConstructor pConstructor;
|
||||
pConstructor.ConstructParticle();
|
||||
}
|
||||
|
||||
void G4VUserPhysicsList::ConstructAllBarions()
|
||||
{
|
||||
// Construct all barions
|
||||
G4BarionConstructor pConstructor;
|
||||
pConstructor.ConstructParticle();
|
||||
}
|
||||
|
||||
void G4VUserPhysicsList::ConstructAllIons()
|
||||
{
|
||||
// Construct light ions
|
||||
G4IonConstructor pConstructor;
|
||||
pConstructor.ConstructParticle();
|
||||
}
|
||||
|
||||
void G4VUserPhysicsList::ConstructAllShortLiveds()
|
||||
{
|
||||
// Construct resonaces and quarks
|
||||
G4ShortLivedConstructor pConstructor;
|
||||
pConstructor.ConstructParticle();
|
||||
}
|
||||
|
||||
|
||||
void G4VUserPhysicsList::DumpList() const
|
||||
{
|
||||
theParticleIterator->reset();
|
||||
G4int idx = 0;
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
G4cout << particle->GetParticleName();
|
||||
if ((idx++ % 4) == 3) {
|
||||
G4cout << endl;
|
||||
} else {
|
||||
G4cout << ", ";
|
||||
}
|
||||
}
|
||||
G4cout << endl;
|
||||
}
|
||||
|
||||
void G4VUserPhysicsList::DumpCutValues(const G4String &particle_name) const
|
||||
{
|
||||
G4ParticleDefinition* particle;
|
||||
if ((particle_name == "ALL") || (particle_name == "all")) {
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
particle = theParticleIterator->value();
|
||||
DumpCutValues(particle);
|
||||
}
|
||||
} else {
|
||||
particle = theParticleTable->FindParticle(particle_name);
|
||||
if (particle != NULL) DumpCutValues(particle);
|
||||
}
|
||||
}
|
||||
|
||||
void G4VUserPhysicsList::DumpCutValues( G4ParticleDefinition* particle) const
|
||||
{
|
||||
if (particle == NULL) return;
|
||||
|
||||
G4int prec = G4cout.precision(3);
|
||||
|
||||
if (particle->IsShortLived()) {
|
||||
G4cout << " --- " << particle->GetParticleName() << " is a short lived particle ------ " << endl;
|
||||
} else {
|
||||
G4cout << " --- " << particle->GetParticleName() << " ------ " << endl;
|
||||
G4cout << " - Cut in range = " << G4BestUnit(particle->GetLengthCuts(),"Length") << endl;
|
||||
G4double* theKineticEnergyCuts = particle->GetEnergyCuts();
|
||||
|
||||
if (theKineticEnergyCuts != NULL) {
|
||||
const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
|
||||
G4cout << " - Material ---------------- Energy Cut ---" << endl;
|
||||
for (G4int idx=0; idx<materialTable->length(); idx++){
|
||||
G4cout << " " << setw(19) << (*materialTable)[idx]->GetName();
|
||||
G4cout << " : " << setw(10) << G4BestUnit(theKineticEnergyCuts[idx],"Energy");
|
||||
G4cout << endl;
|
||||
}
|
||||
} else {
|
||||
G4cout << " - Cuts in energy are not calculated yet --" << endl;
|
||||
G4cout << " Enter /run/initialize command to calculate cuts " << endl;
|
||||
}
|
||||
}
|
||||
G4cout.precision(prec);
|
||||
}
|
||||
|
||||
void G4VUserPhysicsList::DumpCutValuesTable() const
|
||||
{
|
||||
// This methods Print out a table of cut value information
|
||||
// for "e-", "gamma", "mu-", "proton" and "neutron"
|
||||
G4int prec = G4cout.precision(3);
|
||||
const G4int size = 5;
|
||||
G4String name[size] = {"gamma", "e-", "mu-", "proton", "neutron"};
|
||||
G4ParticleDefinition* particle[size];
|
||||
G4bool IsOK = true;
|
||||
G4int idx;
|
||||
for (idx=0; idx <size; idx++) {
|
||||
particle[idx] = theParticleTable->FindParticle(name[idx]);
|
||||
}
|
||||
|
||||
//line 1 //-- Commented out (M.Asai)
|
||||
//G4cout << "Default cut value in range :";
|
||||
//G4cout << defaultCutValue/mm << "[mm]" << endl;
|
||||
|
||||
//line 2
|
||||
G4cout << "============= The cut Energy ==============================" <<endl;
|
||||
|
||||
// line 3
|
||||
G4cout << " ";
|
||||
for (idx=0; idx <size; idx++) {
|
||||
G4cout << " " << setw(11) << name[idx] << " ";
|
||||
}
|
||||
G4cout << endl;
|
||||
|
||||
// line 4
|
||||
G4cout << "Cut in range ";
|
||||
for (idx=0; idx <size; idx++) {
|
||||
if (particle[idx] == NULL) {
|
||||
G4cout << " ";
|
||||
} else {
|
||||
G4cout << " " << setw(11) << G4BestUnit(particle[idx]->GetLengthCuts(),"Length");
|
||||
}
|
||||
}
|
||||
G4cout << endl;
|
||||
|
||||
// line 5
|
||||
G4cout << "Cut in energy";
|
||||
G4cout << endl;
|
||||
|
||||
// line 6 ..
|
||||
const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
|
||||
for (G4int J=0; J<materialTable->length(); J++) {
|
||||
G4cout << " " << setw(18) << ((*materialTable)[J])->GetName();
|
||||
for (idx=0; idx <size; idx++) {
|
||||
if (particle[idx] == NULL) {
|
||||
G4cout << " ";
|
||||
} else {
|
||||
if (particle[idx]->GetEnergyCuts() == NULL) {
|
||||
G4cout << " ---------- ";
|
||||
IsOK = false;
|
||||
} else {
|
||||
G4cout << " " << setw(11) << G4BestUnit((particle[idx]->GetEnergyCuts())[J],"Energy");
|
||||
}
|
||||
}
|
||||
}
|
||||
G4cout << endl;
|
||||
}
|
||||
|
||||
if (!IsOK) {
|
||||
G4cout << " Cuts in energy have not calculated yet !!" << endl;
|
||||
G4cout << " Enter /run/initialize command to calculate cuts " << endl;
|
||||
}
|
||||
|
||||
// last line
|
||||
G4cout << "===================================================" << endl;
|
||||
G4cout.precision(prec);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4VUserPrimaryGeneratorAction.cc,v 2.0 1998/07/02 17:28:11 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
|
||||
#include "G4VUserPrimaryGeneratorAction.hh"
|
||||
|
||||
G4VUserPrimaryGeneratorAction::G4VUserPrimaryGeneratorAction()
|
||||
{;}
|
||||
|
||||
G4VUserPrimaryGeneratorAction::~G4VUserPrimaryGeneratorAction()
|
||||
{;}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user