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;
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 if(
nullptr != mySeed.hit ) {
112 auto seedNeighbours = mySeed.hit->neighbours();
115 seedNeighbours = mySeed.hit->neighbours4();
118 seedNeighbours = mySeed.hit->neighbours8();
124 auto compute = [&](LHit
const& rhf) {
126 const auto rh_energy = rhf.
energy * rhf.fraction;
130 const auto rhpos_xyz = refhit.
position()*norm;
134 depth += refhit.
depth()*norm;
135 position_norm += norm;
139 std::sort(hits.begin(),hits.end(),[](LHit
const&
a, LHit
const&
b) {
return a.hit<
b.hit;});
143 for(
auto const & rhf : hits )
compute(rhf);
148 for(
auto k : seedNeighbours){
149 nei.push_back(recHitCollection+
k);
151 std::sort(nei.begin(),nei.end());
153 auto operator()(LHit
const &a,
reco::PFRecHit const *
b)
const {
return a.hit<
b;}
154 auto operator()(
reco::PFRecHit const * b, LHit
const &a)
const {
return b<a.hit;}
156 std::set_intersection(hits.begin(),hits.end(),nei.begin(),nei.end(),
157 boost::make_function_output_iterator(
compute),
163 <<
"Cluster seed hit is null, something is wrong with PFlow RecHit!";
168 <<
"PFCluster too far from seeding cell: set position to (0,0,0).";
172 const double norm_inverse = 1.0/position_norm;
176 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)
void setTime(float time, float timeError=0)
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 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