Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
PHG4ZDCSubsystem.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file PHG4ZDCSubsystem.cc
1
#include "
PHG4ZDCSubsystem.h
"
2
3
#include "
PHG4ZDCDetector.h
"
4
#include "
PHG4ZDCDisplayAction.h
"
5
#include "
PHG4ZDCSteppingAction.h
"
6
7
#include <phparameter/PHParameters.h>
8
9
#include <
g4main/PHG4DisplayAction.h
>
// for PHG4DisplayAction
10
#include <
g4main/PHG4HitContainer.h
>
11
#include <
g4main/PHG4SteppingAction.h
>
// for PHG4SteppingAction
12
13
#include <
phool/PHCompositeNode.h
>
14
#include <
phool/PHIODataNode.h
>
// for PHIODataNode
15
#include <
phool/PHNode.h
>
// for PHNode
16
#include <
phool/PHNodeIterator.h
>
// for PHNodeIterator
17
#include <
phool/PHObject.h
>
// for PHObject
18
#include <
phool/getClass.h
>
19
20
#include <fstream>
21
#include <set>
// for set
22
#include <sstream>
23
24
class
PHG4Detector
;
25
26
//_______________________________________________________________________
27
PHG4ZDCSubsystem::PHG4ZDCSubsystem
(
const
std::string
&
name
,
const
int
lyr)
28
:
PHG4DetectorSubsystem
(name, lyr)
29
{
30
InitializeParameters
();
31
}
32
33
//_______________________________________________________________________
34
PHG4ZDCSubsystem::~PHG4ZDCSubsystem
()
35
{
36
delete
m_DisplayAction
;
37
}
38
39
//_______________________________________________________________________
40
int
PHG4ZDCSubsystem::InitRunSubsystem
(
PHCompositeNode
*
topNode
)
41
{
42
PHNodeIterator
iter(topNode);
43
PHCompositeNode
* dstNode =
dynamic_cast<
PHCompositeNode
*
>
(iter.
findFirst
(
"PHCompositeNode"
,
"DST"
));
44
45
// create display settings before detector
46
m_DisplayAction
=
new
PHG4ZDCDisplayAction
(
Name
());
47
// create detector
48
m_Detector
=
new
PHG4ZDCDetector
(
this
, topNode,
GetParams
(),
Name
(),
GetLayer
());
49
50
m_Detector
->
SuperDetector
(
SuperDetector
());
51
m_Detector
->
OverlapCheck
(
CheckOverlap
());
52
m_Detector
->
Verbosity
(
Verbosity
());
53
54
if
(
GetParams
()->
get_int_param
(
"active"
))
55
{
56
std::set<std::string> nodes;
57
PHNodeIterator
dstIter(dstNode);
58
PHCompositeNode
* DetNode = dstNode;
59
if
(
SuperDetector
() !=
"NONE"
&& !
SuperDetector
().empty())
60
{
61
PHNodeIterator
iter_dst(dstNode);
62
DetNode =
dynamic_cast<
PHCompositeNode
*
>
(iter_dst.
findFirst
(
"PHCompositeNode"
,
SuperDetector
()));
63
64
if
(!DetNode)
65
{
66
DetNode =
new
PHCompositeNode
(
SuperDetector
());
67
dstNode->
addNode
(DetNode);
68
}
69
}
70
// create hit output nodes
71
std::string
detector_suffix =
SuperDetector
();
72
if
(detector_suffix ==
"NONE"
|| detector_suffix.empty())
73
{
74
detector_suffix =
Name
();
75
}
76
77
m_HitNodeName
=
"G4HIT_"
+ detector_suffix;
78
nodes.insert(
m_HitNodeName
);
79
m_AbsorberNodeName
=
"G4HIT_ABSORBER_"
+ detector_suffix;
80
if
(
GetParams
()->
get_int_param
(
"absorberactive"
))
81
{
82
nodes.insert(
m_AbsorberNodeName
);
83
}
84
m_SupportNodeName
=
"G4HIT_SUPPORT_"
+ detector_suffix;
85
if
(
GetParams
()->
get_int_param
(
"supportactive"
))
86
{
87
nodes.insert(
m_SupportNodeName
);
88
}
89
90
for
(
const
auto
& nodename : nodes)
91
{
92
PHG4HitContainer
* g4_hits = findNode::getClass<PHG4HitContainer>(
topNode
, nodename);
93
if
(!g4_hits)
94
{
95
g4_hits =
new
PHG4HitContainer
(nodename);
96
DetNode->
addNode
(
new
PHIODataNode<PHObject>
(g4_hits, nodename,
"PHObject"
));
97
}
98
}
99
// create stepping action
100
m_SteppingAction
=
new
PHG4ZDCSteppingAction
(
m_Detector
,
GetParams
());
101
m_SteppingAction
->
SetHitNodeName
(
"G4HIT"
,
m_HitNodeName
);
102
m_SteppingAction
->
SetHitNodeName
(
"G4HIT_ABSORBER"
,
m_AbsorberNodeName
);
103
m_SteppingAction
->
SetHitNodeName
(
"G4HIT_SUPPORT"
,
m_SupportNodeName
);
104
}
105
else
if
(
GetParams
()->
get_int_param
(
"blackhole"
))
106
{
107
m_SteppingAction
=
new
PHG4ZDCSteppingAction
(
m_Detector
,
GetParams
());
108
}
109
return
0;
110
}
111
112
//_______________________________________________________________________
113
int
PHG4ZDCSubsystem::process_event
(
PHCompositeNode
*
topNode
)
114
{
115
// pass top node to stepping action so that it gets
116
// relevant nodes needed internally
117
if
(
m_SteppingAction
)
118
{
119
m_SteppingAction
->
SetInterfacePointers
(topNode);
120
}
121
return
0;
122
}
123
124
//_______________________________________________________________________
125
PHG4Detector
*
PHG4ZDCSubsystem::GetDetector
()
const
126
{
127
return
m_Detector
;
128
}
129
130
void
PHG4ZDCSubsystem::SetDefaultParameters
()
131
{
132
set_default_double_param
(
"place_x"
, 0.);
133
set_default_double_param
(
"place_y"
, 0.);
134
set_default_double_param
(
"place_z"
, 1843.0);
135
set_default_double_param
(
"rot_x"
, 0.);
136
set_default_double_param
(
"rot_y"
, 0.);
137
set_default_double_param
(
"rot_z"
, 0.);
138
return
;
139
}
coresoftware
blob
master
simulation
g4simulation
g4detectors
PHG4ZDCSubsystem.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:13
using
1.8.2 with
sPHENIX GitHub integration