ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Utilities
G4UserActions
src
StoppedParticleAction.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
StoppedParticleAction.h
"
6
7
#include "
TrackWriteFastSim/TrackFastSimSD.h
"
8
9
#include "
TruthUtils/HepMCHelpers.h
"
10
11
#include "G4Step.hh"
12
#include "G4Track.hh"
13
#include "G4DynamicParticle.hh"
14
#include "G4ParticleDefinition.hh"
15
#include "G4Material.hh"
16
#include "G4Element.hh"
17
#include "G4SDManager.hh"
18
#include "G4VSensitiveDetector.hh"
19
#include "G4VProcess.hh"
20
#include "G4ProcessType.hh"
21
22
#include <cmath>
23
24
#include "GaudiKernel/Bootstrap.h"
25
#include "GaudiKernel/ISvcLocator.h"
26
#include "GaudiKernel/IMessageSvc.h"
27
28
29
namespace
G4UA
30
{
31
32
//---------------------------------------------------------------------------
33
StoppedParticleAction::StoppedParticleAction
()
34
:
AthMessaging
(
Gaudi
::svcLocator()->service< IMessageSvc >(
"MessageSvc"
),
35
"StoppedParticleAction"
),
36
m_fsSD
(0),
m_init
(false)
37
{}
38
39
//---------------------------------------------------------------------------
40
void
StoppedParticleAction::UserSteppingAction
(
const
G4Step* aStep)
41
{
42
43
// Trigger if the energy is below our threshold or if the R-hadron is decaying
44
const
int
id
= std::abs(aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->GetPDGEncoding());
45
46
// Special treatment for SUSY particles and R-hadrons
47
if
(
id
>=1000000 &&
id
<=1100000 &&
// exclude super-partners of RH-fermions
48
(
MC::isSquarkLH
(
id
) ||
49
id
== 1000021 ||
// gluino
50
MC::isRHadron
(
id
))) {
51
52
G4Material * mat = aStep->GetTrack()->GetMaterial();
53
double
minA=1500000.;
54
for
(
unsigned
int
i=0;i<mat->GetNumberOfElements();++i){
55
if
(mat->GetElement(i) &&
56
minA>mat->GetElement(i)->GetN()){
57
minA=mat->GetElement(i)->GetN();
58
}
59
}
60
61
// Stopping condition
62
if
(aStep->GetPostStepPoint()->GetVelocity()>0.15*std::pow(minA,-2./3.)*CLHEP::c_light &&
// Stopping condition or...
63
( !aStep->GetPostStepPoint()->GetProcessDefinedStep() ||
// null pointer?
64
aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessType()!=fDecay) )
// Decaying particle (does not fire for hadronic interactions)
65
return
;
66
67
if
(!
m_init
){
68
m_init
=
true
;
69
70
G4SDManager * g4sdm = G4SDManager::GetSDMpointer();
71
if
(!g4sdm) {
72
ATH_MSG_ERROR
(
"StoppedParticleFastSim could not get sensitive detector catalog."
);
73
}
else
{
74
G4VSensitiveDetector * g4sd = g4sdm->FindSensitiveDetector(
"ToolSvc.SensitiveDetectorMasterTool.TrackFastSimSD"
);
75
if
(!g4sd) {
76
ATH_MSG_ERROR
(
"StoppedParticleFastSim could not get ToolSvc.SensitiveDetectorMasterTool.TrackFastSimSD sensitive detector."
);
77
}
else
{
78
m_fsSD
=
dynamic_cast<
TrackFastSimSD
*
>
(g4sd);
79
if
(!
m_fsSD
) {
80
ATH_MSG_ERROR
(
"StoppedParticleFastSim could not cast the SD."
);
81
}
82
}
// found the SD
83
}
// got the catalog
84
}
85
86
if
(
m_fsSD
) {
87
m_fsSD
->WriteTrack( aStep->GetTrack() ,
false
,
true
);
88
}
89
}
90
91
aStep->GetTrack()->SetTrackStatus(fStopAndKill);
92
const
G4TrackVector *tv = aStep->GetSecondary();
93
for
(
unsigned
int
i=0;i<tv->size();i++){
94
(*tv)[i]->SetTrackStatus(fStopAndKill);
95
}
96
}
97
98
}
// namespace G4UA
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
HepMCHelpers.h
ATLAS-specific HepMC functions.
StoppedParticleAction.h
TrackFastSimSD.h
AthMessaging::AthMessaging
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Definition
AthMessaging.cxx:13
G4UA::StoppedParticleAction::m_init
bool m_init
Definition
StoppedParticleAction.h:26
G4UA::StoppedParticleAction::StoppedParticleAction
StoppedParticleAction()
Definition
StoppedParticleAction.cxx:33
G4UA::StoppedParticleAction::m_fsSD
TrackFastSimSD * m_fsSD
Definition
StoppedParticleAction.h:25
G4UA::StoppedParticleAction::UserSteppingAction
virtual void UserSteppingAction(const G4Step *) override
Definition
StoppedParticleAction.cxx:40
TrackFastSimSD
Definition
TrackFastSimSD.h:24
G4UA
for nSW
Definition
CalibrationDefaultProcessing.h:19
Gaudi
=============================================================================
Definition
CaloGPUClusterAndCellDataMonitorOptions.h:273
MC::isSquarkLH
bool isSquarkLH(const T &p)
Definition
HepMCHelpers.h:473
MC::isRHadron
bool isRHadron(const T &p)
Definition
HepMCHelpers.h:610
Generated on
for ATLAS Offline Software by
1.17.0