Graduation-Project/main.cpp

66 lines
1.8 KiB
C++
Raw Permalink Normal View History

2023-05-08 23:23:29 +08:00
// clang-format off
2023-04-09 22:30:59 +08:00
#include "TROOT.h"
#include "time.h"
2023-02-13 14:50:36 +08:00
2023-04-09 22:30:59 +08:00
#include "G4RunManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4UIExecutive.hh"
#include "G4UImanager.hh"
#include "G4UItcsh.hh"
#include "G4UIterminal.hh"
#include "G4UnitsTable.hh"
#include "G4VisExecutive.hh"
2023-05-08 23:23:29 +08:00
#include "G4OpticalPhysics.hh"
#include "QGSP_BERT_HP.hh"
2023-02-13 14:50:36 +08:00
#include "GeneDetectorConstruction.hh"
#include "GeneEventAction.hh"
#include "GenePrimaryGeneratorAction.hh"
#include "GeneRunAction.hh"
2023-05-08 23:23:29 +08:00
// clang-format on
2023-02-13 14:50:36 +08:00
int main(int argc, char **argv) {
2023-05-08 11:10:33 +08:00
// random engine
// CLHEP::HepJamesRandom randomEngine;
G4long seeds;
seeds = time(NULL);
CLHEP::Ranlux64Engine randomEngine;
CLHEP::HepRandom::setTheEngine(&randomEngine);
CLHEP::HepRandom::setTheSeed(seeds);
CLHEP::HepRandom::showEngineStatus();
2023-02-13 15:10:21 +08:00
G4UIExecutive *ui = nullptr;
2023-02-13 14:50:36 +08:00
if (argc == 1) ui = new G4UIExecutive(argc, argv);
// run manager
G4RunManager *runManager = new G4RunManager;
runManager->SetUserInitialization(new GeneDetectorConstruction);
2023-05-08 23:23:29 +08:00
G4VModularPhysicsList *physics = new QGSP_BERT_HP;
physics->RegisterPhysics(new G4OpticalPhysics);
runManager->SetUserInitialization(physics);
2023-02-13 14:50:36 +08:00
runManager->SetUserAction(new GenePrimaryGeneratorAction);
runManager->SetUserAction(new GeneRunAction);
runManager->SetUserAction(new GeneEventAction);
runManager->Initialize();
G4VisManager *visManager = new G4VisExecutive;
G4UImanager *UIManager = G4UImanager::GetUIpointer();
visManager->Initialize();
if (!ui) {
G4String command = "/control/execute ";
G4String fileName = argv[1];
UIManager->ApplyCommand(command + fileName);
} else {
2023-05-08 23:23:29 +08:00
UIManager->ApplyCommand("/control/execute init_vis.mac");
2023-02-13 14:50:36 +08:00
ui->SessionStart();
delete ui;
}
delete visManager;
delete runManager;
return 0;
}