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_;
32 if( cluDetId.zside() != firstClusterDetId.zside() ){
44 unsigned int searchInd,
46 std::vector<unsigned int>& neighbors
49 if(clustersPtrs.size() <= searchInd || clustersPtrs.size() < rankedList.size()){
50 throw cms::Exception(
"IndexOutOfBound: clustersPtrs in 'findNeighbor'");
53 for(
unsigned int ind = searchInd+1; ind < rankedList.size() && fabs(rankedList.at(ind).second - rankedList.at(searchInd).second) <
distDbscan_ ; ind++){
55 if(clustersPtrs.size() <= rankedList.at(ind).first){
56 throw cms::Exception(
"IndexOutOfBound: clustersPtrs in 'findNeighbor'");
58 }
else if(((*(clustersPtrs[rankedList.at(ind).first])).centreProj() - (*(clustersPtrs[rankedList.at(searchInd).first])).centreProj()).
mag() <
distDbscan_){
59 neighbors.push_back(ind);
63 for(
unsigned int ind = 0; ind < searchInd && fabs(rankedList.at(searchInd).second - rankedList.at(ind).second) <
distDbscan_ ; ind++){
65 if(clustersPtrs.size() <= rankedList.at(ind).first){
66 throw cms::Exception(
"IndexOutOfBound: clustersPtrs in 'findNeighbor'");
68 }
else if(((*(clustersPtrs[rankedList.at(ind).first])).centreProj() - (*(clustersPtrs[rankedList.at(searchInd).first])).centreProj()).
mag() <
distDbscan_){
69 neighbors.push_back(ind);
80 std::vector<l1t::HGCalMulticluster> multiclustersTmp;
86 vector<int> tcPertinentMulticlusters;
87 for(
const auto& mclu : multiclustersTmp ){
89 tcPertinentMulticlusters.push_back(imclu);
93 if( tcPertinentMulticlusters.empty() ){
94 multiclustersTmp.emplace_back( *clu );
98 unsigned targetMulticlu = 0;
99 for(
int imclu : tcPertinentMulticlusters ){
100 double d = ( multiclustersTmp.at(imclu).centreProj() - (*clu)->centreProj() ).
mag() ;
103 targetMulticlu = imclu;
107 multiclustersTmp.at( targetMulticlu ).addConstituent( *clu );
121 std::vector<l1t::HGCalMulticluster> multiclustersTmp;
123 std::vector<bool>
visited(clustersPtrs.size(),
false);
124 std::vector<bool> merged (clustersPtrs.size(),
false);
125 std::vector<std::pair<unsigned int,double>> rankedList;
126 rankedList.reserve(clustersPtrs.size());
127 std::vector<std::vector<unsigned int>> neighborList;
128 neighborList.reserve(clustersPtrs.size());
130 int iclu = 0, imclu = 0, neighNo;
133 for(std::vector<
edm::Ptr<l1t::HGCalCluster>>::const_iterator clu = clustersPtrs.begin(); clu != clustersPtrs.end(); ++clu, ++iclu){
135 rankedList.push_back(std::make_pair(iclu,dist));
138 std::sort(rankedList.begin(), rankedList.end(), [](
auto &left,
auto &right) {
139 return left.second < right.second;
142 for(
const auto& cluRanked: rankedList){
143 std::vector<unsigned int> neighbors;
147 findNeighbor(rankedList, iclu, clustersPtrs, neighbors);
148 neighborList.push_back(
std::move(neighbors));
151 multiclustersTmp.emplace_back( clustersPtrs[cluRanked.first] );
152 merged.at(iclu) =
true;
154 for(
unsigned int neighInd = 0; neighInd < neighborList.at(iclu).size(); neighInd++){
155 neighNo = neighborList.at(iclu).at(neighInd);
157 if(!merged.at(neighNo) ){
158 merged.at(neighNo) =
true;
159 multiclustersTmp.at(imclu).addConstituent( clustersPtrs[rankedList.at(neighNo).first] );
163 std::vector<unsigned int> secNeighbors;
164 findNeighbor(rankedList, neighNo,clustersPtrs, secNeighbors);
167 neighborList.at(iclu).insert(neighborList.at(iclu).end(), secNeighbors.begin(), secNeighbors.end());
175 else neighborList.push_back(
std::move(neighbors));
188 for(
auto& multicluster : multiclusters_in) {
192 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>&
clusters = multicluster.constituents();
193 for(
const auto& id_cluster : clusters) sumPt += id_cluster.second->pt();
196 multicluster.centre().eta(),
197 multicluster.centre().phi(),
199 multicluster.setP4( multiclusterP4 );
217 multicluster.setHwQual(
id_->decision(multicluster));
219 multiclusters_out.
push_back( 0, multicluster);
float sigmaRRMax(const l1t::HGCalMulticluster &c3d) const
T getParameter(std::string const &) const
HGCalMulticlusteringImpl(const edm::ParameterSet &conf)
def create(alignables, pedeDump, additionalData, outputFile, config)
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
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)
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)
void finalizeClusters(std::vector< l1t::HGCalMulticluster > &, l1t::HGCalMulticlusterBxCollection &, const HGCalTriggerGeometryBase &)
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
T get(const Candidate &c)
void push_back(int bx, T object)
void clusterizeDBSCAN(const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtr, l1t::HGCalMulticlusterBxCollection &multiclusters, const HGCalTriggerGeometryBase &triggerGeometry)