ATLAS Offline Software
Loading...
Searching...
No Matches
G4TrackCounterTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7namespace G4UA
8{
9
10 //---------------------------------------------------------------------------
11 // Constructor
12 //---------------------------------------------------------------------------
14 G4TrackCounterTool(const std::string& type, const std::string& name,
15 const IInterface* parent)
16 : UserActionToolBase<G4TrackCounter>(type, name, parent)
17 {
18 }
19
20 //---------------------------------------------------------------------------
21 // Initialize
22 //---------------------------------------------------------------------------
24 {
25 ATH_MSG_DEBUG( "Initializing " << name() );
26 return StatusCode::SUCCESS;
27 }
28
29 //---------------------------------------------------------------------------
30 // Merge results from all threads
31 //---------------------------------------------------------------------------
33 {
34 ATH_MSG_DEBUG( "Finalizing " << name() );
35
36 // Accumulate the results across threads
38 m_actions.accumulate(report, &G4TrackCounter::getReport,
40
41 // Report the totals
42 ATH_MSG_INFO("nEvents " << report.nEvents);
43 ATH_MSG_INFO("nPrimaryTracks " << report.nPrimaryTracks);
44 ATH_MSG_INFO("nSecondaryTracks " << report.nSecondaryTracks);
45 ATH_MSG_INFO("n50MeVTracks " << report.n50MeVTracks);
46
47 return StatusCode::SUCCESS;
48 }
49
50 //---------------------------------------------------------------------------
51 // Create the action on request
52 //---------------------------------------------------------------------------
53 std::unique_ptr<G4TrackCounter>
55 {
56 ATH_MSG_DEBUG("Making a G4TrackCounter action");
57 auto action = std::make_unique<G4TrackCounter>();
58 actionList.eventActions.push_back( action.get() );
59 actionList.trackingActions.push_back( action.get() );
60 return action;
61 }
62
63}
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
G4TrackCounterTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
virtual StatusCode finalize() override final
Finalize and merge results from all threads.
virtual std::unique_ptr< G4TrackCounter > makeAndFillAction(G4AtlasUserActions &) override final
Create action for this thread.
virtual StatusCode initialize() override final
Initialize tool.
A simple action which counts tracks.
const Report & getReport() const
Retrieve my counts.
ThreadSpecificUserAction< G4TrackCounter > m_actions
UserActionToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Struct for passing around user actions.
std::vector< G4UserTrackingAction * > trackingActions
std::vector< G4UserEventAction * > eventActions
Simple struct for holding the counts Might want to use larger integral types for this....
void merge(const Report &rep)