Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <proio/event.h>
#include <G4Event.hh>
#include <G4HCofThisEvent.hh>
#include <G4VHit.hh>
#include "EventAction.hh"
#include "RunAction.hh"
using namespace g4testbench;
EventAction::EventAction() { ; }
EventAction::~EventAction() { ; }
void EventAction::BeginOfEventAction(const G4Event *) { ; }
void EventAction::EndOfEventAction(const G4Event *event) {
pthread_mutex_lock(eventWriteLock);
auto proioEvent = new proio::Event();
G4HCofThisEvent *hcc = event->GetHCofThisEvent();
for (int i = 0; i < hcc->GetCapacity(); i++) {
G4VHitsCollection *hc = hcc->GetHC(i);
if (!hc) continue;
for (size_t j = 0; j < hc->GetSize(); j++) {
auto hit = dynamic_cast<google::protobuf::Message *>(hc->GetHit(j));
if (hit) {
auto hitCopy = hit->New();
hitCopy->CopyFrom(*hit);
proioEvent->AddEntry(hitCopy, "Simulated");
}
}
}
proioWriter->Push(proioEvent);
delete proioEvent;
pthread_mutex_unlock(eventWriteLock);
}