ATLAS Offline Software
Loading...
Searching...
No Matches
Simulation
ISF
ISF_Geant4
ISF_Geant4Tools
src
MCTruthUserAction.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// MCTruthUserAction.cxx, (c) ATLAS Detector software
8
9
// class header
10
#include "
MCTruthUserAction.h
"
11
12
// package includes
13
#include "
ISFTrajectory.h
"
14
15
// ISF includes
16
#include "
ISF_Event/ISFParticle.h
"
17
18
#include "
ISF_Interfaces/ITruthSvc.h
"
19
#include "
ISF_Interfaces/IParticleBroker.h
"
20
21
// ISF Geant4 includes
22
#include "
ISF_Geant4Event/Geant4TruthIncident.h
"
23
24
// Athena includes
25
#include "
MCTruth/TrackInformation.h
"
26
#include "
MCTruth/AtlasG4EventUserInfo.h
"
27
#include "
MCTruth/TrackHelper.h
"
28
29
#include "G4EventManager.hh"
30
31
// Atlas G4 Helpers
32
33
34
namespace
G4UA
{
35
36
namespace
iGeant4
{
37
38
MCTruthUserAction::MCTruthUserAction
(
const
Config
&
config
)
39
:
m_config
(
config
)
40
,
m_truthRecordSvcQuick
(nullptr)
41
{
42
43
if
(4<
m_config
.verboseLevel)
44
{
45
G4cout <<
"create MCTruthUserAction"
<< G4endl;
46
}
47
48
if
(
m_config
.truthRecordSvc.retrieve().isFailure()){
49
G4ExceptionDescription description;
50
description << G4String(
"MCTruthUserAction: "
) +
"Could not retrieve "
<< m_config.truthRecordSvc;
51
G4Exception(
"G4UA::iGeant4::MCTruthUserAction"
,
"NoTruthSvc"
, FatalException, description);
52
return;
//The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
53
}
54
55
// store a pointer directly to the truth service class
56
// by doing so, the Gaudi overhead can be minimized
57
m_truthRecordSvcQuick
= &(*(
m_config
.truthRecordSvc));
58
}
59
60
void
MCTruthUserAction::PreUserTrackingAction
(
const
G4Track* inTrack){
61
62
TrackHelper
trackHelper(inTrack);
63
64
if
(trackHelper.
IsPrimary
() ||
65
(trackHelper.
IsRegisteredSecondary
()&&
m_config
.ilevel>1) ||
66
(trackHelper.
IsSecondary
()&&
m_config
.ilevel>2)) {
67
68
auto
trkMgr = G4EventManager::GetEventManager()->GetTrackingManager();
69
G4Trajectory *temp=new ::iGeant4::ISFTrajectory(inTrack,
m_truthRecordSvcQuick
);
70
trkMgr->SetStoreTrajectory(
true
);
71
trkMgr->SetTrajectory(temp);
72
73
// TODO: check that the 'temp' object is actually deleted by the G4TrackingManager
74
// after FADS::FadsTrackingAction::GetTrackingAction()->ResetTraj() is executed
75
}
76
77
}
78
79
void
MCTruthUserAction::PostUserTrackingAction
(
const
G4Track*){
80
G4EventManager::GetEventManager()->GetTrackingManager()->SetStoreTrajectory(
false
);
81
}
82
}
// namespace iGeant4
83
84
}
// namespace G4UA
AtlasG4EventUserInfo.h
Geant4TruthIncident.h
IParticleBroker.h
ISFParticle.h
ISFTrajectory.h
ITruthSvc.h
if
if(febId1==febId2)
Definition
LArRodBlockPhysicsV0.cxx:567
MCTruthUserAction.h
TrackHelper.h
TrackInformation.h
G4UA::iGeant4::MCTruthUserAction::PreUserTrackingAction
virtual void PreUserTrackingAction(const G4Track *) override
Definition
MCTruthUserAction.cxx:60
G4UA::iGeant4::MCTruthUserAction::PostUserTrackingAction
virtual void PostUserTrackingAction(const G4Track *) override
Definition
MCTruthUserAction.cxx:79
G4UA::iGeant4::MCTruthUserAction::m_config
Config m_config
Definition
MCTruthUserAction.h:54
G4UA::iGeant4::MCTruthUserAction::m_truthRecordSvcQuick
ISF::ITruthSvc * m_truthRecordSvcQuick
used for faster access
Definition
MCTruthUserAction.h:55
G4UA::iGeant4::MCTruthUserAction::MCTruthUserAction
MCTruthUserAction(const Config &config)
Definition
MCTruthUserAction.cxx:38
TrackHelper
Definition
TrackHelper.h:18
TrackHelper::IsPrimary
bool IsPrimary() const
Definition
TrackHelper.cxx:15
TrackHelper::IsSecondary
bool IsSecondary() const
Definition
TrackHelper.cxx:30
TrackHelper::IsRegisteredSecondary
bool IsRegisteredSecondary() const
Definition
TrackHelper.cxx:25
G4UA
for nSW
Definition
CalibrationDefaultProcessing.h:19
config
Definition
PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
iGeant4
Definition
Geant4TruthIncident.h:35
G4UA::iGeant4::MCTruthUserAction::Config
Definition
MCTruthUserAction.h:42
Generated on
for ATLAS Offline Software by
1.14.0