1 #ifndef RecoEcal_EgammaCoreTools_PositionCalc_h
2 #define RecoEcal_EgammaCoreTools_PositionCalc_h
45 template <
typename HitType>
64 template <
typename HitType>
74 if (
nullptr == iRecHits ||
nullptr == iSubGeom) {
75 throw cms::Exception(
"PositionCalc") <<
"Calculate_Location() called uninitialized or wrong initialization.";
78 if (!iDetIds.empty() && !iRecHits->
empty()) {
80 detIds.reserve(iDetIds.size());
87 typename HitTypeCollection::const_iterator endRecHits(iRecHits->
end());
88 HitsAndFractions::const_iterator
n, endDiDs(iDetIds.end());
89 for (
n = iDetIds.begin();
n != endDiDs; ++
n) {
90 const DetId dId((*n).first);
91 const float frac((*n).second);
93 typename HitTypeCollection::const_iterator iHit(iRecHits->
find(dId));
94 if (iHit != endRecHits) {
96 detIds.push_back(std::make_pair(dId,
energy));
109 LogDebug(
"ZeroClusterEnergy") <<
"cluster with 0 energy: " << eTot <<
" size: " << detIds.size()
110 <<
" , returning (0,0,0)";
113 if (
nullptr != iESGeom &&
m_esGeom != iESGeom) {
124 const double ctreta(center_cell->getPosition().eta());
130 const double preshowerStartEta = 1.653;
131 const int subdet = maxId.
subdetId();
133 : (((preshowerStartEta < fabs(ctreta)) &&
140 const float maxToFront(center_cell->getPosition().mag());
143 double total_weight = 0;
144 const double eTot_inv = 1.0 / eTot;
151 HitsAndEnergies::const_iterator
j, hAndE_end = detIds.end();
152 for (
j = detIds.begin();
j != hAndE_end; ++
j) {
153 const DetId dId((*j).first);
154 const double e_j((*j).second);
168 const float depth(
maxDepth + maxToFront - cell->getPosition().mag());
178 returnValue =
math::XYZPoint(xw / total_weight, yw / total_weight,
zw / total_weight);