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);
std::vector< std::pair< DetId, float > > HitsAndFractions
const PositionCalc & operator=(const PositionCalc &rhs)
constexpr bool null() const
is this a null id ?
double param_T0_endcPresh_
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
math::XYZPoint Calculate_Location(const HitsAndFractions &iDetIds, const edm::SortedCollection< HitType > *iRecHits, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorGeometry *iESGeom=nullptr)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
const_iterator end() const
XYZPointD XYZPoint
point in space with cartesian internal representation
iterator find(key_type k)
auto zw(V v) -> Vec2< typename std::remove_reference< decltype(v[0])>::type >
const CaloSubdetectorGeometry * m_esGeom
std::vector< std::pair< DetId, double > > HitsAndEnergies