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
20 //---------------------------------------------------------------------------
21 // Initialize the tool
22 //---------------------------------------------------------------------------
24 {
25 ATH_MSG_DEBUG( "Initializing " << name() );
26 ATH_CHECK(m_truthRecordSvc.retrieve());
27 ATH_CHECK(m_geoIDSvc.retrieve());
28 return StatusCode::SUCCESS;
29 }
30
31 //---------------------------------------------------------------------------
32 // Create an MCTruthSteppingAction
33 //---------------------------------------------------------------------------
34 std::unique_ptr<MCTruthSteppingAction>
36 {
37 ATH_MSG_DEBUG("Constructing an MCTruthSteppingAction");
38 auto action = std::make_unique<MCTruthSteppingAction> (
40 m_subDetVolLevel.value(),
42 msgSvc(), msg().level() );
43 actionLists.eventActions.push_back( action.get() );
44 actionLists.steppingActions.push_back( action.get() );
45 return action;
46 }
47
50 {
51 for(const auto& volCollPair : m_volumeCollectionMap.value()) {
52 hitCollections.Emplace<TrackRecordCollection>(volCollPair.second, volCollPair.second);
53 }
54 return StatusCode::SUCCESS;
55 }
56
58 {
59 for(const auto& volCollPair : m_volumeCollectionMap.value()) {
60 CHECK(hitCollections.Record<TrackRecordCollection>(volCollPair.second));
61 }
62 return StatusCode::SUCCESS;
63 }
64
65} // namespace G4UA
#define ATH_CHECK
Evaluate an expression and check for errors.
#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.
ServiceHandle< ISF::IGeoIDSvc > m_geoIDSvc
Geo ID Service.
ServiceHandle< ISF::ITruthSvc > m_truthRecordSvc
Central Truth Service.
Gaudi::Property< MCTruthSteppingAction::VolumeCollectionMap_t > m_volumeCollectionMap
Map of volume name to output collection name.
MCTruthSteppingActionTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Gaudi::Property< int > m_subDetVolLevel
The level in the G4 volume hierarchy at which we find the sub-detector.
virtual StatusCode initialize() override final
Initialize the tool.
StatusCode EndOfAthenaEvent(HitCollectionMap &) override
Calls EndOfAthenaEvent.
StatusCode BeginOfAthenaEvent(HitCollectionMap &) override
Calls BeginOfAthenaEvent.
Gaudi::Property< int > m_secondarySavingLevel
The saving level for secondaries.
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