ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Utilities
G4UserActions
src
LooperThresholdSet.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
LooperThresholdSet.h
"
6
#include <iostream>
7
8
#include "G4Version.hh"
9
10
#include "G4Electron.hh"
11
#include "G4ProcessManager.hh"
12
13
#include "GaudiKernel/Bootstrap.h"
14
#include "GaudiKernel/ISvcLocator.h"
15
#include "GaudiKernel/IMessageSvc.h"
16
17
namespace
G4UA
18
{
19
20
//---------------------------------------------------------------------------
21
LooperThresholdSet::LooperThresholdSet
(
const
Config
& config) :
22
AthMessaging
(
Gaudi
::svcLocator()->service<IMessageSvc>(
"MessageSvc"
),
"LooperThresholdSet"
),
23
m_config
(config)
24
{
25
}
26
27
//---------------------------------------------------------------------------
28
void
LooperThresholdSet::BeginOfRunAction
(
const
G4Run*)
29
{
30
ChangeLooperParameters
( G4Electron::Electron() );
31
}
32
33
void
LooperThresholdSet::ChangeLooperParameters
(
const
G4ParticleDefinition* particleDef)
34
{
35
if
( particleDef ==
nullptr
)
36
particleDef = G4Electron::Electron();
37
auto
transportPair =
findTransportation
( particleDef );
38
auto
transport = transportPair.first;
39
auto
coupledTransport = transportPair.second;
40
41
if
( transport !=
nullptr
)
42
{
43
// Change the values of the looping particle parameters of Transportation
44
ATH_MSG_INFO
(
"Setting looper values of G4Transportation process..."
);
45
if
(
m_config
.WarningEnergy >= 0.0 ) {
46
transport->SetThresholdWarningEnergy(
m_config
.WarningEnergy );
47
ATH_MSG_INFO
(
"Set ThresholdWarningEnergy to "
<<
m_config
.WarningEnergy);
48
}
49
else
50
ATH_MSG_WARNING
(
"Invalid ThresholdEnergy: "
<<
m_config
.WarningEnergy);
51
if
(
m_config
.ImportantEnergy >= 0.0 ) {
52
transport->SetThresholdImportantEnergy(
m_config
.ImportantEnergy );
53
ATH_MSG_INFO
(
"Set ImportantEnergy to "
<<
m_config
.ImportantEnergy);
54
55
}
56
else
57
ATH_MSG_WARNING
(
"Invalid ImportantEnergy: "
<<
m_config
.ImportantEnergy);
58
if
(
m_config
.NumberOfTrials > 0 ) {
59
transport->SetThresholdTrials(
m_config
.NumberOfTrials );
60
ATH_MSG_INFO
(
"Set NumberOfTrials to "
<<
m_config
.NumberOfTrials);
61
62
}
63
else
64
ATH_MSG_WARNING
(
"Invalid NumberOfTrials: "
<<
m_config
.NumberOfTrials);
65
// Geant4 printout
66
#if G4VERSION_NUMBER > 1049
67
transport->ReportLooperThresholds();
68
#endif
69
}
70
else
if
( coupledTransport !=
nullptr
)
71
{
72
// Change the values for Coupled Transport
73
ATH_MSG_INFO
(
"Setting looper values of G4CoupledTransportation process..."
);
74
if
(
m_config
.WarningEnergy >= 0.0 ) {
75
coupledTransport->SetThresholdWarningEnergy(
m_config
.WarningEnergy );
76
ATH_MSG_INFO
(
"Set ThresholdWarningEnergy to "
<<
m_config
.WarningEnergy);
77
}
78
else
79
ATH_MSG_WARNING
(
"Invalid ThresholdEnergy: "
<<
m_config
.WarningEnergy);
80
if
(
m_config
.ImportantEnergy >= 0.0 ) {
81
coupledTransport->SetThresholdImportantEnergy(
m_config
.ImportantEnergy );
82
ATH_MSG_INFO
(
"Set ImportantEnergy to "
<<
m_config
.ImportantEnergy);
83
84
}
85
else
86
ATH_MSG_WARNING
(
"Invalid ImportantEnergy: "
<<
m_config
.ImportantEnergy);
87
if
(
m_config
.NumberOfTrials > 0 ) {
88
coupledTransport->SetThresholdTrials(
m_config
.NumberOfTrials );
89
ATH_MSG_INFO
(
"Set NumberOfTrials to "
<<
m_config
.NumberOfTrials);
90
91
}
92
else
93
ATH_MSG_WARNING
(
"Invalid NumberOfTrials: "
<<
m_config
.NumberOfTrials);
94
// Geant4 printout
95
#if G4VERSION_NUMBER > 1049
96
coupledTransport->ReportLooperThresholds();
97
#endif
98
}
99
}
100
101
std::pair<G4Transportation*, G4CoupledTransportation*>
102
LooperThresholdSet::findTransportation
(
const
G4ParticleDefinition* particleDef )
103
{
104
const
auto
*partPM = particleDef->GetProcessManager();
105
106
G4VProcess* partTransport = partPM->GetProcess(
"Transportation"
);
107
auto
transport =
dynamic_cast<
G4Transportation*
>
(partTransport);
108
109
partTransport = partPM->GetProcess(
"CoupledTransportation"
);
110
auto
coupledTransport=
111
dynamic_cast<
G4CoupledTransportation*
>
(partTransport);
112
113
return
std::make_pair( transport, coupledTransport );
114
}
115
116
}
// namespace G4UA
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
LooperThresholdSet.h
AthMessaging::AthMessaging
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Definition
AthMessaging.cxx:13
G4UA::LooperThresholdSet::ChangeLooperParameters
void ChangeLooperParameters(const G4ParticleDefinition *particleDef)
Definition
LooperThresholdSet.cxx:33
G4UA::LooperThresholdSet::BeginOfRunAction
virtual void BeginOfRunAction(const G4Run *aRun) override
Definition
LooperThresholdSet.cxx:28
G4UA::LooperThresholdSet::m_config
Config m_config
Definition
LooperThresholdSet.h:36
G4UA::LooperThresholdSet::LooperThresholdSet
LooperThresholdSet()
G4UA::LooperThresholdSet::findTransportation
std::pair< G4Transportation *, G4CoupledTransportation * > findTransportation(const G4ParticleDefinition *particleDef, bool reportError)
G4UA
for nSW
Definition
CalibrationDefaultProcessing.h:19
Gaudi
=============================================================================
Definition
CaloGPUClusterAndCellDataMonitorOptions.h:273
G4UA::LooperThresholdSet::Config
Definition
LooperThresholdSet.h:25
Generated on
for ATLAS Offline Software by
1.17.0