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
PHG4IHCalSubsystem.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file PHG4IHCalSubsystem.cc
1
#include "
PHG4IHCalSubsystem.h
"
2
3
#include "
PHG4IHCalDetector.h
"
4
#include "
PHG4IHCalDisplayAction.h
"
5
#include "
PHG4IHCalSteppingAction.h
"
6
7
#include <
g4detectors/PHG4DetectorSubsystem.h
>
// for PHG4DetectorSubsystem
8
#include <
g4detectors/PHG4HcalDefs.h
>
9
10
#include <phparameter/PHParameters.h>
11
12
#include <
g4main/PHG4DisplayAction.h
>
// for PHG4DisplayAction
13
#include <
g4main/PHG4HitContainer.h
>
14
#include <
g4main/PHG4SteppingAction.h
>
// for PHG4SteppingAction
15
16
#include <
phool/PHCompositeNode.h
>
17
#include <
phool/PHIODataNode.h
>
// for PHIODataNode
18
#include <
phool/PHNode.h
>
// for PHNode
19
#include <
phool/PHNodeIterator.h
>
// for PHNodeIterator
20
#include <
phool/PHObject.h
>
// for PHObject
21
#include <
phool/getClass.h
>
22
23
24
#include <cmath>
// for NAN
25
#include <iostream>
// for operator<<, basic_ostream
26
#include <set>
27
28
class
PHG4Detector
;
29
30
//_______________________________________________________________________
31
PHG4IHCalSubsystem::PHG4IHCalSubsystem
(
const
std::string
&
name
,
const
int
lyr)
32
:
PHG4DetectorSubsystem
(name, lyr)
33
{
34
InitializeParameters
();
35
}
36
37
//_______________________________________________________________________
38
PHG4IHCalSubsystem::~PHG4IHCalSubsystem
()
39
{
40
delete
m_DisplayAction
;
41
}
42
43
//_______________________________________________________________________
44
int
PHG4IHCalSubsystem::InitRunSubsystem
(
PHCompositeNode
*
topNode
)
45
{
46
PHNodeIterator
iter(topNode);
47
PHCompositeNode
*dstNode =
dynamic_cast<
PHCompositeNode
*
>
(iter.
findFirst
(
"PHCompositeNode"
,
"DST"
));
48
49
// create display settings before detector
50
m_DisplayAction
=
new
PHG4IHCalDisplayAction
(
Name
());
51
52
// create detector
53
m_Detector
=
new
PHG4IHCalDetector
(
this
, topNode,
GetParams
(),
Name
());
54
m_Detector
->
SuperDetector
(
SuperDetector
());
55
m_Detector
->
OverlapCheck
(
CheckOverlap
());
56
std::set<std::string> nodes;
57
if
(
GetParams
()->
get_int_param
(
"active"
))
58
{
59
PHNodeIterator
dstIter(dstNode);
60
PHCompositeNode
*DetNode = dstNode;
61
62
if
(
SuperDetector
() !=
"NONE"
&& !
SuperDetector
().empty())
63
{
64
PHNodeIterator
iter_dst(dstNode);
65
DetNode =
dynamic_cast<
PHCompositeNode
*
>
(iter_dst.
findFirst
(
"PHCompositeNode"
,
SuperDetector
()));
66
67
if
(!DetNode)
68
{
69
DetNode =
new
PHCompositeNode
(
SuperDetector
());
70
dstNode->
addNode
(DetNode);
71
}
72
}
73
std::string
detector_suffix =
SuperDetector
();
74
if
(detector_suffix ==
"NONE"
|| detector_suffix.empty())
75
{
76
detector_suffix =
Name
();
77
}
78
79
m_HitNodeName
=
"G4HIT_"
+ detector_suffix;
80
nodes.insert(
m_HitNodeName
);
81
m_AbsorberNodeName
=
"G4HIT_ABSORBER_"
+ detector_suffix;
82
if
(
GetParams
()->
get_int_param
(
"absorberactive"
))
83
{
84
nodes.insert(
m_AbsorberNodeName
);
85
}
86
for
(
const
auto
&nodename : nodes)
87
{
88
PHG4HitContainer
*g4_hits = findNode::getClass<PHG4HitContainer>(
topNode
, nodename);
89
if
(!g4_hits)
90
{
91
g4_hits =
new
PHG4HitContainer
(nodename);
92
DetNode->
addNode
(
new
PHIODataNode<PHObject>
(g4_hits, nodename,
"PHObject"
));
93
}
94
}
95
96
// create stepping action
97
m_SteppingAction
=
new
PHG4IHCalSteppingAction
(
m_Detector
,
GetParams
());
98
m_SteppingAction
->
InitWithNode
(topNode);
99
m_SteppingAction
->
SetHitNodeName
(
"G4HIT"
,
m_HitNodeName
);
100
m_SteppingAction
->
SetHitNodeName
(
"G4HIT_ABSORBER"
,
m_AbsorberNodeName
);
101
}
102
else
103
{
104
// if this is a black hole it does not have to be active
105
if
(
GetParams
()->
get_int_param
(
"blackhole"
))
106
{
107
m_SteppingAction
=
new
PHG4IHCalSteppingAction
(
m_Detector
,
GetParams
());
108
m_SteppingAction
->
InitWithNode
(topNode);
109
}
110
}
111
return
0;
112
}
113
114
//_______________________________________________________________________
115
int
PHG4IHCalSubsystem::process_event
(
PHCompositeNode
*
topNode
)
116
{
117
// pass top node to stepping action so that it gets
118
// relevant nodes needed internally
119
if
(
m_SteppingAction
)
120
{
121
m_SteppingAction
->
SetInterfacePointers
(topNode);
122
}
123
return
0;
124
}
125
126
void
PHG4IHCalSubsystem::Print
(
const
std::string
&what)
const
127
{
128
std::cout <<
Name
() <<
" Parameters: "
<< std::endl;
129
GetParams
()->
Print
();
130
if
(
m_Detector
)
131
{
132
m_Detector
->
Print
(what);
133
}
134
if
(
m_SteppingAction
)
135
{
136
m_SteppingAction
->
Print
(what);
137
}
138
139
return
;
140
}
141
142
//_______________________________________________________________________
143
PHG4Detector
*
PHG4IHCalSubsystem::GetDetector
()
const
144
{
145
return
m_Detector
;
146
}
147
148
void
PHG4IHCalSubsystem::SetDefaultParameters
()
149
{
150
set_default_double_param
(
PHG4HcalDefs::innerrad
, 115);
151
set_default_double_param
(
"light_balance_inner_corr"
, NAN);
152
set_default_double_param
(
"light_balance_inner_radius"
, NAN);
153
set_default_double_param
(
"light_balance_outer_corr"
, NAN);
154
set_default_double_param
(
"light_balance_outer_radius"
, NAN);
155
set_default_double_param
(
"phistart"
, NAN);
156
set_default_double_param
(
"scinti_eta_coverage_neg"
, 1.1);
157
set_default_double_param
(
"scinti_eta_coverage_pos"
, 1.1);
158
set_default_double_param
(
PHG4HcalDefs::outerrad
, 274.010 / 2 + 3);
159
set_default_double_param
(
"place_x"
, 0.);
160
set_default_double_param
(
"place_y"
, 0.);
161
set_default_double_param
(
"place_z"
, 0.);
162
set_default_double_param
(
"rot_x"
, 0.);
163
set_default_double_param
(
"rot_y"
, 180.);
164
set_default_double_param
(
"rot_z"
, 0.);
165
set_default_double_param
(
"size_z"
, 435.000 + 10 );
166
set_default_double_param
(
"Birk_const"
, 0.07943);
167
set_default_double_param
(
"tmin"
, -20.);
168
set_default_double_param
(
"tmax"
, 60.);
169
set_default_double_param
(
"dt"
, 100.);
170
171
172
set_default_int_param
(
"light_scint_model"
, 1);
173
set_default_int_param
(
PHG4HcalDefs::n_towers
, 64);
174
set_default_int_param
(
PHG4HcalDefs::scipertwr
, 4);
175
set_default_int_param
(
PHG4HcalDefs::n_scinti_tiles
, 12);
176
set_default_int_param
(
"etabins"
, 24);
177
set_default_int_param
(
"saveg4hit"
, 1);
178
179
180
set_default_string_param
(
"GDMPath"
,
"DefaultParameters-InvadPath"
);
181
const
char
* Calibroot = getenv(
"CALIBRATIONROOT"
);
182
std::string
defaultmapfilename;
183
if
(Calibroot)
184
{
185
defaultmapfilename = Calibroot;
186
defaultmapfilename +=
"/HCALIN/tilemap/ihcalgdmlmap09212022.root"
;
187
}
188
set_default_string_param
(
"MapFileName"
, defaultmapfilename);
189
set_default_string_param
(
"MapHistoName"
,
"ihcalcombinedgdmlnormtbyt"
);
190
}
191
192
void
PHG4IHCalSubsystem::SetLightCorrection
(
const
double
inner_radius
,
const
double
inner_corr,
const
double
outer_radius
,
const
double
outer_corr)
193
{
194
set_double_param
(
"light_balance_inner_corr"
, inner_corr);
195
set_double_param
(
"light_balance_inner_radius"
, inner_radius);
196
set_double_param
(
"light_balance_outer_corr"
, outer_corr);
197
set_double_param
(
"light_balance_outer_radius"
, outer_radius);
198
return
;
199
}
coresoftware
blob
master
simulation
g4simulation
g4ihcal
PHG4IHCalSubsystem.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:14
using
1.8.2 with
sPHENIX GitHub integration