133 if (!cluster.
seed()) {
134 throw cms::Exception(
"ClusterWithNoSeed") <<
" Found a cluster with no seed: " << cluster;
136 double cl_energy = 0;
138 double cl_timeweight = 0.0;
148 auto const recHitCollection =
159 auto k =
hf.recHitRef().key();
160 auto p = recHitCollection +
k;
166 for (
auto const& rhf :
hits) {
170 const auto rh_fraction = rhf.fraction;
171 const auto rh_rawenergy = rhf.energy;
172 const auto rh_energy = rh_rawenergy * rh_fraction;
175 throw cms::Exception(
"PFClusterAlgo") <<
"rechit " << refhit.
detId() <<
" has a NaN energy... " 176 <<
"The input of the particle flow clustering seems to be corrupted.";
179 cl_energy += rh_energy;
183 int cell_layer = (
int)refhit.
layer();
186 cl_time += rh_fraction * refhit.
time() * res2;
187 cl_timeweight += rh_fraction * res2;
189 const double rh_rawenergy2 = rh_rawenergy * rh_rawenergy;
190 cl_timeweight += rh_rawenergy2 * rh_fraction;
191 cl_time += rh_rawenergy2 * rh_fraction * refhit.
time();
194 if (rh_energy > max_e) {
196 max_e_layer = refhit.
layer();
201 cluster.
setTime(cl_time / cl_timeweight);
208 bool single_depth =
true;
211 double position_norm = 0.0;
212 double x(0.0),
y(0.0),
z(0.0);
213 if (
nullptr !=
mySeed.hit) {
214 auto seedNeighbours =
mySeed.hit->neighbours();
217 seedNeighbours =
mySeed.hit->neighbours4();
220 seedNeighbours =
mySeed.hit->neighbours8();
226 auto compute = [&](LHit
const& rhf) {
229 int cell_layer = (
int)refhit.
layer();
232 if (hcalCuts !=
nullptr &&
252 ref_depth = refhit.
depth();
253 else if (refhit.
depth() != ref_depth) {
255 single_depth =
false;
257 const auto rh_energy = rhf.energy * rhf.fraction;
260 const auto rhpos_xyz = refhit.
position() * norm;
265 position_norm += norm;
272 for (
auto const& rhf :
hits)
278 for (
auto k : seedNeighbours) {
279 nei.push_back(recHitCollection +
k);
287 hits.begin(),
hits.end(), nei.begin(), nei.end(), boost::make_function_output_iterator(
compute), LHitLess());
291 <<
"Cluster seed hit is null, something is wrong with PFlow RecHit!";
295 edm::LogError(
"WeirdClusterNormalization") <<
"PFCluster too far from seeding cell: set position to (0,0,0).";
299 const double norm_inverse = 1.0 / position_norm;
306 depth *= norm_inverse;
void setLayer(PFLayer::Layer layer)
set layer
constexpr bool isNotFinite(T x)
void setPosition(const math::XYZPoint &p)
DetId seed() const
return DetId of seed
void setTime(float time, float timeError=0)
PFLayer::Layer layer() const
rechit layer
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
void setEnergy(double energy)
float time() const
timing for cleaned hits
Log< level::Error, false > LogError
PositionType const & position() const
rechit cell centre x, y, z
const Item * getValues(DetId fId, bool throwOnFail=true) const
unsigned detId() const
rechit detId
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
void calculatePositionREP()
computes posrep_ once and for all
#define unInitDynArray(T, n, x)
void setTimeError(float timeError)
constexpr uint32_t rawId() const
get the raw id
XYZPointD XYZPoint
point in space with cartesian internal representation
std::unique_ptr< CaloRecHitResolutionProvider > _timeResolutionCalcBarrel
const float _minFractionInCalc
std::tuple< std::vector< int >, std::vector< int >, std::vector< float > > _logWeightDenom
const int _posCalcNCrystals
std::unique_ptr< CaloRecHitResolutionProvider > _timeResolutionCalcEndcap
void setDepth(double depth)
#define declareDynArray(T, n, x)
int depth() const
depth for segemntation
const float _minAllowedNorm