// $Id$
// Category: run
//
+// Author: I. Hrivnacova
+//
+// Class TG4RunManager
+// -------------------
// See the class description in the header file.
#include "TG4RunManager.h"
-#include "TG4RunMessenger.h"
#include "TG4VRunConfiguration.h"
-#include "TGeant4.h"
#include "TG4Globals.h"
#include "TG4GeometryManager.h"
+#include "TG4GeometryServices.h"
+#include "TG4SDManager.h"
+#include "TG4SDServices.h"
#include "TG4PhysicsManager.h"
-//#include "TG4StepManager.h"
+#include "TG4G3PhysicsManager.h"
#include <G4RunManager.hh>
-#include <G4StateManager.hh>
#include <G4UIsession.hh>
#include <G4UImanager.hh>
#include <G4UIterminal.hh>
#ifdef G4UI_USE_GAG
#include <G4UIGAG.hh>
#endif
-#include <globals.hh>
+#ifdef G4UI_USE_TCSH
+#include "G4UItcsh.hh"
+#endif
-#include <TRint.h>
#include <TROOT.h>
+#include <TRint.h>
#include <TCint.h>
TG4RunManager* TG4RunManager::fgInstance = 0;
+//_____________________________________________________________________________
TG4RunManager::TG4RunManager(TG4VRunConfiguration* runConfiguration,
int argc, char** argv)
- : fRunConfiguration(runConfiguration),
+ : TG4Verbose("runManager"),
+ fMessenger(this),
+ fRunConfiguration(runConfiguration),
fGeantUISession(0),
fRootUISession(0),
fRootUIOwner(false),
fARGC(argc),
- fARGV(argv)
-
+ fARGV(argv)
{
//
if (fgInstance) {
TG4Globals::Exception(
"TG4RunManager: attempt to create two instances of singleton.");
- };
+ }
if (!fRunConfiguration) {
TG4Globals::Exception(
"TG4RunManager: attempt to create instance without runConfiguration.");
- };
+ }
fgInstance = this;
// create and configure geant4 run manager
fRunManager = new G4RunManager();
fRunConfiguration->ConfigureRunManager(fRunManager);
- // add verbose level
- //G4cout << "G4RunManager has been created." << G4endl;
+
+ if (VerboseLevel() > 1) {
+ G4cout << "G4RunManager has been created." << G4endl;
+ }
// create geant4 UI
CreateGeantUI();
// create root UI
CreateRootUI();
-
- // messenger
- fMessenger = new TG4RunMessenger(this);
}
+//_____________________________________________________________________________
TG4RunManager::TG4RunManager(TG4VRunConfiguration* runConfiguration)
- : fRunConfiguration(runConfiguration),
+ : TG4Verbose("runManager"),
+ fMessenger(this),
+ fRunConfiguration(runConfiguration),
fGeantUISession(0),
fRootUISession(0),
fRootUIOwner(false),
if (fgInstance) {
TG4Globals::Exception(
"TG4RunManager: attempt to create two instances of singleton.");
- };
+ }
if (!fRunConfiguration) {
TG4Globals::Exception(
"TG4RunManager: attempt to create instance without runConfiguration.");
- };
+ }
fgInstance = this;
// create and configure geant4 run manager
fRunManager = new G4RunManager();
fRunConfiguration->ConfigureRunManager(fRunManager);
- // add verbose level
- //G4cout << "G4RunManager has been created." << G4endl;
+
+ if (VerboseLevel() > 1) {
+ G4cout << "G4RunManager has been created." << G4endl;
+ }
// create geant4 UI
CreateGeantUI();
// create root UI
CreateRootUI();
-
- // messenger
- fMessenger = new TG4RunMessenger(this);
}
-TG4RunManager::TG4RunManager() {
+//_____________________________________________________________________________
+TG4RunManager::TG4RunManager()
+ : TG4Verbose("runManager"),
+ fMessenger(this) {
//
}
-TG4RunManager::TG4RunManager(const TG4RunManager& right) {
+//_____________________________________________________________________________
+TG4RunManager::TG4RunManager(const TG4RunManager& right)
+ : TG4Verbose("runManager"),
+ fMessenger(this) {
//
TG4Globals::Exception(
"Attempt to copy TG4RunManager singleton.");
}
+//_____________________________________________________________________________
TG4RunManager::~TG4RunManager() {
//
delete fRunConfiguration;
delete fRunManager;
delete fGeantUISession;
if (fRootUIOwner) delete fRootUISession;
- delete fMessenger;
}
// operators
+//_____________________________________________________________________________
TG4RunManager& TG4RunManager::operator=(const TG4RunManager& right)
{
// check assignement to self
// private methods
+//_____________________________________________________________________________
void TG4RunManager::CreateGeantUI()
{
// Creates interactive Geant4.
if (fARGC == 1) {
#ifdef G4UI_USE_GAG
fGeantUISession = new G4UIGAG();
-#else
+#else
+ #ifdef G4UI_USE_TCSH
+ fGeantUISession = new G4UIterminal(new G4UItcsh);
+ #else
fGeantUISession = new G4UIterminal();
+ #endif
#endif
}
else if (strcmp (fARGV[1], "dumb") == 0) {
}
}
+//_____________________________________________________________________________
void TG4RunManager::CreateRootUI()
{
// Creates interactive Root.
// public methods
+//_____________________________________________________________________________
void TG4RunManager::Initialize()
{
// Initializes G4.
// ---
+ // create physics constructor
+ // (this operation has to precede the "Init" phase)
+ TG4PhysicsManager::Instance()->CreatePhysicsConstructors();
+
// initialize Geant4
fRunManager->Initialize();
+ // initialize SD manager
+ TG4SDManager::Instance()->Initialize();
+}
+
+//_____________________________________________________________________________
+void TG4RunManager::LateInitialize()
+{
+// Finishes initialization of G4 after the AliRoot initialization
+// is finished.
+// ---
+
+ // set user limits
+ TG4GeometryManager::Instance()
+ ->SetUserLimits(*TG4G3PhysicsManager::Instance()->GetCutVector(),
+ *TG4G3PhysicsManager::Instance()->GetControlVector());
+
+ // final clear of G3toG4 objects
+ TG4GeometryManager::Instance()->ClearG3TablesFinal();
+
// activate/inactivate physics processes
- // (this operation is not allowed in "Init" phase)
- TG4PhysicsManager* physicsManager = TG4PhysicsManager::Instance();
- physicsManager->SetProcessActivation();
+ TG4PhysicsManager::Instance()->SetProcessActivation();
+
+ // print statistics
+ TG4GeometryServices::Instance()->PrintStatistics(true, false);
+ TG4SDServices::Instance()->PrintStatistics(false, true);
+
+ if (VerboseLevel() > 2) {
+ TG4GeometryServices::Instance()->PrintLogicalVolumeStore();
+ }
}
+//_____________________________________________________________________________
void TG4RunManager::ProcessEvent()
{
// Not yet implemented.
TG4Globals::Warning("TG4RunManager::ProcessEvent(): is not yet implemented.");
}
+//_____________________________________________________________________________
void TG4RunManager::ProcessRun(G4int nofEvents)
{
// Processes Geant4 run.
fRunManager->BeamOn(nofEvents);
}
+//_____________________________________________________________________________
void TG4RunManager::StartGeantUI()
{
// Starts interactive/batch Geant4.
}
}
+//_____________________________________________________________________________
void TG4RunManager::StartRootUI()
{
// Starts interactive Root.
}
}
+//_____________________________________________________________________________
void TG4RunManager::ProcessGeantMacro(G4String macroName)
{
// Processes Geant4 macro.
ProcessGeantCommand(command);
}
+//_____________________________________________________________________________
void TG4RunManager::ProcessRootMacro(G4String macroName)
{
// Processes Root macro.
gInterpreter->ProcessLine(macroFunction);
}
+//_____________________________________________________________________________
void TG4RunManager::ProcessGeantCommand(G4String command)
{
// Processes Geant4 command.
pUI->ApplyCommand(command);
}
+//_____________________________________________________________________________
void TG4RunManager::ProcessRootCommand(G4String command)
{
// Processes Root command.
gInterpreter->ProcessLine(command);
}
+//_____________________________________________________________________________
void TG4RunManager::UseG3Defaults()
{
// Controls G3 defaults usage.
// ---
TG4GeometryManager::Instance()->UseG3TrackingMediaLimits();
- TG4PhysicsManager::Instance()->SetG3DefaultCuts();
- TG4PhysicsManager::Instance()->SetG3DefaultProcesses();
+ TG4G3PhysicsManager::Instance()->SetG3DefaultCuts();
+ TG4G3PhysicsManager::Instance()->SetG3DefaultControls();
}
+//_____________________________________________________________________________
Int_t TG4RunManager::CurrentEvent() const
{
// Returns the number of the current event.