1 #include <unordered_set> 2 #include <unordered_map> 9 seedThreshold_(conf.getParameter<double>(
"seeding_threshold")),
10 triggerCellThreshold_(conf.getParameter<double>(
"clustering_threshold")),
11 dr_(conf.getParameter<double>(
"dR_cluster")),
12 clusteringAlgorithmType_(conf.getParameter<
string>(
"clusterType"))
29 if( (tcDetId.layer() != cluDetId.layer()) ||
30 (tcDetId.subdetId() != cluDetId.subdetId()) ||
31 (tcDetId.zside() != cluDetId.zside()) ){
46 bool isSeed[triggerCellsPtrs.
size()];
55 std::vector<l1t::HGCalCluster> clustersTmp;
66 vector<int> tcPertinentClusters;
67 for(
const auto& clu : clustersTmp){
69 tcPertinentClusters.push_back(iclu);
73 if( tcPertinentClusters.size() == 0 && isSeed[itc] ){
74 clustersTmp.emplace_back( *tc );
76 else if ( tcPertinentClusters.size() > 0 ){
78 unsigned minDist(300);
79 unsigned targetClu(0);
81 for(
int iclu : tcPertinentClusters){
82 double d = clustersTmp.at(iclu).distance(**tc);
89 clustersTmp.at(targetClu).addConstituent( *tc );
95 clusters.
resize(0, clustersTmp.size());
96 for(
unsigned i(0);
i<clustersTmp.size(); ++
i ){
97 clusters.
set( 0,
i, clustersTmp.at(
i) );
112 int endcap = (*tc)->zside() == -1 ? 0 : 1 ;
117 if( subdet ==
HGCEE ){
118 layer = (*tc)->layer();
120 else if( subdet ==
HGCHEF ){
123 else if( subdet ==
HGCHEB ){
124 edm::LogWarning(
"DataNotFound") <<
"WARNING: the BH trgCells are not yet implemented";
127 reshuffledTriggerCells[
endcap][layer-1].emplace_back(*tc);
154 std::vector<l1t::HGCalCluster> clustersTmp;
157 std::unordered_map<uint32_t, unsigned> cluNNmap;
160 for(
const auto& tc_ptr : reshuffledTriggerCells ){
169 bool createNewC2d(
true);
171 for(
const auto neighbor : neighbors ){
172 auto tc_cluster_itr = cluNNmap.find(
neighbor);
173 if(tc_cluster_itr!=cluNNmap.end()){
174 createNewC2d =
false;
175 if( tc_cluster_itr->second < clustersTmp.size()){
176 clustersTmp.at(tc_cluster_itr->second).addConstituent(tc_ptr);
178 cluNNmap.emplace(tc_ptr->detId(), tc_cluster_itr->second);
182 <<
"Trying to access a non-existing cluster. But it should exist...\n";
188 clustersTmp.emplace_back(tc_ptr);
189 clustersTmp.back().setValid(
true);
191 cluNNmap.emplace(tc_ptr->detId(), clustersTmp.size()-1);
197 for(
auto& cluster1 : clustersTmp){
199 if( !cluster1.valid() )
continue;
202 std::unordered_set<uint32_t> cluTcSet;
203 for(
const auto& tc_clu1 : cluster1.constituents()){
204 cluTcSet.insert( tc_clu1->detId() );
206 for(
const auto neighbor : neighbors){
211 for(
auto& cluster2 : clustersTmp ){
213 if( cluster1.detId()==cluster2.detId() )
continue;
214 if( !cluster2.valid() )
continue;
217 for(
const auto& tc_clu2 : cluster2.constituents()){
218 if( cluTcSet.find(tc_clu2->detId())!=cluTcSet.end() ){
220 cluTcSet.insert( tc_clu2->detId() );
222 for(
const auto neighbor : neighbors){
225 cluster2.setValid(
false);
234 for(
auto& cluster : clustersTmp ){
235 if( !cluster.valid() )
continue;
236 bool saveInCollection(
false);
237 for(
const auto& tc_ptr : cluster.constituents() ){
240 saveInCollection =
true;
244 if(saveInCollection){
256 std::array< std::array< std::vector<edm::Ptr<l1t::HGCalTriggerCell> >,
kLayers_>,
kNSides_> reshuffledTriggerCells;
259 for(
unsigned iec=0; iec<
kNSides_; ++iec){
260 for(
unsigned il=0; il<
kLayers_; ++il){
261 NNKernel( reshuffledTriggerCells[iec][il], clusters, triggerGeometry );
double distance(const l1t::HGCalTriggerCell &tc) const
size_type size() const
Size of the RefVector.
void clusterizeDR(const edm::PtrVector< l1t::HGCalTriggerCell > &triggerCellsPtrs, l1t::HGCalClusterBxCollection &clusters)
double triggerCellThreshold_
virtual geom_set getNeighborsFromTriggerCell(const unsigned trigger_cell_det_id) const =0
void mergeClusters(l1t::HGCalCluster &main_cluster, const l1t::HGCalCluster &secondary_cluster) const
bool neighbor(int endcap, int sector, int SectIndex, int id, int sub, int station)
void clusterizeNN(const edm::PtrVector< l1t::HGCalTriggerCell > &triggerCellsPtrs, l1t::HGCalClusterBxCollection &clusters, const HGCalTriggerGeometryBase &triggerGeometry)
const_iterator begin() const
bool isPertinent(const l1t::HGCalTriggerCell &tc, const l1t::HGCalCluster &clu, double distXY) const
void triggerCellReshuffling(const edm::PtrVector< l1t::HGCalTriggerCell > &triggerCellsPtrs, std::array< std::array< std::vector< edm::Ptr< l1t::HGCalTriggerCell >>, kLayers_ >, kNSides_ > &reshuffledTriggerCells)
static const unsigned kLayersEE_
std::string clusteringAlgorithmType_
const_iterator end() const
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
void set(int bx, unsigned i, const T &object)
static const unsigned kNSides_
void addConstituent(const edm::Ptr< C > &c)
HGCalClusteringImpl(const edm::ParameterSet &conf)
void resize(int bx, unsigned size)
const edm::PtrVector< C > & constituents() const
void NNKernel(const std::vector< edm::Ptr< l1t::HGCalTriggerCell >> &reshuffledTriggerCells, l1t::HGCalClusterBxCollection &clusters, const HGCalTriggerGeometryBase &triggerGeometry)
static const unsigned kLayers_
void push_back(int bx, T object)