10 #include "Math/GenVector/VectorUtil.h" 11 #include "vdt/vdtMath.h" 14 #include <unordered_map> 35 const std::vector<bool>&,
45 const std::unordered_map<std::string, int>
_layerMap;
52 const std::vector<bool>&,
57 const std::vector<bool>&,
58 const unsigned toleranceScaling,
70 #define LOGVERB(x) edm::LogVerbatim(x) 71 #define LOGWARN(x) edm::LogWarning(x) 72 #define LOGERR(x) edm::LogError(x) 73 #define LOGDRESSED(x) edm::LogInfo(x) 75 #define LOGVERB(x) LogTrace(x) 76 #define LOGWARN(x) edm::LogWarning(x) 77 #define LOGERR(x) edm::LogError(x) 78 #define LOGDRESSED(x) LogDebug(x) 84 _maxIterations(conf.getParameter<unsigned>(
"maxIterations")),
85 _stoppingTolerance(conf.getParameter<double>(
"stoppingTolerance")),
86 _showerSigma2(
std::
pow(conf.getParameter<double>(
"showerSigma"), 2.0)),
87 _excludeOtherSeeds(conf.getParameter<
bool>(
"excludeOtherSeeds")),
88 _minFracTot(conf.getParameter<double>(
"minFracTot")),
100 const std::vector<edm::ParameterSet>&
thresholds = conf.getParameterSetVector(
"recHitEnergyNorms");
105 std::vector<double> rhE_norm;
108 depths =
pset.getParameter<std::vector<int> >(
"depths");
109 rhE_norm =
pset.getParameter<std::vector<double> >(
"recHitEnergyNorm");
112 rhE_norm.push_back(
pset.getParameter<
double>(
"recHitEnergyNorm"));
115 if (rhE_norm.size() !=
depths.size()) {
117 <<
"PFlowClusterizerThreshold mismatch with the numbers of depths";
120 auto entry = _layerMap.find(det);
121 if (
entry == _layerMap.end()) {
122 throw cms::Exception(
"InvalidDetectorLayer") <<
"Detector layer : " << det <<
" is not in the list of recognized" 123 <<
" detector layers!";
125 _recHitEnergyNorms.emplace(_layerMap.find(det)->second, std::make_pair(
depths, rhE_norm));
128 if (conf.exists(
"allCellsPositionCalc")) {
134 if (conf.exists(
"positionCalcForConvergence")) {
142 const std::vector<bool>& seedable,
146 for (
const auto& topocluster :
input) {
147 clustersInTopo.clear();
149 const unsigned tolScal =
std::pow(
std::max(1.0, clustersInTopo.size() - 1.0), 2.0);
150 growPFClusters(topocluster, seedable, tolScal, 0, tolScal, clustersInTopo, hcalCuts);
163 _positionCalc->calculateAndSetPositions(clustersInTopo, hcalCuts);
166 for (
auto& clusterout : clustersInTopo) {
173 const std::vector<bool>& seedable,
177 for (
const auto& rhf : recHitFractions) {
178 if (!seedable[rhf.recHitRef().key()])
183 current.
setSeed(rhf.recHitRef()->detId());
193 const std::vector<bool>& seedable,
194 const unsigned toleranceScaling,
200 LOGDRESSED(
"Basic2DGenericPFlowClusterizer:growAndStabilizePFClusters")
201 <<
"reached " <<
_maxIterations <<
" iterations, terminated position " 202 <<
"fit with diff = " <<
diff;
207 std::vector<reco::PFCluster::REPPoint> clus_prev_pos;
210 clus_prev_pos.emplace_back(repp.rho(), repp.eta(), repp.phi());
218 cluster.resetHitsAndFractions();
221 std::vector<double> dist2,
frac;
225 int cell_layer = (
int)refhit->layer();
238 if (hcalCuts !=
nullptr &&
244 for (
unsigned int j = 0;
j < recHitEnergyNormDepthPair.second.size(); ++
j) {
245 int depth = recHitEnergyNormDepthPair.first[
j];
258 dist2.emplace_back(d2);
260 LOGDRESSED(
"Basic2DGenericPFlowClusterizer:growAndStabilizePFClusters")
261 <<
"Warning! :: pfcluster-topocell distance is too large! d= " << d2;
293 if (dist2[
i] < 100.0 ||
frac[
i] > 0.9999) {
317 clus_prev_pos.clear();
T getParameter(std::string const &) const
const unsigned _maxIterations
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
uint32_t cc[maxCellsPerHit]
std::unique_ptr< PosCalc > _positionCalc
ParameterSet const & getParameterSet(std::string const &) const
const std::unordered_map< std::string, int > _layerMap
Fraction of a PFRecHit (rechits can be shared between several PFCluster's)
const double _stoppingTolerance
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
std::unique_ptr< PFCPositionCalculatorBase > _convergencePosCalc
key_type key() const
Accessor for product key.
void seedPFClustersFromTopo(const reco::PFCluster &, const std::vector< bool > &, reco::PFClusterCollection &, const HcalPFCuts *) const
const Item * getValues(DetId fId, bool throwOnFail=true) const
static std::string const input
void setSeed(const DetId &id)
Basic2DGenericPFlowClusterizer(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
std::unique_ptr< PFCPositionCalculatorBase > _allCellsPosCalc
void prunePFClusters(reco::PFClusterCollection &) const
~Basic2DGenericPFlowClusterizer() override=default
Abs< T >::type abs(const T &t)
B2DGPF & operator=(const B2DGPF &)=delete
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
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 float _minFractionToKeep
std::unordered_map< int, std::pair< std::vector< int >, std::vector< double > > > _recHitEnergyNorms
void addRecHitFraction(const reco::PFRecHitFraction &frac)
add a given fraction of the rechit
const bool _excludeOtherSeeds
const double _showerSigma2
ROOT::Math::PositionVector3D< ROOT::Math::CylindricalEta3D< double > > REPPoint
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
#define DEFINE_EDM_PLUGIN(factory, type, name)
void growPFClusters(const reco::PFCluster &, const std::vector< bool > &, const unsigned toleranceScaling, const unsigned iter, double dist, reco::PFClusterCollection &, const HcalPFCuts *) const
void update(const edm::EventSetup &es) override
Power< A, B >::type pow(const A &a, const B &b)
void buildClusters(const reco::PFClusterCollection &, const std::vector< bool > &, reco::PFClusterCollection &outclus, const HcalPFCuts *) override
Basic2DGenericPFlowClusterizer B2DGPF