remove: user action
This commit is contained in:
parent
e7026fc966
commit
06b92fd866
@ -13,10 +13,6 @@ public:
|
|||||||
~DetectorConstruction() override;
|
~DetectorConstruction() override;
|
||||||
|
|
||||||
G4VPhysicalVolume* Construct() override;
|
G4VPhysicalVolume* Construct() override;
|
||||||
G4LogicalVolume* GetScoringVolume() const { return fScoringVolume; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
G4LogicalVolume* fScoringVolume = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -14,11 +14,8 @@ public:
|
|||||||
void BeginOfEventAction(const G4Event*) override;
|
void BeginOfEventAction(const G4Event*) override;
|
||||||
void EndOfEventAction(const G4Event*) override;
|
void EndOfEventAction(const G4Event*) override;
|
||||||
|
|
||||||
void AddEdep(G4double edep) { fEdep += edep; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RunAction* fRunAction = nullptr;
|
RunAction* fRunAction = nullptr;
|
||||||
G4double fEdep = 0.;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -14,12 +14,6 @@ public:
|
|||||||
|
|
||||||
void BeginOfRunAction(const G4Run*) override;
|
void BeginOfRunAction(const G4Run*) override;
|
||||||
void EndOfRunAction(const G4Run*) override;
|
void EndOfRunAction(const G4Run*) override;
|
||||||
|
|
||||||
void AddEdep(G4double edep);
|
|
||||||
|
|
||||||
private:
|
|
||||||
G4Accumulable<G4double> fEdep = 0.;
|
|
||||||
G4Accumulable<G4double> fEdep2 = 0.;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,7 +16,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
EventAction* fEventAction = nullptr;
|
EventAction* fEventAction = nullptr;
|
||||||
G4LogicalVolume* fScoringVolume = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -18,7 +18,5 @@ G4VPhysicalVolume* DetectorConstruction::Construct() {
|
|||||||
G4VPhysicalVolume* physics_world =
|
G4VPhysicalVolume* physics_world =
|
||||||
new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logic_world, "world", 0, false, 0, true);
|
new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logic_world, "world", 0, false, 0, true);
|
||||||
|
|
||||||
fScoringVolume = logic_world;
|
|
||||||
|
|
||||||
return physics_world;
|
return physics_world;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,6 @@ EventAction::EventAction(RunAction* r) : fRunAction(r) {}
|
|||||||
|
|
||||||
EventAction::~EventAction() {}
|
EventAction::~EventAction() {}
|
||||||
|
|
||||||
void EventAction::BeginOfEventAction(const G4Event* event) { fEdep = 0.; }
|
void EventAction::BeginOfEventAction(const G4Event* event) { }
|
||||||
|
|
||||||
void EventAction::EndOfEventAction(const G4Event* event) { fRunAction->AddEdep(fEdep); }
|
void EventAction::EndOfEventAction(const G4Event* event) { }
|
||||||
|
@ -11,77 +11,12 @@
|
|||||||
#include "PrimaryGeneratorAction.h"
|
#include "PrimaryGeneratorAction.h"
|
||||||
|
|
||||||
RunAction::RunAction() {
|
RunAction::RunAction() {
|
||||||
const G4double milligray = 1.e-3 * gray;
|
|
||||||
const G4double microgray = 1.e-6 * gray;
|
|
||||||
const G4double nanogray = 1.e-9 * gray;
|
|
||||||
const G4double picogray = 1.e-12 * gray;
|
|
||||||
|
|
||||||
new G4UnitDefinition("milligray", "mGy", "Dose", milligray);
|
|
||||||
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() {}
|
RunAction::~RunAction() {}
|
||||||
|
|
||||||
void RunAction::BeginOfRunAction(const G4Run*) {
|
void RunAction::BeginOfRunAction(const G4Run*) {
|
||||||
G4RunManager::GetRunManager()->SetRandomNumberStore(false);
|
|
||||||
|
|
||||||
G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
|
|
||||||
accumulableManager->Reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunAction::EndOfRunAction(const G4Run* run) {
|
void RunAction::EndOfRunAction(const G4Run* run) {
|
||||||
G4int nofEvents = run->GetNumberOfEvent();
|
|
||||||
if (nofEvents == 0) return;
|
|
||||||
|
|
||||||
G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
|
|
||||||
accumulableManager->Merge();
|
|
||||||
|
|
||||||
G4double edep = fEdep.GetValue();
|
|
||||||
G4double edep2 = fEdep2.GetValue();
|
|
||||||
G4double rms = edep2 - edep * edep / nofEvents;
|
|
||||||
if (rms > 0.)
|
|
||||||
rms = std::sqrt(rms);
|
|
||||||
else
|
|
||||||
rms = 0.;
|
|
||||||
|
|
||||||
const DetectorConstruction* detConstruction =
|
|
||||||
static_cast<const DetectorConstruction*>(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
|
|
||||||
G4double mass = detConstruction->GetScoringVolume()->GetMass();
|
|
||||||
G4double dose = edep / mass;
|
|
||||||
G4double rmsDose = rms / mass;
|
|
||||||
|
|
||||||
G4String runCondition;
|
|
||||||
const PrimaryGeneratorAction* generatorAction =
|
|
||||||
static_cast<const PrimaryGeneratorAction*>(G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction());
|
|
||||||
if (generatorAction) {
|
|
||||||
const G4ParticleGun* particleGun = generatorAction->GetParticleGun();
|
|
||||||
runCondition += particleGun->GetParticleDefinition()->GetParticleName();
|
|
||||||
runCondition += " of ";
|
|
||||||
G4double particleEnergy = particleGun->GetParticleEnergy();
|
|
||||||
runCondition += G4BestUnit(particleEnergy, "Energy");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print
|
|
||||||
if (IsMaster()) {
|
|
||||||
G4cout << G4endl << "--------------------End of Global Run-----------------------";
|
|
||||||
} else {
|
|
||||||
G4cout << G4endl << "--------------------End of Local Run------------------------";
|
|
||||||
}
|
|
||||||
|
|
||||||
G4cout << G4endl << " The run consists of " << nofEvents << " " << runCondition << G4endl
|
|
||||||
<< " Cumulated dose per run, in scoring volume : " << G4BestUnit(dose, "Dose")
|
|
||||||
<< " rms = " << G4BestUnit(rmsDose, "Dose") << G4endl
|
|
||||||
<< "------------------------------------------------------------" << G4endl << G4endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunAction::AddEdep(G4double edep) {
|
|
||||||
// 累加沉积能量
|
|
||||||
fEdep += edep;
|
|
||||||
fEdep2 += edep * edep;
|
|
||||||
}
|
}
|
||||||
|
@ -12,19 +12,4 @@ SteppingAction::SteppingAction(EventAction* e) : fEventAction(e) {}
|
|||||||
SteppingAction::~SteppingAction() {}
|
SteppingAction::~SteppingAction() {}
|
||||||
|
|
||||||
void SteppingAction::UserSteppingAction(const G4Step* step) {
|
void SteppingAction::UserSteppingAction(const G4Step* step) {
|
||||||
if (!fScoringVolume) {
|
|
||||||
const DetectorConstruction* detConstruction =
|
|
||||||
static_cast<const DetectorConstruction*>(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
|
|
||||||
fScoringVolume = detConstruction->GetScoringVolume();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取当前的 Volume
|
|
||||||
G4LogicalVolume* volume = step->GetPreStepPoint()->GetTouchableHandle()->GetVolume()->GetLogicalVolume();
|
|
||||||
|
|
||||||
// 检查是否在计算的 Volume (Shape 2)
|
|
||||||
if (volume != fScoringVolume) return;
|
|
||||||
|
|
||||||
// 获取当前 step 的沉积能量
|
|
||||||
G4double edepStep = step->GetTotalEnergyDeposit();
|
|
||||||
fEventAction->AddEdep(edepStep);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user