7 #include <unordered_map> 13 #include "vdt/vdtMath.h" 23 caloGeom.
get(geohandle);
53 constexpr double preshowerStartEta = 1.653;
55 if( !cluster.
seed() ) {
57 <<
" Found a cluster with no seed: " << cluster;
60 double cl_energy_float = 0;
62 double cl_timeweight=0.0;
64 double clusterT0 = 0.0;
70 const double rh_fraction = rhf.fraction();
71 const double rh_rawenergy = refhit->energy();
72 const double rh_energy = rh_rawenergy * rh_fraction;
73 const double rh_energyf = ((
float)rh_rawenergy) * ((
float) rh_fraction);
76 <<
"rechit " << refhit->detId() <<
" has non-finite energy... " 77 <<
"The input of the particle flow clustering seems to be corrupted.";
79 cl_energy += rh_energy;
80 cl_energy_float += rh_energyf;
84 cl_time += rh_fraction*refhit->time()*res2;
85 cl_timeweight += rh_fraction*res2;
88 const double rh_rawenergy2 = rh_rawenergy*rh_rawenergy;
89 cl_timeweight+=rh_rawenergy2*rh_fraction;
90 cl_time += rh_rawenergy2*rh_fraction*refhit->time();
92 if( rh_energy > max_e ) {
94 max_e_layer = rhf.recHitRef()->layer();
99 cluster.
setTime(cl_time/cl_timeweight);
117 <<
"ECAL Position Calc only accepts ECAL_BARREL or ECAL_ENDCAP";
120 auto center_cell = ecal_geom->
getGeometry(refmax->detId());
121 const double ctreta = center_cell->etaPos();
122 const double actreta =
std::abs(ctreta);
124 if( actreta > preshowerStartEta && actreta < preshowerEndEta ) {
130 const float maxToFront = center_cell->getPosition().mag();
132 const double logETot_inv = -vdt::fast_log(cl_energy_float);
133 double position_norm = 0.0;
134 double x(0.0),
y(0.0),
z(0.0);
138 const double rh_energy = ((
float)refhit->energy()) * ((
float)rhf.fraction());
140 vdt::fast_log(rh_energy) +
142 auto cell = ecal_geom->
getGeometry(refhit->detId());
143 const float depth = maxDepth + maxToFront - cell->getPosition().mag();
147 x += weight*pos.
x() ;
148 y += weight*pos.
y() ;
149 z += weight*pos.
z() ;
155 if (position_norm == 0.) {
159 const double rh_energy = ((
float)refhit->energy()) * ((
float)rhf.fraction());
160 if( rh_energy > 0.0 )
161 weight = rh_energy/cluster.
energy();
163 auto cell = ecal_geom->
getGeometry(refhit->detId());
164 const float depth = maxDepth + maxToFront - cell->getPosition().mag();
167 x += weight*pos.
x() ;
168 y += weight*pos.
y() ;
169 z += weight*pos.
z() ;
177 <<
"PFCluster too far from seeding cell: set position to (0,0,0).";
180 const double norm_inverse = 1.0/position_norm;
void setLayer(PFLayer::Layer layer)
set layer
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
void setPosition(const math::XYZPoint &p)
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
void setEnergy(double energy)
constexpr bool isFinite(T x)
void calculateAndSetPositionActual(reco::PFCluster &) const
const double _param_T0_ES
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
void update(const edm::EventSetup &es) override
void calculateAndSetPosition(reco::PFCluster &) override
const double _param_T0_EE
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
void calculatePositionREP()
computes posrep_ once and for all
const double _minAllowedNorm
Abs< T >::type abs(const T &t)
double energy() const
cluster energy
void setTimeError(float timeError)
DetId seed() const
return DetId of seed
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.
XYZPointD XYZPoint
point in space with cartesian internal representation
const CaloSubdetectorGeometry * _ebGeom
void calculateAndSetPositions(reco::PFClusterCollection &) override
const CaloSubdetectorGeometry * _esGeom
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
const CaloSubdetectorGeometry * _eeGeom
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions