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 =
44 conf.getParameterSetVector(
"recHitEnergyNorms");
45 for(
const auto&
pset : thresholds ) {
49 std::vector<double> rhE_norm;
52 depths=
pset.getParameter<std::vector<int> >(
"depths");
53 rhE_norm =
pset.getParameter<std::vector<double> >(
"recHitEnergyNorm");
56 rhE_norm.push_back(
pset.getParameter<
double>(
"recHitEnergyNorm"));
59 if( rhE_norm.size()!=depths.size() ) {
61 <<
"PFlowClusterizerThreshold mismatch with the numbers of depths";
68 <<
"Detector layer : " << det <<
" is not in the list of recognized" 69 <<
" detector layers!";
75 if( conf.exists(
"allCellsPositionCalc") ) {
86 if( conf.exists(
"positionCalcForConvergence") ) {
99 const std::vector<bool>& seedable,
102 for(
const auto& topocluster : input ) {
103 clustersInTopo.clear();
105 const unsigned tolScal =
107 growPFClusters(topocluster,seedable,tolScal,0,tolScal,clustersInTopo);
123 for(
auto& clusterout : clustersInTopo ) {
124 output.insert(output.end(),
std::move(clusterout));
131 const std::vector<bool>& seedable,
134 for(
const auto& rhf : recHitFractions ) {
135 if( !seedable[rhf.recHitRef().key()] )
continue;
139 current.
setSeed(rhf.recHitRef()->detId());
150 const std::vector<bool>& seedable,
151 const unsigned toleranceScaling,
156 LOGDRESSED(
"Basic2DGenericPFlowClusterizer:growAndStabilizePFClusters")
157 <<
"reached " <<
_maxIterations <<
" iterations, terminated position " 158 <<
"fit with diff = " <<
diff;
163 std::vector<reco::PFCluster::REPPoint> clus_prev_pos;
164 for(
auto& cluster : clusters) {
166 clus_prev_pos.emplace_back(repp.rho(),repp.eta(),repp.phi());
174 cluster.resetHitsAndFractions();
177 std::vector<double> dist2,
frac;
181 int cell_layer = (
int)refhit->layer();
183 std::abs(refhit->positionREP().eta()) > 0.34 ) {
188 dist2.clear(); frac.clear(); fractot = 0;
193 for (
unsigned int j=0; j<recHitEnergyNormDepthPair.second.size(); ++j) {
194 int depth=recHitEnergyNormDepthPair.first[j];
199 ) recHitEnergyNorm = recHitEnergyNormDepthPair.second[j];
203 for(
auto& cluster : clusters ) {
207 dist2.emplace_back( d2 );
209 LOGDRESSED(
"Basic2DGenericPFlowClusterizer:growAndStabilizePFClusters")
210 <<
"Warning! :: pfcluster-topocell distance is too large! d= " 221 fraction = cluster.energy()/recHitEnergyNorm *
vdt::fast_expf( -0.5*d2 );
224 frac.emplace_back(fraction);
226 for(
unsigned i = 0;
i < clusters.size(); ++
i ) {
228 ( refhit->detId() == clusters[
i].seed() && fractot > 0.0 ) ) {
244 if( dist2[
i] < 100.0 || frac[
i] > 0.9999 ) {
251 for(
unsigned i = 0;
i < clusters.size(); ++
i ) {
261 const double delta2 =
263 if( delta2 > diff2 ) diff2 = delta2;
266 dist2.clear(); frac.clear(); clus_prev_pos.clear();
267 growPFClusters(topo,seedable,toleranceScaling,iter+1,diff,clusters);
272 for(
auto& cluster : clusters ) {
T getParameter(std::string const &) const
const unsigned _maxIterations
void growPFClusters(const reco::PFCluster &, const std::vector< bool > &, const unsigned toleranceScaling, const unsigned iter, double dist, reco::PFClusterCollection &) const
void buildClusters(const reco::PFClusterCollection &, const std::vector< bool > &, reco::PFClusterCollection &outclus) override
std::unordered_map< int, std::pair< std::vector< int >, std::vector< double > > > _recHitEnergyNorms
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
std::unique_ptr< PosCalc > _positionCalc
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)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
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)
void seedPFClustersFromTopo(const reco::PFCluster &, const std::vector< bool > &, reco::PFClusterCollection &) const
Basic2DGenericPFlowClusterizer(const edm::ParameterSet &conf)