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);
112 double position_norm = 0.0;
113 double x(0.0),
y(0.0),
z(0.0);
114 if(
nullptr != mySeed.hit ) {
115 auto seedNeighbours = mySeed.hit->neighbours();
118 seedNeighbours = mySeed.hit->neighbours4();
121 seedNeighbours = mySeed.hit->neighbours8();
127 auto compute = [&](LHit
const& rhf) {
130 int cell_layer = (
int)refhit.
layer();
145 const auto rh_energy = rhf.energy * rhf.fraction;
149 const auto rhpos_xyz = refhit.
position()*norm;
153 depth += refhit.
depth()*norm;
154 position_norm += norm;
159 std::sort(hits.begin(),hits.end(),[](LHit
const&
a, LHit
const&
b) {
return a.hit<
b.hit;});
163 for(
auto const & rhf : hits )
compute(rhf);
168 for(
auto k : seedNeighbours){
169 nei.push_back(recHitCollection+
k);
171 std::sort(nei.begin(),nei.end());
173 auto operator()(LHit
const &a,
reco::PFRecHit const *
b)
const {
return a.hit<
b;}
174 auto operator()(
reco::PFRecHit const * b, LHit
const &a)
const {
return b<a.hit;}
176 std::set_intersection(hits.begin(),hits.end(),nei.begin(),nei.end(),
177 boost::make_function_output_iterator(
compute),
183 <<
"Cluster seed hit is null, something is wrong with PFlow RecHit!";
188 <<
"PFCluster too far from seeding cell: set position to (0,0,0).";
192 const double norm_inverse = 1.0/position_norm;
196 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
constexpr bool isNotFinite(T x)
void setPosition(const math::XYZPoint &p)
bool isBarrel(GeomDetEnumerators::SubDetector m)
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
PFLayer::Layer layer() const
rechit layer
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
void calculatePositionREP()
computes posrep_ once and for all
std::tuple< std::vector< int >,std::vector< int >, std::vector< float > > _logWeightDenom
#define unInitDynArray(T, n, x)
void setTimeError(float timeError)
DetId seed() const
return DetId of seed
void calculateAndSetPositions(reco::PFClusterCollection &) override
XYZPointD XYZPoint
point in space with cartesian internal representation
std::unique_ptr< CaloRecHitResolutionProvider > _timeResolutionCalcBarrel
const float _minFractionInCalc
void calculateAndSetPosition(reco::PFCluster &) override
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