From 027b6cbe1e6e90b5d1c53001bafe299fc437f16f Mon Sep 17 00:00:00 2001 From: tschuh Date: Wed, 4 Jun 2025 16:58:49 +0100 Subject: [PATCH 1/2] missing data member initialization added and bad bit widths intercepted. --- DataFormats/L1TrackTrigger/interface/TTBV.h | 17 +++++++++++------ L1Trigger/TrackTrigger/plugins/ProducerSetup.cc | 1 + L1Trigger/TrackTrigger/src/Setup.cc | 1 + 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/DataFormats/L1TrackTrigger/interface/TTBV.h b/DataFormats/L1TrackTrigger/interface/TTBV.h index f05b348cc8471..eccf3903e911b 100644 --- a/DataFormats/L1TrackTrigger/interface/TTBV.h +++ b/DataFormats/L1TrackTrigger/interface/TTBV.h @@ -389,8 +389,8 @@ class TTBV { // check if value fits into binary BV void checkU(unsigned long long int value) { - if (size_ == 0) - return; + if (size_ <= 0 || size_ > S_) + throwSize(); if (value < iMax()) return; cms::Exception exception("RunTimeError."); @@ -401,8 +401,6 @@ class TTBV { // check if value fits into twos's complement BV void checkT(int value) { - if (size_ == 0) - return; static const std::array lut = powersOfTwo(); auto abs = [](int val) { return val < 0 ? std::abs(val) - 1 : val; }; if (abs(value) < std::round(lut[size_ - 1])) @@ -415,8 +413,8 @@ class TTBV { // check if value fits into twos complement / binary BV void checkI(int value) { - if (size_ == 0) - return; + if (size_ <= 0 || size_ > S_) + throwSize(); if (twos_) checkT(value); else if (value < 0) { @@ -427,6 +425,13 @@ class TTBV { } else checkU(value); } + + // nonsensical bitwith of smaller equal 0 or unsupported size, bigger 64, deteced + void throwSize() const { + cms::Exception exception("RunTimeError."); + exception << "TTBV constructor called with bad bit width (" << size_ << ")."; + throw exception; + } }; #endif diff --git a/L1Trigger/TrackTrigger/plugins/ProducerSetup.cc b/L1Trigger/TrackTrigger/plugins/ProducerSetup.cc index 82fa6039354a8..540eed4dbf537 100644 --- a/L1Trigger/TrackTrigger/plugins/ProducerSetup.cc +++ b/L1Trigger/TrackTrigger/plugins/ProducerSetup.cc @@ -66,6 +66,7 @@ namespace tt { iConfig_.tbWidthsR_ = pSetHybrid.getParameter>("WidthsRTB"); const edm::ParameterSet& pSetFW = iConfig.getParameter("Firmware"); iConfig_.enableTruncation_ = pSetFW.getParameter("EnableTruncation"); + iConfig_.useHybrid_ = pSetFW.getParameter("UseHybrid"); iConfig_.widthDSPa_ = pSetFW.getParameter("WidthDSPa"); iConfig_.widthDSPb_ = pSetFW.getParameter("WidthDSPb"); iConfig_.widthDSPc_ = pSetFW.getParameter("WidthDSPc"); diff --git a/L1Trigger/TrackTrigger/src/Setup.cc b/L1Trigger/TrackTrigger/src/Setup.cc index da31845bae339..f526b7d6d2e95 100644 --- a/L1Trigger/TrackTrigger/src/Setup.cc +++ b/L1Trigger/TrackTrigger/src/Setup.cc @@ -54,6 +54,7 @@ namespace tt { tbWidthsR_(iConfig.tbWidthsR_), // Fimrware specific Parameter enableTruncation_(iConfig.enableTruncation_), + useHybrid_(iConfig.useHybrid_), widthDSPa_(iConfig.widthDSPa_), widthDSPb_(iConfig.widthDSPb_), widthDSPc_(iConfig.widthDSPc_), From 0fabb3e9f53d87a33ea21e5762f92f9f9f9c1c55 Mon Sep 17 00:00:00 2001 From: tschuh Date: Thu, 5 Jun 2025 15:16:06 +0100 Subject: [PATCH 2/2] little fix of test script, fixes of 0b TTBV constructor calls. --- .../interface/DataFormats.h | 4 ++-- .../test/HybridTracksNewKF_cfg.py | 4 ++-- L1Trigger/TrackerDTC/src/Stub.cc | 21 ++++++++++--------- L1Trigger/TrackerTFP/interface/DataFormats.h | 4 ++-- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/DataFormats.h b/L1Trigger/TrackFindingTracklet/interface/DataFormats.h index 2df12cf1efe0a..b2b53114ff388 100644 --- a/L1Trigger/TrackFindingTracklet/interface/DataFormats.h +++ b/L1Trigger/TrackFindingTracklet/interface/DataFormats.h @@ -198,7 +198,7 @@ namespace trklet { // converts ntuple of variables to bits template void convertStub(Process p, const std::tuple& data, tt::Frame& bv) const { - TTBV ttBV(1, numUnusedBitsStubs_[+p]); + TTBV ttBV(1, 1 + numUnusedBitsStubs_[+p]); attachStub(p, data, ttBV); bv = ttBV.bs(); } @@ -211,7 +211,7 @@ namespace trklet { // converts ntuple of variables to bits template void convertTrack(Process p, const std::tuple& data, tt::Frame& bv) const { - TTBV ttBV(1, numUnusedBitsTracks_[+p]); + TTBV ttBV(1, 1 + numUnusedBitsTracks_[+p]); attachTrack(p, data, ttBV); bv = ttBV.bs(); } diff --git a/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py b/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py index 337f50afde177..70dd3f5c4bb35 100644 --- a/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py +++ b/L1Trigger/TrackFindingTracklet/test/HybridTracksNewKF_cfg.py @@ -19,7 +19,7 @@ process.load( 'L1Trigger.TrackTrigger.TrackTrigger_cff' ) from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, 'auto::phase2_realistic', '') +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') # load code that associates stubs with mctruth process.load( 'SimTracker.TrackTriggerAssociation.StubAssociator_cff' ) @@ -58,7 +58,7 @@ #from MCsamples.Scripts.getCMSlocaldata_cfi import * #from MCsamples.RelVal_1260_D88.PU200_TTbar_14TeV_cfi import * #inputMC = getCMSdataFromCards() -Samples = [""] +Samples = ["/store/mc/Phase2Spring24DIGIRECOMiniAOD/TT_TuneCP5_14TeV-powheg-pythia8/GEN-SIM-DIGI-RAW-MINIAOD/PU200_Trk1GeV_140X_mcRun4_realistic_v4-v2/130000/00c7f40e-b44e-4eea-a86b-def8f7d82b0e.root"] options.register( 'inputMC', Samples, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "Files to be processed" ) # specify number of events to process. options.register( 'Events',100,VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.int, "Number of Events to analyze" ) diff --git a/L1Trigger/TrackerDTC/src/Stub.cc b/L1Trigger/TrackerDTC/src/Stub.cc index 420bc87f1d8c6..1e2b7664666ff 100644 --- a/L1Trigger/TrackerDTC/src/Stub.cc +++ b/L1Trigger/TrackerDTC/src/Stub.cc @@ -149,17 +149,18 @@ namespace trackerDTC { double phi = phi_ - (region - .5) * setup_->baseRegion() + setup_->hybridRangePhi() / 2.; // convert stub variables into bit vectors const bool twosR = type == tt::SensorModule::BarrelPS || type == tt::SensorModule::Barrel2S; - const TTBV hwR(r_, setup_->hybridBaseR(type), setup_->hybridWidthR(type), twosR); - const TTBV hwPhi(phi, setup_->hybridBasePhi(type), setup_->hybridWidthPhi(type)); - const TTBV hwZ(z_, setup_->hybridBaseZ(type), setup_->hybridWidthZ(type), true); - const TTBV hwAlpha(row_, setup_->hybridBaseAlpha(type), setup_->hybridWidthAlpha(type), true); - const TTBV hwBend(bend_, setup_->hybridWidthBend(type), true); - const TTBV hwLayer(decodedLayerId, setup_->hybridWidthLayerId()); - const TTBV hwGap(0, setup_->hybridNumUnusedBits(type)); - const TTBV hwValid(1, 1); + const bool noAlpha = type != tt::SensorModule::Disk2S; + const std::string hwR = TTBV(r_, setup_->hybridBaseR(type), setup_->hybridWidthR(type), twosR).str(); + const std::string hwPhi = TTBV(phi, setup_->hybridBasePhi(type), setup_->hybridWidthPhi(type)).str(); + const std::string hwZ = TTBV(z_, setup_->hybridBaseZ(type), setup_->hybridWidthZ(type), true).str(); + const std::string hwAlpha = + noAlpha ? "" : TTBV(row_, setup_->hybridBaseAlpha(type), setup_->hybridWidthAlpha(type), true).str(); + const std::string hwBend = TTBV(bend_, setup_->hybridWidthBend(type), true).str(); + const std::string hwLayer = TTBV(decodedLayerId, setup_->hybridWidthLayerId()).str(); + const std::string hwGap = TTBV(0, setup_->hybridNumUnusedBits(type)).str(); + const std::string hwValid = TTBV(1, 1).str(); // assemble final bitset - return tt::Frame(hwGap.str() + hwR.str() + hwZ.str() + hwPhi.str() + hwAlpha.str() + hwBend.str() + hwLayer.str() + - hwValid.str()); + return tt::Frame(hwGap + hwR + hwZ + hwPhi + hwAlpha + hwBend + hwLayer + hwValid); } tt::Frame Stub::formatTMTT(int region) const { diff --git a/L1Trigger/TrackerTFP/interface/DataFormats.h b/L1Trigger/TrackerTFP/interface/DataFormats.h index 0aeb99918bc72..7e1582e50cf96 100644 --- a/L1Trigger/TrackerTFP/interface/DataFormats.h +++ b/L1Trigger/TrackerTFP/interface/DataFormats.h @@ -317,7 +317,7 @@ namespace trackerTFP { // converts ntuple of variables to bits template void convertStub(Process p, const std::tuple& data, tt::Frame& bv) const { - TTBV ttBV(1, numUnusedBitsStubs_[+p]); + TTBV ttBV(1, 1 + numUnusedBitsStubs_[+p]); attachStub(p, data, ttBV); bv = ttBV.bs(); } @@ -330,7 +330,7 @@ namespace trackerTFP { // converts ntuple of variables to bits template void convertTrack(Process p, const std::tuple& data, tt::Frame& bv) const { - TTBV ttBV(1, numUnusedBitsTracks_[+p]); + TTBV ttBV(1, 1 + numUnusedBitsTracks_[+p]); attachTrack(p, data, ttBV); bv = ttBV.bs(); }