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
m_secondarySavingLevel
(2),
19
m_subDetVolLevel
(1)
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
//---------------------------------------------------------------------------
34
StatusCode
MCTruthSteppingActionTool::initialize
()
35
{
36
ATH_MSG_DEBUG
(
"Initializing "
<< name() );
37
return
StatusCode::SUCCESS;
38
}
39
40
//---------------------------------------------------------------------------
41
// Create an MCTruthSteppingAction
42
//---------------------------------------------------------------------------
43
std::unique_ptr<MCTruthSteppingAction>
44
MCTruthSteppingActionTool::makeAndFillAction
(
G4AtlasUserActions
& actionLists)
45
{
46
ATH_MSG_DEBUG
(
"Constructing an MCTruthSteppingAction"
);
47
auto
action = std::make_unique<MCTruthSteppingAction> (
48
m_volumeCollectionMap
,
m_secondarySavingLevel
,
m_subDetVolLevel
,
49
msgSvc(),
msg
().level() );
50
actionLists.
eventActions
.push_back( action.get() );
51
actionLists.
steppingActions
.push_back( action.get() );
52
return
action;
53
}
54
56
StatusCode
MCTruthSteppingActionTool::BeginOfAthenaEvent
(
HitCollectionMap
& hitCollections)
57
{
58
for
(
const
auto
& volCollPair :
m_volumeCollectionMap
) {
59
hitCollections.
Emplace
<
TrackRecordCollection
>(volCollPair.second, volCollPair.second);
60
}
61
return
StatusCode::SUCCESS;
62
}
63
64
StatusCode
MCTruthSteppingActionTool::EndOfAthenaEvent
(
HitCollectionMap
& hitCollections)
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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
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:44
G4UA::MCTruthSteppingActionTool::m_secondarySavingLevel
int m_secondarySavingLevel
The saving level for secondaries.
Definition
MCTruthSteppingActionTool.h:55
G4UA::MCTruthSteppingActionTool::m_subDetVolLevel
int m_subDetVolLevel
The level in the G4 volume hierarchy at which we find the sub-detector.
Definition
MCTruthSteppingActionTool.h:58
G4UA::MCTruthSteppingActionTool::m_volumeCollectionMap
std::map< std::string, std::string > m_volumeCollectionMap
Map of volume name to output collection name.
Definition
MCTruthSteppingActionTool.h:52
G4UA::MCTruthSteppingActionTool::MCTruthSteppingActionTool
MCTruthSteppingActionTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition
MCTruthSteppingActionTool.cxx:15
G4UA::MCTruthSteppingActionTool::initialize
virtual StatusCode initialize() override final
Initialize the tool.
Definition
MCTruthSteppingActionTool.cxx:34
G4UA::MCTruthSteppingActionTool::EndOfAthenaEvent
StatusCode EndOfAthenaEvent(HitCollectionMap &) override
Calls EndOfAthenaEvent.
Definition
MCTruthSteppingActionTool.cxx:64
G4UA::MCTruthSteppingActionTool::BeginOfAthenaEvent
StatusCode BeginOfAthenaEvent(HitCollectionMap &) override
Calls BeginOfAthenaEvent.
Definition
MCTruthSteppingActionTool.cxx:56
G4UA::MCTruthSteppingAction
User action which handles recording-envelope truth tracks.
Definition
MCTruthSteppingAction.h:37
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