32 #include "CLHEP/Units/SystemOfUnits.h"
63 constexpr
float cm_per_ns = 29.9792458;
68 const std::vector<T>&
values,
70 auto valMap = std::make_unique<edm::ValueMap<T>>();
80 ebClustersToken_(consumes<
std::vector<
reco::PFCluster>>(conf.getParameter<
edm::
InputTag>(
"ebClusters"))),
81 minFraction_(conf.getParameter<double>(
"minFractionToConsider")),
82 minEnergy_(conf.getParameter<double>(
"minEnergyToConsider")),
83 ecalDepth_(conf.getParameter<double>(
"ecalDepth")) {
86 for (
const auto& reso : resos) {
91 produces<edm::ValueMap<float>>(
name);
104 const auto& timehits = *timehitsH;
107 unsigned int runNum_uint = static_cast<unsigned int>(evt.
id().
run());
108 unsigned int lumiNum_uint = static_cast<unsigned int>(evt.
id().
luminosityBlock());
109 unsigned int evNum_uint = static_cast<unsigned int>(evt.
id().
event());
110 std::uint32_t
seed = (lumiNum_uint << 10) + (runNum_uint << 20) + evNum_uint;
111 std::mt19937 rng(
seed);
113 std::vector<std::pair<float, DetId>> times;
116 for (
const auto& cluster :
clusters) {
123 std::vector<float> smeared_times;
125 smeared_times.reserve(
clusters.size());
129 const float theresolution = reso->getTimeResolution(
clusters[
i]);
130 std::normal_distribution<float> gausTime(times[
i].
first, theresolution);
132 smeared_times.emplace_back(gausTime(rng));
136 writeValueMap(evt, clustersH, smeared_times,
name);
144 unsigned best_hit = 0;
145 float best_energy = -1.f;
146 for (
const auto& rhf : rhfs) {
147 const auto& hitref = rhf.recHitRef();
148 const unsigned detid = hitref->detId();
149 const auto fraction = rhf.fraction();
150 const auto energy = hitref->energy();
153 auto timehit = timehits.
find(detid);
154 float e_hit = rhf.fraction() * hitref->energy();
155 if (e_hit > best_energy && timehit->isTimeValid()) {
162 if (best_energy > 0.) {
163 best_time_guess = timehits.
find(best_hit)->time();
168 return std::make_pair(best_time_guess,
DetId(best_hit));
172 const DetId& timeDet,
175 if (timeDet.
rawId() == 0)
178 auto cellGeometry = ecalGeom->
getGeometry(timeDet);
179 if (
nullptr == cellGeometry) {
181 << std::hex << timeDet.
rawId() <<
std::dec <<
" is not a valid ECAL Barrel DetId!";
194 return intime + to_center.r() / cm_per_ns - to_vtx.r() / cm_per_ns;