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
PHG4MicromegasSubsystem.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file PHG4MicromegasSubsystem.cc
1
6
#include "
PHG4MicromegasSubsystem.h
"
7
8
#include "
PHG4MicromegasDetector.h
"
9
#include "
PHG4MicromegasDisplayAction.h
"
10
#include "
PHG4MicromegasSteppingAction.h
"
11
12
#include <phparameter/PHParameters.h>
13
14
#include <
g4main/PHG4HitContainer.h
>
15
#include <
g4main/PHG4SteppingAction.h
>
16
17
#include <
phool/PHCompositeNode.h
>
18
#include <
phool/PHIODataNode.h
>
19
#include <
phool/PHNode.h
>
20
#include <
phool/PHNodeIterator.h
>
21
#include <
phool/PHObject.h
>
22
#include <
phool/getClass.h
>
23
24
//_______________________________________________________________________
25
PHG4MicromegasSubsystem::PHG4MicromegasSubsystem
(
const
std::string
&
name
,
int
layerno)
26
:
PHG4DetectorSubsystem
(name, layerno)
27
{
28
// call base class method which will set up parameter infrastructure
29
// and call our SetDefaultParameters() method
30
InitializeParameters
();
31
32
SuperDetector
(name);
33
}
34
35
//_______________________________________________________________________
36
PHG4MicromegasSubsystem::~PHG4MicromegasSubsystem
()
37
{
38
delete
m_DisplayAction
;
39
}
40
41
//_______________________________________________________________________
42
int
PHG4MicromegasSubsystem::InitRunSubsystem
(
PHCompositeNode
*topNode)
43
{
44
PHNodeIterator
iter(topNode);
45
auto
dstNode =
dynamic_cast<
PHCompositeNode
*
>
(iter.
findFirst
(
"PHCompositeNode"
,
"DST"
));
46
PHNodeIterator
dstIter(dstNode);
47
if
(
GetParams
()->
get_int_param
(
"active"
))
48
{
49
std::set<std::string> nodes;
50
auto
detNode =
dynamic_cast<
PHCompositeNode
*
>
(dstIter.
findFirst
(
"PHCompositeNode"
,
SuperDetector
()));
51
if
(!detNode)
52
{
53
detNode =
new
PHCompositeNode
(
SuperDetector
());
54
dstNode->addNode(detNode);
55
}
56
57
// create hit output nodes
58
std::string
detector_suffix =
SuperDetector
();
59
if
(detector_suffix ==
"NONE"
|| detector_suffix.empty())
60
{
61
detector_suffix =
Name
();
62
}
63
64
m_HitNodeName
=
"G4HIT_"
+ detector_suffix;
65
nodes.insert(
m_HitNodeName
);
66
m_SupportNodeName
=
"G4HIT_SUPPORT_"
+ detector_suffix;
67
if
(
GetParams
()->
get_int_param
(
"supportactive"
))
68
{
69
nodes.insert(
m_SupportNodeName
);
70
}
71
72
for
(
const
auto
&g4hitnodename : nodes)
73
{
74
auto
g4_hits = findNode::getClass<PHG4HitContainer>(detNode, g4hitnodename);
75
if
(!g4_hits)
76
{
77
g4_hits =
new
PHG4HitContainer
(g4hitnodename);
78
detNode->addNode(
new
PHIODataNode<PHObject>
(g4_hits, g4hitnodename,
"PHObject"
));
79
}
80
}
81
}
82
83
// create detector
84
m_DisplayAction
=
new
PHG4MicromegasDisplayAction
(
Name
());
85
m_Detector
=
new
PHG4MicromegasDetector
(
this
, topNode,
GetParams
(),
Name
());
86
m_Detector
->
set_first_layer
(
GetLayer
());
87
88
m_Detector
->
Verbosity
(
Verbosity
());
89
m_Detector
->
SuperDetector
(
SuperDetector
());
90
m_Detector
->
OverlapCheck
(
CheckOverlap
());
91
92
// create stepping action if detector is active
93
if
(
GetParams
()->
get_int_param
(
"active"
))
94
{
95
m_SteppingAction
=
new
PHG4MicromegasSteppingAction
(
m_Detector
,
GetParams
());
96
m_SteppingAction
->
SetHitNodeName
(
"G4HIT"
,
m_HitNodeName
);
97
m_SteppingAction
->
SetHitNodeName
(
"G4HIT_SUPPORT"
,
m_SupportNodeName
);
98
}
99
return
0;
100
}
101
102
//_______________________________________________________________________
103
int
PHG4MicromegasSubsystem::process_event
(
PHCompositeNode
*topNode)
104
{
105
// pass top node to stepping action so that it gets
106
// relevant nodes needed internally
107
if
(
m_SteppingAction
)
108
{
109
m_SteppingAction
->
SetInterfacePointers
(topNode);
110
}
111
return
0;
112
}
113
114
//_______________________________________________________________________
115
void
PHG4MicromegasSubsystem::Print
(
const
std::string
&what)
const
116
{
117
if
(
m_Detector
)
118
{
119
m_Detector
->
Print
(what);
120
}
121
}
122
123
//_______________________________________________________________________
124
PHG4Detector
*
PHG4MicromegasSubsystem::GetDetector
()
const
125
{
126
return
m_Detector
;
127
}
coresoftware
blob
master
simulation
g4simulation
g4micromegas
PHG4MicromegasSubsystem.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:15
using
1.8.2 with
sPHENIX GitHub integration