diff --git a/auto.mac b/auto.mac index f40a323..7050df3 100644 --- a/auto.mac +++ b/auto.mac @@ -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 diff --git a/include/PrimaryGeneratorAction.h b/include/PrimaryGeneratorAction.h index 7bf386d..4eb189c 100644 --- a/include/PrimaryGeneratorAction.h +++ b/include/PrimaryGeneratorAction.h @@ -3,8 +3,11 @@ #include "G4ParticleGun.hh" #include "G4VUserPrimaryGeneratorAction.hh" +#include "globals.hh" +class G4ParticleGun; class G4Event; +class G4Box; class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction { public: diff --git a/include/RunAction.h b/include/RunAction.h index d6a8ba5..e048815 100644 --- a/include/RunAction.h +++ b/include/RunAction.h @@ -18,8 +18,8 @@ public: void AddEdep(G4double edep); private: - G4double fEdep = 0.; - G4double fEdep2 = 0.; + G4Accumulable fEdep = 0.; + G4Accumulable fEdep2 = 0.; }; #endif diff --git a/main.cpp b/main.cpp index 91c6842..fa8cbcf 100644 --- a/main.cpp +++ b/main.cpp @@ -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 { diff --git a/src/DetectorConstruction.cpp b/src/DetectorConstruction.cpp index 0f153c7..87a0ae1 100644 --- a/src/DetectorConstruction.cpp +++ b/src/DetectorConstruction.cpp @@ -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; } diff --git a/src/RunAction.cpp b/src/RunAction.cpp index 8c55935..e8343b3 100644 --- a/src/RunAction.cpp +++ b/src/RunAction.cpp @@ -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(G4RunManager::GetRunManager()->GetUserDetectorConstruction()); G4double mass = detConstruction->GetScoringVolume()->GetMass(); - G4double dose = fEdep / mass; + G4double dose = edep / mass; G4double rmsDose = rms / mass; G4String runCondition; diff --git a/vis.mac b/vis.mac index 88e821d..6193b12 100644 --- a/vis.mac +++ b/vis.mac @@ -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 \ No newline at end of file +/vis/viewer/set/style surface + +# 坐标轴 +/vis/scene/add/scale # Simple scale line +/vis/scene/add/axes # Simple axes: x=red, y=green, z=blue. \ No newline at end of file