ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Sim
MCTruthBase
src
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
5
#include "
MCTruthSteppingActionTool.h
"
6
7
8
namespace
G4UA
9
{
10
11
//---------------------------------------------------------------------------
12
// Constructor
13
//---------------------------------------------------------------------------
14
MCTruthSteppingActionTool::
15
MCTruthSteppingActionTool
(
const
std::string&
type
,
const
std::string& name,
16
const
IInterface* parent)
17
:
UserActionToolBase
<
MCTruthSteppingAction
>(
type
, name, parent)
18
{}
19
20
//---------------------------------------------------------------------------
21
// Initialize the tool
22
//---------------------------------------------------------------------------
23
StatusCode
MCTruthSteppingActionTool::initialize
()
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>
35
MCTruthSteppingActionTool::makeAndFillAction
(
G4AtlasUserActions
& actionLists)
36
{
37
ATH_MSG_DEBUG
(
"Constructing an MCTruthSteppingAction"
);
38
auto
action = std::make_unique<MCTruthSteppingAction> (
39
m_volumeCollectionMap
.value(),
m_secondarySavingLevel
.value(),
40
m_subDetVolLevel
.value(),
41
*
m_truthRecordSvc
, *
m_geoIDSvc
,
42
msgSvc(),
msg
().level() );
43
actionLists.
eventActions
.push_back( action.get() );
44
actionLists.
steppingActions
.push_back( action.get() );
45
return
action;
46
}
47
49
StatusCode
MCTruthSteppingActionTool::BeginOfAthenaEvent
(
HitCollectionMap
& hitCollections)
50
{
51
for
(
const
auto
& volCollPair :
m_volumeCollectionMap
.value()) {
52
hitCollections.
Emplace
<
TrackRecordCollection
>(volCollPair.second, volCollPair.second);
53
}
54
return
StatusCode::SUCCESS;
55
}
56
57
StatusCode
MCTruthSteppingActionTool::EndOfAthenaEvent
(
HitCollectionMap
& hitCollections)
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
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
MCTruthSteppingActionTool.h
TrackRecordCollection
AtlasHitsVector< TrackRecord > TrackRecordCollection
Definition
TrackRecordCollection.h:12
G4UA::MCTruthSteppingActionTool::makeAndFillAction
virtual std::unique_ptr< MCTruthSteppingAction > makeAndFillAction(G4AtlasUserActions &) override final
Setup the user action for current thread.
Definition
MCTruthSteppingActionTool.cxx:35
G4UA::MCTruthSteppingActionTool::m_geoIDSvc
ServiceHandle< ISF::IGeoIDSvc > m_geoIDSvc
Geo ID Service.
Definition
MCTruthSteppingActionTool.h:76
G4UA::MCTruthSteppingActionTool::m_truthRecordSvc
ServiceHandle< ISF::ITruthSvc > m_truthRecordSvc
Central Truth Service.
Definition
MCTruthSteppingActionTool.h:72
G4UA::MCTruthSteppingActionTool::m_volumeCollectionMap
Gaudi::Property< MCTruthSteppingAction::VolumeCollectionMap_t > m_volumeCollectionMap
Map of volume name to output collection name.
Definition
MCTruthSteppingActionTool.h:58
G4UA::MCTruthSteppingActionTool::MCTruthSteppingActionTool
MCTruthSteppingActionTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition
MCTruthSteppingActionTool.cxx:15
G4UA::MCTruthSteppingActionTool::m_subDetVolLevel
Gaudi::Property< int > m_subDetVolLevel
The level in the G4 volume hierarchy at which we find the sub-detector.
Definition
MCTruthSteppingActionTool.h:67
G4UA::MCTruthSteppingActionTool::initialize
virtual StatusCode initialize() override final
Initialize the tool.
Definition
MCTruthSteppingActionTool.cxx:23
G4UA::MCTruthSteppingActionTool::EndOfAthenaEvent
StatusCode EndOfAthenaEvent(HitCollectionMap &) override
Calls EndOfAthenaEvent.
Definition
MCTruthSteppingActionTool.cxx:57
G4UA::MCTruthSteppingActionTool::BeginOfAthenaEvent
StatusCode BeginOfAthenaEvent(HitCollectionMap &) override
Calls BeginOfAthenaEvent.
Definition
MCTruthSteppingActionTool.cxx:49
G4UA::MCTruthSteppingActionTool::m_secondarySavingLevel
Gaudi::Property< int > m_secondarySavingLevel
The saving level for secondaries.
Definition
MCTruthSteppingActionTool.h:62
G4UA::MCTruthSteppingAction
User action which handles recording-envelope truth tracks.
Definition
MCTruthSteppingAction.h:41
G4UA::UserActionToolBase< MCTruthSteppingAction >::UserActionToolBase
UserActionToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Definition
UserActionToolBase.h:40
HitCollectionMap
Small wrapper around hit collection map to facilitate accessing the hit collection.
Definition
HitCollectionMap.h:23
HitCollectionMap::Record
StatusCode Record(std::string const &sgKey, std::string const &hitCollectionName, EventContext const &ctx)
Record the hit collection hitCollectionName to the StoreGate sgKey.
Definition
HitCollectionMap.h:83
HitCollectionMap::Emplace
std::pair< StorageIterator, bool > Emplace(std::string const &hitCollectionName, CollectionArgs &&... args)
Insert a container in the map with in-place construction.
Definition
HitCollectionMap.h:40
G4UA
for nSW
Definition
CalibrationDefaultProcessing.h:19
G4UA::G4AtlasUserActions
Struct for passing around user actions.
Definition
IUserActionTool.h:35
G4UA::G4AtlasUserActions::steppingActions
std::vector< G4UserSteppingAction * > steppingActions
Definition
IUserActionTool.h:41
G4UA::G4AtlasUserActions::eventActions
std::vector< G4UserEventAction * > eventActions
Definition
IUserActionTool.h:39
type
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0