ATLAS Offline Software
Loading...
Searching...
No Matches
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
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
17namespace G4UA
18{
19
20//---------------------------------------------------------------------------
22 AthMessaging(Gaudi::svcLocator()->service<IMessageSvc>("MessageSvc"), "LooperThresholdSet"),
24{
25}
26
27//---------------------------------------------------------------------------
29{
30 ChangeLooperParameters( G4Electron::Electron() );
31}
32
33void 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
101std::pair<G4Transportation*, G4CoupledTransportation*>
102LooperThresholdSet::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
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
void ChangeLooperParameters(const G4ParticleDefinition *particleDef)
virtual void BeginOfRunAction(const G4Run *aRun) override
std::pair< G4Transportation *, G4CoupledTransportation * > findTransportation(const G4ParticleDefinition *particleDef, bool reportError)
=============================================================================