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] V11 geometry compatibility #29400

Merged
merged 2 commits into from
Apr 14, 2020
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
4 changes: 1 addition & 3 deletions L1Trigger/Configuration/python/SimL1Emulator_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,4 @@
_phase2_siml1emulator.add(hgcalTriggerPrimitivesTask)

from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal
from Configuration.Eras.Modifier_phase2_hgcalV11_cff import phase2_hgcalV11
(phase2_hgcal & ~phase2_hgcalV11).toReplaceWith( SimL1EmulatorTask , _phase2_siml1emulator )
#phase2_hgcal.toReplaceWith( SimL1EmulatorTask , _phase2_siml1emulator )
phase2_hgcal.toReplaceWith( SimL1EmulatorTask , _phase2_siml1emulator )
1 change: 1 addition & 0 deletions L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class HGCalTriggerGeometryBase {
virtual GlobalPoint getTriggerCellPosition(const unsigned trigger_cell_det_id) const = 0;
virtual GlobalPoint getModulePosition(const unsigned module_det_id) const = 0;

virtual bool validCell(const unsigned cell_id) const = 0;
virtual bool validTriggerCell(const unsigned trigger_cell_id) const = 0;
virtual bool disconnectedModule(const unsigned module_id) const = 0;
virtual unsigned lastTriggerLayer() const = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class HGCalTriggerGeometryGenericMapping : public HGCalTriggerGeometryBase {
GlobalPoint getTriggerCellPosition(const unsigned trigger_cell_det_id) const final;
GlobalPoint getModulePosition(const unsigned module_det_id) const final;

bool validCell(const unsigned cell_det_id) const final { return true; }
bool validTriggerCell(const unsigned trigger_cell_det_id) const final;
bool disconnectedModule(const unsigned module_id) const final;
unsigned lastTriggerLayer() const final;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class HGCalTriggerGeometryHexImp2 : public HGCalTriggerGeometryBase {
GlobalPoint getTriggerCellPosition(const unsigned) const final;
GlobalPoint getModulePosition(const unsigned) const final;

bool validCell(const unsigned) const final;
bool validTriggerCell(const unsigned) const final;
bool disconnectedModule(const unsigned) const final;
unsigned lastTriggerLayer() const final;
Expand Down Expand Up @@ -752,6 +753,32 @@ int HGCalTriggerGeometryHexImp2::detIdWaferType(unsigned subdet, short wafer) co
return wafer_type;
}

bool HGCalTriggerGeometryHexImp2::validCell(unsigned cell_id) const {
bool is_valid = false;
if (DetId(cell_id).det() == DetId::Hcal) {
HcalDetId cell_det_id(cell_id);
if (cell_det_id.subdetId() != HcalEndcap)
is_valid = false;
else
is_valid = bhTopology().valid(cell_id);
} else if (DetId(cell_id).det() == DetId::Forward) {
HGCalDetId cell_det_id(cell_id);
unsigned subdet = cell_det_id.subdetId();
switch (subdet) {
case ForwardSubdetector::HGCEE:
is_valid = eeTopology().valid(cell_id);
break;
case ForwardSubdetector::HGCHEF:
is_valid = fhTopology().valid(cell_id);
break;
default:
is_valid = false;
break;
}
}
return is_valid;
}

bool HGCalTriggerGeometryHexImp2::validTriggerCell(const unsigned trigger_cell_id) const {
return invalid_triggercells_.find(trigger_cell_id) == invalid_triggercells_.end();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class HGCalTriggerGeometryHexLayerBasedImp1 : public HGCalTriggerGeometryBase {
GlobalPoint getTriggerCellPosition(const unsigned) const final;
GlobalPoint getModulePosition(const unsigned) const final;

bool validCell(const unsigned) const final;
bool validTriggerCell(const unsigned) const final;
bool disconnectedModule(const unsigned) const final;
unsigned lastTriggerLayer() const final { return last_trigger_layer_; }
Expand Down Expand Up @@ -660,6 +661,32 @@ void HGCalTriggerGeometryHexLayerBasedImp1::unpackIetaIphi(unsigned ieta_iphi, u
ieta = (ieta_iphi >> HcalDetId::kHcalEtaOffset2) & HcalDetId::kHcalEtaMask2;
}

bool HGCalTriggerGeometryHexLayerBasedImp1::validCell(unsigned cell_id) const {
bool is_valid = false;
if (DetId(cell_id).det() == DetId::Hcal) {
HcalDetId cell_det_id(cell_id);
if (cell_det_id.subdetId() != HcalEndcap)
is_valid = false;
else
is_valid = bhTopology().valid(cell_id);
} else if (DetId(cell_id).det() == DetId::Forward) {
HGCalDetId cell_det_id(cell_id);
unsigned subdet = cell_det_id.subdetId();
switch (subdet) {
case ForwardSubdetector::HGCEE:
is_valid = eeTopology().valid(cell_id);
break;
case ForwardSubdetector::HGCHEF:
is_valid = fhTopology().valid(cell_id);
break;
default:
is_valid = false;
break;
}
}
return is_valid;
}

bool HGCalTriggerGeometryHexLayerBasedImp1::validTriggerCell(const unsigned trigger_cell_id) const {
return invalid_triggercells_.find(trigger_cell_id) == invalid_triggercells_.end();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class HGCalTriggerGeometryV9Imp1 : public HGCalTriggerGeometryBase {
GlobalPoint getTriggerCellPosition(const unsigned) const final;
GlobalPoint getModulePosition(const unsigned) const final;

bool validCell(const unsigned) const final;
bool validTriggerCell(const unsigned) const final;
bool disconnectedModule(const unsigned) const final;
unsigned lastTriggerLayer() const final { return last_trigger_layer_; }
Expand Down Expand Up @@ -899,6 +900,29 @@ void HGCalTriggerGeometryV9Imp1::unpackIetaIphi(unsigned ieta_iphi, unsigned& ie
ieta = (ieta_iphi >> HGCScintillatorDetId::kHGCalRadiusOffset) & HGCScintillatorDetId::kHGCalRadiusMask;
}

bool HGCalTriggerGeometryV9Imp1::validCell(unsigned cell_id) const {
bool is_valid = false;
unsigned det = DetId(cell_id).det();
switch (det) {
case DetId::HGCalEE:
is_valid = eeTopology().valid(cell_id);
break;
case DetId::HGCalHSi:
is_valid = hsiTopology().valid(cell_id);
break;
case DetId::HGCalHSc:
is_valid = hscTopology().valid(cell_id);
break;
case DetId::Forward:
is_valid = noseTopology().valid(cell_id);
break;
default:
is_valid = false;
break;
}
return is_valid;
}

bool HGCalTriggerGeometryV9Imp1::validTriggerCell(const unsigned trigger_cell_id) const {
return invalid_triggercells_.find(trigger_cell_id) == invalid_triggercells_.end();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class HGCalTriggerGeometryV9Imp2 : public HGCalTriggerGeometryBase {
GlobalPoint getTriggerCellPosition(const unsigned) const final;
GlobalPoint getModulePosition(const unsigned) const final;

bool validCell(const unsigned) const final;
bool validTriggerCell(const unsigned) const final;
bool disconnectedModule(const unsigned) const final;
unsigned lastTriggerLayer() const final { return last_trigger_layer_; }
Expand All @@ -54,6 +55,8 @@ class HGCalTriggerGeometryV9Imp2 : public HGCalTriggerGeometryBase {
unsigned hSc_links_per_module_ = 1;
unsigned hSc_wafers_per_module_ = 3;

unsigned sector0_mask_ = 0x7f; // 7 bits to encode module number in 60deg sector

edm::FileInPath l1tModulesMapping_;
edm::FileInPath l1tLinksMapping_;

Expand Down Expand Up @@ -505,8 +508,7 @@ unsigned HGCalTriggerGeometryV9Imp2::getLinksInModule(const unsigned module_id)
HGCalDetId module_det_id_si(module_id);
unsigned module = module_det_id_si.wafer();
unsigned layer = layerWithOffset(module_id);
const unsigned sector0_mask = 0x7F;
module = (module & sector0_mask);
module = (module & sector0_mask_);
links = links_per_module_.at(packLayerModuleId(layer, module));
}
return links;
Expand Down Expand Up @@ -617,10 +619,13 @@ void HGCalTriggerGeometryV9Imp2::fillMaps() {
throw cms::Exception("MissingDataFile") << "Cannot open HGCalTriggerGeometry L1TLinksMapping file\n";
}
short links = 0;
const short max_modules_60deg_sector = 127;
for (; l1tLinksMappingStream >> layer >> module >> links;) {
if (module_to_wafers_.find(packLayerModuleId(layer, module)) == module_to_wafers_.end()) {
links = 0;
}
if (module > max_modules_60deg_sector)
sector0_mask_ = 0xff; // Use 8 bits to encode module number in 120deg sector
links_per_module_.emplace(packLayerModuleId(layer, module), links);
}
if (!l1tLinksMappingStream.eof()) {
Expand Down Expand Up @@ -708,6 +713,29 @@ unsigned HGCalTriggerGeometryV9Imp2::triggerLayer(const unsigned id) const {
return trigger_layers_[layer];
}

bool HGCalTriggerGeometryV9Imp2::validCell(unsigned cell_id) const {
bool is_valid = false;
unsigned det = DetId(cell_id).det();
switch (det) {
case DetId::HGCalEE:
is_valid = eeTopology().valid(cell_id);
break;
case DetId::HGCalHSi:
is_valid = hsiTopology().valid(cell_id);
break;
case DetId::HGCalHSc:
is_valid = hscTopology().valid(cell_id);
break;
case DetId::Forward:
is_valid = noseTopology().valid(cell_id);
break;
default:
is_valid = false;
break;
}
return is_valid;
}

bool HGCalTriggerGeometryV9Imp2::validTriggerCellFromCells(const unsigned trigger_cell_id) const {
// Check the validity of a trigger cell with the
// validity of the cells. One valid cell in the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ void HGCalVFEProcessorSums::run(const HGCalDigiCollection& digiColl,
for (const auto& digiData : digiColl) {
if (DetId(digiData.id()).det() == DetId::Hcal && HcalDetId(digiData.id()).subdetId() != HcalEndcap)
continue;
if (!geometry_->validCell(digiData.id()))
continue;
uint32_t module = geometry_->getModuleFromCell(digiData.id());

// no disconnected layer for HFNose
Expand Down
17 changes: 17 additions & 0 deletions L1Trigger/L1THGCal/python/customTriggerGeometry.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
import FWCore.ParameterSet.Config as cms


def custom_geometry_decentralized_V11(process, links='signaldriven'):
if links=='signaldriven':
links_mapping = 'L1Trigger/L1THGCal/data/links_mapping_V11_decentralized_signaldriven_0.txt'
elif links=='pudriven':
links_mapping = 'L1Trigger/L1THGCal/data/links_mapping_V11_decentralized_march20_0.txt'
else:
raise RuntimeError('Unknown links mapping "{}". Options are "signaldriven" or "pudriven".'.format(links))
process.hgcalTriggerGeometryESProducer.TriggerGeometry.TriggerGeometryName = cms.string('HGCalTriggerGeometryV9Imp2')
process.hgcalTriggerGeometryESProducer.TriggerGeometry.ScintillatorTriggerCellSize = cms.uint32(2)
process.hgcalTriggerGeometryESProducer.TriggerGeometry.ScintillatorModuleSize = cms.uint32(6)
process.hgcalTriggerGeometryESProducer.TriggerGeometry.L1TModulesMapping = cms.FileInPath("L1Trigger/L1THGCal/data/panel_mapping_V11_decentralized_march20_0.txt")
process.hgcalTriggerGeometryESProducer.TriggerGeometry.L1TLinksMapping = cms.FileInPath(links_mapping)
process.hgcalTriggerGeometryESProducer.TriggerGeometry.DisconnectedModules = cms.vuint32(0)
process.hgcalTriggerGeometryESProducer.TriggerGeometry.ScintillatorLinksPerModule = cms.uint32(2)
return process


def custom_geometry_decentralized_V9(process, links='signaldriven', implementation=2):
if links=='signaldriven':
links_mapping = 'L1Trigger/L1THGCal/data/links_mapping_decentralized_signaldriven_0.txt'
Expand Down
6 changes: 4 additions & 2 deletions L1Trigger/L1THGCal/python/hgcalTriggerPrimitives_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
hgcalTriggerPrimitives = cms.Sequence(hgcalTriggerPrimitivesTask)

from Configuration.Eras.Modifier_phase2_hgcalV9_cff import phase2_hgcalV9
from L1Trigger.L1THGCal.customTriggerGeometry import custom_geometry_V9
from Configuration.Eras.Modifier_phase2_hgcalV11_cff import phase2_hgcalV11
from L1Trigger.L1THGCal.customTriggerGeometry import custom_geometry_decentralized_V9, custom_geometry_decentralized_V11
from L1Trigger.L1THGCal.customCalibration import custom_cluster_calibration_global
modifyHgcalTriggerPrimitivesWithV9Geometry_ = phase2_hgcalV9.makeProcessModifier(custom_geometry_V9)
modifyHgcalTriggerPrimitivesWithV9Geometry_ = phase2_hgcalV9.makeProcessModifier(custom_geometry_decentralized_V9)
modifyHgcalTriggerPrimitivesWithV11Geometry_ = phase2_hgcalV11.makeProcessModifier(custom_geometry_decentralized_V11)

from Configuration.ProcessModifiers.convertHGCalDigisSim_cff import convertHGCalDigisSim
# can't declare a producer version of simHGCalUnsuppressedDigis in the normal flow of things,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ void HGCalConcentratorSuperTriggerCellImpl::createAllTriggerCells(
std::unordered_map<unsigned, SuperTriggerCell>& STCs, std::vector<l1t::HGCalTriggerCell>& trigCellVecOutput) const {
for (auto& s : STCs) {
std::vector<uint32_t> output_ids = superTCmapping_.getConstituentTriggerCells(s.second.getSTCId());
if (output_ids.empty())
continue;

int thickness = (!output_ids.empty() ? triggerTools_.thicknessIndex(output_ids.at(0), true) : 0);

Expand Down
Loading