5 #include <unordered_map> 7 #include "vdt/vdtMath.h" 15 #include "TPrincipal.h" 22 pca_(new TPrincipal(3,
"D")) {}
31 std::unique_ptr<TPrincipal>
pca_;
41 pca_.reset(
new TPrincipal(3,
"D"));
47 pca_.reset(
new TPrincipal(3,
"D"));
53 if (!cluster.
seed()) {
54 throw cms::Exception(
"ClusterWithNoSeed") <<
" Found a cluster with no seed: " << cluster;
58 double avg_time = 0.0;
59 double time_norm = 0.0;
66 double rh_energy = refhit->energy();
67 double rh_time = refhit->time();
68 cl_energy += rh_energy * rhf.fraction();
73 avg_time += (rh_time - 1.0);
76 if (rh_energy > max_e) {
78 max_e_layer = rhf.recHitRef()->layer();
80 if (refhit->detId() == cluster.
seed())
82 const double rh_fraction = rhf.fraction();
83 rh_energy = refhit->energy() * rh_fraction;
87 edm::LogWarning(
"PFClusterAlgo") <<
"rechit " << refhit->detId() <<
" has a NaN energy... " 88 <<
"The input of the particle flow clustering seems to be corrupted.";
91 pcavars[0] = refhit->position().x();
92 pcavars[1] = refhit->position().y();
93 pcavars[2] = refhit->position().z();
94 int nhit =
int(rh_energy * 100);
96 for (
int i = 0;
i < nhit; ++
i) {
97 pca_->AddRow(pcavars);
104 pca_->MakePrincipals();
105 const TVectorD& means = *(
pca_->GetMeanValues());
106 const TMatrixD& eigens = *(
pca_->GetEigenVectors());
111 if (time_norm > 0.0) {
112 avg_time = avg_time / time_norm;
117 if (axis.z() * barycenter.z() < 0.0) {
void setLayer(PFLayer::Layer layer)
set layer
Cluster3DPCACalculator & operator=(const Cluster3DPCACalculator &)=delete
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
constexpr bool isNotFinite(T x)
void setPosition(const math::XYZPoint &p)
void setTime(float time, float timeError=0)
void showerParameters(const reco::PFCluster &, math::XYZPoint &, math::XYZVector &)
Fraction of a PFRecHit (rechits can be shared between several PFCluster's)
void setEnergy(double energy)
void calculatePositionREP()
computes posrep_ once and for all
Cluster3DPCACalculator(const edm::ParameterSet &conf)
void calculateAndSetPositionActual(reco::PFCluster &)
DetId seed() const
return DetId of seed
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
void calculateAndSetPositions(reco::PFClusterCollection &) override
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
std::unique_ptr< TPrincipal > pca_
void calculateAndSetPosition(reco::PFCluster &) override
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
#define DEFINE_EDM_PLUGIN(factory, type, name)