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