7 #include <unordered_map> 9 #include "vdt/vdtMath.h" 19 #include "TPrincipal.h" 26 pca_(new TPrincipal(3,
"D")) {}
35 std::unique_ptr<TPrincipal>
pca_;
45 pca_ = std::make_unique<TPrincipal>(3,
"D");
51 pca_ = std::make_unique<TPrincipal>(3,
"D");
57 if (!cluster.
seed()) {
58 throw cms::Exception(
"ClusterWithNoSeed") <<
" Found a cluster with no seed: " << cluster;
62 double avg_time = 0.0;
63 double time_norm = 0.0;
70 double rh_energy = refhit->energy();
71 double rh_time = refhit->time();
72 cl_energy += rh_energy * rhf.fraction();
77 avg_time += (rh_time - 1.0);
80 if (rh_energy > max_e) {
82 max_e_layer = rhf.recHitRef()->layer();
84 if (refhit->detId() == cluster.
seed())
86 const double rh_fraction = rhf.fraction();
87 rh_energy = refhit->energy() * rh_fraction;
91 edm::LogWarning(
"PFClusterAlgo") <<
"rechit " << refhit->detId() <<
" has a NaN energy... " 92 <<
"The input of the particle flow clustering seems to be corrupted.";
95 pcavars[0] = refhit->position().x();
96 pcavars[1] = refhit->position().y();
97 pcavars[2] = refhit->position().z();
98 int nhit =
int(rh_energy * 100);
100 for (
int i = 0;
i < nhit; ++
i) {
101 pca_->AddRow(pcavars);
108 pca_->MakePrincipals();
109 const TVectorD&
means = *(
pca_->GetMeanValues());
110 const TMatrixD& eigens = *(
pca_->GetEigenVectors());
115 if (time_norm > 0.0) {
116 avg_time = avg_time / time_norm;
121 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)
uint32_t cc[maxCellsPerHit]
void setPosition(const math::XYZPoint &p)
DetId seed() const
return DetId of seed
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)
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
void setEnergy(double energy)
void calculateAndSetPositions(reco::PFClusterCollection &, const HcalPFCuts *) override
void calculatePositionREP()
computes posrep_ once and for all
void calculateAndSetPositionActual(reco::PFCluster &)
void calculateAndSetPosition(reco::PFCluster &, const HcalPFCuts *) override
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
std::unique_ptr< TPrincipal > pca_
Cluster3DPCACalculator(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
#define DEFINE_EDM_PLUGIN(factory, type, name)
Log< level::Warning, false > LogWarning