Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HGCAL trigger] Bugfixes #24195

Merged
merged 14 commits into from Aug 7, 2018
Expand Up @@ -238,7 +238,7 @@ getModuleFromTriggerCell( const unsigned trigger_cell_id ) const
}
module = module_itr->second;
}
return HGCalDetId((ForwardSubdetector)trigger_cell_det_id.subdetId(), trigger_cell_det_id.zside(), trigger_cell_det_id.layer(), trigger_cell_det_id.waferType(), module, HGCalDetId::kHGCalCellMask).rawId();
return HGCalDetId((ForwardSubdetector)trigger_cell_det_id.subdetId(), trigger_cell_det_id.zside(), trigger_cell_det_id.layer(), (trigger_cell_det_id.waferType()==1 ? 1:0), module, HGCalDetId::kHGCalCellMask).rawId();
}

HGCalTriggerGeometryBase::geom_set
Expand Down Expand Up @@ -275,7 +275,7 @@ getCellsFromTriggerCell( const unsigned trigger_cell_id ) const
unsigned wafer = 0;
unsigned cell = 0;
unpackWaferCellId(tc_c_itr->second, wafer, cell);
unsigned wafer_type = detIdWaferType(subdet, wafer);
unsigned wafer_type = (detIdWaferType(subdet, wafer)==1 ? 1 : 0);
unsigned cell_det_id = HGCalDetId((ForwardSubdetector)trigger_cell_det_id.subdetId(), trigger_cell_det_id.zside(), trigger_cell_det_id.layer(), wafer_type, wafer, cell).rawId();
if(validCellId(subdet, cell_det_id)) cell_det_ids.emplace(cell_det_id);
}
Expand Down
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
23 changes: 16 additions & 7 deletions L1Trigger/L1THGCal/test/HGCalTriggerGeomTester.cc
Expand Up @@ -17,7 +17,6 @@
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
#include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
Expand Down Expand Up @@ -373,10 +372,11 @@ void HGCalTriggerGeomTester::checkMappingConsistency()
{
if(id.rawId()==0) continue;
HGCalDetId waferid(id);
unsigned wafer_type = (triggerGeometry_->eeTopology().dddConstants().waferTypeT(waferid.wafer())==2?0:1);
int nCells = triggerGeometry_->eeTopology().dddConstants().numberCellsHexagon(waferid.wafer());
for(int i=0;i<nCells;i++)
{
HGCalDetId id(ForwardSubdetector(waferid.subdetId()), waferid.zside(), waferid.layer(), waferid.waferType(), waferid.wafer(), i);
HGCalDetId id(ForwardSubdetector(waferid.subdetId()), waferid.zside(), waferid.layer(), wafer_type, waferid.wafer(), i);
if(!triggerGeometry_->eeTopology().valid(id)) continue;
// fill trigger cells
uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id);
Expand All @@ -393,10 +393,11 @@ void HGCalTriggerGeomTester::checkMappingConsistency()
{
if(id.rawId()==0) continue;
HGCalDetId waferid(id);
unsigned wafer_type = (triggerGeometry_->fhTopology().dddConstants().waferTypeT(waferid.wafer())==2?0:1);
int nCells = triggerGeometry_->fhTopology().dddConstants().numberCellsHexagon(waferid.wafer());
for(int i=0;i<nCells;i++)
{
HGCalDetId id(ForwardSubdetector(waferid.subdetId()), waferid.zside(), waferid.layer(), waferid.waferType(), waferid.wafer(), i);
HGCalDetId id(ForwardSubdetector(waferid.subdetId()), waferid.zside(), waferid.layer(), wafer_type, waferid.wafer(), i);
if(!triggerGeometry_->fhTopology().valid(id)) continue;
// fill trigger cells
uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id);
Expand Down Expand Up @@ -455,6 +456,7 @@ void HGCalTriggerGeomTester::checkMappingConsistency()
output<<cell_geom<<" ";
}
edm::LogProblem("BadTriggerCell")<<output.str();
throw cms::Exception("BadTriggerCell")<<"Trigger cell <-> cell inconsistency";
}
}
}
Expand All @@ -479,6 +481,7 @@ void HGCalTriggerGeomTester::checkMappingConsistency()
output<<cell_geom<<" ";
}
edm::LogProblem("BadModule")<<output.str();
throw cms::Exception("BadModule")<<"Trigger cell <-> module inconsistency";
}
}
}
Expand Down Expand Up @@ -508,6 +511,7 @@ void HGCalTriggerGeomTester::checkMappingConsistency()
output<<cell_geom<<" ";
}
edm::LogProblem("BadModule")<<output.str();
throw cms::Exception("BadModule")<<"Cell <-> module inconsistency";
}
}
}
Expand All @@ -522,10 +526,11 @@ void HGCalTriggerGeomTester::checkNeighborConsistency()
{
if(id.rawId()==0) continue;
HGCalDetId waferid(id);
unsigned wafer_type = (triggerGeometry_->eeTopology().dddConstants().waferTypeT(waferid.wafer())==2?0:1);
int nCells = triggerGeometry_->eeTopology().dddConstants().numberCellsHexagon(waferid.wafer());
for(int i=0;i<nCells;i++)
{
HGCalDetId id(ForwardSubdetector(waferid.subdetId()), waferid.zside(), waferid.layer(), waferid.waferType(), waferid.wafer(), i);
HGCalDetId id(ForwardSubdetector(waferid.subdetId()), waferid.zside(), waferid.layer(), wafer_type, waferid.wafer(), i);
if(!triggerGeometry_->eeTopology().valid(id)) continue;
// fill trigger cells
// Skip trigger cells in module 0
Expand All @@ -541,10 +546,11 @@ void HGCalTriggerGeomTester::checkNeighborConsistency()
{
if(id.rawId()==0) continue;
HGCalDetId waferid(id);
unsigned wafer_type = (triggerGeometry_->fhTopology().dddConstants().waferTypeT(waferid.wafer())==2?0:1);
int nCells = triggerGeometry_->fhTopology().dddConstants().numberCellsHexagon(waferid.wafer());
for(int i=0;i<nCells;i++)
{
HGCalDetId id(ForwardSubdetector(waferid.subdetId()), waferid.zside(), waferid.layer(), waferid.waferType(), waferid.wafer(), i);
HGCalDetId id(ForwardSubdetector(waferid.subdetId()), waferid.zside(), waferid.layer(), wafer_type, waferid.wafer(), i);
if(!triggerGeometry_->fhTopology().valid(id)) continue;
// fill trigger cells
// Skip trigger cells in module 0
Expand Down Expand Up @@ -590,6 +596,7 @@ void HGCalTriggerGeomTester::checkNeighborConsistency()
output<<" "<< HGCalDetId(neighbor_of_neighbor)<<"\n";
}
edm::LogProblem("BadNeighbor")<<output.str();
throw cms::Exception("BadNeighbor")<<"Neighbor mapping not consistent";
}
}
}
Expand All @@ -610,10 +617,11 @@ void HGCalTriggerGeomTester::fillTriggerGeometry()
{
if(id.rawId()==0) continue;
HGCalDetId waferid(id);
unsigned wafer_type = (triggerGeometry_->eeTopology().dddConstants().waferTypeT(waferid.wafer())==2?0:1);
int nCells = triggerGeometry_->eeTopology().dddConstants().numberCellsHexagon(waferid.wafer());
for(int i=0;i<nCells;i++)
{
HGCalDetId id(ForwardSubdetector(waferid.subdetId()), waferid.zside(), waferid.layer(), waferid.waferType(), waferid.wafer(), i);
HGCalDetId id(ForwardSubdetector(waferid.subdetId()), waferid.zside(), waferid.layer(), wafer_type, waferid.wafer(), i);
if(!triggerGeometry_->eeTopology().valid(id)) continue;
cellId_ = id.rawId();
cellSide_ = id.zside();
Expand Down Expand Up @@ -660,10 +668,11 @@ void HGCalTriggerGeomTester::fillTriggerGeometry()
{
if(id.rawId()==0) continue;
HGCalDetId waferid(id);
unsigned wafer_type = (triggerGeometry_->fhTopology().dddConstants().waferTypeT(waferid.wafer())==2?0:1);
int nCells = triggerGeometry_->fhTopology().dddConstants().numberCellsHexagon(waferid.wafer());
for(int i=0;i<nCells;i++)
{
HGCalDetId id(ForwardSubdetector(waferid.subdetId()), waferid.zside(), waferid.layer(), waferid.waferType(), waferid.wafer(), i);
HGCalDetId id(ForwardSubdetector(waferid.subdetId()), waferid.zside(), waferid.layer(), wafer_type, waferid.wafer(), i);
if(!triggerGeometry_->fhTopology().valid(id)) continue;
cellId_ = id.rawId();
cellSide_ = id.zside();
Expand Down
5 changes: 2 additions & 3 deletions L1Trigger/L1THGCal/test/testHGCalL1T_RelVal_cfg.py
@@ -1,9 +1,8 @@
import FWCore.ParameterSet.Config as cms
from Configuration.StandardSequences.Eras import eras
from Configuration.ProcessModifiers.convertHGCalDigisSim_cff import convertHGCalDigisSim



process = cms.Process('DIGI',eras.Phase2)
process = cms.Process('DIGI',eras.Phase2,convertHGCalDigisSim)

# import of standard configurations
process.load('Configuration.StandardSequences.Services_cff')
Expand Down