3 #include <calobase/RawTower.h>
4 #include <calobase/RawTowerContainer.h>
5 #include <calobase/RawTowerDeadMap.h>
6 #include <calobase/RawTowerDefs.h>
7 #include <calobase/RawTowerGeom.h>
8 #include <calobase/RawTowerGeomContainer.h>
9 #include <calobase/RawTowerv1.h>
33 , m_calibTowers(nullptr)
35 , m_deadTowerMap(nullptr)
37 , _calib_tower_node_prefix(
"CALIB")
51 cout <<
Name() <<
"::" <<
m_detector <<
"::" << __PRETTY_FUNCTION__
52 <<
"DST Node missing, doing nothing." << std::endl;
60 catch (std::exception &
e)
62 std::cout << e.what() << std::endl;
74 <<
"Process event entered" << std::endl;
77 double recovery_energy = 0;
98 <<
" - processing tower " << key;
103 if (towerGeom ==
nullptr)
107 <<
" - invalid dead tower ID " << key << endl;
117 cout <<
" bin " << bineta <<
"-" << binphi;
118 cout <<
". Add neighbors: ";
122 assert(bineta <= eta_bins);
124 assert(binphi <= phi_bins);
127 static const vector<pair<int, int>> neighborIndexs =
128 {{+1, 0}, {+1, +1}, {0, +1}, {-1, +1}, {-1, 0}, {-1, -1}, {0, -1}, {+1, -1}};
131 double E_SumNeighbor = 0;
132 for (
const pair<int, int> &neighborIndex : neighborIndexs)
134 int ieta = bineta + neighborIndex.first;
135 int iphi = binphi + neighborIndex.second;
137 if (ieta >= eta_bins)
continue;
138 if (ieta < 0)
continue;
140 if (iphi >= phi_bins) iphi -= phi_bins;
141 if (iphi < 0) iphi += phi_bins;
144 assert(ieta <= eta_bins);
146 assert(iphi <= phi_bins);
155 if (neighTower ==
nullptr)
continue;
159 cout << neighTower->
get_energy() <<
" (" << ieta <<
"-" << iphi <<
"), ";
166 if (n_neighbor > 0 and E_SumNeighbor != 0)
170 if (deadTower ==
nullptr)
176 deadTower->
set_energy(E_SumNeighbor / n_neighbor);
184 cout <<
" -> " << deadTower->
get_energy() <<
" GeV @ " << deadTower->
get_id();
192 cout <<
"No neighbor towers found.";
206 static bool once =
true;
214 <<
" - missing dead map node. Do nothing ..."
223 <<
"recovery_energy = " << recovery_energy
224 <<
" GeV from " << recoverTower <<
" towers out of total " << deadTowerCnt <<
" dead towers"
225 <<
", output sum energy = "
240 "PHCompositeNode",
"RUN"));
245 <<
"Run Node missing, doing nothing." << std::endl;
246 throw std::runtime_error(
247 "Failed to find Run node in RawTowerDeadTowerInterp::CreateNodes");
250 const string deadMapName =
"DEADMAP_" +
m_detector;
251 m_deadTowerMap = findNode::getClass<RawTowerDeadMap>(topNode, deadMapName);
256 <<
" use dead map: ";
260 const string geometry_node =
"TOWERGEOM_" +
m_detector;
261 m_geometry = findNode::getClass<RawTowerGeomContainer>(topNode, geometry_node);
266 <<
" " << geometry_node <<
" Node missing, doing bail out!"
268 throw std::runtime_error(
269 "Failed to find " + geometry_node +
" node in RawTowerDeadTowerInterp::CreateNodes");
278 "PHCompositeNode",
"DST"));
283 <<
"DST Node missing, doing nothing." << std::endl;
284 throw std::runtime_error(
285 "Failed to find DST node in RawTowerDeadTowerInterp::CreateNodes");
289 m_calibTowers = findNode::getClass<RawTowerContainer>(dstNode, rawTowerNodeName);
292 std::cerr <<
Name() <<
"::" << m_detector <<
"::" << __PRETTY_FUNCTION__
293 <<
" " << rawTowerNodeName <<
" Node missing, doing bail out!"
295 throw std::runtime_error(
296 "Failed to find " + rawTowerNodeName +
" node in RawTowerDeadTowerInterp::CreateNodes");