-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent.cc
More file actions
46 lines (28 loc) · 925 Bytes
/
event.cc
File metadata and controls
46 lines (28 loc) · 925 Bytes
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
39
40
41
42
43
44
45
46
#include "event.hh"
#include "G4AnalysisManager.hh"
#include "G4SystemOfUnits.hh"
#include <cmath>
MyEventAction::MyEventAction(MyRunAction*)
{
}
MyEventAction::~MyEventAction()
{
}
void MyEventAction::BeginOfEventAction(const G4Event*)
{
}
void MyEventAction::EndOfEventAction(const G4Event* event)
{
auto analysisManager = G4AnalysisManager::Instance();
G4int eventID = event->GetEventID();
const G4PrimaryVertex *vertex = event->GetPrimaryVertex();
const G4PrimaryParticle *particle = vertex->GetPrimary();
G4ThreeVector mom = particle->GetMomentum();
G4double mass = particle->GetMass();
G4double energy = std::sqrt(mom.mag2() + mass*mass);
G4double KE = energy - mass;
G4cout << "KE:" << KE /MeV << " Mev" << G4endl;
analysisManager->FillNtupleIColumn(2, eventID);
analysisManager->FillNtupleDColumn(9, KE);
analysisManager->AddNtupleRow();
}