8 #include "Math/GenVector/VectorUtil.h"
9 #include "vdt/vdtMath.h"
12 #include <unordered_map>
33 const std::vector<bool>&,
42 const std::unordered_map<std::string, int>
_layerMap;
51 const std::vector<bool>&,
52 const unsigned toleranceScaling,
63 #define LOGVERB(x) edm::LogVerbatim(x)
64 #define LOGWARN(x) edm::LogWarning(x)
65 #define LOGERR(x) edm::LogError(x)
66 #define LOGDRESSED(x) edm::LogInfo(x)
68 #define LOGVERB(x) LogTrace(x)
69 #define LOGWARN(x) edm::LogWarning(x)
70 #define LOGERR(x) edm::LogError(x)
71 #define LOGDRESSED(x) LogDebug(x)
77 _maxIterations(conf.getParameter<unsigned>(
"maxIterations")),
78 _stoppingTolerance(conf.getParameter<double>(
"stoppingTolerance")),
79 _showerSigma2(
std::
pow(conf.getParameter<double>(
"showerSigma"), 2.0)),
80 _excludeOtherSeeds(conf.getParameter<
bool>(
"excludeOtherSeeds")),
81 _minFracTot(conf.getParameter<double>(
"minFracTot")),
93 const std::vector<edm::ParameterSet>&
thresholds = conf.getParameterSetVector(
"recHitEnergyNorms");
98 std::vector<double> rhE_norm;
101 depths =
pset.getParameter<std::vector<int> >(
"depths");
102 rhE_norm =
pset.getParameter<std::vector<double> >(
"recHitEnergyNorm");
105 rhE_norm.push_back(
pset.getParameter<
double>(
"recHitEnergyNorm"));
108 if (rhE_norm.size() !=
depths.size()) {
110 <<
"PFlowClusterizerThreshold mismatch with the numbers of depths";
113 auto entry = _layerMap.find(det);
114 if (
entry == _layerMap.end()) {
115 throw cms::Exception(
"InvalidDetectorLayer") <<
"Detector layer : " << det <<
" is not in the list of recognized"
116 <<
" detector layers!";
118 _recHitEnergyNorms.emplace(_layerMap.find(det)->second, std::make_pair(
depths, rhE_norm));
121 if (conf.exists(
"allCellsPositionCalc")) {
127 if (conf.exists(
"positionCalcForConvergence")) {
135 const std::vector<bool>& seedable,
138 for (
const auto& topocluster :
input) {
139 clustersInTopo.clear();
141 const unsigned tolScal =
std::pow(
std::max(1.0, clustersInTopo.size() - 1.0), 2.0);
142 growPFClusters(topocluster, seedable, tolScal, 0, tolScal, clustersInTopo);
158 for (
auto& clusterout : clustersInTopo) {
165 const std::vector<bool>& seedable,
168 for (
const auto& rhf : recHitFractions) {
169 if (!seedable[rhf.recHitRef().key()])
174 current.
setSeed(rhf.recHitRef()->detId());
184 const std::vector<bool>& seedable,
185 const unsigned toleranceScaling,
190 LOGDRESSED(
"Basic2DGenericPFlowClusterizer:growAndStabilizePFClusters")
191 <<
"reached " <<
_maxIterations <<
" iterations, terminated position "
192 <<
"fit with diff = " <<
diff;
197 std::vector<reco::PFCluster::REPPoint> clus_prev_pos;
200 clus_prev_pos.emplace_back(repp.rho(), repp.eta(), repp.phi());
208 cluster.resetHitsAndFractions();
211 std::vector<double> dist2,
frac;
215 int cell_layer = (
int)refhit->layer();
228 for (
unsigned int j = 0;
j < recHitEnergyNormDepthPair.second.size(); ++
j) {
229 int depth = recHitEnergyNormDepthPair.first[
j];
242 dist2.emplace_back(d2);
244 LOGDRESSED(
"Basic2DGenericPFlowClusterizer:growAndStabilizePFClusters")
245 <<
"Warning! :: pfcluster-topocell distance is too large! d= " << d2;
277 if (dist2[
i] < 100.0 ||
frac[
i] > 0.9999) {
301 clus_prev_pos.clear();