5 #include "CLHEP/Units/SystemOfUnits.h"
59 desc.add<
double>(
"ecalDepth", 7.0);
63 std::vector<edm::ParameterSet> temp1;
68 temp1.push_back(temp2);
70 desc.addVPSet(
"resolutionModels", vpsd1, temp1);
73 desc.add<
double>(
"minFractionToConsider", 0.1);
75 desc.add<
double>(
"minEnergyToConsider", 0.0);
77 descriptions.
add(
"ecalBarrelClusterFastTimer",
desc);
83 constexpr
float cm_per_ns = 29.9792458;
88 const std::vector<T>&
values,
90 auto valMap = std::make_unique<edm::ValueMap<T>>();
101 minFraction_(conf.getParameter<double>(
"minFractionToConsider")),
102 minEnergy_(conf.getParameter<double>(
"minEnergyToConsider")),
103 ecalDepth_(conf.getParameter<double>(
"ecalDepth")) {
106 for (
const auto& reso : resos) {
111 produces<edm::ValueMap<float>>(
name);
124 const auto& timehits = *timehitsH;
127 unsigned int runNum_uint = static_cast<unsigned int>(evt.
id().
run());
128 unsigned int lumiNum_uint = static_cast<unsigned int>(evt.
id().
luminosityBlock());
129 unsigned int evNum_uint = static_cast<unsigned int>(evt.
id().
event());
130 std::uint32_t
seed = (lumiNum_uint << 10) + (runNum_uint << 20) + evNum_uint;
131 std::mt19937 rng(
seed);
133 std::vector<std::pair<float, DetId>> times;
136 for (
const auto& cluster :
clusters) {
143 std::vector<float> smeared_times;
145 smeared_times.reserve(
clusters.size());
149 const float theresolution = reso->getTimeResolution(
clusters[
i]);
150 std::normal_distribution<float> gausTime(times[
i].
first, theresolution);
152 smeared_times.emplace_back(gausTime(rng));
156 writeValueMap(evt, clustersH, smeared_times,
name);
164 unsigned best_hit = 0;
165 float best_energy = -1.f;
166 for (
const auto& rhf : rhfs) {
167 const auto& hitref = rhf.recHitRef();
168 const unsigned detid = hitref->detId();
169 const auto fraction = rhf.fraction();
170 const auto energy = hitref->energy();
173 auto timehit = timehits.
find(detid);
174 float e_hit = rhf.fraction() * hitref->energy();
175 if (e_hit > best_energy && timehit->isTimeValid()) {
182 if (best_energy > 0.) {
183 best_time_guess = timehits.
find(best_hit)->time();
188 return std::make_pair(best_time_guess,
DetId(best_hit));
192 const DetId& timeDet,
195 if (timeDet.
rawId() == 0)
198 auto cellGeometry = ecalGeom->
getGeometry(timeDet);
199 if (
nullptr == cellGeometry) {
201 << std::hex << timeDet.
rawId() <<
std::dec <<
" is not a valid ECAL Barrel DetId!";
214 return intime + to_center.r() / cm_per_ns - to_vtx.r() / cm_per_ns;