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;
edm::EDGetTokenT< std::vector< reco::PFCluster > > ebClustersToken_
def create(alignables, pedeDump, additionalData, outputFile, config)
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
#define DEFINE_FWK_MODULE(type)
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
bool getByToken(EDGetToken token, Handle< PROD > &result) const
float correctTimeToVertex(const float intime, const DetId &timeDet, const reco::Vertex &vtx, const CaloSubdetectorGeometry *ecalGeom) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
LuminosityBlockNumber_t luminosityBlock() const
std::vector< std::unique_ptr< const ResolutionModel > > _resolutions
void addParameter(std::string const &name, T const &value)
EcalBarrelClusterFastTimer(const edm::ParameterSet &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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.
std::pair< float, DetId > getTimeForECALPFCluster(const EcalRecHitCollection &, const reco::PFCluster &) const
edm::EDGetTokenT< EcalRecHitCollection > ebTimeHitsToken_
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
XYZVectorD XYZVector
spatial vector with cartesian internal representation
constexpr uint32_t rawId() const
get the raw id
XYZPointD XYZPoint
point in space with cartesian internal representation
const unsigned ecalDepth_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
iterator find(key_type k)
VParameterSet const & getParameterSetVector(std::string const &name) const
EventNumber_t event() const