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
PHG4MvtxSubsystem.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file PHG4MvtxSubsystem.cc
1
#include "
PHG4MvtxSubsystem.h
"
2
3
#include "
PHG4MvtxDefs.h
"
4
#include "
PHG4MvtxDetector.h
"
5
#include "
PHG4MvtxDisplayAction.h
"
6
#include "
PHG4MvtxSteppingAction.h
"
7
8
#include <
mvtx/SegmentationAlpide.h
>
// for Alpide constants
9
10
#include <phparameter/PHParameters.h>
11
#include <phparameter/PHParametersContainer.h>
12
13
#include <
g4detectors/PHG4DetectorGroupSubsystem.h
>
// for PHG4DetectorGrou...
14
15
#include <
g4main/PHG4DisplayAction.h
>
// for PHG4DisplayAction
16
#include <
g4main/PHG4HitContainer.h
>
17
#include <
g4main/PHG4SteppingAction.h
>
// for PHG4SteppingAction
18
19
#include <
phool/PHCompositeNode.h
>
20
#include <
phool/PHIODataNode.h
>
// for PHIODataNode
21
#include <
phool/PHNode.h
>
// for PHNode
22
#include <
phool/PHNodeIterator.h
>
// for PHNodeIterator
23
#include <
phool/PHObject.h
>
// for PHObject
24
#include <
phool/getClass.h
>
25
#include <
phool/phool.h
>
// for PHWHERE
26
27
#include <cstdlib>
// for getenv
28
#include <iostream>
// for operator<<, basi...
29
#include <set>
// for _Rb_tree_const_i...
30
#include <sstream>
31
#include <utility>
// for pair
32
33
class
PHG4Detector
;
34
35
//_______________________________________________________________________
36
PHG4MvtxSubsystem::PHG4MvtxSubsystem
(
const
std::string
&
name
,
const
int
_n_layers)
37
:
PHG4DetectorGroupSubsystem
(name)
38
, n_layers(_n_layers)
39
, detector_type(name)
40
{
41
for
(
unsigned
int
iLyr = 0; iLyr <
n_layers
; ++iLyr)
42
{
43
AddDetId
(iLyr);
44
}
45
46
InitializeParameters
();
47
48
// put the layers into name so we get unique names
49
// for multiple layers
50
Name
(name);
51
SuperDetector
(name);
52
}
53
54
//_______________________________________________________________________
55
PHG4MvtxSubsystem::~PHG4MvtxSubsystem
()
56
{
57
delete
m_DisplayAction
;
58
}
59
60
//_______________________________________________________________________
61
int
PHG4MvtxSubsystem::InitRunSubsystem
(
PHCompositeNode
*
topNode
)
62
{
63
if
(
Verbosity
() > 0)
64
{
65
std::cout <<
"PHG4MvtxSubsystem::Init started"
<< std::endl;
66
}
67
68
PHNodeIterator
iter(topNode);
69
PHCompositeNode
* dstNode =
dynamic_cast<
PHCompositeNode
*
>
(iter.
findFirst
(
"PHCompositeNode"
,
"DST"
));
70
71
// create display settings before detector (detector adds its volumes to it)
72
m_DisplayAction
=
new
PHG4MvtxDisplayAction
(
Name
());
73
// create detector
74
// These values are set from the calling macro using the setters defined in the .h file
75
if
(
Verbosity
())
76
{
77
std::cout <<
" create Mvtx detector with "
<<
n_layers
<<
" layers."
<< std::endl;
78
}
79
m_Detector
=
new
PHG4MvtxDetector
(
this
, topNode,
GetParamsContainer
(),
Name
());
80
m_Detector
->
Verbosity
(
Verbosity
());
81
m_Detector
->
SuperDetector
(
SuperDetector
());
82
m_Detector
->
Detector
(
detector_type
);
83
m_Detector
->
OverlapCheck
(
CheckOverlap
());
84
if
(
Verbosity
())
85
{
86
std::cout <<
" ------ created detector "
<<
Name
() << std::endl;
87
GetParamsContainer
()->
Print
();
88
}
89
// loop all layer to find atleast one active layer
90
int
active
= 0;
91
int
supportactive = 0;
92
int
blackhole = 0;
93
for
(std::set<int>::const_iterator parContainerIter =
GetDetIds
().first; parContainerIter !=
GetDetIds
().second; ++parContainerIter)
94
{
95
if
(active ||
GetParamsContainer
()->
GetParameters
(*parContainerIter)->
get_int_param
(
"active"
))
96
{
97
active = 1;
98
}
99
if
(supportactive ||
GetParamsContainer
()->
GetParameters
(*parContainerIter)->
get_int_param
(
"supportactive"
))
100
{
101
supportactive = 1;
102
}
103
if
(blackhole ||
GetParamsContainer
()->
GetParameters
(*parContainerIter)->
get_int_param
(
"blackhole"
))
104
{
105
blackhole = 1;
106
}
107
}
108
if
(active)
109
{
110
std::set<std::string> nodes;
111
PHNodeIterator
dstIter(dstNode);
112
PHCompositeNode
* detNode = dstNode;
113
if
(
SuperDetector
() !=
"NONE"
&& !
SuperDetector
().empty())
114
{
115
detNode =
dynamic_cast<
PHCompositeNode
*
>
(dstIter.
findFirst
(
"PHCompositeNode"
,
SuperDetector
()));
116
if
(!detNode)
117
{
118
detNode =
new
PHCompositeNode
(
SuperDetector
());
119
dstNode->
addNode
(detNode);
120
}
121
}
122
123
std::string
detector_suffix =
SuperDetector
();
124
if
(detector_suffix ==
"NONE"
|| detector_suffix.empty())
125
{
126
detector_suffix =
Name
();
127
}
128
129
m_HitNodeName
=
"G4HIT_"
+ detector_suffix;
130
nodes.insert(
m_HitNodeName
);
131
m_SupportNodeName
=
"G4HIT_SUPPORT_"
+ detector_suffix;
132
if
(supportactive)
133
{
134
nodes.insert(
m_SupportNodeName
);
135
}
136
for
(
const
auto
& nodename : nodes)
137
{
138
PHG4HitContainer
* g4_hits = findNode::getClass<PHG4HitContainer>(
topNode
, nodename);
139
if
(!g4_hits)
140
{
141
g4_hits =
new
PHG4HitContainer
(nodename);
142
if
(
Verbosity
())
143
{
144
std::cout <<
PHWHERE
<<
"creating hits node "
<< nodename << std::endl;
145
}
146
detNode->
addNode
(
new
PHIODataNode<PHObject>
(g4_hits, nodename,
"PHObject"
));
147
}
148
}
149
150
// create stepping action
151
m_SteppingAction
=
new
PHG4MvtxSteppingAction
(
m_Detector
,
GetParamsContainer
());
152
m_SteppingAction
->
SetHitNodeName
(
"G4HIT"
,
m_HitNodeName
);
153
m_SteppingAction
->
SetHitNodeName
(
"G4HIT_SUPPORT"
,
m_SupportNodeName
);
154
m_SteppingAction
->
Verbosity
(
Verbosity
());
155
}
156
else
157
{
158
if
(blackhole)
159
{
160
m_SteppingAction
=
new
PHG4MvtxSteppingAction
(
m_Detector
,
GetParamsContainer
());
161
}
162
}
163
return
0;
164
}
165
166
//_______________________________________________________________________
167
int
PHG4MvtxSubsystem::process_event
(
PHCompositeNode
*
topNode
)
168
{
169
// pass top node to stepping action so that it gets
170
// relevant nodes needed internally
171
if
(
m_SteppingAction
)
172
{
173
m_SteppingAction
->
SetInterfacePointers
(topNode);
174
}
175
return
0;
176
}
177
178
//_______________________________________________________________________
179
PHG4Detector
*
PHG4MvtxSubsystem::GetDetector
()
const
180
{
181
return
m_Detector
;
182
}
183
184
//_______________________________________________________________________
185
void
PHG4MvtxSubsystem::SetDefaultParameters
()
186
{
187
for
(std::set<int>::const_iterator lyr_it =
GetDetIds
().first; lyr_it !=
GetDetIds
().second; ++lyr_it)
188
{
189
const
int
& ilyr = *lyr_it;
190
const
double
rLr =
PHG4MvtxDefs::mvtxdat
[ilyr][
PHG4MvtxDefs::kRmd
];
191
double
turbo =
radii2Turbo
(
PHG4MvtxDefs::mvtxdat
[ilyr][
PHG4MvtxDefs::kRmn
], rLr,
PHG4MvtxDefs::mvtxdat
[ilyr][
PHG4MvtxDefs::kRmx
],
SegmentationAlpide::SensorSizeRows
* 10.);
192
193
set_default_int_param
(ilyr,
"active"
, 1);
// non-automatic initialization in PHG4DetectorGroupSubsystem
194
set_default_int_param
(ilyr,
"layer"
, ilyr);
195
set_default_int_param
(ilyr,
"N_staves"
,
PHG4MvtxDefs::mvtxdat
[ilyr][
PHG4MvtxDefs::kNStave
]);
196
197
set_default_double_param
(ilyr,
"layer_nominal_radius"
, rLr);
198
set_default_double_param
(ilyr,
"phitilt"
, turbo);
199
set_default_double_param
(ilyr,
"phi0"
,
PHG4MvtxDefs::mvtxdat
[ilyr][
PHG4MvtxDefs::kPhi0
]);
200
set_default_string_param
(ilyr,
"material"
,
"G4_AIR"
);
// default - almost nothing
201
}
202
203
set_default_string_param
(
PHG4MvtxDefs::GLOBAL
,
"stave_geometry_file"
,
"ITS.gdml"
);
// default - almost nothing
204
char
* calibrationsroot = getenv(
"CALIBRATIONROOT"
);
205
std::string
end_wheels_sideS =
"ITS_ibEndWheelSideA.gdml"
;
206
std::string
end_wheels_sideN =
"ITS_ibEndWheelSideC.gdml"
;
207
if
(calibrationsroot !=
nullptr
)
208
{
209
end_wheels_sideS =
std::string
(calibrationsroot) +
std::string
(
"/Tracking/geometry/"
) + end_wheels_sideS;
210
end_wheels_sideN =
std::string
(calibrationsroot) +
std::string
(
"/Tracking/geometry/"
) + end_wheels_sideN;
211
}
212
}
coresoftware
blob
master
simulation
g4simulation
g4mvtx
PHG4MvtxSubsystem.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:16
using
1.8.2 with
sPHENIX GitHub integration