9 dr_(conf.getParameter<double>(
"dR_multicluster")),
10 ptC3dThreshold_(conf.getParameter<double>(
"minPt_multicluster")),
11 multiclusterAlgoType_(conf.getParameter<
string>(
"type_multicluster")),
12 distDbscan_(conf.getParameter<double>(
"dist_dbscan_multicluster")),
13 minNDbscan_(conf.getParameter<unsigned>(
"minN_dbscan_multicluster"))
15 edm::LogInfo(
"HGCalMulticlusterParameters") <<
"Multicluster dR for Near Neighbour search: " <<
dr_;
18 edm::LogInfo(
"HGCalMulticlusterParameters") <<
"Multicluster clustering min number of subclusters: " <<
minNDbscan_;
30 if( cluDetId.zside() != firstClusterDetId.zside() ){
42 unsigned int searchInd,
44 std::vector<unsigned int>& neighbors
47 if(clustersPtrs.size() <= searchInd || clustersPtrs.size() < rankedList.size()){
48 throw cms::Exception(
"IndexOutOfBound: clustersPtrs in 'findNeighbor'");
51 for(
unsigned int ind = searchInd+1; ind < rankedList.size() && fabs(rankedList.at(ind).second - rankedList.at(searchInd).second) <
distDbscan_ ; ind++){
53 if(clustersPtrs.size() <= rankedList.at(ind).first){
54 throw cms::Exception(
"IndexOutOfBound: clustersPtrs in 'findNeighbor'");
56 }
else if(((*(clustersPtrs[rankedList.at(ind).first])).centreProj() - (*(clustersPtrs[rankedList.at(searchInd).first])).centreProj()).
mag() <
distDbscan_){
57 neighbors.push_back(ind);
61 for(
unsigned int ind = 0; ind < searchInd && fabs(rankedList.at(searchInd).second - rankedList.at(ind).second) <
distDbscan_ ; ind++){
63 if(clustersPtrs.size() <= rankedList.at(ind).first){
64 throw cms::Exception(
"IndexOutOfBound: clustersPtrs in 'findNeighbor'");
66 }
else if(((*(clustersPtrs[rankedList.at(ind).first])).centreProj() - (*(clustersPtrs[rankedList.at(searchInd).first])).centreProj()).
mag() <
distDbscan_){
67 neighbors.push_back(ind);
78 std::vector<l1t::HGCalMulticluster> multiclustersTmp;
84 vector<int> tcPertinentMulticlusters;
85 for(
const auto& mclu : multiclustersTmp ){
87 tcPertinentMulticlusters.push_back(imclu);
91 if( tcPertinentMulticlusters.empty() ){
92 multiclustersTmp.emplace_back( *clu );
96 unsigned targetMulticlu = 0;
97 for(
int imclu : tcPertinentMulticlusters ){
98 double d = ( multiclustersTmp.at(imclu).centreProj() - (*clu)->centreProj() ).
mag() ;
101 targetMulticlu = imclu;
105 multiclustersTmp.at( targetMulticlu ).addConstituent( *clu );
111 for(
unsigned i(0);
i<multiclustersTmp.size(); ++
i ){
116 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>> &pertinentClu = multiclustersTmp[
i].constituents();
117 for(
const auto& id_cluster : pertinentClu) sumPt += id_cluster.second->pt();
119 multiclustersTmp[
i].centre().
eta(),
120 multiclustersTmp[
i].centre().
phi(),
122 multiclustersTmp[
i].setP4( multiclusterP4 );
140 multiclustersTmp[
i].eMax(
shape_.
eMax(multiclustersTmp[i]));
142 multiclusters.
push_back( 0, multiclustersTmp[i]);
152 std::vector<l1t::HGCalMulticluster> multiclustersTmp;
154 std::vector<bool>
visited(clustersPtrs.size(),
false);
155 std::vector<bool> merged (clustersPtrs.size(),
false);
156 std::vector<std::pair<unsigned int,double>> rankedList;
157 rankedList.reserve(clustersPtrs.size());
158 std::vector<std::vector<unsigned int>> neighborList;
159 neighborList.reserve(clustersPtrs.size());
161 int iclu = 0, imclu = 0, neighNo;
164 for(std::vector<
edm::Ptr<l1t::HGCalCluster>>::const_iterator clu = clustersPtrs.begin(); clu != clustersPtrs.end(); ++clu, ++iclu){
166 rankedList.push_back(std::make_pair(iclu,dist));
169 std::sort(rankedList.begin(), rankedList.end(), [](
auto &left,
auto &right) {
170 return left.second < right.second;
173 for(
const auto& cluRanked: rankedList){
174 std::vector<unsigned int> neighbors;
178 findNeighbor(rankedList, iclu, clustersPtrs, neighbors);
179 neighborList.push_back(
std::move(neighbors));
182 multiclustersTmp.emplace_back( clustersPtrs[cluRanked.first] );
183 merged.at(iclu) =
true;
185 for(
unsigned int neighInd = 0; neighInd < neighborList.at(iclu).size(); neighInd++){
186 neighNo = neighborList.at(iclu).at(neighInd);
188 if(!merged.at(neighNo) ){
189 merged.at(neighNo) =
true;
190 multiclustersTmp.at(imclu).addConstituent( clustersPtrs[rankedList.at(neighNo).first] );
194 std::vector<unsigned int> secNeighbors;
195 findNeighbor(rankedList, neighNo,clustersPtrs, secNeighbors);
198 neighborList.at(iclu).insert(neighborList.at(iclu).end(), secNeighbors.begin(), secNeighbors.end());
206 else neighborList.push_back(
std::move(neighbors));
210 for(
unsigned i(0);
i<multiclustersTmp.size(); ++
i ){
215 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>> &pertinentClu = multiclustersTmp[
i].constituents();
216 for(
const auto& id_cluster : pertinentClu) sumPt += id_cluster.second->pt();
219 multiclustersTmp[
i].centre().
eta(),
220 multiclustersTmp[
i].centre().
phi(),
222 multiclustersTmp[
i].setP4( multiclusterP4 );
240 multiclustersTmp[
i].eMax(
shape_.
eMax(multiclustersTmp[i]));
242 multiclusters.
push_back( 0, multiclustersTmp[i]);
float sigmaRRMax(const l1t::HGCalMulticluster &c3d) const
HGCalMulticlusteringImpl(const edm::ParameterSet &conf)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
int coreShowerLength(const l1t::HGCalMulticluster &c3d, const HGCalTriggerGeometryBase &triggerGeometry) const
float sigmaRRTot(const l1t::HGCalMulticluster &c3d) const
float sigmaPhiPhiTot(const l1t::HGCalMulticluster &c3d) const
int firstLayer(const l1t::HGCalMulticluster &c3d) const
const GlobalPoint & centreProj() const
std::string multiclusterAlgoType_
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
float sigmaRRMean(const l1t::HGCalMulticluster &c3d, float radius=5.) const
float sigmaEtaEtaMax(const l1t::HGCalMulticluster &c3d) const
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)
bool isPertinent(const l1t::HGCalCluster &clu, const l1t::HGCalMulticluster &mclu, double dR) const
void clusterizeDR(const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtr, l1t::HGCalMulticlusterBxCollection &multiclusters, const HGCalTriggerGeometryBase &triggerGeometry)
int showerLength(const l1t::HGCalMulticluster &c3d) const
float sigmaZZ(const l1t::HGCalMulticluster &c3d) const
float sigmaPhiPhiMax(const l1t::HGCalMulticluster &c3d) const
int maxLayer(const l1t::HGCalMulticluster &c3d) const
float eMax(const l1t::HGCalMulticluster &c3d) const
float sigmaEtaEtaTot(const l1t::HGCalMulticluster &c3d) const
void push_back(int bx, T object)
void clusterizeDBSCAN(const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtr, l1t::HGCalMulticlusterBxCollection &multiclusters, const HGCalTriggerGeometryBase &triggerGeometry)