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
DeadHotMapLoader.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file DeadHotMapLoader.cc
1
// $Id: $
2
11
#include "
DeadHotMapLoader.h
"
12
13
#include <calobase/RawTowerDeadMap.h>
14
#include <calobase/RawTowerDeadMapv1.h>
15
#include <calobase/RawTowerDefs.h>
16
#include <calobase/TowerInfoDefs.h>
17
18
#include <
cdbobjects/CDBTTree.h
>
19
20
#include <
ffamodules/CDBInterface.h
>
21
22
#include <
fun4all/Fun4AllReturnCodes.h
>
23
#include <
fun4all/SubsysReco.h
>
24
25
#include <
phool/PHCompositeNode.h
>
26
#include <
phool/PHIODataNode.h
>
27
#include <
phool/PHNode.h
>
28
#include <
phool/PHNodeIterator.h
>
29
#include <
phool/PHObject.h
>
30
#include <
phool/getClass.h
>
31
#include <
phool/phool.h
>
// for PHWHERE
32
33
#include <cassert>
34
#include <iostream>
35
#include <stdexcept>
36
#include <string>
37
38
DeadHotMapLoader::DeadHotMapLoader
(
const
std::string
&
detector
)
39
:
SubsysReco
(
"DeadHotMapLoader_"
+ detector)
40
, m_detector(detector)
41
{
42
}
43
44
int
DeadHotMapLoader::InitRun
(
PHCompositeNode
*topNode)
45
{
46
PHNodeIterator
iter(topNode);
47
PHCompositeNode
*runNode =
static_cast<
PHCompositeNode
*
>
(iter.
findFirst
(
48
"PHCompositeNode"
,
"RUN"
));
49
if
(!runNode)
50
{
51
std::cerr <<
Name
() <<
"::"
<<
m_detector
<<
"::"
<< __PRETTY_FUNCTION__
52
<<
"Run Node missing, doing nothing."
<< std::endl;
53
throw
std::runtime_error(
"Failed to find Run node in RawTowerCalibration::CreateNodes"
);
54
}
55
56
// Create the tower nodes on the tree
57
PHNodeIterator
dstiter(runNode);
58
PHCompositeNode
*DetNode =
dynamic_cast<
PHCompositeNode
*
>
(dstiter.
findFirst
(
"PHCompositeNode"
,
m_detector
));
59
if
(!DetNode)
60
{
61
DetNode =
new
PHCompositeNode
(
m_detector
);
62
runNode->
addNode
(DetNode);
63
}
64
65
// Be careful as a previous calibrator may have been registered for this detector
66
std::string
deadMapName =
"DEADMAP_"
+
m_detector
;
67
RawTowerDeadMap
*m_deadmap = findNode::getClass<RawTowerDeadMapv1>(DetNode, deadMapName);
68
if
(!m_deadmap)
69
{
70
const
RawTowerDefs::CalorimeterId
caloid =
RawTowerDefs::convert_name_to_caloid
(
m_detector
);
71
72
m_deadmap =
new
RawTowerDeadMapv1
(caloid);
73
PHIODataNode<PHObject>
*towerNode =
new
PHIODataNode<PHObject>
(m_deadmap, deadMapName,
"PHObject"
);
74
DetNode->addNode(towerNode);
75
}
76
77
// assert(m_deadmap);
78
79
std::string
url
=
CDBInterface::instance
()->
getUrl
(
m_detector
+
"_BadTowerMap"
);
80
if
(url.empty())
81
{
82
std::cout <<
PHWHERE
<<
" Could not get Dead Map for CDB. Detector: "
<<
m_detector
<< std::endl;
83
return
Fun4AllReturnCodes::ABORTRUN
;
84
}
85
86
m_CDBTTree
=
new
CDBTTree
(url);
87
88
if
(!
m_CDBTTree
)
89
{
90
std::cout <<
"No CDB TTree found from url "
<< url << std::endl;
91
return
Fun4AllReturnCodes::ABORTRUN
;
92
}
93
94
int
etabins;
95
int
phibins
;
96
97
if
(
m_detector
.c_str()[0] ==
'H'
)
98
{
//HCal towers
99
etabins = 24;
100
phibins = 64;
101
102
103
for
(
int
i
= 0;
i
< etabins*
phibins
;
i
++)
104
{
105
int
isDead =
m_CDBTTree
->
GetIntValue
(
i
,
"status"
);
106
if
(isDead > 0)
107
{
108
unsigned
int
key =
TowerInfoDefs::encode_hcal
(
i
);
109
int
ieta =
TowerInfoDefs::getCaloTowerEtaBin
(key);
110
int
iphi =
TowerInfoDefs::getCaloTowerPhiBin
(key);
111
m_deadmap->
addDeadTower
(ieta, iphi);
112
}
113
}
114
}
115
116
else
if
(
m_detector
.c_str()[0] ==
'C'
)
117
{
118
etabins = 96;
119
phibins = 256;
120
121
for
(
int
i
= 0;
i
< 96*256;
i
++)
122
{
123
int
isDead =
m_CDBTTree
->
GetIntValue
(
i
,
"status"
);
124
if
(isDead > 0)
125
{
126
unsigned
int
key =
TowerInfoDefs::encode_emcal
(
i
);
127
int
ieta =
TowerInfoDefs::getCaloTowerEtaBin
(key);
128
int
iphi =
TowerInfoDefs::getCaloTowerPhiBin
(key);
129
m_deadmap->
addDeadTower
(ieta, iphi);
130
}
131
}
132
}
133
134
135
if
(
Verbosity
())
136
{
137
std::cout <<
"DeadHotMapLoader::"
<<
m_detector
<<
"::InitRun - loading dead map completed : "
;
138
m_deadmap->
identify
();
139
}
140
return
Fun4AllReturnCodes::EVENT_OK
;
141
}
coresoftware
blob
master
offline
packages
CaloReco
DeadHotMapLoader.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:05
using
1.8.2 with
sPHENIX GitHub integration