5 #include <unordered_map> 7 #include "vdt/vdtMath.h" 15 #include "TPrincipal.h" 21 pca_(new TPrincipal(3,
"D")){
30 std::unique_ptr<TPrincipal>
pca_;
40 "Cluster3DPCACalculator");
44 pca_.reset(
new TPrincipal(3,
"D"));
51 pca_.reset(
new TPrincipal(3,
"D"));
58 if( !cluster.
seed() ) {
60 <<
" Found a cluster with no seed: " << cluster;
64 double avg_time = 0.0;
65 double time_norm = 0.0;
72 double rh_energy = refhit->energy();
73 double rh_time = refhit->time();
74 cl_energy += rh_energy * rhf.fraction();
79 avg_time += (rh_time - 1.0);
82 if( rh_energy > max_e ) {
84 max_e_layer = rhf.recHitRef()->layer();
86 if( refhit->detId() == cluster.
seed() ) refseed = refhit;
87 const double rh_fraction = rhf.fraction();
88 rh_energy = refhit->energy()*rh_fraction;
91 <<
"rechit " << refhit->detId() <<
" has a NaN energy... " 92 <<
"The input of the particle flow clustering seems to be corrupted.";
94 pcavars[0] = refhit->position().x();
95 pcavars[1] = refhit->position().y();
96 pcavars[2] = refhit->position().z();
97 int nhit =
int( rh_energy*100 );
99 for(
int i = 0;
i < nhit; ++
i ) {
100 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.
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
std::unique_ptr< TPrincipal > pca_
void calculateAndSetPosition(reco::PFCluster &) override
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
#define DEFINE_EDM_PLUGIN(factory, type, name)