File indexing completed on 2024-04-06 12:27:27
0001 #ifndef KDTreeLinkerBase_h
0002 #define KDTreeLinkerBase_h
0003
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "DataFormats/ParticleFlowReco/interface/PFRecHitFraction.h"
0006 #include "DataFormats/ParticleFlowReco/interface/PFBlockElement.h"
0007 #include "DataFormats/ParticleFlowReco/interface/PFRecHit.h"
0008
0009 #include <vector>
0010 #include <map>
0011 #include <set>
0012
0013 using BlockEltSet = std::set<reco::PFBlockElement *>;
0014 using RecHitSet = std::set<const reco::PFRecHit *>;
0015
0016 using RecHit2BlockEltMap = std::map<const reco::PFRecHit *, BlockEltSet>;
0017 using BlockElt2BlockEltMap = std::map<reco::PFBlockElement *, BlockEltSet>;
0018
0019 class KDTreeLinkerBase {
0020 public:
0021 KDTreeLinkerBase(const edm::ParameterSet &conf) {}
0022 virtual ~KDTreeLinkerBase() {}
0023
0024 void setTargetType(const reco::PFBlockElement::Type &tgt) { _targetType = tgt; }
0025
0026 void setFieldType(const reco::PFBlockElement::Type &fld) { _fieldType = fld; }
0027
0028 const reco::PFBlockElement::Type &targetType() const { return _targetType; }
0029
0030 const reco::PFBlockElement::Type &fieldType() const { return _fieldType; }
0031
0032
0033
0034
0035
0036
0037
0038
0039 void setDebug(bool isDebug);
0040
0041
0042 virtual void insertTargetElt(reco::PFBlockElement *target) = 0;
0043
0044
0045
0046
0047 virtual void insertFieldClusterElt(reco::PFBlockElement *cluster) = 0;
0048
0049
0050 virtual void buildTree() = 0;
0051
0052
0053
0054
0055 virtual void searchLinks() = 0;
0056
0057
0058
0059 virtual void updatePFBlockEltWithLinks() = 0;
0060
0061
0062 virtual void clear() = 0;
0063
0064
0065
0066 inline void process() {
0067 buildTree();
0068 searchLinks();
0069 updatePFBlockEltWithLinks();
0070 clear();
0071 }
0072
0073 protected:
0074
0075 reco::PFBlockElement::Type _targetType, _fieldType;
0076
0077 float cristalPhiEtaMaxSize_ = 0.04;
0078 float cristalXYMaxSize_ = 3.;
0079
0080
0081
0082
0083
0084 float phiOffset_ = 0.25;
0085
0086
0087 const float cutOffFrac = 1E-4;
0088
0089
0090 bool debug_ = false;
0091
0092
0093 template <typename T>
0094 static std::vector<size_t> sort_indexes(const std::vector<T> &v) {
0095 std::vector<size_t> idx(v.size());
0096 for (size_t i = 0; i != idx.size(); ++i)
0097 idx[i] = i;
0098 std::sort(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) { return v[i1] < v[i2]; });
0099 return idx;
0100 }
0101 };
0102
0103 #include "FWCore/PluginManager/interface/PluginFactory.h"
0104 typedef edmplugin::PluginFactory<KDTreeLinkerBase *(const edm::ParameterSet &)> KDTreeLinkerFactory;
0105
0106 #endif