9 #include <boost/function_output_iterator.hpp>
11 #include "vdt/vdtMath.h"
37 if( !cluster.
seed() ) {
39 <<
" Found a cluster with no seed: " << cluster;
43 double cl_timeweight=0.0;
60 auto k = hf.recHitRef().key();
61 auto p = recHitCollection+
k;
62 hits[
i]= {
p,(*p).energy(), float(hf.fraction())};
68 for(
auto const & rhf : hits ) {
70 if( refhit.
detId() == cluster.
seed() ) mySeed = rhf;
71 const auto rh_fraction = rhf.fraction;
72 const auto rh_rawenergy = rhf.energy;
73 const auto rh_energy = rh_rawenergy * rh_fraction;
77 <<
"rechit " << refhit.
detId() <<
" has a NaN energy... "
78 <<
"The input of the particle flow clustering seems to be corrupted.";
81 cl_energy += rh_energy;
85 int cell_layer = (int)refhit.
layer();
88 cl_time += rh_fraction*refhit.
time()*res2;
89 cl_timeweight += rh_fraction*res2;
92 const double rh_rawenergy2 = rh_rawenergy*rh_rawenergy;
93 cl_timeweight+=rh_rawenergy2*rh_fraction;
94 cl_time += rh_rawenergy2*rh_fraction*refhit.
time();
97 if( rh_energy > max_e ) {
99 max_e_layer = refhit.
layer();
104 cluster.
setTime(cl_time/cl_timeweight);
109 double position_norm = 0.0;
110 double x(0.0),
y(0.0),
z(0.0);
111 auto seedNeighbours = mySeed.hit->neighbours();
114 seedNeighbours = mySeed.hit->neighbours4();
117 seedNeighbours = mySeed.hit->neighbours8();
123 auto compute = [&](LHit
const& rhf) {
125 const auto rh_energy = rhf.
energy * rhf.fraction;
129 const auto rhpos_xyz = refhit.
position()*norm;
133 depth += refhit.
depth()*norm;
134 position_norm += norm;
138 std::sort(hits.begin(),hits.end(),[](LHit
const&
a, LHit
const&
b) {
return a.hit<
b.hit;});
142 for(
auto const & rhf : hits )
compute(rhf);
147 for(
auto k : seedNeighbours){
148 nei.push_back(recHitCollection+k);
150 std::sort(nei.begin(),nei.end());
152 auto operator()(LHit
const &a,
reco::PFRecHit const *
b)
const {
return a.hit<
b;}
153 auto operator()(
reco::PFRecHit const * b, LHit
const &a)
const {
return b<a.hit;}
155 std::set_intersection(hits.begin(),hits.end(),nei.begin(),nei.end(),
156 boost::make_function_output_iterator(
compute),
164 <<
"PFCluster too far from seeding cell: set position to (0,0,0).";
168 const double norm_inverse = 1.0/position_norm;
172 depth *= norm_inverse;
void setLayer(PFLayer::Layer layer)
set layer
void calculateAndSetPositionActual(reco::PFCluster &) const
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
float time() const
timing for cleaned hits
unsigned detId() const
rechit detId
void setPosition(const math::XYZPoint &p)
bool isBarrel(GeomDetEnumerators::SubDetector m)
void setEnergy(double energy)
PositionType const & position() const
rechit cell centre x, y, z
int depth() const
depth for segemntation
void calculateAndSetPositions(reco::PFClusterCollection &)
PFLayer::Layer layer() const
rechit layer
void calculateAndSetPosition(reco::PFCluster &)
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
void setTime(double time)
void calculatePositionREP()
computes posrep_ once and for all
#define unInitDynArray(T, n, x)
float energy() const
rechit energy
DetId seed() const
return DetId of seed
XYZPointD XYZPoint
point in space with cartesian internal representation
std::unique_ptr< CaloRecHitResolutionProvider > _timeResolutionCalcBarrel
const float _minFractionInCalc
const int _posCalcNCrystals
std::unique_ptr< CaloRecHitResolutionProvider > _timeResolutionCalcEndcap
void setDepth(double depth)
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
#define declareDynArray(T, n, x)
const float _minAllowedNorm
const float _logWeightDenom