File indexing completed on 2026-09-09 08:29:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #include "RE05EventAction.hh"
0030
0031 #include "RE05CalorimeterHit.hh"
0032 #include "RE05MuonHit.hh"
0033 #include "RE05TrackerHit.hh"
0034
0035 #include "G4Event.hh"
0036 #include "G4EventManager.hh"
0037 #include "G4HCofThisEvent.hh"
0038 #include "G4SDManager.hh"
0039 #include "G4SystemOfUnits.hh"
0040 #include "G4Trajectory.hh"
0041 #include "G4TrajectoryContainer.hh"
0042 #include "G4UImanager.hh"
0043 #include "G4VHitsCollection.hh"
0044 #include "G4VVisManager.hh"
0045 #include "G4ios.hh"
0046
0047
0048
0049 RE05EventAction::RE05EventAction()
0050 : G4UserEventAction(), fTrackerCollID(-1), fCalorimeterCollID(-1), fMuonCollID(-1)
0051 {}
0052
0053
0054
0055 RE05EventAction::~RE05EventAction() {}
0056
0057
0058
0059 void RE05EventAction::BeginOfEventAction(const G4Event*)
0060 {
0061 G4SDManager* SDman = G4SDManager::GetSDMpointer();
0062 if (fTrackerCollID < 0 || fCalorimeterCollID < 0 || fMuonCollID < 0) {
0063 G4String colNam;
0064 fTrackerCollID = SDman->GetCollectionID(colNam = "trackerCollection");
0065 fCalorimeterCollID = SDman->GetCollectionID(colNam = "calCollection");
0066 fMuonCollID = SDman->GetCollectionID(colNam = "muonCollection");
0067 }
0068 }
0069
0070
0071
0072 void RE05EventAction::EndOfEventAction(const G4Event* evt)
0073 {
0074 G4cout << ">>> Event " << evt->GetEventID() << G4endl;
0075
0076 if (fTrackerCollID < 0 || fCalorimeterCollID < 0 || fMuonCollID < 0) return;
0077
0078 G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
0079 RE05TrackerHitsCollection* THC = 0;
0080 RE05CalorimeterHitsCollection* CHC = 0;
0081 RE05MuonHitsCollection* MHC = 0;
0082 if (HCE) {
0083 THC = (RE05TrackerHitsCollection*)(HCE->GetHC(fTrackerCollID));
0084 CHC = (RE05CalorimeterHitsCollection*)(HCE->GetHC(fCalorimeterCollID));
0085 MHC = (RE05MuonHitsCollection*)(HCE->GetHC(fMuonCollID));
0086 }
0087
0088 if (THC) {
0089 int n_hit = THC->entries();
0090 G4cout << " " << n_hit << " hits are stored in RE05TrackerHitsCollection." << G4endl;
0091 }
0092 if (CHC) {
0093 int n_hit = CHC->entries();
0094 G4cout << " " << n_hit << " hits are stored in RE05CalorimeterHitsCollection." << G4endl;
0095 G4double totE = 0;
0096 for (int i = 0; i < n_hit; i++) {
0097 totE += (*CHC)[i]->GetEdep();
0098 }
0099 G4cout << " Total energy deposition in calorimeter : " << totE / GeV << " (GeV)" << G4endl;
0100 }
0101 if (MHC) {
0102 int n_hit = MHC->entries();
0103 G4cout << " " << n_hit << " hits are stored in RE05MuonHitsCollection." << G4endl;
0104 }
0105 }
0106
0107