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)
20 {
21 declareProperty("VolumeCollectionMap", m_volumeCollectionMap,
22 "Map of volume name to output collection name");
23 declareProperty("SecondarySavingLevel", m_secondarySavingLevel,
24 "Three valid options: 1 - Primaries; "
25 "2 - StoredSecondaries(default); 3 - All");
26 declareProperty("SubDetVolumeLevel", m_subDetVolLevel,
27 "The level in the G4 volume hierarchy at which can we find "
28 "the sub-detector name");
29 }
30
31 //---------------------------------------------------------------------------
32 // Initialize the tool
33 //---------------------------------------------------------------------------
35 {
36 ATH_MSG_DEBUG( "Initializing " << name() );
37 return StatusCode::SUCCESS;
38 }
39
40 //---------------------------------------------------------------------------
41 // Create an MCTruthSteppingAction
42 //---------------------------------------------------------------------------
43 std::unique_ptr<MCTruthSteppingAction>
45 {
46 ATH_MSG_DEBUG("Constructing an MCTruthSteppingAction");
47 auto action = std::make_unique<MCTruthSteppingAction> (
49 msgSvc(), msg().level() );
50 actionLists.eventActions.push_back( action.get() );
51 actionLists.steppingActions.push_back( action.get() );
52 return action;
53 }
54
57 {
58 for(const auto& volCollPair : m_volumeCollectionMap) {
59 hitCollections.Emplace<TrackRecordCollection>(volCollPair.second, volCollPair.second);
60 }
61 return StatusCode::SUCCESS;
62 }
63
65 {
66 for(const auto& volCollPair : m_volumeCollectionMap) {
67 CHECK(hitCollections.Record<TrackRecordCollection>(volCollPair.second));
68 }
69 return StatusCode::SUCCESS;
70 }
71
72} // namespace G4UA
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
AtlasHitsVector< TrackRecord > TrackRecordCollection
virtual std::unique_ptr< MCTruthSteppingAction > makeAndFillAction(G4AtlasUserActions &) override final
Setup the user action for current thread.
int m_secondarySavingLevel
The saving level for secondaries.
int m_subDetVolLevel
The level in the G4 volume hierarchy at which we find the sub-detector.
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.
StatusCode 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