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 const auto& acConf = conf.getParameterSet(
"allCellsPositionCalc");
129 if (!acConf.empty()) {
135 const auto& convConf = conf.getParameterSet(
"positionCalcForConvergence");
136 if (!convConf.empty()) {
138 if (!algoconv.empty())
144 const std::vector<bool>& seedable,
148 for (
const auto& topocluster :
input) {
149 clustersInTopo.clear();
151 const unsigned tolScal =
std::pow(
std::max(1.0, clustersInTopo.size() - 1.0), 2.0);
152 growPFClusters(topocluster, seedable, tolScal, 0, tolScal, clustersInTopo, hcalCuts);
165 _positionCalc->calculateAndSetPositions(clustersInTopo, hcalCuts);
168 for (
auto& clusterout : clustersInTopo) {
175 const std::vector<bool>& seedable,
179 for (
const auto& rhf : recHitFractions) {
180 if (!seedable[rhf.recHitRef().key()])
185 current.
setSeed(rhf.recHitRef()->detId());
195 const std::vector<bool>& seedable,
196 const unsigned toleranceScaling,
202 LOGDRESSED(
"Basic2DGenericPFlowClusterizer:growAndStabilizePFClusters")
203 <<
"reached " <<
_maxIterations <<
" iterations, terminated position " 204 <<
"fit with diff = " <<
diff;
209 std::vector<reco::PFCluster::REPPoint> clus_prev_pos;
212 clus_prev_pos.emplace_back(repp.rho(), repp.eta(), repp.phi());
220 cluster.resetHitsAndFractions();
223 std::vector<double> dist2,
frac;
227 int cell_layer = (
int)refhit->layer();
240 if (hcalCuts !=
nullptr &&
246 for (
unsigned int j = 0;
j < recHitEnergyNormDepthPair.second.size(); ++
j) {
247 int depth = recHitEnergyNormDepthPair.first[
j];
260 dist2.emplace_back(d2);
262 LOGDRESSED(
"Basic2DGenericPFlowClusterizer:growAndStabilizePFClusters")
263 <<
"Warning! :: pfcluster-topocell distance is too large! d= " << d2;
295 if (dist2[
i] < 100.0 ||
frac[
i] > 0.9999) {
319 clus_prev_pos.clear();
const unsigned _maxIterations
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
uint32_t cc[maxCellsPerHit]
std::unique_ptr< PosCalc > _positionCalc
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