6 #include "Math/GenVector/VectorUtil.h"
8 #include "vdt/vdtMath.h"
15 #define LOGVERB(x) edm::LogVerbatim(x)
16 #define LOGWARN(x) edm::LogWarning(x)
17 #define LOGERR(x) edm::LogError(x)
18 #define LOGDRESSED(x) edm::LogInfo(x)
20 #define LOGVERB(x) LogTrace(x)
21 #define LOGWARN(x) edm::LogWarning(x)
22 #define LOGERR(x) edm::LogError(x)
23 #define LOGDRESSED(x) LogDebug(x)
28 _maxIterations(conf.getParameter<unsigned>(
"maxIterations")),
29 _stoppingTolerance(conf.getParameter<double>(
"stoppingTolerance")),
30 _showerSigma2(
std::
pow(conf.getParameter<double>(
"showerSigma"), 2.0)),
31 _timeSigma_eb(
std::
pow(conf.getParameter<double>(
"timeSigmaEB"), 2.0)),
32 _timeSigma_ee(
std::
pow(conf.getParameter<double>(
"timeSigmaEE"), 2.0)),
33 _excludeOtherSeeds(conf.getParameter<
bool>(
"excludeOtherSeeds")),
34 _minFracTot(conf.getParameter<double>(
"minFracTot")),
35 _maxNSigmaTime(
std::
pow(conf.getParameter<double>(
"maxNSigmaTime"), 2.0)),
36 _minChi2Prob(conf.getParameter<double>(
"minChi2Prob")),
37 _clusterTimeResFromSeed(conf.getParameter<
bool>(
"clusterTimeResFromSeed")),
50 const std::vector<edm::ParameterSet>&
thresholds = conf.getParameterSetVector(
"recHitEnergyNorms");
53 const double& rhE_norm =
pset.getParameter<
double>(
"recHitEnergyNorm");
54 auto entry = _layerMap.find(det);
55 if (
entry == _layerMap.end()) {
56 throw cms::Exception(
"InvalidDetectorLayer") <<
"Detector layer : " << det <<
" is not in the list of recognized"
57 <<
" detector layers!";
59 _recHitEnergyNorms.emplace(_layerMap.find(det)->second, rhE_norm);
62 if (conf.exists(
"allCellsPositionCalc")) {
68 if (conf.exists(
"positionCalcForConvergence")) {
73 if (conf.exists(
"timeResolutionCalcBarrel")) {
75 _timeResolutionCalcBarrel = std::make_unique<CaloRecHitResolutionProvider>(timeResConf);
77 if (conf.exists(
"timeResolutionCalcEndcap")) {
79 _timeResolutionCalcEndcap = std::make_unique<CaloRecHitResolutionProvider>(timeResConf);
84 const std::vector<bool>& seedable,
87 for (
const auto& topocluster :
input) {
88 clustersInTopo.clear();
90 const unsigned tolScal =
std::pow(
std::max(1.0, clustersInTopo.size() - 1.0), 2.0);
91 growPFClusters(topocluster, seedable, tolScal, 0, tolScal, clustersInTopo);
107 for (
auto& clusterout : clustersInTopo) {
114 const std::vector<bool>& seedable,
117 for (
const auto& rhf : recHitFractions) {
118 if (!seedable[rhf.recHitRef().key()])
123 current.
setSeed(rhf.recHitRef()->detId());
133 const std::vector<bool>& seedable,
134 const unsigned toleranceScaling,
139 LOGDRESSED(
"PFlow2DClusterizerWithTime:growAndStabilizePFClusters")
140 <<
"reached " <<
_maxIterations <<
" iterations, terminated position "
141 <<
"fit with diff = " <<
diff;
146 std::vector<reco::PFCluster::REPPoint> clus_prev_pos;
148 std::vector<double> clus_prev_timeres2;
152 clus_prev_pos.emplace_back(repp.rho(), repp.eta(), repp.phi());
165 clus_prev_timeres2.push_back(resCluster2);
166 cluster.resetHitsAndFractions();
169 std::vector<double> dist2,
frac;
172 std::vector<double> clus_chi2;
173 std::vector<size_t> clus_chi2_nhits;
178 int cell_layer = (
int)refhit->layer();
190 for (
size_t iCluster = 0; iCluster <
clusters.size(); ++iCluster) {
196 double d2time =
dist2Time(cluster, refhit, cell_layer, clus_prev_timeres2[iCluster]);
202 dist2.emplace_back(d2);
205 LOGDRESSED(
"PFlow2DClusterizerWithTime:growAndStabilizePFClusters")
206 <<
"Warning! :: pfcluster-topocell distance is too large! d= " << d2;
237 if (dist2[
i] < 100.0 ||
frac[
i] > 0.9999) {
261 clus_prev_pos.clear();
263 clus_chi2_nhits.clear();
264 clus_prev_timeres2.clear();
275 clusterRes2 = 10000.;
292 double sumTimeSigma2 = 0.;
293 double sumSigma2 = 0.;
297 const double rhf_f = rhf.fraction();
304 double res2 = 10000.;
310 sumTimeSigma2 += rhf_f * rh.
time() / res2;
311 sumSigma2 += rhf_f / res2;
313 if (sumSigma2 > 0.) {
314 clusterRes2 = 1. / sumSigma2;
315 cluster.
setTime(sumTimeSigma2 / sumSigma2);
318 clusterRes2 = 999999.;
325 double prev_timeres2)
const {
326 const double deltaT = cluster.
time() - refhit->time();
327 const double t2 = deltaT * deltaT;
333 const double resCluster2 = prev_timeres2;
341 const double resCluster2 = prev_timeres2;
348 double distTime2 =
t2 / res2;
357 std::vector<double>& clus_chi2,
358 std::vector<size_t>& clus_chi2_nhits)
const {
359 if (iCluster >= clus_chi2.size()) {
360 clus_chi2.push_back(dist2);
361 clus_chi2_nhits.push_back(1);
364 double chi2 = clus_chi2[iCluster];
365 size_t nhitsCluster = clus_chi2_nhits[iCluster];
368 clus_chi2[iCluster] =
chi2;
369 clus_chi2_nhits[iCluster] = nhitsCluster + 1;