Skip to content

Commit

Permalink
Merge pull request cms-sw#212 from PFCal-dev/fix-clusters-towers-back…
Browse files Browse the repository at this point in the history
…port-1017

[Backport 10_1_7] Fixes in clustering and towers
  • Loading branch information
jbsauvan committed Aug 3, 2018
2 parents e54d203 + 42a657a commit 52fc47a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 49 deletions.
7 changes: 4 additions & 3 deletions L1Trigger/L1THGCal/src/HGCalTriggerTowerGeometryHelper.cc
Expand Up @@ -45,12 +45,13 @@ HGCalTriggerTowerGeometryHelper::HGCalTriggerTowerGeometryHelper(const edm::Para
}
}


for(int zside = -1; zside <= 1; zside+=2) {
for(unsigned int bin1 = 0; bin1 != nBinsEta_; bin1++) {
for(unsigned int bin2 = 0; bin2 != nBinsPhi_; bin2++) {
l1t::HGCalTowerID towerId(zside, bin1, bin2);
tower_coords_.emplace_back(towerId.rawId(),
(binsEta_[bin1+1] + binsEta_[bin1])/2,
zside*((binsEta_[bin1+1] + binsEta_[bin1])/2),
(binsPhi_[bin2+1] + binsPhi_[bin2])/2);
}
}
Expand Down Expand Up @@ -109,7 +110,7 @@ unsigned short HGCalTriggerTowerGeometryHelper::getTriggerTowerFromTriggerCell(c
edm::LogError("HGCalTriggerTowerGeometryHelper") << " did not manage to map TC " << trigger_cell_id << " (eta: " << eta << ") to any Trigger Tower\n";
}
} else {
bin_eta = bin_eta_l - binsEta_.begin();
bin_eta = bin_eta_l - binsEta_.begin() - 1;
}


Expand All @@ -124,7 +125,7 @@ unsigned short HGCalTriggerTowerGeometryHelper::getTriggerTowerFromTriggerCell(c
edm::LogError("HGCalTriggerTowerGeometryHelper") << " did not manage to map TC " << trigger_cell_id << " (phi: " << phi << ") to any Trigger Tower\n";
}
} else {
bin_phi = bin_phi_l - binsPhi_.begin();
bin_phi = bin_phi_l - binsPhi_.begin() - 1;
}
int zside = eta < 0 ? -1 : 1;
return l1t::HGCalTowerID(zside, bin_eta, bin_phi).rawId();
Expand Down
37 changes: 14 additions & 23 deletions L1Trigger/L1THGCal/src/be_algorithms/HGCalClusteringImpl.cc
Expand Up @@ -74,33 +74,24 @@ void HGCalClusteringImpl::clusterizeDR( const std::vector<edm::Ptr<l1t::HGCalTri
ToBeFixed: if a tc is not a seed, but could be potencially be part of a cluster generated by a late seed,
the tc will not be clusterized
*/
int iclu=0;
vector<int> tcPertinentClusters;
for( const auto& clu : clustersTmp){
if( this->isPertinent(**tc, clu, dr_) ){
tcPertinentClusters.push_back(iclu);

double minDist = dr_;
int targetClu = -1;

for(unsigned iclu=0; iclu<clustersTmp.size(); iclu++){

if(!this->isPertinent(**tc, clustersTmp.at(iclu), dr_)) continue;

double d = clustersTmp.at(iclu).distance(**tc);
if(d<minDist){
minDist = d;
targetClu = int(iclu);
}
++iclu;
}
if( tcPertinentClusters.empty() && isSeed[itc] ){
clustersTmp.emplace_back( *tc );
}
else if ( !tcPertinentClusters.empty() ){

unsigned minDist(300);
unsigned targetClu(0);

for( int iclu : tcPertinentClusters){
double d = clustersTmp.at(iclu).distance(**tc);
if( d < minDist ){
minDist = d;
targetClu = iclu;
}
}

clustersTmp.at(targetClu).addConstituent( *tc );
if(targetClu<0 && isSeed[itc]) clustersTmp.emplace_back( *tc );
else if(targetClu>=0) clustersTmp.at( targetClu ).addConstituent( *tc );

}
}

/* store clusters in the persistent collection */
Expand Down
38 changes: 15 additions & 23 deletions L1Trigger/L1THGCal/src/be_algorithms/HGCalMulticlusteringImpl.cc
Expand Up @@ -81,32 +81,24 @@ void HGCalMulticlusteringImpl::clusterizeDR( const std::vector<edm::Ptr<l1t::HGC

int iclu = 0;
for(std::vector<edm::Ptr<l1t::HGCalCluster>>::const_iterator clu = clustersPtrs.begin(); clu != clustersPtrs.end(); ++clu, ++iclu){

int imclu=0;
vector<int> tcPertinentMulticlusters;
for( const auto& mclu : multiclustersTmp ){
if( this->isPertinent(**clu, mclu, dr_) ){
tcPertinentMulticlusters.push_back(imclu);

double minDist = dr_;
int targetMulticlu = -1;

for(unsigned imclu=0; imclu<multiclustersTmp.size(); imclu++){

if(!this->isPertinent(**clu, multiclustersTmp.at(imclu), dr_)) continue;

double d = ( multiclustersTmp.at(imclu).centreProj() - (*clu)->centreProj() ).mag() ;
if(d<minDist){
minDist = d;
targetMulticlu = int(imclu);
}
++imclu;
}
if( tcPertinentMulticlusters.empty() ){
multiclustersTmp.emplace_back( *clu );
}
else{
unsigned minDist = 1;
unsigned targetMulticlu = 0;
for( int imclu : tcPertinentMulticlusters ){
double d = ( multiclustersTmp.at(imclu).centreProj() - (*clu)->centreProj() ).mag() ;
if( d < minDist ){
minDist = d;
targetMulticlu = imclu;
}
}

multiclustersTmp.at( targetMulticlu ).addConstituent( *clu );
}
if(targetMulticlu<0) multiclustersTmp.emplace_back( *clu );
else multiclustersTmp.at( targetMulticlu ).addConstituent( *clu );

}

/* making the collection of multiclusters */
Expand Down

0 comments on commit 52fc47a

Please sign in to comment.