1 #include <unordered_set> 2 #include <unordered_map> 9 siliconSeedThreshold_(conf.getParameter<double>(
"seeding_threshold_silicon")),
10 siliconTriggerCellThreshold_(conf.getParameter<double>(
"clustering_threshold_silicon")),
11 scintillatorSeedThreshold_(conf.getParameter<double>(
"seeding_threshold_scintillator")),
12 scintillatorTriggerCellThreshold_(conf.getParameter<double>(
"clustering_threshold_scintillator")),
13 dr_(conf.getParameter<double>(
"dR_cluster")),
14 clusteringAlgorithmType_(conf.getParameter<
string>(
"clusterType"))
33 if( (tcDetId.layer() != cluDetId.layer()) ||
34 (tcDetId.subdetId() != cluDetId.subdetId()) ||
35 (tcDetId.zside() != cluDetId.zside()) ){
50 bool isSeed[triggerCellsPtrs.
size()];
56 isSeed[itc] = ( (*tc)->mipPt() >
seedThreshold) ?
true :
false;
60 std::vector<l1t::HGCalCluster> clustersTmp;
71 vector<int> tcPertinentClusters;
72 for(
const auto& clu : clustersTmp){
74 tcPertinentClusters.push_back(iclu);
78 if( tcPertinentClusters.size() == 0 && isSeed[itc] ){
79 clustersTmp.emplace_back( *tc );
81 else if ( tcPertinentClusters.size() > 0 ){
83 unsigned minDist(300);
84 unsigned targetClu(0);
86 for(
int iclu : tcPertinentClusters){
87 double d = clustersTmp.at(iclu).distance(**tc);
94 clustersTmp.at(targetClu).addConstituent( *tc );
100 clusters.
resize(0, clustersTmp.size());
101 for(
unsigned i(0);
i<clustersTmp.size(); ++
i ){
102 clusters.
set( 0,
i, clustersTmp.at(
i) );
116 for(
const auto& tc : triggerCellsPtrs ){
117 int endcap = tc->zside() == -1 ? 0 : 1 ;
122 if( subdet ==
HGCEE ){
125 else if( subdet ==
HGCHEF ){
128 else if( subdet ==
HGCHEB ){
132 reshuffledTriggerCells[
endcap][layer-1].emplace_back(tc);
159 std::vector<l1t::HGCalCluster> clustersTmp;
162 std::unordered_map<uint32_t, unsigned> cluNNmap;
165 for(
const auto& tc_ptr : reshuffledTriggerCells ){
174 bool createNewC2d(
true);
176 for(
const auto neighbor : neighbors ){
177 auto tc_cluster_itr = cluNNmap.find(neighbor);
178 if(tc_cluster_itr!=cluNNmap.end()){
179 createNewC2d =
false;
180 if( tc_cluster_itr->second < clustersTmp.size()){
181 clustersTmp.at(tc_cluster_itr->second).addConstituent(tc_ptr);
183 cluNNmap.emplace(tc_ptr->detId(), tc_cluster_itr->second);
187 <<
"Trying to access a non-existing cluster. But it should exist...\n";
193 clustersTmp.emplace_back(tc_ptr);
194 clustersTmp.back().setValid(
true);
196 cluNNmap.emplace(tc_ptr->detId(), clustersTmp.size()-1);
202 for(
auto& cluster1 : clustersTmp){
204 if( !cluster1.valid() )
continue;
207 std::unordered_set<uint32_t> cluTcSet;
208 for(
const auto& tc_clu1 : cluster1.constituents()){
209 cluTcSet.insert( tc_clu1->detId() );
211 for(
const auto neighbor : neighbors){
212 cluTcSet.insert( neighbor );
216 for(
auto& cluster2 : clustersTmp ){
218 if( cluster1.detId()==cluster2.detId() )
continue;
219 if( !cluster2.valid() )
continue;
222 for(
const auto& tc_clu2 : cluster2.constituents()){
223 if( cluTcSet.find(tc_clu2->detId())!=cluTcSet.end() ){
225 cluTcSet.insert( tc_clu2->detId() );
227 for(
const auto neighbor : neighbors){
228 cluTcSet.insert( neighbor );
230 cluster2.setValid(
false);
239 for(
auto& cluster : clustersTmp ){
240 if( !cluster.valid() )
continue;
241 bool saveInCollection(
false);
242 for(
const auto& tc_ptr : cluster.constituents() ){
246 saveInCollection =
true;
250 if(saveInCollection){
262 std::array< std::array< std::vector<edm::Ptr<l1t::HGCalTriggerCell> >,
kLayers_>,
kNSides_> reshuffledTriggerCells;
265 for(
unsigned iec=0; iec<
kNSides_; ++iec){
266 for(
unsigned il=0; il<
kLayers_; ++il){
267 NNKernel( reshuffledTriggerCells[iec][il], clusters, triggerGeometry );
double distance(const l1t::HGCalTriggerCell &tc) const
double siliconSeedThreshold_
size_type size() const
Size of the RefVector.
double scintillatorSeedThreshold_
void clusterizeDR(const edm::PtrVector< l1t::HGCalTriggerCell > &triggerCellsPtrs, l1t::HGCalClusterBxCollection &clusters)
virtual geom_set getNeighborsFromTriggerCell(const unsigned trigger_cell_det_id) const =0
void mergeClusters(l1t::HGCalCluster &main_cluster, const l1t::HGCalCluster &secondary_cluster) const
static const unsigned kLayersFH_
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_
double scintillatorTriggerCellThreshold_
double siliconTriggerCellThreshold_
void push_back(int bx, T object)