ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Atlas
G4AtlasTools
src
RegionCreator.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
// Base class
6
#include "
G4AtlasTools/RegionCreator.h
"
7
8
// Geant4 includes used in functions
9
10
#include "G4LogicalVolume.hh"
11
#include "G4LogicalVolumeStore.hh"
12
#include "G4Region.hh"
13
#include "G4ProductionCuts.hh"
14
15
RegionCreator::RegionCreator
(
const
std::string&
type
,
const
std::string& name,
const
IInterface* parent)
16
: base_class(
type
,name,parent)
17
{
18
}
19
20
// Athena method, called at initialization time
21
StatusCode
RegionCreator::initialize
()
22
{
23
ATH_MSG_VERBOSE
(
" initializing RegionCreator "
<<name() );
24
if
(
m_regionName
.empty()) {
25
m_regionName
= this->name();
26
// re-initialize m_regionName in order to take the real tool name rather than the path to it
27
size_t
ipos=
m_regionName
.value().find_last_of(
'.'
);
28
size_t
length
=
m_regionName
.value().size();
29
if
(ipos<
length
) {
30
ATH_MSG_VERBOSE
(
"m_regionName: "
<<
m_regionName
.value() <<
" needs to be reset."
);
31
m_regionName
=
m_regionName
.value().substr(ipos+1,
length
-ipos-1);
32
}
33
ATH_MSG_VERBOSE
(
"m_regionName default value reset to "
<<
m_regionName
.value());
34
}
35
return
StatusCode::SUCCESS;
36
}
37
38
void
RegionCreator::Construct
()
39
{
40
//create a new G4Region
41
G4Region* theRegion=
new
G4Region(
m_regionName
.value());
42
43
// loop over volumes and fish for those in the list
44
size_t
nVolumes{0};
45
G4LogicalVolumeStore* logStore=G4LogicalVolumeStore::GetInstance();
46
for
(
const
auto
& vol:
m_logicalVolumes
) {
47
size_t
nVolumesCurrent{0};
48
for
(
auto
* it: *logStore)
49
{
50
51
if
(vol ==
static_cast<
const
std::string&
>
(it->GetName()))
52
{
53
nVolumesCurrent++;
54
it->SetRegion(theRegion);
55
theRegion->AddRootLogicalVolume(it);
56
}
57
}
58
if
(nVolumesCurrent==0) {
59
ATH_MSG_WARNING
(
"No volumes matching \""
<< vol <<
"\" found in G4 LogicalVolumeStore. "
<<
m_regionName
.value() <<
" G4PhysicsRegion may not behave as intended."
);
60
}
61
nVolumes += nVolumesCurrent;
62
}
63
64
if
(
m_dumpRegion
) {
ATH_MSG_INFO
(
"A total of "
<<nVolumes<<
" volumes was assigned to region "
<<
m_regionName
.value() ); }
65
66
// create a G4ProductionCuts object and set appropriate values
67
G4ProductionCuts* cuts=
new
G4ProductionCuts();
68
cuts->SetProductionCut(
m_gammaCut
,
"gamma"
);
69
cuts->SetProductionCut(
m_electronCut
,
"e-"
);
70
cuts->SetProductionCut(
m_positronCut
,
"e+"
);
71
cuts->SetProductionCut(
m_protonCut
,
"proton"
);
72
73
// assign cuts to the region and return succesfully
74
theRegion->SetProductionCuts(cuts);
75
76
if
(
m_dumpRegion
) {
Dump
(); }
77
}
78
79
void
RegionCreator::Dump
()
80
{
81
ATH_MSG_INFO
(
"+----------------------------------------------------+"
);
82
ATH_MSG_INFO
(
" "
);
83
ATH_MSG_INFO
(
" Dump of region "
<<
m_regionName
.value());
84
ATH_MSG_INFO
(
" Volumes being assigned to this region:"
);
85
for
(
const
auto
& vol:
m_logicalVolumes
)
86
{
87
ATH_MSG_INFO
(
" "
<<vol);
88
}
89
ATH_MSG_INFO
(
" "
);
90
ATH_MSG_INFO
(
" Cuts selected for this region:"
);
91
ATH_MSG_INFO
(
" Gamma ="
<<
m_gammaCut
);
92
ATH_MSG_INFO
(
" Electron ="
<<
m_electronCut
);
93
ATH_MSG_INFO
(
" Positron ="
<<
m_positronCut
);
94
ATH_MSG_INFO
(
" Proton ="
<<
m_protonCut
);
95
ATH_MSG_INFO
(
" "
);
96
ATH_MSG_INFO
(
"+----------------------------------------------------+"
);
97
}
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
length
double length(const pvec &v)
Definition
FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
RegionCreator.h
RegionCreator::Construct
void Construct() override
Definition
RegionCreator.cxx:38
RegionCreator::m_regionName
Gaudi::Property< std::string > m_regionName
Definition
RegionCreator.h:38
RegionCreator::m_electronCut
Gaudi::Property< double > m_electronCut
Definition
RegionCreator.h:40
RegionCreator::initialize
virtual StatusCode initialize() override
Definition
RegionCreator.cxx:21
RegionCreator::m_logicalVolumes
Gaudi::Property< std::vector< std::string > > m_logicalVolumes
Definition
RegionCreator.h:43
RegionCreator::m_protonCut
Gaudi::Property< double > m_protonCut
Definition
RegionCreator.h:42
RegionCreator::Dump
void Dump() override
Definition
RegionCreator.cxx:79
RegionCreator::m_gammaCut
Gaudi::Property< double > m_gammaCut
Definition
RegionCreator.h:39
RegionCreator::m_dumpRegion
BooleanProperty m_dumpRegion
Definition
RegionCreator.h:44
RegionCreator::RegionCreator
RegionCreator(const std::string &type, const std::string &name, const IInterface *parent)
Definition
RegionCreator.cxx:15
RegionCreator::m_positronCut
Gaudi::Property< double > m_positronCut
Definition
RegionCreator.h:41
type
Generated on
for ATLAS Offline Software by
1.17.0