G4StationEventAction.cc
Go to the documentation of this file.
1 #include "G4StationEventAction.h"
3 #include "G4UMDPixelAction.h"
4 
5 #include <fwk/RunController.h>
6 
7 #include <G4Event.hh>
8 #include <G4Timer.hh>
9 #include <G4SDManager.hh>
10 
11 #include <string>
12 
13 
14 namespace G4StationSimulatorOG {
15 
17  fG4StationSimulator(
18  dynamic_cast<G4StationSimulator&>(fwk::RunController::GetInstance().GetModule("G4StationSimulatorOG"))
19  ),
20  fTimer(new G4Timer),
21  fIsUMDEnabled(umdEnabled)
22  { }
23 
24 
26  {
27  delete fTimer;
28  }
29 
30 
31  void
32  G4StationEventAction::BeginOfEventAction(const G4Event* const /*event*/)
33  {
34  fTimer->Start();
36  fUMDPixelCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("pixelCollection");
37  }
38 
39 
40  void
41  G4StationEventAction::EndOfEventAction(const G4Event* const event)
42  {
46 
47  if (fIsUMDEnabled) {
48  if (!G4StationSimulator::fgCurrent.GetDetectorStation().ExistsAssociatedCounter())
49  return;
50  ProcessUMD(event);
51  }
52 
54  fTimer->Stop();
55  }
56 
57 
58  void
59  G4StationEventAction::ProcessUMD(const G4Event* const event)
60  {
61  if (fUMDPixelCollectionID < 0)
62  return;
63 
64  // retrieve the hit collections of this event
65  auto hce = event->GetHCofThisEvent();
66  if (!hce)
67  return;
68 
69  auto phc = hce->GetHC(fUMDPixelCollectionID);
70  if (!phc)
71  return;
72 
73  // Pixel collection
74  const size_t pixel_hit = phc->GetSize();
75 
76  for (size_t i = 0; i < pixel_hit; ++i) {
77  auto hit = static_cast<G4UMDPixelHit*>(phc->GetHit(i));
78  const int pId = hit->GetPixelId();
79  const int mId = hit->GetModuleId();
80  const auto& times = hit->GetTimes();
81  for (const auto& t : times)
82  fG4StationSimulator.AddUMDPhoton(mId, pId, t);
83  }
84 
85  phc->DrawAllHits();
86  }
87 
88 }
virtual void EndOfEventAction(const G4Event *const event) override
virtual void BeginOfEventAction(const G4Event *const event) override
void ProcessUMD(const G4Event *const event)
class that handles Geant4 SD Station simulation adopted from G4TankSimulator
void AddUMDPhoton(const size_t modId, const size_t pixId, const double peTime) const

, generated on Tue Sep 26 2023.