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] Updates in Module sums and Towers #34093

Merged
merged 6 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DataFormats/L1THGCal/interface/HGCalTower.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace l1t {
double etHad,
double eta,
double phi,
unsigned short id,
uint32_t id,
int hwpt = 0,
int hweta = 0,
int hwphi = 0,
Expand Down
24 changes: 15 additions & 9 deletions DataFormats/L1THGCal/interface/HGCalTowerID.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#ifndef DataFormats_L1TCalorimeter_HGCalTowerID_h
#define DataFormats_L1TCalorimeter_HGCalTowerID_h
#ifndef DataFormats_L1THGCal_HGCalTowerID_h
#define DataFormats_L1THGCal_HGCalTowerID_h

#include <cstdint>

// NOTE: in the current implementation HGCalTowerID can only
// accomodate 127 bins per coordinate x2 zsides
Expand All @@ -9,13 +11,15 @@ namespace l1t {
public:
HGCalTowerID() : HGCalTowerID(0) {}

HGCalTowerID(unsigned short rawId) : rawId_(rawId) {}
HGCalTowerID(uint32_t rawId) : rawId_(rawId) {}

HGCalTowerID(short zside, unsigned short coord1, unsigned short coord2) {
rawId_ = ((coord1 & coordMask) << coord1Shift) | ((coord2 & coordMask) << coord2Shift) |
(((zside > 0) & zsideMask) << zsideShift);
HGCalTowerID(short subdetIsNode, short zside, unsigned short coord1, unsigned short coord2) {
rawId_ = (((subdetIsNode & subDetMask) << subDetShift) | ((coord1 & coordMask) << coord1Shift) |
((coord2 & coordMask) << coord2Shift) | ((zside > 0) & zsideMask) << zsideShift);
}

short subdet() const { return (rawId_ >> subDetShift) & subDetMask; }

short zside() const { return ((rawId_ >> zsideShift) & zsideMask) ? 1 : -1; }

unsigned short iEta() const { return (rawId_ >> coord1Shift) & coordMask; }
Expand All @@ -25,7 +29,9 @@ namespace l1t {
unsigned short rawId() const { return rawId_; }

private:
unsigned short rawId_;
uint32_t rawId_;
static const int subDetMask = 0x1; // two for now 0 is HGC and 1 is HFNose
static const int subDetShift = 16;
static const int zsideMask = 0x1;
static const int zsideShift = 15;
static const int coordMask = 0x007F;
Expand All @@ -34,9 +40,9 @@ namespace l1t {
};

struct HGCalTowerCoord {
HGCalTowerCoord(unsigned short rawId, float eta, float phi) : rawId(rawId), eta(eta), phi(phi) {}
HGCalTowerCoord(uint32_t rawId, float eta, float phi) : rawId(rawId), eta(eta), phi(phi) {}

const unsigned short rawId;
const uint32_t rawId;
const float eta;
const float phi;
};
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/L1THGCal/src/HGCalTower.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ HGCalTower::HGCalTower(double etEm,
double etHad,
double eta,
double phi,
unsigned short id,
uint32_t id,
int hwpt,
int hweta,
int hwphi,
Expand Down
3 changes: 2 additions & 1 deletion L1Trigger/L1THGCal/interface/HGCalTriggerTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ class HGCalTriggerTools {
// in the v8 geometry detid scheme
int thicknessIndex(const DetId&, bool tc = false) const;

unsigned lastLayerEE() const { return eeLayers_; }
unsigned lastLayerEE(bool nose = false) const { return (nose ? HFNoseDetId::HFNoseLayerEEmax : eeLayers_); }
unsigned lastLayerFH() const { return eeLayers_ + fhLayers_; }
unsigned lastLayerBH() const { return totalLayers_; }
unsigned lastLayerNose() const { return noseLayers_; }
unsigned lastLayer(bool nose = false) const { return nose ? noseLayers_ : totalLayers_; }

// 4-vector helper functions using GlobalPoint
float getEta(const GlobalPoint& position, const float& vertex_z = 0.) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ class HGCalTriggerTowerGeometryHelper {
unsigned short getTriggerTower(const l1t::HGCalTriggerCell&) const;
unsigned short getTriggerTower(const l1t::HGCalTriggerSums&) const;

const bool isNose() { return doNose_; }

private:
std::vector<l1t::HGCalTowerCoord> tower_coords_;
std::unordered_map<unsigned, short> cells_to_trigger_towers_;

bool doNose_;
double minEta_;
double maxEta_;
double minPhi_;
Expand Down
8 changes: 4 additions & 4 deletions L1Trigger/L1THGCal/interface/backend/HGCalTowerMap2DImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class HGCalTowerMap2DImpl {
std::unordered_map<int, l1t::HGCalTowerMap> towerMapsTmp = newTowerMaps();

for (const auto& ptr : ptrs) {
if (triggerTools_.isNose(ptr->detId()))
continue;
bool isNose = triggerTools_.isNose(ptr->detId());
unsigned layer = triggerTools_.layerWithOffset(ptr->detId());

if (towerMapsTmp.find(layer) == towerMapsTmp.end()) {
throw cms::Exception("Out of range")
<< "HGCalTowerMap2dImpl: Found trigger sum in layer " << layer << " for which there is no tower map\n";
Expand All @@ -34,8 +34,8 @@ class HGCalTowerMap2DImpl {
if (useLayerWeights_)
calibPt = layerWeights_[layer] * ptr->mipPt();

double etEm = layer <= triggerTools_.lastLayerEE() ? calibPt : 0;
double etHad = layer > triggerTools_.lastLayerEE() ? calibPt : 0;
double etEm = layer <= triggerTools_.lastLayerEE(isNose) ? calibPt : 0;
double etHad = layer > triggerTools_.lastLayerEE(isNose) ? calibPt : 0;

towerMapsTmp[layer].addEt(towerGeometryHelper_.getTriggerTower(*ptr), etEm, etHad);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class HGCalConcentratorProcessorSelection : public HGCalConcentratorProcessorBas

private:
bool fixedDataSizePerHGCROC_;
bool allTrigCellsInTrigSums_;
std::vector<unsigned> coarsenTriggerCells_;
static constexpr int kHighDensityThickness_ = 0;
static constexpr int kNSubDetectors_ = 3;
Expand Down
43 changes: 25 additions & 18 deletions L1Trigger/L1THGCal/plugins/backend/HGCalTowerProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class HGCalTowerProcessor : public HGCalTowerProcessorBase {
public:
HGCalTowerProcessor(const edm::ParameterSet& conf) : HGCalTowerProcessorBase(conf) {
includeTrigCells_ = conf.getParameter<bool>("includeTrigCells"),
towermap2D_ = std::make_unique<HGCalTowerMap2DImpl>(conf.getParameterSet("towermap_parameters"));
towermap3D_ = std::make_unique<HGCalTowerMap3DImpl>();
}
Expand All @@ -33,33 +34,39 @@ class HGCalTowerProcessor : public HGCalTowerProcessorBase {
towerMapsPtrs.emplace_back(towerMapCollHandle, i);
}

/* create additional TowerMaps from the unclustered TCs */
if (includeTrigCells_) {
/* create additional TowerMaps from the unclustered TCs */

// translate our HGCalClusters into HGCalTriggerCells
std::vector<edm::Ptr<l1t::HGCalTriggerCell>> trigCellVec;
for (unsigned i = 0; i < unclTCsCollHandle->size(); ++i) {
edm::Ptr<l1t::HGCalCluster> ptr(unclTCsCollHandle, i);
for (const auto& itTC : ptr->constituents()) {
trigCellVec.push_back(itTC.second);
// translate our HGCalClusters into HGCalTriggerCells
std::vector<edm::Ptr<l1t::HGCalTriggerCell>> trigCellVec;
for (unsigned i = 0; i < unclTCsCollHandle->size(); ++i) {
edm::Ptr<l1t::HGCalCluster> ptr(unclTCsCollHandle, i);
for (const auto& itTC : ptr->constituents()) {
trigCellVec.push_back(itTC.second);
}
}
}

// fill the TowerMaps with the HGCalTriggersCells
l1t::HGCalTowerMapBxCollection towerMapsFromUnclTCs;
towermap2D_->buildTowerMap2D(trigCellVec, towerMapsFromUnclTCs);
// fill the TowerMaps with the HGCalTriggersCells
l1t::HGCalTowerMapBxCollection towerMapsFromUnclTCs;
towermap2D_->buildTowerMap2D(trigCellVec, towerMapsFromUnclTCs);

/* merge the two sets of TowerMaps */
unsigned int towerMapsPtrsSize = towerMapsPtrs.size();
for (unsigned int i = 0; i < towerMapsFromUnclTCs.size(); ++i) {
towerMapsPtrs.emplace_back(&(towerMapsFromUnclTCs[i]), i + towerMapsPtrsSize);
}
/* merge the two sets of TowerMaps */
unsigned int towerMapsPtrsSize = towerMapsPtrs.size();
for (unsigned int i = 0; i < towerMapsFromUnclTCs.size(); ++i) {
towerMapsPtrs.emplace_back(&(towerMapsFromUnclTCs[i]), i + towerMapsPtrsSize);
}

/* call to towerMap3D clustering */
towermap3D_->buildTowerMap3D(towerMapsPtrs, collTowers);
/* call to towerMap3D clustering */
towermap3D_->buildTowerMap3D(towerMapsPtrs, collTowers);
} else {
/* call to towerMap3D clustering */
towermap3D_->buildTowerMap3D(towerMapsPtrs, collTowers);
}
}

private:
edm::ESHandle<HGCalTriggerGeometryBase> triggerGeometry_;
bool includeTrigCells_;

/* algorithms instances */
std::unique_ptr<HGCalTowerMap2DImpl> towermap2D_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ DEFINE_EDM_PLUGIN(HGCalConcentratorFactory, HGCalConcentratorProcessorSelection,
HGCalConcentratorProcessorSelection::HGCalConcentratorProcessorSelection(const edm::ParameterSet& conf)
: HGCalConcentratorProcessorBase(conf),
fixedDataSizePerHGCROC_(conf.getParameter<bool>("fixedDataSizePerHGCROC")),
allTrigCellsInTrigSums_(conf.getParameter<bool>("allTrigCellsInTrigSums")),
coarsenTriggerCells_(conf.getParameter<std::vector<unsigned>>("coarsenTriggerCells")),
selectionType_(kNSubDetectors_) {
std::vector<std::string> selectionType(conf.getParameter<std::vector<std::string>>("Method"));
Expand Down Expand Up @@ -164,7 +165,11 @@ void HGCalConcentratorProcessorSelection::run(const edm::Handle<l1t::HGCalTrigge

// trigger sum
if (trigSumImpl_) {
trigSumImpl_->doSum(module_trigcell.first, trigCellVecNotSelected, trigSumsVecOutput);
if (allTrigCellsInTrigSums_) { // using all TCs
trigSumImpl_->doSum(module_trigcell.first, module_trigcell.second, trigSumsVecOutput);
} else { // using only unselected TCs
trigSumImpl_->doSum(module_trigcell.first, trigCellVecNotSelected, trigSumsVecOutput);
}
}

for (const auto& trigCell : trigCellVecOutput) {
Expand Down
31 changes: 31 additions & 0 deletions L1Trigger/L1THGCal/python/customTriggerSums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import FWCore.ParameterSet.Config as cms

def custom_partial_trigger_sums(process):
process.tower.includeTrigCells = cms.bool(True)
process.hgcalTowerProducer.ProcessorParameters.includeTrigCells = cms.bool(True)
process.hgcalTowerProducerHFNose.ProcessorParameters.includeTrigCells = cms.bool(True)
process.threshold_conc_proc.allTrigCellsInTrigSums = cms.bool(False)
process.best_conc_proc.allTrigCellsInTrigSums = cms.bool(False)
process.supertc_conc_proc.allTrigCellsInTrigSums = cms.bool(False)
process.custom_conc_proc.allTrigCellsInTrigSums = cms.bool(False)
process.coarsetc_onebitfraction_proc.allTrigCellsInTrigSums = cms.bool(False)
process.coarsetc_equalshare_proc.allTrigCellsInTrigSums = cms.bool(False)
process.autoEncoder_conc_proc.allTrigCellsInTrigSums = cms.bool(False)
process.hgcalConcentratorProducer.ProcessorParameters.allTrigCellsInTrigSums = cms.bool(False)
process.hgcalConcentratorProducerHFNose.ProcessorParameters.allTrigCellsInTrigSums = cms.bool(False)
return process

def custom_full_trigger_sums(process):
process.tower.includeTrigCells = cms.bool(False)
process.hgcalTowerProducer.ProcessorParameters.includeTrigCells = cms.bool(False)
process.hgcalTowerProducerHFNose.ProcessorParameters.includeTrigCells = cms.bool(False)
process.threshold_conc_proc.allTrigCellsInTrigSums = cms.bool(True)
process.best_conc_proc.allTrigCellsInTrigSums = cms.bool(True)
process.supertc_conc_proc.allTrigCellsInTrigSums = cms.bool(True)
process.custom_conc_proc.allTrigCellsInTrigSums = cms.bool(True)
process.coarsetc_onebitfraction_proc.allTrigCellsInTrigSums = cms.bool(True)
process.coarsetc_equalshare_proc.allTrigCellsInTrigSums = cms.bool(True)
process.autoEncoder_conc_proc.allTrigCellsInTrigSums = cms.bool(True)
process.hgcalConcentratorProducer.ProcessorParameters.allTrigCellsInTrigSums = cms.bool(True)
process.hgcalConcentratorProducerHFNose.ProcessorParameters.allTrigCellsInTrigSums = cms.bool(True)
return process
7 changes: 7 additions & 0 deletions L1Trigger/L1THGCal/python/hgcalConcentratorProducer_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
threshold_scintillator = cms.double(2.), # MipT
coarsenTriggerCells = cms.vuint32(0,0,0),
fixedDataSizePerHGCROC = cms.bool(False),
allTrigCellsInTrigSums = cms.bool(True),
ctcSize = cms.vuint32(CTC_SIZE),
)

Expand Down Expand Up @@ -81,6 +82,7 @@
NData = cms.vuint32(bestchoice_ndata_decentralized),
coarsenTriggerCells = cms.vuint32(0,0,0),
fixedDataSizePerHGCROC = cms.bool(False),
allTrigCellsInTrigSums = cms.bool(False),
coarseTCCompression = coarseTCCompression_proc.clone(),
superTCCalibration_ee = vfe_proc.calibrationCfg_ee.clone(),
superTCCalibration_hesi = vfe_proc.calibrationCfg_hesi.clone(),
Expand All @@ -95,6 +97,7 @@
stcSize = cms.vuint32(STC_SIZE),
ctcSize = cms.vuint32(CTC_SIZE),
fixedDataSizePerHGCROC = cms.bool(False),
allTrigCellsInTrigSums = cms.bool(False),
coarsenTriggerCells = cms.vuint32(0,0,0),
superTCCompression = superTCCompression_proc.clone(),
coarseTCCompression = coarseTCCompression_proc.clone(),
Expand All @@ -111,6 +114,7 @@
threshold_scintillator = cms.double(2.), # MipT
coarsenTriggerCells = cms.vuint32(0,0,0),
fixedDataSizePerHGCROC = cms.bool(False),
allTrigCellsInTrigSums = cms.bool(False),
type_energy_division = cms.string('superTriggerCell'),# superTriggerCell,oneBitFraction,equalShare
stcSize = cms.vuint32(STC_SIZE),
ctcSize = cms.vuint32(CTC_SIZE),
Expand All @@ -129,6 +133,7 @@
stcSize = cms.vuint32([4]*(MAX_LAYERS+1)+ [8]*(MAX_LAYERS+1)*3),
ctcSize = cms.vuint32(CTC_SIZE),
fixedDataSizePerHGCROC = cms.bool(True),
allTrigCellsInTrigSums = cms.bool(False),
coarsenTriggerCells = cms.vuint32(0,0,0),
oneBitFractionThreshold = cms.double(0.125),
oneBitFractionLowValue = cms.double(0.0625),
Expand All @@ -148,6 +153,7 @@
stcSize = cms.vuint32([4]*(MAX_LAYERS+1)+ [8]*(MAX_LAYERS+1)*3),
ctcSize = cms.vuint32(CTC_SIZE),
fixedDataSizePerHGCROC = cms.bool(True),
allTrigCellsInTrigSums = cms.bool(False),
coarsenTriggerCells = cms.vuint32(0,0,0),
superTCCompression = superTCCompression_proc.clone(),
coarseTCCompression = coarseTCCompression_proc.clone(),
Expand Down Expand Up @@ -212,6 +218,7 @@
stcSize = supertc_conc_proc.stcSize,
ctcSize = supertc_conc_proc.ctcSize,
fixedDataSizePerHGCROC = supertc_conc_proc.fixedDataSizePerHGCROC,
allTrigCellsInTrigSums = supertc_conc_proc.allTrigCellsInTrigSums,
coarsenTriggerCells = supertc_conc_proc.coarsenTriggerCells,
superTCCompression = superTCCompression_proc.clone(),
coarseTCCompression = coarseTCCompression_proc.clone(),
Expand Down
18 changes: 17 additions & 1 deletion L1Trigger/L1THGCal/python/hgcalTowerMapProducer_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import math

L1TTriggerTowerConfig_etaphi = cms.PSet(readMappingFile=cms.bool(False),
doNose=cms.bool(False),
minEta=cms.double(1.479),
maxEta=cms.double(3.0),
minPhi=cms.double(-1*math.pi),
Expand All @@ -26,6 +27,21 @@
ProcessorParameters = tower_map.clone()
)

L1TTriggerTowerConfigHFNose_etaphi = L1TTriggerTowerConfig_etaphi.clone(
doNose = True ,
minEta = 3.0 ,
maxEta = 4.2
)

towerMap2DHFNose_parValues = towerMap2D_parValues.clone(
L1TTriggerTowerConfig = L1TTriggerTowerConfigHFNose_etaphi
)

towerHFNose_map = cms.PSet( ProcessorName = cms.string('HGCalTowerMapProcessor'),
towermap_parameters = towerMap2DHFNose_parValues.clone()
)

hgcalTowerMapProducerHFNose = hgcalTowerMapProducer.clone(
InputTriggerSums = cms.InputTag('hgcalConcentratorProducerHFNose:HGCalConcentratorProcessorSelection')
InputTriggerSums = cms.InputTag('hgcalConcentratorProducerHFNose:HGCalConcentratorProcessorSelection'),
ProcessorParameters = towerHFNose_map.clone()
)
5 changes: 5 additions & 0 deletions L1Trigger/L1THGCal/python/hgcalTowerProducer_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import L1Trigger.L1THGCal.hgcalTowerMapProducer_cfi as hgcalTowerMapProducer_cfi

tower = cms.PSet( ProcessorName = cms.string('HGCalTowerProcessor'),
includeTrigCells = cms.bool(False),
towermap_parameters = hgcalTowerMapProducer_cfi.towerMap2D_parValues.clone()
)

Expand All @@ -12,9 +13,13 @@
ProcessorParameters = tower.clone(),
)

towerHFNose = tower.clone(
towermap_parameters = hgcalTowerMapProducer_cfi.towerMap2DHFNose_parValues.clone()
)

hgcalTowerProducerHFNose = hgcalTowerProducer.clone(
InputTowerMaps = cms.InputTag('hgcalTowerMapProducerHFNose:HGCalTowerMapProcessor'),
InputTriggerCells = cms.InputTag('hgcalBackEndLayer1ProducerHFNose:HGCalBackendLayer1Processor2DClustering'),
ProcessorParameters = towerHFNose.clone(),
)

9 changes: 5 additions & 4 deletions L1Trigger/L1THGCal/src/HGCalTriggerTowerGeometryHelper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#include <algorithm>

HGCalTriggerTowerGeometryHelper::HGCalTriggerTowerGeometryHelper(const edm::ParameterSet& conf)
: minEta_(conf.getParameter<double>("minEta")),
: doNose_(conf.getParameter<bool>("doNose")),
minEta_(conf.getParameter<double>("minEta")),
maxEta_(conf.getParameter<double>("maxEta")),
minPhi_(conf.getParameter<double>("minPhi")),
maxPhi_(conf.getParameter<double>("maxPhi")),
Expand Down Expand Up @@ -46,7 +47,7 @@ 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);
l1t::HGCalTowerID towerId(doNose_, zside, bin1, bin2);
tower_coords_.emplace_back(towerId.rawId(),
zside * ((binsEta_[bin1 + 1] + binsEta_[bin1]) / 2),
(binsPhi_[bin2 + 1] + binsPhi_[bin2]) / 2);
Expand All @@ -73,7 +74,7 @@ HGCalTriggerTowerGeometryHelper::HGCalTriggerTowerGeometryHelper(const edm::Para
<< " to TT iEta: " << iEta << " iPhi: " << iPhi << " when max #bins eta: " << nBinsEta_
<< " phi: " << nBinsPhi_ << std::endl;
}
l1t::HGCalTowerID towerId(triggerTools_.zside(DetId(trigger_cell_id)), iEta, iPhi);
l1t::HGCalTowerID towerId(doNose_, triggerTools_.zside(DetId(trigger_cell_id)), iEta, iPhi);
cells_to_trigger_towers_[trigger_cell_id] = towerId.rawId();
}
l1tTriggerTowerMappingStream.close();
Expand Down Expand Up @@ -116,7 +117,7 @@ unsigned short HGCalTriggerTowerGeometryHelper::getTriggerTowerFromEtaPhi(const
bin_phi = bin_phi_l - binsPhi_.begin() - 1;
}
int zside = eta < 0 ? -1 : 1;
return l1t::HGCalTowerID(zside, bin_eta, bin_phi).rawId();
return l1t::HGCalTowerID(doNose_, zside, bin_eta, bin_phi).rawId();
}

unsigned short HGCalTriggerTowerGeometryHelper::getTriggerTower(const l1t::HGCalTriggerCell& thecell) const {
Expand Down
Loading