6 #include "Math/GenVector/VectorUtil.h"
8 #include "vdt/vdtMath.h"
13 #define LOGVERB(x) edm::LogVerbatim(x)
14 #define LOGWARN(x) edm::LogWarning(x)
15 #define LOGERR(x) edm::LogError(x)
16 #define LOGDRESSED(x) edm::LogInfo(x)
18 #define LOGVERB(x) LogTrace(x)
19 #define LOGWARN(x) edm::LogWarning(x)
20 #define LOGERR(x) edm::LogError(x)
21 #define LOGDRESSED(x) LogDebug(x)
27 _maxIterations(conf.getParameter<unsigned>(
"maxIterations")),
28 _stoppingTolerance(conf.getParameter<double>(
"stoppingTolerance")),
29 _showerSigma2(std::
pow(conf.getParameter<double>(
"showerSigma"),2.0)),
30 _excludeOtherSeeds(conf.getParameter<bool>(
"excludeOtherSeeds")),
31 _minFracTot(conf.getParameter<double>(
"minFracTot")),
43 const std::vector<edm::ParameterSet>& thresholds =
45 for(
const auto& pset : thresholds ) {
47 const double& rhE_norm = pset.getParameter<
double>(
"recHitEnergyNorm");
51 <<
"Detector layer : " << det <<
" is not in the list of recognized"
52 <<
" detector layers!";
58 if( conf.
exists(
"allCellsPositionCalc") ) {
69 if( conf.
exists(
"positionCalcForConvergence") ) {
82 const std::vector<bool>& seedable,
85 for(
const auto& topocluster : input ) {
86 clustersInTopo.clear();
88 const unsigned tolScal =
90 growPFClusters(topocluster,seedable,tolScal,0,tolScal,clustersInTopo);
106 for(
auto& clusterout : clustersInTopo ) {
107 output.insert(output.end(),
std::move(clusterout));
114 const std::vector<bool>& seedable,
117 for(
const auto& rhf : recHitFractions ) {
118 if( !seedable[rhf.recHitRef().key()] )
continue;
122 current.
setSeed(rhf.recHitRef()->detId());
133 const std::vector<bool>& seedable,
134 const unsigned toleranceScaling,
139 LOGDRESSED(
"Basic2DGenericPFlowClusterizer:growAndStabilizePFClusters")
140 <<
"reached " <<
_maxIterations <<
" iterations, terminated position "
141 <<
"fit with diff = " <<
diff;
146 std::vector<reco::PFCluster::REPPoint> clus_prev_pos;
147 for(
auto& cluster : clusters) {
149 clus_prev_pos.emplace_back(repp.rho(),repp.eta(),repp.phi());
157 cluster.resetHitsAndFractions();
160 std::vector<double> dist2,
frac;
164 int cell_layer = (int)refhit->layer();
166 std::abs(refhit->positionREP().eta()) > 0.34 ) {
169 const double recHitEnergyNorm =
172 dist2.clear(); frac.clear(); fractot = 0;
174 for(
auto& cluster : clusters ) {
179 dist2.emplace_back( d2 );
181 LOGDRESSED(
"Basic2DGenericPFlowClusterizer:growAndStabilizePFClusters")
182 <<
"Warning! :: pfcluster-topocell distance is too large! d= "
196 for(
unsigned i = 0;
i < clusters.size(); ++
i ) {
198 ( refhit->detId() == clusters[
i].seed() && fractot > 0.0 ) ) {
214 if( dist2[
i] < 100.0 || frac[
i] > 0.9999 ) {
221 for(
unsigned i = 0;
i < clusters.size(); ++
i ) {
231 const double delta2 =
233 if( delta2 > diff2 ) diff2 = delta2;
236 dist2.clear(); frac.clear(); clus_prev_pos.clear();
237 growPFClusters(topo,seedable,toleranceScaling,iter+1,diff,clusters);
242 for(
auto& cluster : clusters ) {
T getParameter(std::string const &) const
VParameterSet const & getParameterSetVector(std::string const &name) const
const unsigned _maxIterations
void growPFClusters(const reco::PFCluster &, const std::vector< bool > &, const unsigned toleranceScaling, const unsigned iter, double dist, reco::PFClusterCollection &) const
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
std::unique_ptr< PosCalc > _positionCalc
bool exists(std::string const ¶meterName) const
checks if a parameter exists
Fraction of a PFRecHit (rechits can be shared between several PFCluster's)
const double _stoppingTolerance
std::unique_ptr< PFCPositionCalculatorBase > _convergencePosCalc
key_type key() const
Accessor for product key.
static std::string const input
void setSeed(const DetId &id)
std::unique_ptr< PFCPositionCalculatorBase > _allCellsPosCalc
Abs< T >::type abs(const T &t)
double deltaR2(const T1 &t1, const T2 &t2)
std::unordered_map< int, double > _recHitEnergyNorms
const std::unordered_map< std::string, int > _layerMap
ParameterSet const & getParameterSet(std::string const &) const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
const float _minFractionToKeep
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
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
void prunePFClusters(reco::PFClusterCollection &) const
Power< A, B >::type pow(const A &a, const B &b)
T get(const Candidate &c)
PFCPositionCalculatorBase PosCalc
void buildClusters(const reco::PFClusterCollection &, const std::vector< bool > &, reco::PFClusterCollection &outclus)
void seedPFClustersFromTopo(const reco::PFCluster &, const std::vector< bool > &, reco::PFClusterCollection &) const
Basic2DGenericPFlowClusterizer(const edm::ParameterSet &conf)