1 #ifndef RecoEcal_EgammaCoreTools_PositionCalc_h
2 #define RecoEcal_EgammaCoreTools_PositionCalc_h
46 template<
typename HitType>
66 template<
typename HitType>
77 if( 0 == iRecHits || 0 == iSubGeom ) {
79 <<
"Calculate_Location() called uninitialized or wrong initialization.";
82 if( 0 != iDetIds.size() &&
83 0 != iRecHits->
size() ) {
86 detIds.reserve( iDetIds.size() ) ;
93 typename HitTypeCollection::const_iterator endRecHits ( iRecHits->
end() ) ;
94 HitsAndFractions::const_iterator
n, endDiDs( iDetIds.end() );
95 for( n = iDetIds.begin(); n != endDiDs ; ++
n ) {
96 const DetId dId ( (*n).first ) ;
97 const float frac( (*n).second) ;
99 typename HitTypeCollection::const_iterator iHit ( iRecHits->
find( dId ) ) ;
100 if( iHit != endRecHits ) {
101 const double energy ( iHit->energy() *
frac ) ;
102 detIds.push_back( std::make_pair(dId,
energy) );
115 LogDebug(
"ZeroClusterEnergy") <<
"cluster with 0 energy: "
116 << eTot <<
" size: " << detIds.size()
117 <<
" , returning (0,0,0)";
120 if( 0 != iESGeom &&
m_esGeom != iESGeom ) {
122 for( uint32_t ic ( 0 ) ;
133 const double ctreta (center_cell->getPosition().eta());
139 const double preshowerStartEta = 1.653;
140 const int subdet = maxId.
subdetId();
142 ( ( ( preshowerStartEta < fabs( ctreta ) ) &&
143 ( ( ( 0 < ctreta ) &&
151 const float maxToFront ( center_cell->getPosition().mag() ) ;
154 double total_weight = 0;
155 const double eTot_inv = 1.0/eTot;
163 HitsAndEnergies::const_iterator
j, hAndE_end = detIds.end();
164 for( j = detIds.begin() ; j != hAndE_end ; ++
j ) {
165 const DetId dId ( (*j).first ) ;
166 const double e_j( (*j).second ) ;
176 weight = e_j*eTot_inv;
180 const float depth ( maxDepth + maxToFront - cell->getPosition().mag() ) ;
182 const GlobalPoint pos (static_cast<const TruncatedPyramid*>( cell )->getPosition(
depth ) );
184 xw += weight*pos.x() ;
185 yw += weight*pos.y() ;
186 zw += weight*pos.z() ;
auto zw(V v) -> Vec2< typenamestd::remove_reference< decltype(v[0])>::type >
const PositionCalc & operator=(const PositionCalc &rhs)
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)
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
double param_T0_endcPresh_
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::vector< std::pair< DetId, double > > HitsAndEnergies
const_iterator end() const
std::vector< std::pair< DetId, float > > HitsAndFractions
XYZPointD XYZPoint
point in space with cartesian internal representation
bool null() const
is this a null id ?
iterator find(key_type k)
math::XYZPoint Calculate_Location(const HitsAndFractions &iDetIds, const edm::SortedCollection< HitType > *iRecHits, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorGeometry *iESGeom=0)
const CaloSubdetectorGeometry * m_esGeom