6 : dr_(conf.getParameter<double>(
"dR_multicluster")),
7 ptC3dThreshold_(conf.getParameter<double>(
"minPt_multicluster")),
8 multiclusterAlgoType_(conf.getParameter<
string>(
"type_multicluster")),
9 distDbscan_(conf.getParameter<double>(
"dist_dbscan_multicluster")),
10 minNDbscan_(conf.getParameter<unsigned>(
"minN_dbscan_multicluster")) {
11 edm::LogInfo(
"HGCalMulticlusterParameters") <<
"Multicluster dR for Near Neighbour search: " <<
dr_;
14 edm::LogInfo(
"HGCalMulticlusterParameters") <<
"Multicluster clustering min number of subclusters: " <<
minNDbscan_;
17 id_ = std::unique_ptr<HGCalTriggerClusterIdentificationBase>{
38 unsigned int searchInd,
40 std::vector<unsigned int>& neighbors) {
41 if (clustersPtrs.size() <= searchInd || clustersPtrs.size() < rankedList.size()) {
42 throw cms::Exception(
"IndexOutOfBound: clustersPtrs in 'findNeighbor'");
45 for (
unsigned int ind = searchInd + 1;
46 ind < rankedList.size() && fabs(rankedList.at(ind).second - rankedList.at(searchInd).second) <
distDbscan_;
48 if (clustersPtrs.size() <= rankedList.at(ind).first) {
49 throw cms::Exception(
"IndexOutOfBound: clustersPtrs in 'findNeighbor'");
51 }
else if (((*(clustersPtrs[rankedList.at(ind).first])).centreProj() -
52 (*(clustersPtrs[rankedList.at(searchInd).first])).centreProj())
54 neighbors.push_back(ind);
58 for (
unsigned int ind = 0;
59 ind < searchInd && fabs(rankedList.at(searchInd).second - rankedList.at(ind).second) <
distDbscan_;
61 if (clustersPtrs.size() <= rankedList.at(ind).first) {
62 throw cms::Exception(
"IndexOutOfBound: clustersPtrs in 'findNeighbor'");
64 }
else if (((*(clustersPtrs[rankedList.at(ind).first])).centreProj() -
65 (*(clustersPtrs[rankedList.at(searchInd).first])).centreProj())
67 neighbors.push_back(ind);
75 std::vector<l1t::HGCalMulticluster> multiclustersTmp;
81 int targetMulticlu = -1;
83 for (
unsigned imclu = 0; imclu < multiclustersTmp.size(); imclu++) {
87 double d = (multiclustersTmp.at(imclu).centreProj() - (*clu)->centreProj()).
mag();
90 targetMulticlu =
int(imclu);
94 if (targetMulticlu < 0)
95 multiclustersTmp.emplace_back(*clu);
97 multiclustersTmp.at(targetMulticlu).addConstituent(*clu);
106 std::vector<l1t::HGCalMulticluster> multiclustersTmp;
108 std::vector<bool>
visited(clustersPtrs.size(),
false);
109 std::vector<bool> merged(clustersPtrs.size(),
false);
110 std::vector<std::pair<unsigned int, double>> rankedList;
111 rankedList.reserve(clustersPtrs.size());
112 std::vector<std::vector<unsigned int>> neighborList;
113 neighborList.reserve(clustersPtrs.size());
115 int iclu = 0, imclu = 0, neighNo;
121 rankedList.push_back(std::make_pair(iclu, dist));
124 std::sort(rankedList.begin(), rankedList.end(), [](
auto& left,
auto& right) {
return left.second < right.second; });
126 for (
const auto& cluRanked : rankedList) {
127 std::vector<unsigned int> neighbors;
131 findNeighbor(rankedList, iclu, clustersPtrs, neighbors);
132 neighborList.push_back(
std::move(neighbors));
135 multiclustersTmp.emplace_back(clustersPtrs[cluRanked.first]);
136 merged.at(iclu) =
true;
138 for (
unsigned int neighInd = 0; neighInd < neighborList.at(iclu).size(); neighInd++) {
139 neighNo = neighborList.at(iclu).at(neighInd);
141 if (!merged.at(neighNo)) {
142 merged.at(neighNo) =
true;
143 multiclustersTmp.at(imclu).addConstituent(clustersPtrs[rankedList.at(neighNo).first]);
147 std::vector<unsigned int> secNeighbors;
148 findNeighbor(rankedList, neighNo, clustersPtrs, secNeighbors);
151 neighborList.at(iclu).insert(neighborList.at(iclu).end(), secNeighbors.begin(), secNeighbors.end());
159 neighborList.push_back(
std::move(neighbors));
169 for (
auto& multicluster : multiclusters_in) {
173 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>&
clusters = multicluster.constituents();
174 for (
const auto& id_cluster :
clusters)
175 sumPt += id_cluster.second->pt();
178 multicluster.setP4(multiclusterP4);
184 multicluster.setHwQual(
id_->decision(multicluster));
186 multicluster.saveHOverE();
188 multiclusters_out.
push_back(0, multicluster);
T getParameter(std::string const &) const
HGCalTriggerTools triggerTools_
HGCalMulticlusteringImpl(const edm::ParameterSet &conf)
std::string multiclusterAlgoType_
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
void fillShapes(l1t::HGCalMulticluster &, const HGCalTriggerGeometryBase &) const
std::unique_ptr< HGCalTriggerClusterIdentificationBase > id_
void findNeighbor(const std::vector< std::pair< unsigned int, double >> &rankedList, unsigned int searchInd, const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtr, std::vector< unsigned int > &neigbors)
void clusterizeDR(const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtr, l1t::HGCalMulticlusterBxCollection &multiclusters, const HGCalTriggerGeometryBase &triggerGeometry)
void finalizeClusters(std::vector< l1t::HGCalMulticluster > &, l1t::HGCalMulticlusterBxCollection &, const HGCalTriggerGeometryBase &)
bool isPertinent(const l1t::HGCalCluster &clu, const l1t::HGCalMulticluster &mclu, double dR) const
Log< level::Info, false > LogInfo
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const GlobalPoint & centreProj() const
void push_back(int bx, T object)
void clusterizeDBSCAN(const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtr, l1t::HGCalMulticlusterBxCollection &multiclusters, const HGCalTriggerGeometryBase &triggerGeometry)