ATLAS Offline Software
Loading...
Searching...
No Matches
G4TrackCounter.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "G4TrackCounter.h"
7#include "G4Track.hh"
8
9namespace G4UA
10{
11
12 //---------------------------------------------------------------------------
13 // Merge results
14 //---------------------------------------------------------------------------
16 {
17 nEvents += rep.nEvents;
18 nTotalTracks += rep.nTotalTracks;
19 nPrimaryTracks += rep.nPrimaryTracks;
20 nSecondaryTracks += rep.nSecondaryTracks;
21 n50MeVTracks += rep.n50MeVTracks;
22 }
23
24 //---------------------------------------------------------------------------
25 // Increment event counter
26 //---------------------------------------------------------------------------
27 void G4TrackCounter::BeginOfEventAction(const G4Event* /*event*/)
28 {
29 m_report.nEvents++;
30 }
31
32 //---------------------------------------------------------------------------
33 // Increment track counters
34 //---------------------------------------------------------------------------
35 void G4TrackCounter::PreUserTrackingAction(const G4Track* track)
36 {
37 m_report.nTotalTracks++;
38 TrackHelper helper(track);
39
40 // Primary tracks
41 if(helper.IsPrimary() || helper.IsRegeneratedPrimary())
42 m_report.nPrimaryTracks++;
43
44 // Secondary tracks
45 if(helper.IsRegisteredSecondary())
46 m_report.nSecondaryTracks++;
47
48 // 50 MeV tracks
49 const double minE = 50.;
50 if(track->GetKineticEnergy() > minE)
51 m_report.n50MeVTracks++;
52 }
53
54} // namespace G4UA
virtual void PreUserTrackingAction(const G4Track *track) override final
Increments the track counters.
Report m_report
Track counts for this thread.
virtual void BeginOfEventAction(const G4Event *event) override final
Increments event counter.
Simple struct for holding the counts Might want to use larger integral types for this....
unsigned int nPrimaryTracks
Number of primary tracks.
unsigned int n50MeVTracks
Number of tracks with kinetic E > 50 MeV.
unsigned int nSecondaryTracks
Number of secondary tracks.
unsigned int nTotalTracks
Total number of tracks.
unsigned int nEvents
Event counter. Might want a larger int for this.
void merge(const Report &rep)