fix: batch mode, scroing volume, GunAction headers;

change: message verbose, Accumulable in run, QGSP_BERT to QBBC;
This commit is contained in:
liuyihui 2022-04-29 15:33:52 +08:00
parent bd83ed359a
commit de0caaaae0
7 changed files with 33 additions and 16 deletions

View File

@ -2,10 +2,10 @@
/run/numberOfThreads 4
# verbose
/control/verbose 2
/run/verbose 2
/event/verbose 2
/tracking/verbose 2
/control/verbose 1
/run/verbose 1
/event/verbose 0
/tracking/verbose 0
# 初始化
/run/initialize
@ -25,7 +25,7 @@
# 发射粒子
/gun/particle gamma
/gun/energy 1 MeV
/run/beamOn 1000
/run/beamOn 50000
# 保存数据
/score/dumpQuantityToFile water_box eDep eDep.txt

View File

@ -3,8 +3,11 @@
#include "G4ParticleGun.hh"
#include "G4VUserPrimaryGeneratorAction.hh"
#include "globals.hh"
class G4ParticleGun;
class G4Event;
class G4Box;
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction {
public:

View File

@ -18,8 +18,8 @@ public:
void AddEdep(G4double edep);
private:
G4double fEdep = 0.;
G4double fEdep2 = 0.;
G4Accumulable<G4double> fEdep = 0.;
G4Accumulable<G4double> fEdep2 = 0.;
};
#endif

View File

@ -6,7 +6,7 @@
#include "G4UImanager.hh"
#include "G4VisExecutive.hh"
#include "PrimaryGeneratorAction.h"
#include "QGSP_BERT.hh"
#include "QBBC.hh"
int main(int argc, char** argv) {
G4UIExecutive* ui = nullptr;
@ -18,12 +18,12 @@ int main(int argc, char** argv) {
G4ScoringManager::GetScoringManager();
runManager->SetUserInitialization(new DetectorConstruction());
runManager->SetUserInitialization(new QGSP_BERT);
runManager->SetUserInitialization(new QBBC);
runManager->SetUserInitialization(new ActionInitialization());
visManager->Initialize();
if (!ui) {
G4String command = "/control/execute";
G4String command = "/control/execute ";
G4String fileName = argv[1];
UIManager->ApplyCommand(command + fileName);
} else {

View File

@ -18,5 +18,7 @@ G4VPhysicalVolume* DetectorConstruction::Construct() {
G4VPhysicalVolume* physics_world =
new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logic_world, "world", 0, false, 0, true);
fScoringVolume = logic_world;
return physics_world;
}

View File

@ -20,6 +20,10 @@ RunAction::RunAction() {
new G4UnitDefinition("microgray", "uGy", "Dose", microgray);
new G4UnitDefinition("nanogray", "nGy", "Dose", nanogray);
new G4UnitDefinition("picogray", "pGy", "Dose", picogray);
G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
accumulableManager->RegisterAccumulable(fEdep);
accumulableManager->RegisterAccumulable(fEdep2);
}
RunAction::~RunAction() {}
@ -38,7 +42,9 @@ void RunAction::EndOfRunAction(const G4Run* run) {
G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
accumulableManager->Merge();
G4double rms = fEdep2 - fEdep * fEdep / nofEvents;
G4double edep = fEdep.GetValue();
G4double edep2 = fEdep2.GetValue();
G4double rms = edep2 - edep * edep / nofEvents;
if (rms > 0.)
rms = std::sqrt(rms);
else
@ -47,7 +53,7 @@ void RunAction::EndOfRunAction(const G4Run* run) {
const DetectorConstruction* detConstruction =
static_cast<const DetectorConstruction*>(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
G4double mass = detConstruction->GetScoringVolume()->GetMass();
G4double dose = fEdep / mass;
G4double dose = edep / mass;
G4double rmsDose = rms / mass;
G4String runCondition;

14
vis.mac
View File

@ -1,10 +1,12 @@
# 多线程设置
/run/numberOfThreads 1
/run/numberOfThreads 4
# verbose
/control/verbose 2
/control/saveHistory
/run/verbose 2
/control/verbose 2
/run/verbose 1
/event/verbose 0
/tracking/verbose 0
# 初始化
/run/initialize
@ -31,4 +33,8 @@
# 设置颜色
/vis/geometry/set/colour world 0 0 0 1 .3
/vis/viewer/set/style surface
/vis/viewer/set/style surface
# 坐标轴
/vis/scene/add/scale # Simple scale line
/vis/scene/add/axes # Simple axes: x=red, y=green, z=blue.