105 constexpr double preshowerStartEta = 1.653;
107 if (!cluster.
seed()) {
108 throw cms::Exception(
"ClusterWithNoSeed") <<
" Found a cluster with no seed: " << cluster;
110 double cl_energy = 0;
111 double cl_energy_float = 0;
113 double cl_timeweight = 0.0;
115 double clusterT0 = 0.0;
121 const double rh_fraction = rhf.fraction();
122 const double rh_rawenergy = refhit->energy();
123 const double rh_energy = rh_rawenergy * rh_fraction;
124 const double rh_energyf = ((
float)rh_rawenergy) * ((
float)rh_fraction);
126 throw cms::Exception(
"PFClusterAlgo") <<
"rechit " << refhit->detId() <<
" has non-finite energy... " 127 <<
"The input of the particle flow clustering seems to be corrupted.";
129 cl_energy += rh_energy;
130 cl_energy_float += rh_energyf;
134 cl_time += rh_fraction * refhit->time() * res2;
135 cl_timeweight += rh_fraction * res2;
137 const double rh_rawenergy2 = rh_rawenergy * rh_rawenergy;
138 cl_timeweight += rh_rawenergy2 * rh_fraction;
139 cl_time += rh_rawenergy2 * rh_fraction * refhit->time();
141 if (rh_energy > max_e) {
143 max_e_layer = rhf.recHitRef()->layer();
148 cluster.
setTime(cl_time / cl_timeweight);
155 switch (max_e_layer) {
165 throw cms::Exception(
"InvalidLayer") <<
"ECAL Position Calc only accepts ECAL_BARREL or ECAL_ENDCAP";
168 auto center_cell = ecal_geom->
getGeometry(refmax->detId());
169 const double ctreta = center_cell->etaPos();
170 const double actreta =
std::abs(ctreta);
172 if (actreta > preshowerStartEta && actreta < preshowerEndEta) {
180 const float maxToFront = center_cell->getPosition().mag();
182 const double logETot_inv = -vdt::fast_log(cl_energy_float);
183 double position_norm = 0.0;
184 double x(0.0),
y(0.0),
z(0.0);
188 const double rh_energy = ((
float)refhit->energy()) * ((
float)rhf.fraction());
191 auto cell = ecal_geom->
getGeometry(refhit->detId());
192 const float depth =
maxDepth + maxToFront - cell->getPosition().mag();
203 if (position_norm == 0.) {
207 const double rh_energy = ((
float)refhit->energy()) * ((
float)rhf.fraction());
211 auto cell = ecal_geom->
getGeometry(refhit->detId());
212 const float depth =
maxDepth + maxToFront - cell->getPosition().mag();
224 edm::LogError(
"WeirdClusterNormalization") <<
"PFCluster too far from seeding cell: set position to (0,0,0).";
227 const double norm_inverse = 1.0 / position_norm;
void setLayer(PFLayer::Layer layer)
set layer
void setPosition(const math::XYZPoint &p)
DetId seed() const
return DetId of seed
void setTime(float time, float timeError=0)
const double _param_T0_EB
Fraction of a PFRecHit (rechits can be shared between several PFCluster's)
std::unique_ptr< CaloRecHitResolutionProvider > _timeResolutionCalc
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
void setEnergy(double energy)
Log< level::Error, false > LogError
constexpr bool isFinite(T x)
const double _param_T0_ES
const double _param_T0_EE
void calculatePositionREP()
computes posrep_ once and for all
const double _minAllowedNorm
double energy() const
cluster energy
Abs< T >::type abs(const T &t)
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
void setTimeError(float timeError)
XYZPointD XYZPoint
point in space with cartesian internal representation
const CaloSubdetectorGeometry * _ebGeom
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
const CaloSubdetectorGeometry * _eeGeom