File indexing completed on 2025-02-23 09:22:24
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
0030
0031
0032 #include "WLSEventAction.hh"
0033
0034 #include "WLSEventActionMessenger.hh"
0035 #include "WLSPhotonDetHit.hh"
0036 #include "WLSRun.hh"
0037 #include "WLSRunAction.hh"
0038
0039 #include "G4AnalysisManager.hh"
0040 #include "G4Event.hh"
0041 #include "G4EventManager.hh"
0042 #include "G4RunManager.hh"
0043 #include "G4SDManager.hh"
0044 #include "G4TrajectoryContainer.hh"
0045 #include "G4VVisManager.hh"
0046 #include "Randomize.hh"
0047
0048
0049
0050
0051
0052
0053 WLSEventAction::WLSEventAction()
0054 {
0055 fEventMessenger = new WLSEventActionMessenger(this);
0056 }
0057
0058
0059
0060 WLSEventAction::~WLSEventAction()
0061 {
0062 delete fEventMessenger;
0063 }
0064
0065
0066
0067 void WLSEventAction::BeginOfEventAction(const G4Event*)
0068 {
0069 fNTIR = 0;
0070 fNExiting = 0;
0071 fEscapedEnd = 0;
0072 fEscapedMid = 0;
0073 fBounce = 0;
0074 fWLSBounce = 0;
0075 fClad1Bounce = 0;
0076 fClad2Bounce = 0;
0077 fReflected = 0;
0078 fEscaped = 0;
0079 fMirror = 0;
0080 }
0081
0082
0083
0084 void WLSEventAction::EndOfEventAction(const G4Event* evt)
0085 {
0086
0087 G4SDManager* SDman = G4SDManager::GetSDMpointer();
0088 G4String colName = "PhotonDetHitCollection";
0089 fMPPCCollID = SDman->GetCollectionID(colName);
0090
0091 G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
0092 WLSPhotonDetHitsCollection* mppcHC = nullptr;
0093
0094
0095 if (HCE) {
0096 if (fMPPCCollID >= 0) {
0097 mppcHC = (WLSPhotonDetHitsCollection*)(HCE->GetHC(fMPPCCollID));
0098 }
0099 }
0100
0101
0102 G4int n_hit = 0;
0103 if (mppcHC) {
0104 n_hit = mppcHC->entries();
0105 }
0106
0107 auto analysisManager = G4AnalysisManager::Instance();
0108 analysisManager->FillH1(2, mppcHC->entries());
0109 for (size_t i = 0; i < mppcHC->entries(); ++i) {
0110 auto pdHit = (*mppcHC)[i];
0111 analysisManager->FillH1(0, pdHit->GetEnergy());
0112 analysisManager->FillH1(1, pdHit->GetArrivalTime());
0113 }
0114
0115 if (fVerboseLevel > 1) {
0116 G4cout << "-------------------------------------" << G4endl
0117 << " In this event, number of:" << G4endl << " TIR: " << fNTIR << G4endl
0118 << " Exiting: " << fNExiting << G4endl << " Escaped Mid: " << fEscapedMid
0119 << G4endl << " Escaped End: " << fEscapedEnd << G4endl
0120 << " Bounced: " << fBounce << G4endl << " WLS Bounce: " << fWLSBounce
0121 << G4endl << " Clad1 Bounce: " << fClad1Bounce << G4endl
0122 << " Clad2 Bounce: " << fClad2Bounce << G4endl << " Reflected: " << fReflected
0123 << G4endl << " Escaped: " << fEscaped << G4endl << " Mirror: " << fMirror
0124 << G4endl << " Detector hit: " << n_hit << G4endl;
0125 }
0126
0127 auto run = static_cast<WLSRun*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0128
0129 run->AddTIR(fNTIR);
0130 run->AddExiting(fNExiting);
0131 run->AddEscapedEnd(fEscapedEnd);
0132 run->AddEscapedMid(fEscapedMid);
0133 run->AddBounce(fBounce);
0134 run->AddClad1Bounce(fClad1Bounce);
0135 run->AddClad2Bounce(fClad2Bounce);
0136 run->AddReflected(fReflected);
0137 run->AddEscaped(fEscaped);
0138 run->AddMirror(fMirror);
0139 run->AddDetectorHits(n_hit);
0140 }
0141
0142
0143
0144 G4int WLSEventAction::GetEventNo()
0145 {
0146 return fpEventManager->GetConstCurrentEvent()->GetEventID();
0147 }
0148
0149
0150
0151 void WLSEventAction::SetEventVerbose(G4int level)
0152 {
0153 fVerboseLevel = level;
0154 }