91 lines
3.0 KiB
C++
91 lines
3.0 KiB
C++
#include "GeneEventAction.hh"
|
|
|
|
#include "G4Event.hh"
|
|
#include "G4EventManager.hh"
|
|
#include "G4HCofThisEvent.hh"
|
|
#include "G4SDManager.hh"
|
|
#include "G4SystemOfUnits.hh"
|
|
#include "G4Trajectory.hh"
|
|
#include "G4TrajectoryContainer.hh"
|
|
#include "G4UImanager.hh"
|
|
#include "G4UnitsTable.hh"
|
|
#include "G4VHitsCollection.hh"
|
|
#include "G4VVisManager.hh"
|
|
#include "G4ios.hh"
|
|
#include "GeneAnalysisManager.hh"
|
|
#include "GeneHe3detHit.hh"
|
|
#include "Randomize.hh"
|
|
|
|
GeneEventAction::GeneEventAction() : GeneHe3detSDCollID(-1), drawFlag("non") {}
|
|
|
|
GeneEventAction::~GeneEventAction() {}
|
|
|
|
void GeneEventAction::BeginOfEventAction(const G4Event* evt) {
|
|
G4int evtNb = evt->GetEventID();
|
|
if (evtNb % 1000 == 0) G4cout << "Event No." << evtNb << G4endl;
|
|
|
|
G4SDManager* SDman = G4SDManager::GetSDMpointer();
|
|
if (GeneHe3detSDCollID == -1) {
|
|
GeneHe3detSDCollID = SDman->GetCollectionID("GeneHe3detHitCollection");
|
|
}
|
|
}
|
|
|
|
void GeneEventAction::EndOfEventAction(const G4Event* evt) {
|
|
G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
|
|
GeneHe3detHitsCollection* GeneHe3detHC = 0;
|
|
GeneAnalysisManager* analysisManager = GeneAnalysisManager::GetInstance();
|
|
if (HCE) {
|
|
GeneHe3detHC = (GeneHe3detHitsCollection*)(HCE->GetHC(GeneHe3detSDCollID));
|
|
G4double ede = 0.;
|
|
G4double Etot[24];
|
|
G4int Ndet[24];
|
|
G4int cpNo;
|
|
for (G4int i = 0; i < 24; i++) {
|
|
Etot[i] = 0.;
|
|
Ndet[i] = -1;
|
|
}
|
|
// GeneHe3det event
|
|
if (GeneHe3detHC) {
|
|
G4int n_hits = GeneHe3detHC->entries();
|
|
if (n_hits > 0) {
|
|
for (G4int i = 0; i < n_hits; i++) {
|
|
cpNo = (*GeneHe3detHC)[i]->GetCpNo();
|
|
ede = (*GeneHe3detHC)[i]->GetEdep();
|
|
// Construcion copy number add 300
|
|
Etot[cpNo - 300] += ede;
|
|
}
|
|
cpNo = 0;
|
|
for (G4int i = 0; i < 24; i++) {
|
|
if (Etot[i] > 0) {
|
|
Ndet[cpNo] = i;
|
|
Etot[cpNo] = Etot[i];
|
|
cpNo++;
|
|
}
|
|
}
|
|
analysisManager->FillDetData(cpNo, Etot, Ndet);
|
|
// analysisManager->EventNo(); // evtNo++ only for detected events
|
|
analysisManager->FillTree();
|
|
}
|
|
}
|
|
}
|
|
|
|
// G4cout << "--> EndOfEventAction in EventAction" << G4endl;
|
|
|
|
if (drawFlag == "all") drawtracks(evt);
|
|
}
|
|
|
|
// Draw track 画出轨迹(不包含可见光)
|
|
void GeneEventAction::drawtracks(const G4Event* evt) {
|
|
if (G4VVisManager::GetConcreteInstance()) {
|
|
G4TrajectoryContainer* trajContainer = evt->GetTrajectoryContainer();
|
|
G4int n_trajectories = 0;
|
|
|
|
if (trajContainer) n_trajectories = trajContainer->entries();
|
|
for (G4int i = 0; i < n_trajectories; i++) {
|
|
G4Trajectory* trj = (G4Trajectory*)(*trajContainer)[i];
|
|
if (trj->GetParticleName() != "opticalphoton") trj->DrawTrajectory();
|
|
}
|
|
G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update");
|
|
}
|
|
}
|