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
CaloTowerStatus.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file CaloTowerStatus.cc
1
#include "
CaloTowerStatus.h
"
2
#include "
CaloTowerDefs.h
"
3
4
#include <calobase/TowerInfo.h>
// for TowerInfo
5
#include <calobase/TowerInfo.h>
6
#include <calobase/TowerInfoContainer.h>
7
#include <calobase/TowerInfoContainerv1.h>
8
#include <calobase/TowerInfoContainerv2.h>
9
#include <calobase/TowerInfov1.h>
10
#include <calobase/TowerInfov2.h>
11
12
#include <
cdbobjects/CDBTTree.h
>
// for CDBTTree
13
14
#include <
ffamodules/CDBInterface.h
>
15
16
#include <
ffaobjects/EventHeader.h
>
17
18
#include <
fun4all/Fun4AllReturnCodes.h
>
19
#include <
fun4all/SubsysReco.h
>
// for SubsysReco
20
21
#include <
phool/PHCompositeNode.h
>
22
#include <
phool/PHIODataNode.h
>
// for PHIODataNode
23
#include <
phool/PHNode.h
>
// for PHNode
24
#include <
phool/PHNodeIterator.h
>
// for PHNodeIterator
25
#include <
phool/PHObject.h
>
// for PHObject
26
#include <
phool/getClass.h
>
27
#include <
phool/phool.h
>
28
#include <
phool/recoConsts.h
>
29
30
#include <TSystem.h>
31
32
#include <cstdlib>
// for exit
33
#include <exception>
// for exception
34
#include <iostream>
// for operator<<, basic_ostream
35
#include <stdexcept>
// for runtime_error
36
37
//____________________________________________________________________________..
38
CaloTowerStatus::CaloTowerStatus
(
const
std::string
&
name
)
39
:
SubsysReco
(name)
40
{
41
if
(
Verbosity
() > 0)
42
{
43
std::cout <<
"CaloTowerStatus::CaloTowerStatus(const std::string &name) Calling ctor"
<< std::endl;
44
}
45
}
46
47
//____________________________________________________________________________..
48
CaloTowerStatus::~CaloTowerStatus
()
49
{
50
delete
m_cdbttree_chi2
;
51
delete
m_cdbttree_time
;
52
if
(
Verbosity
() > 0)
53
{
54
std::cout <<
"CaloTowerStatus::~CaloTowerStatus() Calling dtor"
<< std::endl;
55
}
56
}
57
58
//____________________________________________________________________________..
59
int
CaloTowerStatus::InitRun
(
PHCompositeNode
*topNode)
60
{
61
PHNodeIterator
nodeIter(topNode);
62
63
if
(
m_dettype
==
CaloTowerDefs::CEMC
)
64
{
65
m_detector
=
"CEMC"
;
66
}
67
else
if
(
m_dettype
==
CaloTowerDefs::HCALIN
)
68
{
69
m_detector
=
"HCALIN"
;
70
}
71
else
if
(
m_dettype
==
CaloTowerDefs::HCALOUT
)
72
{
73
m_detector
=
"HCALOUT"
;
74
}
75
else
if
(
m_dettype
==
CaloTowerDefs::ZDC
)
76
{
77
m_detector
=
"ZDC"
;
78
}
79
80
else
if
(
m_dettype
==
CaloTowerDefs::SEPD
)
81
{
82
m_detector
=
"SEPD"
;
83
}
84
85
m_calibName_chi2
=
m_detector
+
"_hotTowers_fracBadChi2"
;
86
m_fieldname_chi2
=
"fraction"
;
87
88
std::string
calibdir =
CDBInterface::instance
()->
getUrl
(
m_calibName_chi2
);
89
if
(!calibdir.empty())
90
{
91
m_cdbttree_chi2
=
new
CDBTTree
(calibdir);
92
}
93
else
94
{
95
std::cout <<
"CaloTowerStatus::::InitRun No masking file for domain "
<<
m_calibName_chi2
<<
" found, not doing isHot"
<< std::endl;
96
m_doHotChi2
=
false
;
97
}
98
99
m_calibName_time
=
m_detector
+
"_meanTime"
;
100
m_fieldname_time
=
"time"
;
101
102
calibdir =
CDBInterface::instance
()->
getUrl
(
m_calibName_time
);
103
if
(!calibdir.empty())
104
{
105
m_cdbttree_time
=
new
CDBTTree
(calibdir);
106
}
107
else
108
{
109
std::cout <<
"CaloTowerStatus::::InitRun no timing info, "
<<
m_calibName_time
<<
" not found, not doing isHot"
<< std::endl;
110
m_doTime
=
false
;
111
}
112
113
m_calibName_hotMap
=
m_detector
+
"nome"
;
114
if
(
m_dettype
==
CaloTowerDefs::CEMC
)
m_calibName_hotMap
=
m_detector
+
"_BadTowerMap"
;
115
m_fieldname_hotMap
=
"status"
;
116
117
calibdir =
CDBInterface::instance
()->
getUrl
(
m_calibName_hotMap
);
118
if
(!calibdir.empty())
119
{
120
m_cdbttree_hotMap
=
new
CDBTTree
(calibdir);
121
}
122
else
123
{
124
std::cout <<
"CaloTowerStatus::::InitRun hot map info, "
<<
m_calibName_hotMap
<<
" not found, not doing isHot"
<< std::endl;
125
m_doHotMap
=
false
;
126
}
127
128
129
PHNodeIterator
iter(topNode);
130
131
// Looking for the DST node
132
PHCompositeNode
*dstNode;
133
dstNode =
dynamic_cast<
PHCompositeNode
*
>
(iter.
findFirst
(
"PHCompositeNode"
,
"DST"
));
134
if
(!dstNode)
135
{
136
std::cout <<
Name
() <<
"::"
<<
m_detector
<<
"::"
<< __PRETTY_FUNCTION__
137
<<
"DST Node missing, doing nothing."
<< std::endl;
138
exit(1);
139
}
140
try
141
{
142
CreateNodeTree
(topNode);
143
}
144
catch
(std::exception &
e
)
145
{
146
std::cout << e.what() << std::endl;
147
return
Fun4AllReturnCodes::ABORTRUN
;
148
}
149
if
(
Verbosity
() > 0)
150
{
151
topNode->
print
();
152
}
153
return
Fun4AllReturnCodes::EVENT_OK
;
154
}
155
156
//____________________________________________________________________________..
157
int
CaloTowerStatus::process_event
(
PHCompositeNode
*
/*topNode*/
)
158
{
159
unsigned
int
ntowers =
m_raw_towers
->
size
();
160
float
fraction_badChi2 = 0;
161
float
mean_time = 0;
162
int
hotMap_val = 0;
163
for
(
unsigned
int
channel
= 0;
channel
< ntowers;
channel
++)
164
{
165
unsigned
int
key =
m_raw_towers
->
encode_key
(
channel
);
166
m_raw_towers
->
get_tower_at_channel
(
channel
)->
set_status
(0);
// resetting status
167
168
if
(
m_doHotChi2
)
169
{
170
fraction_badChi2 =
m_cdbttree_chi2
->
GetFloatValue
(key,
m_fieldname_chi2
);
171
}
172
if
(
m_doTime
)
173
{
174
mean_time =
m_cdbttree_time
->
GetFloatValue
(key,
m_fieldname_time
);
175
}
176
if
(
m_doHotMap
)
177
{
178
hotMap_val =
m_cdbttree_hotMap
->
GetIntValue
(key,
m_fieldname_hotMap
);
179
}
180
float
chi2 =
m_raw_towers
->
get_tower_at_channel
(
channel
)->
get_chi2
();
181
float
time
=
m_raw_towers
->
get_tower_at_channel
(
channel
)->
get_time_float
();
182
183
if
(fraction_badChi2 >
fraction_badChi2_threshold
&&
m_doHotChi2
)
184
{
185
m_raw_towers
->
get_tower_at_channel
(
channel
)->
set_isHot
(
true
);
186
}
187
if
(fabs(time-mean_time) >
time_cut
&&
m_doTime
)
188
{
189
m_raw_towers
->
get_tower_at_channel
(
channel
)->
set_isBadTime
(
true
);
190
}
191
if
(hotMap_val != 0 &&
m_doHotMap
)
192
{
193
m_raw_towers
->
get_tower_at_channel
(
channel
)->
set_isHot
(
true
);
194
}
195
if
(chi2 >
badChi2_treshold
)
196
{
197
m_raw_towers
->
get_tower_at_channel
(
channel
)->
set_isBadChi2
(
true
);
198
}
199
}
200
return
Fun4AllReturnCodes::EVENT_OK
;
201
}
202
203
void
CaloTowerStatus::CreateNodeTree
(
PHCompositeNode
*topNode)
204
{
205
std::string
RawTowerNodeName =
m_inputNodePrefix
+
m_detector
;
206
m_raw_towers
= findNode::getClass<TowerInfoContainer>(topNode, RawTowerNodeName);
207
if
(!
m_raw_towers
)
208
{
209
std::cout <<
Name
() <<
"::"
<< m_detector <<
"::"
<< __PRETTY_FUNCTION__
210
<<
" "
<< RawTowerNodeName <<
" Node missing, doing bail out!"
211
<< std::endl;
212
throw
std::runtime_error(
213
"Failed to find "
+ RawTowerNodeName +
" node in CaloTowerStatus::CreateNodes"
);
214
}
215
216
return
;
217
}
coresoftware
blob
master
offline
packages
CaloReco
CaloTowerStatus.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:05
using
1.8.2 with
sPHENIX GitHub integration