ATLAS Offline Software
Loading...
Searching...
No Matches
MCTruthSteppingActionTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8namespace G4UA
9{
10
11 //---------------------------------------------------------------------------
12 // Constructor
13 //---------------------------------------------------------------------------
15 MCTruthSteppingActionTool(const std::string& type, const std::string& name,
16 const IInterface* parent)
18 {
19 declareProperty("VolumeCollectionMap", m_volumeCollectionMap,
20 "Map of volume name to output collection name");
21 }
22
23 //---------------------------------------------------------------------------
24 // Initialize the tool
25 //---------------------------------------------------------------------------
27 {
28 ATH_MSG_DEBUG( "Initializing " << name() );
29 return StatusCode::SUCCESS;
30 }
31
32 //---------------------------------------------------------------------------
33 // Create an MCTruthSteppingAction
34 //---------------------------------------------------------------------------
35 std::unique_ptr<MCTruthSteppingAction>
37 {
38 ATH_MSG_DEBUG("Constructing an MCTruthSteppingAction");
39 auto action = std::make_unique<MCTruthSteppingAction> (
40 m_volumeCollectionMap, msgSvc(), msg().level() );
41 actionLists.eventActions.push_back( action.get() );
42 actionLists.steppingActions.push_back( action.get() );
43 return action;
44 }
45
48 {
49 for(const auto& volCollPair : m_volumeCollectionMap) {
50 hitCollections.Emplace<TrackRecordCollection>(volCollPair.second, volCollPair.second);
51 }
52 return StatusCode::SUCCESS;
53 }
54
56 {
57 for(const auto& volCollPair : m_volumeCollectionMap) {
58 hitCollections.Record<TrackRecordCollection>(volCollPair.second);
59 }
60 return StatusCode::SUCCESS;
61 }
62
63} // namespace G4UA
#define ATH_MSG_DEBUG(x)
AtlasHitsVector< TrackRecord > TrackRecordCollection
virtual std::unique_ptr< MCTruthSteppingAction > makeAndFillAction(G4AtlasUserActions &) override final
Setup the user action for current thread.
std::map< std::string, std::string > m_volumeCollectionMap
Map of volume name to output collection name.
MCTruthSteppingActionTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
virtual StatusCode initialize() override final
Initialize the tool.
StatusCode EndOfAthenaEvent(HitCollectionMap &) override
Calls EndOfAthenaEvent.
StatusCode BeginOfAthenaEvent(HitCollectionMap &) override
Calls BeginOfAthenaEvent.
User action which handles recording-envelope truth tracks.
UserActionToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Small wrapper around hit collection map to facilitate accessing the hit collection.
void Record(std::string const &sgKey, std::string const &hitCollectionName, EventContext const &ctx)
Record the hit collection hitCollectionName to the StoreGate sgKey.
std::pair< StorageIterator, bool > Emplace(std::string const &hitCollectionName, CollectionArgs &&... args)
Insert a container in the map with in-place construction.
Struct for passing around user actions.
std::vector< G4UserSteppingAction * > steppingActions
std::vector< G4UserEventAction * > eventActions
MsgStream & msg
Definition testRead.cxx:32