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();
void growPFClusters(const reco::PFCluster &, const std::vector< bool > &, const unsigned toleranceScaling, const unsigned iter, double dist, reco::PFClusterCollection &) const
T getParameter(std::string const &) const
const unsigned _maxIterations
void buildClusters(const reco::PFClusterCollection &, const std::vector< bool > &, reco::PFClusterCollection &outclus) override
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.
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)
void seedPFClustersFromTopo(const reco::PFCluster &, const std::vector< bool > &, reco::PFClusterCollection &) const
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
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 update(const edm::EventSetup &es) override
Power< A, B >::type pow(const A &a, const B &b)
Basic2DGenericPFlowClusterizer B2DGPF