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>>();
92 filler.insert(
handle, values.begin(), values.end());
100 ebClustersToken_(consumes<std::
vector<
reco::PFCluster>>(conf.getParameter<edm::
InputTag>(
"ebClusters"))),
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);
112 produces<edm::ValueMap<float>>(name +
resolution);
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) {
142 std::vector<float> resolutions;
143 std::vector<float> smeared_times;
144 resolutions.reserve(clusters.size());
145 smeared_times.reserve(clusters.size());
148 for (
unsigned i = 0;
i < clusters.size(); ++
i) {
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));
153 resolutions.push_back(theresolution);
156 writeValueMap(evt, clustersH, smeared_times, name);
157 writeValueMap(evt, clustersH, resolutions, name +
resolution);
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;
EventNumber_t event() const
VParameterSet const & getParameterSetVector(std::string const &name) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< std::vector< reco::PFCluster > > ebClustersToken_
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
constexpr uint32_t rawId() const
get the raw id
LuminosityBlockNumber_t luminosityBlock() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const Point & position() const
position
std::vector< std::unique_ptr< const ResolutionModel > > _resolutions
void addParameter(std::string const &name, T const &value)
EcalBarrelClusterFastTimer(const edm::ParameterSet &)
float correctTimeToVertex(const float intime, const DetId &timeDet, const reco::Vertex &vtx, const CaloSubdetectorGeometry *ecalGeom) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< EcalRecHitCollection > ebTimeHitsToken_
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
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.
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
const unsigned ecalDepth_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
iterator find(key_type k)
std::pair< float, DetId > getTimeForECALPFCluster(const EcalRecHitCollection &, const reco::PFCluster &) const