106 constexpr
double preshowerStartEta = 1.653;
107 constexpr
double preshowerEndEta = 2.6;
108 if (!cluster.
seed()) {
109 throw cms::Exception(
"ClusterWithNoSeed") <<
" Found a cluster with no seed: " << cluster;
111 double cl_energy = 0;
112 double cl_energy_float = 0;
114 double cl_timeweight = 0.0;
116 double clusterT0 = 0.0;
122 const double rh_fraction = rhf.fraction();
123 const double rh_rawenergy = refhit->energy();
124 const double rh_energy = rh_rawenergy * rh_fraction;
125 const double rh_energyf = ((
float)rh_rawenergy) * ((
float)rh_fraction);
127 throw cms::Exception(
"PFClusterAlgo") <<
"rechit " << refhit->detId() <<
" has non-finite energy... " 128 <<
"The input of the particle flow clustering seems to be corrupted.";
130 cl_energy += rh_energy;
131 cl_energy_float += rh_energyf;
135 cl_time += rh_fraction * refhit->time() * res2;
136 cl_timeweight += rh_fraction * res2;
138 const double rh_rawenergy2 = rh_rawenergy * rh_rawenergy;
139 cl_timeweight += rh_rawenergy2 * rh_fraction;
140 cl_time += rh_rawenergy2 * rh_fraction * refhit->time();
142 if (rh_energy > max_e) {
144 max_e_layer = rhf.recHitRef()->layer();
149 cluster.
setTime(cl_time / cl_timeweight);
156 switch (max_e_layer) {
166 throw cms::Exception(
"InvalidLayer") <<
"ECAL Position Calc only accepts ECAL_BARREL or ECAL_ENDCAP";
169 auto center_cell = ecal_geom->
getGeometry(refmax->detId());
170 const double ctreta = center_cell->etaPos();
171 const double actreta =
std::abs(ctreta);
173 if (actreta > preshowerStartEta && actreta < preshowerEndEta) {
181 const float maxToFront = center_cell->getPosition().mag();
183 const double logETot_inv = -vdt::fast_log(cl_energy_float);
184 double position_norm = 0.0;
185 double x(0.0),
y(0.0),
z(0.0);
189 const double rh_energy = ((
float)refhit->energy()) * ((
float)rhf.fraction());
192 auto cell = ecal_geom->
getGeometry(refhit->detId());
193 const float depth =
maxDepth + maxToFront - cell->getPosition().mag();
204 if (position_norm == 0.) {
208 const double rh_energy = ((
float)refhit->energy()) * ((
float)rhf.fraction());
212 auto cell = ecal_geom->
getGeometry(refhit->detId());
213 const float depth =
maxDepth + maxToFront - cell->getPosition().mag();
225 edm::LogError(
"WeirdClusterNormalization") <<
"PFCluster too far from seeding cell: set position to (0,0,0).";
228 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