From c38363f61c6f3dc076b4a32671baf95a4098c577 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 30 Nov 2023 17:03:55 -0600 Subject: [PATCH 01/24] update config in firmware workflow --- .../DemonstratorTools/test/gtt/createFirmwareInputFiles_cfg.py | 1 - 1 file changed, 1 deletion(-) diff --git a/L1Trigger/DemonstratorTools/test/gtt/createFirmwareInputFiles_cfg.py b/L1Trigger/DemonstratorTools/test/gtt/createFirmwareInputFiles_cfg.py index 293efb9de91e4..4be6147bf4df0 100644 --- a/L1Trigger/DemonstratorTools/test/gtt/createFirmwareInputFiles_cfg.py +++ b/L1Trigger/DemonstratorTools/test/gtt/createFirmwareInputFiles_cfg.py @@ -104,7 +104,6 @@ process.l1tTrackerEmuHTMiss.debug = (options.debug > 0) #Disable internal track selection -#There is a problem with setting all of these (especially eta) to high numbers. process.l1tTrackJetsEmulation.trk_zMax = cms.double(20.46912512) # maximum track z from TrackWord if options.debug: From 79543b0285ca03ecb9d28f8b3c7b0ec3c2b1269e Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Thu, 26 Oct 2023 09:05:25 +0200 Subject: [PATCH 02/24] Temporary fix to broken ingestion, no empty frames; should be configurable --- L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc index 459f79f82a8f0..b304622911b2c 100644 --- a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc +++ b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc @@ -53,7 +53,7 @@ class GTTFileReader : public edm::stream::EDProducer<> { static constexpr size_t kGapLength = 44; static constexpr size_t kVertexTMUX = 6; static constexpr size_t kVertexChanIndex = 0; - static constexpr size_t kEmptyFrames = 10; + static constexpr size_t kEmptyFrames = 0; //FIXME should be configurable! const l1t::demo::BoardDataReader::ChannelMap_t kChannelSpecs = { /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ From ec230adf9427041c6415da4fc204d74cfe7aa6c9 Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Fri, 27 Oct 2023 06:08:57 +0200 Subject: [PATCH 03/24] Fix VertexWord creation, direct instantiation from words produces saturated z0 values. --- .../DemonstratorTools/src/codecs_vertices.cc | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/L1Trigger/DemonstratorTools/src/codecs_vertices.cc b/L1Trigger/DemonstratorTools/src/codecs_vertices.cc index f81e221e5666c..f25cd68304624 100644 --- a/L1Trigger/DemonstratorTools/src/codecs_vertices.cc +++ b/L1Trigger/DemonstratorTools/src/codecs_vertices.cc @@ -29,14 +29,29 @@ namespace l1t::demo::codecs { for (const auto& x : frames) { if (not x.test(VertexWord::kValidLSB)) break; - - VertexWord v(VertexWord::vtxvalid_t(1), - VertexWord::vtxz0_t(x(VertexWord::kZ0MSB, VertexWord::kZ0LSB)), - VertexWord::vtxmultiplicity_t(x(VertexWord::kNTrackInPVMSB, VertexWord::kNTrackInPVLSB)), - VertexWord::vtxsumpt_t(x(VertexWord::kSumPtMSB, VertexWord::kSumPtLSB)), - VertexWord::vtxquality_t(x(VertexWord::kQualityMSB, VertexWord::kQualityLSB)), - VertexWord::vtxinversemult_t(x(VertexWord::kNTrackOutPVMSB, VertexWord::kNTrackOutPVLSB)), - VertexWord::vtxunassigned_t(x(VertexWord::kUnassignedMSB, VertexWord::kUnassignedLSB))); + VertexWord::vtxvalid_t validWord; + VertexWord::vtxz0_t z0Word; + VertexWord::vtxmultiplicity_t multWord; + VertexWord::vtxsumpt_t sumPtWord; + VertexWord::vtxquality_t qualityWord; + VertexWord::vtxinversemult_t inverseMultWord; + VertexWord::vtxunassigned_t unassignedWord; + + validWord.V = x(VertexWord::kValidMSB, VertexWord::kValidLSB); + z0Word.V = x(VertexWord::kZ0MSB, VertexWord::kZ0LSB); + multWord.V = x(VertexWord::kNTrackInPVMSB, VertexWord::kNTrackInPVLSB); + sumPtWord.V = x(VertexWord::kSumPtMSB, VertexWord::kSumPtLSB); + qualityWord.V = x(VertexWord::kQualityMSB, VertexWord::kQualityLSB); + inverseMultWord.V = x(VertexWord::kNTrackOutPVMSB, VertexWord::kNTrackOutPVLSB); + unassignedWord.V = x(VertexWord::kUnassignedMSB, VertexWord::kUnassignedLSB); + + VertexWord v(validWord, + z0Word, + multWord, + sumPtWord, + qualityWord, + qualityWord, + unassignedWord); vertices.push_back(v); } From 9ea934526a66832322d417707a4c6566bc08e489 Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Fri, 27 Oct 2023 06:17:40 +0200 Subject: [PATCH 04/24] Add path for runtime_error if BoardDataReader finds improperly formatted buffers --- L1Trigger/DemonstratorTools/src/BoardDataReader.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/L1Trigger/DemonstratorTools/src/BoardDataReader.cc b/L1Trigger/DemonstratorTools/src/BoardDataReader.cc index 161f62d4974fb..88457c0fca636 100644 --- a/L1Trigger/DemonstratorTools/src/BoardDataReader.cc +++ b/L1Trigger/DemonstratorTools/src/BoardDataReader.cc @@ -74,15 +74,14 @@ namespace l1t::demo { continue; bool expectValid(((j - framesBeforeFirstPacket) % eventLength) < packetLength); - if (expectValid) { if (not chanData.at(j).valid) throw std::runtime_error("Frame " + std::to_string(j) + " on channel " + std::to_string(indices.at(tmuxIndex)) + - " is invalid, but expected valid frame"); + " is invalid, but expected valid frame (path='" + path + "')"); } else if (chanData.at(j).valid) throw std::runtime_error("Frame " + std::to_string(j) + " on channel " + - std::to_string(indices.at(tmuxIndex)) + " is valid, but expected invalid frame"); + std::to_string(indices.at(tmuxIndex)) + " is valid, but expected invalid frame (path='" + path + "')"); } } } From 314ea0cc865795ae0e8dfca68b93c5663024674b Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Fri, 27 Oct 2023 07:44:19 +0200 Subject: [PATCH 05/24] Update GTTFileReader to load and produce collection of fixed Vertices --- L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc | 12 ++++++++---- .../DemonstratorTools/python/l1tGTTFileReader_cfi.py | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc index b304622911b2c..cb26a2b884779 100644 --- a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc +++ b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc @@ -53,7 +53,7 @@ class GTTFileReader : public edm::stream::EDProducer<> { static constexpr size_t kGapLength = 44; static constexpr size_t kVertexTMUX = 6; static constexpr size_t kVertexChanIndex = 0; - static constexpr size_t kEmptyFrames = 0; //FIXME should be configurable! + static constexpr size_t kEmptyFrames = 0; // 10 does not match current file writing configuration const l1t::demo::BoardDataReader::ChannelMap_t kChannelSpecs = { /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ @@ -64,6 +64,7 @@ class GTTFileReader : public edm::stream::EDProducer<> { // ----------member data --------------------------- l1t::demo::BoardDataReader fileReader_; + std::string l1VertexCollectionName_; }; // @@ -76,8 +77,10 @@ GTTFileReader::GTTFileReader(const edm::ParameterSet& iConfig) kFramesPerTMUXPeriod, kVertexTMUX, kEmptyFrames, - kChannelSpecs) { - produces(); + kChannelSpecs), + l1VertexCollectionName_(iConfig.getParameter("l1VertexCollectionName")) { + produces(l1VertexCollectionName_); + } // ------------ method called to produce the data ------------ @@ -91,7 +94,7 @@ void GTTFileReader::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { edm::LogInfo("GTTFileReader") << vertices.size() << " vertices found"; - iEvent.put(std::make_unique(vertices)); + iEvent.put(std::make_unique(vertices), "L1VerticesFirmware"); } // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ @@ -102,6 +105,7 @@ void GTTFileReader::fillDescriptions(edm::ConfigurationDescriptions& description { "gttOutput_0.txt", }); + desc.add("l1VertexCollectionName", "L1VerticesFirmware"); desc.addUntracked("format", "APx"); descriptions.add("GTTFileReader", desc); } diff --git a/L1Trigger/DemonstratorTools/python/l1tGTTFileReader_cfi.py b/L1Trigger/DemonstratorTools/python/l1tGTTFileReader_cfi.py index 10033c8fb738b..b39e50854c430 100644 --- a/L1Trigger/DemonstratorTools/python/l1tGTTFileReader_cfi.py +++ b/L1Trigger/DemonstratorTools/python/l1tGTTFileReader_cfi.py @@ -2,5 +2,6 @@ l1tGTTFileReader = cms.EDProducer('GTTFileReader', files = cms.vstring("gttOutput_0.txt"), #, "gttOutput_1.txt"), + l1VertexCollectionName = cms.string("L1VerticesFirmware"), format = cms.untracked.string("APx") ) From 210a9fa120e932c1a2b4d30023348475e1286af4 Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Fri, 27 Oct 2023 21:22:05 +0200 Subject: [PATCH 06/24] progress towards loading tracks through another reader --- .../plugins/GTTFileReader.cc | 44 ++++++++++++++++++- .../python/l1tGTTFileReader_cfi.py | 3 +- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc index cb26a2b884779..8192f1044d267 100644 --- a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc +++ b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc @@ -51,7 +51,10 @@ class GTTFileReader : public edm::stream::EDProducer<> { // NOTE: At least some of the info from these constants will eventually come from config files static constexpr size_t kFramesPerTMUXPeriod = 9; static constexpr size_t kGapLength = 44; + static constexpr size_t kGapLengthInput = 6; static constexpr size_t kVertexTMUX = 6; + static constexpr size_t kGTTBoardTMUX = 6; + static constexpr size_t kTrackTMUX = 18; static constexpr size_t kVertexChanIndex = 0; static constexpr size_t kEmptyFrames = 0; // 10 does not match current file writing configuration @@ -59,12 +62,39 @@ class GTTFileReader : public edm::stream::EDProducer<> { /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ {{"vertices", 0}, {{kVertexTMUX, kGapLength}, {kVertexChanIndex}}}}; + const l1t::demo::BoardDataReader::ChannelMap_t kChannelSpecsInput = { + /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ + {{"tracks", 0}, {{kTrackTMUX, kGapLengthInput}, {0, 18, 36}}}, + {{"tracks", 1}, {{kTrackTMUX, kGapLengthInput}, {1, 19, 37}}}, + {{"tracks", 2}, {{kTrackTMUX, kGapLengthInput}, {2, 20, 38}}}, + {{"tracks", 3}, {{kTrackTMUX, kGapLengthInput}, {3, 21, 39}}}, + {{"tracks", 4}, {{kTrackTMUX, kGapLengthInput}, {4, 22, 40}}}, + {{"tracks", 5}, {{kTrackTMUX, kGapLengthInput}, {5, 23, 41}}}, + {{"tracks", 6}, {{kTrackTMUX, kGapLengthInput}, {6, 24, 42}}}, + {{"tracks", 7}, {{kTrackTMUX, kGapLengthInput}, {7, 25, 43}}}, + {{"tracks", 8}, {{kTrackTMUX, kGapLengthInput}, {8, 26, 44}}}, + {{"tracks", 9}, {{kTrackTMUX, kGapLengthInput}, {9, 27, 45}}}, + {{"tracks", 10}, {{kTrackTMUX, kGapLengthInput}, {10, 28, 46}}}, + {{"tracks", 11}, {{kTrackTMUX, kGapLengthInput}, {11, 29, 47}}}, + {{"tracks", 12}, {{kTrackTMUX, kGapLengthInput}, {12, 30, 48}}}, + {{"tracks", 13}, {{kTrackTMUX, kGapLengthInput}, {13, 31, 49}}}, + {{"tracks", 14}, {{kTrackTMUX, kGapLengthInput}, {14, 32, 50}}}, + {{"tracks", 15}, {{kTrackTMUX, kGapLengthInput}, {15, 33, 51}}}, + {{"tracks", 16}, {{kTrackTMUX, kGapLengthInput}, {16, 34, 52}}}, + {{"tracks", 17}, {{kTrackTMUX, kGapLengthInput}, {17, 35, 53}}} + }; + // const std::map kChannelSpecsInput = { + // /* interface name -> {link TMUX, inter-packet gap} */ + // {"tracks", {kTrackTMUX, kGapLengthInput}}}; + + // ----------member functions ---------------------- void produce(edm::Event&, const edm::EventSetup&) override; // ----------member data --------------------------- l1t::demo::BoardDataReader fileReader_; std::string l1VertexCollectionName_; + l1t::demo::BoardDataReader fileReaderInputTracks_; }; // @@ -78,7 +108,13 @@ GTTFileReader::GTTFileReader(const edm::ParameterSet& iConfig) kVertexTMUX, kEmptyFrames, kChannelSpecs), - l1VertexCollectionName_(iConfig.getParameter("l1VertexCollectionName")) { + l1VertexCollectionName_(iConfig.getParameter("l1VertexCollectionName")), + fileReaderInputTracks_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), + iConfig.getParameter>("filesInputTracks"), + kFramesPerTMUXPeriod, + kGTTBoardTMUX, + kEmptyFrames, + kChannelSpecsInput) { produces(l1VertexCollectionName_); } @@ -103,9 +139,13 @@ void GTTFileReader::fillDescriptions(edm::ConfigurationDescriptions& description edm::ParameterSetDescription desc; desc.add>("files", { - "gttOutput_0.txt", + "L1GTTOutputToCorrelator_0.txt", }); desc.add("l1VertexCollectionName", "L1VerticesFirmware"); + desc.add>("filesInputTracks", + { + "L1GTTInputFile_0.txt", + }); desc.addUntracked("format", "APx"); descriptions.add("GTTFileReader", desc); } diff --git a/L1Trigger/DemonstratorTools/python/l1tGTTFileReader_cfi.py b/L1Trigger/DemonstratorTools/python/l1tGTTFileReader_cfi.py index b39e50854c430..bf8d8500603cc 100644 --- a/L1Trigger/DemonstratorTools/python/l1tGTTFileReader_cfi.py +++ b/L1Trigger/DemonstratorTools/python/l1tGTTFileReader_cfi.py @@ -1,7 +1,8 @@ import FWCore.ParameterSet.Config as cms l1tGTTFileReader = cms.EDProducer('GTTFileReader', - files = cms.vstring("gttOutput_0.txt"), #, "gttOutput_1.txt"), + files = cms.vstring("L1GTTOutputToCorrelatorFile_0.txt"), + filesInputTracks = cms.vstring("L1GTTInputFile_0.txt"), l1VertexCollectionName = cms.string("L1VerticesFirmware"), format = cms.untracked.string("APx") ) From b2cbb0bad927d2200fb26d8229c785d04511005b Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Sat, 28 Oct 2023 22:17:37 +0200 Subject: [PATCH 07/24] checkpoint for adding tracks to GTTFileReader, include renaming of fileReaders to be more descriptive. --- .../plugins/GTTFileReader.cc | 36 ++++++++++++++----- .../python/l1tGTTFileReader_cfi.py | 1 + 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc index 8192f1044d267..00970968d6aab 100644 --- a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc +++ b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc @@ -34,6 +34,7 @@ #include "DataFormats/L1Trigger/interface/Vertex.h" #include "L1Trigger/DemonstratorTools/interface/BoardDataReader.h" #include "L1Trigger/DemonstratorTools/interface/codecs/vertices.h" +#include "L1Trigger/DemonstratorTools/interface/codecs/tracks.h" #include "L1Trigger/DemonstratorTools/interface/utilities.h" // @@ -83,18 +84,18 @@ class GTTFileReader : public edm::stream::EDProducer<> { {{"tracks", 16}, {{kTrackTMUX, kGapLengthInput}, {16, 34, 52}}}, {{"tracks", 17}, {{kTrackTMUX, kGapLengthInput}, {17, 35, 53}}} }; - // const std::map kChannelSpecsInput = { - // /* interface name -> {link TMUX, inter-packet gap} */ - // {"tracks", {kTrackTMUX, kGapLengthInput}}}; + typedef TTTrack L1Track; + typedef std::vector TTTrackCollection; // ----------member functions ---------------------- void produce(edm::Event&, const edm::EventSetup&) override; // ----------member data --------------------------- - l1t::demo::BoardDataReader fileReader_; + l1t::demo::BoardDataReader fileReaderOutputToCorrelator_; std::string l1VertexCollectionName_; l1t::demo::BoardDataReader fileReaderInputTracks_; + std::string l1TrackCollectionName_; }; // @@ -102,7 +103,7 @@ class GTTFileReader : public edm::stream::EDProducer<> { // GTTFileReader::GTTFileReader(const edm::ParameterSet& iConfig) - : fileReader_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), + : fileReaderOutputToCorrelator_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), iConfig.getParameter>("files"), kFramesPerTMUXPeriod, kVertexTMUX, @@ -114,8 +115,10 @@ GTTFileReader::GTTFileReader(const edm::ParameterSet& iConfig) kFramesPerTMUXPeriod, kGTTBoardTMUX, kEmptyFrames, - kChannelSpecsInput) { + kChannelSpecsInput), + l1TrackCollectionName_(iConfig.getParameter("l1TrackCollectionName")) { produces(l1VertexCollectionName_); + produces(l1TrackCollectionName_); } @@ -124,9 +127,23 @@ void GTTFileReader::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { using namespace edm; using namespace l1t::demo::codecs; - l1t::demo::EventData eventData(fileReader_.getNextEvent()); - - l1t::VertexWordCollection vertices(decodeVertices(eventData.at({"vertices", 0}))); + l1t::demo::EventData correlatorEventData(fileReaderOutputToCorrelator_.getNextEvent()); + l1t::demo::EventData inputEventData(fileReaderInputTracks_.getNextEvent()); + + l1t::VertexWordCollection vertices(decodeVertices(correlatorEventData.at({"vertices", 0}))); + auto inputTracks = std::make_unique(); + for (size_t i = 0; i < 18; i++) { + auto iTracks = decodeTracks(inputEventData.at({"tracks", i})); + // std::cout << inputTracks.size() << " "; + // inputTracks->insert(inputTracks->end(), iTracks.begin(), iTracks.end()); + for( auto& track: iTracks) { + // FIXME need valid bit check, many of these are zeros + std::cout << track.getTrackWord().to_string(16) << std::endl; + //l1tVertexFinder::L1Track(edm::refToPtr( + inputTracks->push_back(track); + } + } + std::cout << std::endl; edm::LogInfo("GTTFileReader") << vertices.size() << " vertices found"; @@ -146,6 +163,7 @@ void GTTFileReader::fillDescriptions(edm::ConfigurationDescriptions& description { "L1GTTInputFile_0.txt", }); + desc.add("l1TrackCollectionName", "Level1TTTracks"); desc.addUntracked("format", "APx"); descriptions.add("GTTFileReader", desc); } diff --git a/L1Trigger/DemonstratorTools/python/l1tGTTFileReader_cfi.py b/L1Trigger/DemonstratorTools/python/l1tGTTFileReader_cfi.py index bf8d8500603cc..7a8cf25d21901 100644 --- a/L1Trigger/DemonstratorTools/python/l1tGTTFileReader_cfi.py +++ b/L1Trigger/DemonstratorTools/python/l1tGTTFileReader_cfi.py @@ -4,5 +4,6 @@ files = cms.vstring("L1GTTOutputToCorrelatorFile_0.txt"), filesInputTracks = cms.vstring("L1GTTInputFile_0.txt"), l1VertexCollectionName = cms.string("L1VerticesFirmware"), + l1TrackCollectionName = cms.string("Level1TTTracks"), format = cms.untracked.string("APx") ) From b0bf3928ae269de6d4d9eafb5135a1d13c87fb8d Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Tue, 31 Oct 2023 05:27:55 +0100 Subject: [PATCH 08/24] Add track decoding with manual word setting and updated gttLinkID method in codecs and L1TrackVertexAssociationProducer, minus conflicts from rebase --- .../plugins/GTTFileReader.cc | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc index 00970968d6aab..ee95b895a34c6 100644 --- a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc +++ b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc @@ -134,20 +134,36 @@ void GTTFileReader::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { auto inputTracks = std::make_unique(); for (size_t i = 0; i < 18; i++) { auto iTracks = decodeTracks(inputEventData.at({"tracks", i})); - // std::cout << inputTracks.size() << " "; - // inputTracks->insert(inputTracks->end(), iTracks.begin(), iTracks.end()); - for( auto& track: iTracks) { - // FIXME need valid bit check, many of these are zeros - std::cout << track.getTrackWord().to_string(16) << std::endl; - //l1tVertexFinder::L1Track(edm::refToPtr( + for( auto& trackword: iTracks) { + if (!trackword.getValidWord()) + continue; + unsigned int etaSector = (trackword.getTrackWord()(TTTrack_TrackWord::TrackBitLocations::kTanlMSB, TTTrack_TrackWord::TrackBitLocations::kTanlMSB) ? 0 : 1); + unsigned int phiSector = (static_cast(i) - etaSector) / 2; + L1Track track = L1Track( + trackword.getValidWord(), + trackword.getRinvWord(), + trackword.getPhiWord(), + trackword.getTanlWord(), + trackword.getZ0Word(), + trackword.getD0Word(), + trackword.getChi2RPhiWord(), + trackword.getChi2RZWord(), + trackword.getBendChi2Word(), + trackword.getHitPatternWord(), + trackword.getMVAQualityWord(), + trackword.getMVAOtherWord() + ); + track.setEtaSector(etaSector); + track.setPhiSector(phiSector); + track.trackWord_ = trackword.trackWord_; inputTracks->push_back(track); } } - std::cout << std::endl; edm::LogInfo("GTTFileReader") << vertices.size() << " vertices found"; - iEvent.put(std::make_unique(vertices), "L1VerticesFirmware"); + iEvent.put(std::make_unique(vertices), l1VertexCollectionName_); + iEvent.put(std::move(inputTracks), l1TrackCollectionName_); } // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ From 6b469c64f6456763069bd000fd9ea220adf21adc Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Tue, 31 Oct 2023 19:57:02 +0100 Subject: [PATCH 09/24] setTrackWordBits as a boolean for l1tGTTInputProducer, which must be set to False for tracks from l1tGTTFileReader --- L1Trigger/L1TTrackMatch/plugins/L1GTTInputProducer.cc | 10 +++++++--- .../L1TTrackMatch/python/l1tGTTInputProducer_cfi.py | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/L1Trigger/L1TTrackMatch/plugins/L1GTTInputProducer.cc b/L1Trigger/L1TTrackMatch/plugins/L1GTTInputProducer.cc index 5074ec2c2cec1..a056cd7b0cd03 100644 --- a/L1Trigger/L1TTrackMatch/plugins/L1GTTInputProducer.cc +++ b/L1Trigger/L1TTrackMatch/plugins/L1GTTInputProducer.cc @@ -112,6 +112,7 @@ class L1GTTInputProducer : public edm::global::EDProducer<> { // ----------member data --------------------------- const edm::EDGetTokenT l1TracksToken_; const std::string outputCollectionName_; + bool setTrackWordBits_; int debug_; std::vector pt_lut_; std::vector eta_lut_; @@ -123,6 +124,7 @@ class L1GTTInputProducer : public edm::global::EDProducer<> { L1GTTInputProducer::L1GTTInputProducer(const edm::ParameterSet& iConfig) : l1TracksToken_(consumes(iConfig.getParameter("l1TracksInputTag"))), outputCollectionName_(iConfig.getParameter("outputCollectionName")), + setTrackWordBits_(iConfig.getParameter("setTrackWordBits")), debug_(iConfig.getParameter("debug")) { // Generate the required luts generate_eta_lut(); @@ -429,7 +431,7 @@ void L1GTTInputProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::E vPtOutput->reserve(nOutput); vEtaOutput->reserve(nOutput); for (const auto& track : *l1TracksHandle) { - if (!(track.nFitPars() == Npars4 || track.nFitPars() == Npars5)) { + if (setTrackWordBits_ && !(track.nFitPars() == Npars4 || track.nFitPars() == Npars5)) { throw cms::Exception("nFitPars unknown") << "L1GTTInputProducer::produce method is called with numFitPars_ = " << track.nFitPars() << ". The only possible values are 4/5."; @@ -439,12 +441,13 @@ void L1GTTInputProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::E vTTTrackOutput->push_back(track); auto& currentTrackRef = vTTTrackOutput->back(); if (debug_ >= 2) { - edm::LogInfo("L1GTTInputProducer") << "produce::word before anything " + edm::LogInfo("L1GTTInputProducer") << "produce::word before anything with setTrackWordBits_ = " << setTrackWordBits_ << ": " << currentTrackRef.getTrackWord().to_string(2); } // Do an initial setting of the bits based on the floating point values - currentTrackRef.setTrackWordBits(); + if(setTrackWordBits_) + currentTrackRef.setTrackWordBits(); if (debug_ >= 2) { edm::LogInfo("L1GTTInputProducer") << "produce::word after initial setting of the track word " << currentTrackRef.getTrackWord().to_string(2); @@ -531,6 +534,7 @@ void L1GTTInputProducer::fillDescriptions(edm::ConfigurationDescriptions& descri desc.add("debug", 0)->setComment("Verbosity levels: 0, 1, 2, 3"); desc.add("l1TracksInputTag", edm::InputTag("TTTracksFromTrackletEmulation", "Level1TTTracks")); desc.add("outputCollectionName", "Level1TTTracksConverted"); + desc.add("setTrackWordBits", true)->setComment("flag indicated whether the TTTrack_TrackWord should be set from float parameters or skipped (if TrackWord set by e.g. GTTFileReader decoding)"); descriptions.addWithDefaultLabel(desc); } diff --git a/L1Trigger/L1TTrackMatch/python/l1tGTTInputProducer_cfi.py b/L1Trigger/L1TTrackMatch/python/l1tGTTInputProducer_cfi.py index 48714cf2597c4..687399712f7e8 100644 --- a/L1Trigger/L1TTrackMatch/python/l1tGTTInputProducer_cfi.py +++ b/L1Trigger/L1TTrackMatch/python/l1tGTTInputProducer_cfi.py @@ -3,11 +3,13 @@ l1tGTTInputProducer = cms.EDProducer('L1GTTInputProducer', l1TracksInputTag = cms.InputTag("l1tTTTracksFromTrackletEmulation", "Level1TTTracks"), outputCollectionName = cms.string("Level1TTTracksConverted"), + setTrackWordBits = cms.bool(True), debug = cms.int32(0) # Verbosity levels: 0, 1, 2, 3 ) l1tGTTInputProducerExtended = cms.EDProducer('L1GTTInputProducer', l1TracksInputTag = cms.InputTag("l1tTTTracksFromExtendedTrackletEmulation", "Level1TTTracks"), outputCollectionName = cms.string("Level1TTTracksExtendedConverted"), + setTrackWordBits = cms.bool(True), debug = cms.int32(0) # Verbosity levels: 0, 1, 2, 3 ) From 1ee0e8279ef982f9584b34003c4181579a074059 Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Wed, 1 Nov 2023 07:13:32 +0100 Subject: [PATCH 10/24] Update gttLinkID and inverse functions in codecs --- L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc index ee95b895a34c6..2564ae2e1926d 100644 --- a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc +++ b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc @@ -137,8 +137,6 @@ void GTTFileReader::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { for( auto& trackword: iTracks) { if (!trackword.getValidWord()) continue; - unsigned int etaSector = (trackword.getTrackWord()(TTTrack_TrackWord::TrackBitLocations::kTanlMSB, TTTrack_TrackWord::TrackBitLocations::kTanlMSB) ? 0 : 1); - unsigned int phiSector = (static_cast(i) - etaSector) / 2; L1Track track = L1Track( trackword.getValidWord(), trackword.getRinvWord(), @@ -153,8 +151,10 @@ void GTTFileReader::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { trackword.getMVAQualityWord(), trackword.getMVAOtherWord() ); - track.setEtaSector(etaSector); - track.setPhiSector(phiSector); + //retrieve the eta (first) and phi (second) sectors for GTT, encoded in an std::pair + auto sectors = (l1t::demo::codecs::sectorsEtaPhiFromGTTLinkID(i)); + track.setEtaSector(sectors.first); + track.setPhiSector(sectors.second); track.trackWord_ = trackword.trackWord_; inputTracks->push_back(track); } From 56803d102ced54268726fc0e3b73d576f2803590 Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Wed, 1 Nov 2023 07:22:14 +0100 Subject: [PATCH 11/24] code-checks and code-format for GTTFileReader updates --- .../plugins/GTTFileReader.cc | 58 +++++++++---------- .../DemonstratorTools/src/BoardDataReader.cc | 3 +- .../DemonstratorTools/src/codecs_vertices.cc | 8 +-- .../plugins/L1GTTInputProducer.cc | 11 ++-- 4 files changed, 37 insertions(+), 43 deletions(-) diff --git a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc index 2564ae2e1926d..2cb83c48b6c39 100644 --- a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc +++ b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc @@ -57,7 +57,7 @@ class GTTFileReader : public edm::stream::EDProducer<> { static constexpr size_t kGTTBoardTMUX = 6; static constexpr size_t kTrackTMUX = 18; static constexpr size_t kVertexChanIndex = 0; - static constexpr size_t kEmptyFrames = 0; // 10 does not match current file writing configuration + static constexpr size_t kEmptyFrames = 0; // 10 does not match current file writing configuration const l1t::demo::BoardDataReader::ChannelMap_t kChannelSpecs = { /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ @@ -82,9 +82,8 @@ class GTTFileReader : public edm::stream::EDProducer<> { {{"tracks", 14}, {{kTrackTMUX, kGapLengthInput}, {14, 32, 50}}}, {{"tracks", 15}, {{kTrackTMUX, kGapLengthInput}, {15, 33, 51}}}, {{"tracks", 16}, {{kTrackTMUX, kGapLengthInput}, {16, 34, 52}}}, - {{"tracks", 17}, {{kTrackTMUX, kGapLengthInput}, {17, 35, 53}}} - }; - + {{"tracks", 17}, {{kTrackTMUX, kGapLengthInput}, {17, 35, 53}}}}; + typedef TTTrack L1Track; typedef std::vector TTTrackCollection; @@ -104,22 +103,21 @@ class GTTFileReader : public edm::stream::EDProducer<> { GTTFileReader::GTTFileReader(const edm::ParameterSet& iConfig) : fileReaderOutputToCorrelator_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), - iConfig.getParameter>("files"), - kFramesPerTMUXPeriod, - kVertexTMUX, - kEmptyFrames, - kChannelSpecs), + iConfig.getParameter>("files"), + kFramesPerTMUXPeriod, + kVertexTMUX, + kEmptyFrames, + kChannelSpecs), l1VertexCollectionName_(iConfig.getParameter("l1VertexCollectionName")), fileReaderInputTracks_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), - iConfig.getParameter>("filesInputTracks"), - kFramesPerTMUXPeriod, - kGTTBoardTMUX, - kEmptyFrames, - kChannelSpecsInput), + iConfig.getParameter>("filesInputTracks"), + kFramesPerTMUXPeriod, + kGTTBoardTMUX, + kEmptyFrames, + kChannelSpecsInput), l1TrackCollectionName_(iConfig.getParameter("l1TrackCollectionName")) { produces(l1VertexCollectionName_); produces(l1TrackCollectionName_); - } // ------------ method called to produce the data ------------ @@ -134,23 +132,21 @@ void GTTFileReader::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { auto inputTracks = std::make_unique(); for (size_t i = 0; i < 18; i++) { auto iTracks = decodeTracks(inputEventData.at({"tracks", i})); - for( auto& trackword: iTracks) { + for (auto& trackword : iTracks) { if (!trackword.getValidWord()) - continue; - L1Track track = L1Track( - trackword.getValidWord(), - trackword.getRinvWord(), - trackword.getPhiWord(), - trackword.getTanlWord(), - trackword.getZ0Word(), - trackword.getD0Word(), - trackword.getChi2RPhiWord(), - trackword.getChi2RZWord(), - trackword.getBendChi2Word(), - trackword.getHitPatternWord(), - trackword.getMVAQualityWord(), - trackword.getMVAOtherWord() - ); + continue; + L1Track track = L1Track(trackword.getValidWord(), + trackword.getRinvWord(), + trackword.getPhiWord(), + trackword.getTanlWord(), + trackword.getZ0Word(), + trackword.getD0Word(), + trackword.getChi2RPhiWord(), + trackword.getChi2RZWord(), + trackword.getBendChi2Word(), + trackword.getHitPatternWord(), + trackword.getMVAQualityWord(), + trackword.getMVAOtherWord()); //retrieve the eta (first) and phi (second) sectors for GTT, encoded in an std::pair auto sectors = (l1t::demo::codecs::sectorsEtaPhiFromGTTLinkID(i)); track.setEtaSector(sectors.first); diff --git a/L1Trigger/DemonstratorTools/src/BoardDataReader.cc b/L1Trigger/DemonstratorTools/src/BoardDataReader.cc index 88457c0fca636..f392c23279ab0 100644 --- a/L1Trigger/DemonstratorTools/src/BoardDataReader.cc +++ b/L1Trigger/DemonstratorTools/src/BoardDataReader.cc @@ -81,7 +81,8 @@ namespace l1t::demo { " is invalid, but expected valid frame (path='" + path + "')"); } else if (chanData.at(j).valid) throw std::runtime_error("Frame " + std::to_string(j) + " on channel " + - std::to_string(indices.at(tmuxIndex)) + " is valid, but expected invalid frame (path='" + path + "')"); + std::to_string(indices.at(tmuxIndex)) + + " is valid, but expected invalid frame (path='" + path + "')"); } } } diff --git a/L1Trigger/DemonstratorTools/src/codecs_vertices.cc b/L1Trigger/DemonstratorTools/src/codecs_vertices.cc index f25cd68304624..363402b342109 100644 --- a/L1Trigger/DemonstratorTools/src/codecs_vertices.cc +++ b/L1Trigger/DemonstratorTools/src/codecs_vertices.cc @@ -45,13 +45,7 @@ namespace l1t::demo::codecs { inverseMultWord.V = x(VertexWord::kNTrackOutPVMSB, VertexWord::kNTrackOutPVLSB); unassignedWord.V = x(VertexWord::kUnassignedMSB, VertexWord::kUnassignedLSB); - VertexWord v(validWord, - z0Word, - multWord, - sumPtWord, - qualityWord, - qualityWord, - unassignedWord); + VertexWord v(validWord, z0Word, multWord, sumPtWord, qualityWord, qualityWord, unassignedWord); vertices.push_back(v); } diff --git a/L1Trigger/L1TTrackMatch/plugins/L1GTTInputProducer.cc b/L1Trigger/L1TTrackMatch/plugins/L1GTTInputProducer.cc index a056cd7b0cd03..0833f7dd6af6e 100644 --- a/L1Trigger/L1TTrackMatch/plugins/L1GTTInputProducer.cc +++ b/L1Trigger/L1TTrackMatch/plugins/L1GTTInputProducer.cc @@ -441,12 +441,12 @@ void L1GTTInputProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::E vTTTrackOutput->push_back(track); auto& currentTrackRef = vTTTrackOutput->back(); if (debug_ >= 2) { - edm::LogInfo("L1GTTInputProducer") << "produce::word before anything with setTrackWordBits_ = " << setTrackWordBits_ << ": " - << currentTrackRef.getTrackWord().to_string(2); + edm::LogInfo("L1GTTInputProducer") << "produce::word before anything with setTrackWordBits_ = " + << setTrackWordBits_ << ": " << currentTrackRef.getTrackWord().to_string(2); } // Do an initial setting of the bits based on the floating point values - if(setTrackWordBits_) + if (setTrackWordBits_) currentTrackRef.setTrackWordBits(); if (debug_ >= 2) { edm::LogInfo("L1GTTInputProducer") << "produce::word after initial setting of the track word " @@ -534,7 +534,10 @@ void L1GTTInputProducer::fillDescriptions(edm::ConfigurationDescriptions& descri desc.add("debug", 0)->setComment("Verbosity levels: 0, 1, 2, 3"); desc.add("l1TracksInputTag", edm::InputTag("TTTracksFromTrackletEmulation", "Level1TTTracks")); desc.add("outputCollectionName", "Level1TTTracksConverted"); - desc.add("setTrackWordBits", true)->setComment("flag indicated whether the TTTrack_TrackWord should be set from float parameters or skipped (if TrackWord set by e.g. GTTFileReader decoding)"); + desc.add("setTrackWordBits", true) + ->setComment( + "flag indicated whether the TTTrack_TrackWord should be set from float parameters or skipped (if TrackWord " + "set by e.g. GTTFileReader decoding)"); descriptions.addWithDefaultLabel(desc); } From 07b31463b5505d377a6454b2fed68ce5107a9103 Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Thu, 2 Nov 2023 15:59:16 +0100 Subject: [PATCH 12/24] Checkpoint factorize GTTInterface.h common elements for GTTFileReader --- .../plugins/GTTFileReader.cc | 85 ++++++++++--------- 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc index 2cb83c48b6c39..64cf0f62da4ba 100644 --- a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc +++ b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc @@ -32,6 +32,7 @@ #include "FWCore/Utilities/interface/StreamID.h" #include "DataFormats/L1Trigger/interface/Vertex.h" +#include "L1Trigger/DemonstratorTools/interface/GTTInterface.h" #include "L1Trigger/DemonstratorTools/interface/BoardDataReader.h" #include "L1Trigger/DemonstratorTools/interface/codecs/vertices.h" #include "L1Trigger/DemonstratorTools/interface/codecs/tracks.h" @@ -50,39 +51,41 @@ class GTTFileReader : public edm::stream::EDProducer<> { private: // ----------constants, enums and typedefs --------- // NOTE: At least some of the info from these constants will eventually come from config files - static constexpr size_t kFramesPerTMUXPeriod = 9; - static constexpr size_t kGapLength = 44; - static constexpr size_t kGapLengthInput = 6; - static constexpr size_t kVertexTMUX = 6; - static constexpr size_t kGTTBoardTMUX = 6; - static constexpr size_t kTrackTMUX = 18; - static constexpr size_t kVertexChanIndex = 0; - static constexpr size_t kEmptyFrames = 0; // 10 does not match current file writing configuration - - const l1t::demo::BoardDataReader::ChannelMap_t kChannelSpecs = { - /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ - {{"vertices", 0}, {{kVertexTMUX, kGapLength}, {kVertexChanIndex}}}}; - - const l1t::demo::BoardDataReader::ChannelMap_t kChannelSpecsInput = { - /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ - {{"tracks", 0}, {{kTrackTMUX, kGapLengthInput}, {0, 18, 36}}}, - {{"tracks", 1}, {{kTrackTMUX, kGapLengthInput}, {1, 19, 37}}}, - {{"tracks", 2}, {{kTrackTMUX, kGapLengthInput}, {2, 20, 38}}}, - {{"tracks", 3}, {{kTrackTMUX, kGapLengthInput}, {3, 21, 39}}}, - {{"tracks", 4}, {{kTrackTMUX, kGapLengthInput}, {4, 22, 40}}}, - {{"tracks", 5}, {{kTrackTMUX, kGapLengthInput}, {5, 23, 41}}}, - {{"tracks", 6}, {{kTrackTMUX, kGapLengthInput}, {6, 24, 42}}}, - {{"tracks", 7}, {{kTrackTMUX, kGapLengthInput}, {7, 25, 43}}}, - {{"tracks", 8}, {{kTrackTMUX, kGapLengthInput}, {8, 26, 44}}}, - {{"tracks", 9}, {{kTrackTMUX, kGapLengthInput}, {9, 27, 45}}}, - {{"tracks", 10}, {{kTrackTMUX, kGapLengthInput}, {10, 28, 46}}}, - {{"tracks", 11}, {{kTrackTMUX, kGapLengthInput}, {11, 29, 47}}}, - {{"tracks", 12}, {{kTrackTMUX, kGapLengthInput}, {12, 30, 48}}}, - {{"tracks", 13}, {{kTrackTMUX, kGapLengthInput}, {13, 31, 49}}}, - {{"tracks", 14}, {{kTrackTMUX, kGapLengthInput}, {14, 32, 50}}}, - {{"tracks", 15}, {{kTrackTMUX, kGapLengthInput}, {15, 33, 51}}}, - {{"tracks", 16}, {{kTrackTMUX, kGapLengthInput}, {16, 34, 52}}}, - {{"tracks", 17}, {{kTrackTMUX, kGapLengthInput}, {17, 35, 53}}}}; + // static constexpr size_t kFramesPerTMUXPeriod = 9; + // static constexpr size_t kGapLength = 44; + // static constexpr size_t kGapLengthInput = 6; + // static constexpr size_t kVertexTMUX = 6; + // static constexpr size_t kGTTBoardTMUX = 6; + // static constexpr size_t kTrackTMUX = 18; + // static constexpr size_t kVertexChanIndex = 0; + static constexpr size_t kEmptyFramesOutputToCorrelator = 0; // 10 does not match current file writing configuration + static constexpr size_t kEmptyFramesInput = 0; + static constexpr size_t kEmptyFramesOutputToGlobalTrigger = 0; + + // const l1t::demo::BoardDataReader::ChannelMap_t kChannelSpecs = { + // /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ + // {{"vertices", 0}, {{kGTTBoardTMUX, kGapLengthOutputToCorrelator}, {kVertexChanIndex}}}}; + + // const l1t::demo::BoardDataReader::ChannelMap_t kChannelSpecsInput = { + // /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ + // {{"tracks", 0}, {{kTrackTMUX, kGapLengthInput}, {0, 18, 36}}}, + // {{"tracks", 1}, {{kTrackTMUX, kGapLengthInput}, {1, 19, 37}}}, + // {{"tracks", 2}, {{kTrackTMUX, kGapLengthInput}, {2, 20, 38}}}, + // {{"tracks", 3}, {{kTrackTMUX, kGapLengthInput}, {3, 21, 39}}}, + // {{"tracks", 4}, {{kTrackTMUX, kGapLengthInput}, {4, 22, 40}}}, + // {{"tracks", 5}, {{kTrackTMUX, kGapLengthInput}, {5, 23, 41}}}, + // {{"tracks", 6}, {{kTrackTMUX, kGapLengthInput}, {6, 24, 42}}}, + // {{"tracks", 7}, {{kTrackTMUX, kGapLengthInput}, {7, 25, 43}}}, + // {{"tracks", 8}, {{kTrackTMUX, kGapLengthInput}, {8, 26, 44}}}, + // {{"tracks", 9}, {{kTrackTMUX, kGapLengthInput}, {9, 27, 45}}}, + // {{"tracks", 10}, {{kTrackTMUX, kGapLengthInput}, {10, 28, 46}}}, + // {{"tracks", 11}, {{kTrackTMUX, kGapLengthInput}, {11, 29, 47}}}, + // {{"tracks", 12}, {{kTrackTMUX, kGapLengthInput}, {12, 30, 48}}}, + // {{"tracks", 13}, {{kTrackTMUX, kGapLengthInput}, {13, 31, 49}}}, + // {{"tracks", 14}, {{kTrackTMUX, kGapLengthInput}, {14, 32, 50}}}, + // {{"tracks", 15}, {{kTrackTMUX, kGapLengthInput}, {15, 33, 51}}}, + // {{"tracks", 16}, {{kTrackTMUX, kGapLengthInput}, {16, 34, 52}}}, + // {{"tracks", 17}, {{kTrackTMUX, kGapLengthInput}, {17, 35, 53}}}}; typedef TTTrack L1Track; typedef std::vector TTTrackCollection; @@ -104,17 +107,17 @@ class GTTFileReader : public edm::stream::EDProducer<> { GTTFileReader::GTTFileReader(const edm::ParameterSet& iConfig) : fileReaderOutputToCorrelator_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), iConfig.getParameter>("files"), - kFramesPerTMUXPeriod, - kVertexTMUX, - kEmptyFrames, - kChannelSpecs), + l1t::demo::kFramesPerTMUXPeriod, + l1t::demo::kGTTBoardTMUX, + kEmptyFramesOutputToCorrelator, + l1t::demo::kChannelMapOutputToCorrelator), l1VertexCollectionName_(iConfig.getParameter("l1VertexCollectionName")), fileReaderInputTracks_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), iConfig.getParameter>("filesInputTracks"), - kFramesPerTMUXPeriod, - kGTTBoardTMUX, - kEmptyFrames, - kChannelSpecsInput), + l1t::demo::kFramesPerTMUXPeriod, + l1t::demo::kGTTBoardTMUX, + kEmptyFramesInput, + l1t::demo::kChannelMapInput), l1TrackCollectionName_(iConfig.getParameter("l1TrackCollectionName")) { produces(l1VertexCollectionName_); produces(l1TrackCollectionName_); From 23bfbfa29b2b44a9a9c6e0eceb573d6370b227c4 Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Thu, 2 Nov 2023 15:59:29 +0100 Subject: [PATCH 13/24] Checkpoint factorize GTTInterface.h common elements for GTTFileWriter --- .../plugins/GTTFileWriter.cc | 167 +++++++++--------- 1 file changed, 84 insertions(+), 83 deletions(-) diff --git a/L1Trigger/DemonstratorTools/plugins/GTTFileWriter.cc b/L1Trigger/DemonstratorTools/plugins/GTTFileWriter.cc index c79de7f8ee836..ca22ae3381bf2 100644 --- a/L1Trigger/DemonstratorTools/plugins/GTTFileWriter.cc +++ b/L1Trigger/DemonstratorTools/plugins/GTTFileWriter.cc @@ -42,6 +42,7 @@ #include "DataFormats/L1Trigger/interface/VertexWord.h" #include "L1Trigger/DemonstratorTools/interface/BoardDataWriter.h" +#include "L1Trigger/DemonstratorTools/interface/GTTInterface.h" #include "L1Trigger/DemonstratorTools/interface/codecs/tracks.h" #include "L1Trigger/DemonstratorTools/interface/codecs/vertices.h" #include "L1Trigger/DemonstratorTools/interface/codecs/tkjets.h" @@ -62,60 +63,60 @@ class GTTFileWriter : public edm::one::EDAnalyzer { private: // ----------constants, enums and typedefs --------- // NOTE: At least some of the info from these constants will eventually come from config files - static constexpr size_t kFramesPerTMUXPeriod = 9; - static constexpr size_t kGapLengthInput = 6; - static constexpr size_t kGapLengthOutputToCorrelator = 44; - static constexpr size_t kGapLengthOutputToGlobalTriggerSums = 3; - static constexpr size_t kGapLengthOutputToGlobalTriggerTaus = 36; - static constexpr size_t kGapLengthOutputToGlobalTriggerMesons = 15; - static constexpr size_t kGapLengthOutputToGlobalTriggerVertices = 6; - static constexpr size_t kTrackTMUX = 18; - static constexpr size_t kGTTBoardTMUX = 6; - static constexpr size_t kMaxLinesPerFile = 1024; - - const std::map> kChannelIdsInput = { - /* logical channel within time slice -> vector of channel indices (one entry per time slice) */ - {{"tracks", 0}, {0, 18, 36}}, - {{"tracks", 1}, {1, 19, 37}}, - {{"tracks", 2}, {2, 20, 38}}, - {{"tracks", 3}, {3, 21, 39}}, - {{"tracks", 4}, {4, 22, 40}}, - {{"tracks", 5}, {5, 23, 41}}, - {{"tracks", 6}, {6, 24, 42}}, - {{"tracks", 7}, {7, 25, 43}}, - {{"tracks", 8}, {8, 26, 44}}, - {{"tracks", 9}, {9, 27, 45}}, - {{"tracks", 10}, {10, 28, 46}}, - {{"tracks", 11}, {11, 29, 47}}, - {{"tracks", 12}, {12, 30, 48}}, - {{"tracks", 13}, {13, 31, 49}}, - {{"tracks", 14}, {14, 32, 50}}, - {{"tracks", 15}, {15, 33, 51}}, - {{"tracks", 16}, {16, 34, 52}}, - {{"tracks", 17}, {17, 35, 53}}}; - - const std::map kChannelSpecsInput = { - /* interface name -> {link TMUX, inter-packet gap} */ - {"tracks", {kTrackTMUX, kGapLengthInput}}}; - - const std::map>> - kChannelSpecsOutputToCorrelator = { - /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ - {{"vertices", 0}, {{kGTTBoardTMUX, kGapLengthOutputToCorrelator}, {0}}}}; - - const std::map> kChannelIdsOutputToGlobalTrigger = { - /* logical channel within time slice -> vector of channel indices (one entry per time slice) */ - {{"sums", 0}, {0}}, - {{"taus", 1}, {1}}, - {{"mesons", 2}, {2}}, - {{"vertices", 3}, {3}}}; - - const std::map kChannelSpecsOutputToGlobalTrigger = { - /* interface name -> {link TMUX, inter-packet gap} */ - {"sums", {kGTTBoardTMUX, kGapLengthOutputToGlobalTriggerSums}}, - {"taus", {kGTTBoardTMUX, kGapLengthOutputToGlobalTriggerTaus}}, - {"mesons", {kGTTBoardTMUX, kGapLengthOutputToGlobalTriggerMesons}}, - {"vertices", {kGTTBoardTMUX, kGapLengthOutputToGlobalTriggerVertices}}}; + // static constexpr size_t kFramesPerTMUXPeriod = 9; + // static constexpr size_t kGapLengthInput = 6; + // static constexpr size_t kGapLengthOutputToCorrelator = 44; + // static constexpr size_t kGapLengthOutputToGlobalTriggerSums = 3; + // static constexpr size_t kGapLengthOutputToGlobalTriggerTaus = 36; + // static constexpr size_t kGapLengthOutputToGlobalTriggerMesons = 15; + // static constexpr size_t kGapLengthOutputToGlobalTriggerVertices = 6; + // static constexpr size_t kTrackTMUX = 18; + // static constexpr size_t kGTTBoardTMUX = 6; + // static constexpr size_t kMaxLinesPerFile = 1024; + + // const std::map> kChannelIdsInput = { + // /* logical channel within time slice -> vector of channel indices (one entry per time slice) */ + // {{"tracks", 0}, {0, 18, 36}}, + // {{"tracks", 1}, {1, 19, 37}}, + // {{"tracks", 2}, {2, 20, 38}}, + // {{"tracks", 3}, {3, 21, 39}}, + // {{"tracks", 4}, {4, 22, 40}}, + // {{"tracks", 5}, {5, 23, 41}}, + // {{"tracks", 6}, {6, 24, 42}}, + // {{"tracks", 7}, {7, 25, 43}}, + // {{"tracks", 8}, {8, 26, 44}}, + // {{"tracks", 9}, {9, 27, 45}}, + // {{"tracks", 10}, {10, 28, 46}}, + // {{"tracks", 11}, {11, 29, 47}}, + // {{"tracks", 12}, {12, 30, 48}}, + // {{"tracks", 13}, {13, 31, 49}}, + // {{"tracks", 14}, {14, 32, 50}}, + // {{"tracks", 15}, {15, 33, 51}}, + // {{"tracks", 16}, {16, 34, 52}}, + // {{"tracks", 17}, {17, 35, 53}}}; + + // const std::map kChannelSpecsInput = { + // /* interface name -> {link TMUX, inter-packet gap} */ + // {"tracks", {kTrackTMUX, kGapLengthInput}}}; + + // const std::map>> + // kChannelSpecsOutputToCorrelator = { + // /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ + // {{"vertices", 0}, {{kGTTBoardTMUX, kGapLengthOutputToCorrelator}, {0}}}}; + + // const std::map> kChannelIdsOutputToGlobalTrigger = { + // /* logical channel within time slice -> vector of channel indices (one entry per time slice) */ + // {{"sums", 0}, {0}}, + // {{"taus", 1}, {1}}, + // {{"mesons", 2}, {2}}, + // {{"vertices", 3}, {3}}}; + + // const std::map kChannelSpecsOutputToGlobalTrigger = { + // /* interface name -> {link TMUX, inter-packet gap} */ + // {"sums", {kGTTBoardTMUX, kGapLengthOutputToGlobalTriggerSums}}, + // {"taus", {kGTTBoardTMUX, kGapLengthOutputToGlobalTriggerTaus}}, + // {"mesons", {kGTTBoardTMUX, kGapLengthOutputToGlobalTriggerMesons}}, + // {"vertices", {kGTTBoardTMUX, kGapLengthOutputToGlobalTriggerVertices}}}; typedef TTTrack Track_t; typedef std::vector TrackCollection_t; @@ -165,51 +166,51 @@ GTTFileWriter::GTTFileWriter(const edm::ParameterSet& iConfig) fileWriterInputTracks_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), iConfig.getUntrackedParameter("inputFilename"), iConfig.getUntrackedParameter("fileExtension"), - kFramesPerTMUXPeriod, - kGTTBoardTMUX, - kMaxLinesPerFile, - kChannelIdsInput, - kChannelSpecsInput), + l1t::demo::kFramesPerTMUXPeriod, + l1t::demo::kGTTBoardTMUX, + l1t::demo::kMaxLinesPerFile, + l1t::demo::kChannelIdsInput, + l1t::demo::kChannelSpecsInput), fileWriterConvertedTracks_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), iConfig.getUntrackedParameter("inputConvertedFilename"), iConfig.getUntrackedParameter("fileExtension"), - kFramesPerTMUXPeriod, - kGTTBoardTMUX, - kMaxLinesPerFile, - kChannelIdsInput, - kChannelSpecsInput), + l1t::demo::kFramesPerTMUXPeriod, + l1t::demo::kGTTBoardTMUX, + l1t::demo::kMaxLinesPerFile, + l1t::demo::kChannelIdsInput, + l1t::demo::kChannelSpecsInput), fileWriterSelectedTracks_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), iConfig.getUntrackedParameter("selectedTracksFilename"), iConfig.getUntrackedParameter("fileExtension"), - kFramesPerTMUXPeriod, - kGTTBoardTMUX, - kMaxLinesPerFile, - kChannelIdsInput, - kChannelSpecsInput), + l1t::demo::kFramesPerTMUXPeriod, + l1t::demo::kGTTBoardTMUX, + l1t::demo::kMaxLinesPerFile, + l1t::demo::kChannelIdsInput, + l1t::demo::kChannelSpecsInput), fileWriterVertexAssociatedTracks_( l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), iConfig.getUntrackedParameter("vertexAssociatedTracksFilename"), iConfig.getUntrackedParameter("fileExtension"), - kFramesPerTMUXPeriod, - kGTTBoardTMUX, - kMaxLinesPerFile, - kChannelIdsInput, - kChannelSpecsInput), + l1t::demo::kFramesPerTMUXPeriod, + l1t::demo::kGTTBoardTMUX, + l1t::demo::kMaxLinesPerFile, + l1t::demo::kChannelIdsInput, + l1t::demo::kChannelSpecsInput), fileWriterOutputToCorrelator_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), iConfig.getUntrackedParameter("outputCorrelatorFilename"), iConfig.getUntrackedParameter("fileExtension"), - kFramesPerTMUXPeriod, - kGTTBoardTMUX, - kMaxLinesPerFile, - kChannelSpecsOutputToCorrelator), + l1t::demo::kFramesPerTMUXPeriod, + l1t::demo::kGTTBoardTMUX, + l1t::demo::kMaxLinesPerFile, + l1t::demo::kChannelMapOutputToCorrelator), fileWriterOutputToGlobalTrigger_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), iConfig.getUntrackedParameter("outputGlobalTriggerFilename"), iConfig.getUntrackedParameter("fileExtension"), - kFramesPerTMUXPeriod, - kGTTBoardTMUX, - kMaxLinesPerFile, - kChannelIdsOutputToGlobalTrigger, - kChannelSpecsOutputToGlobalTrigger) {} + l1t::demo::kFramesPerTMUXPeriod, + l1t::demo::kGTTBoardTMUX, + l1t::demo::kMaxLinesPerFile, + l1t::demo::kChannelIdsOutputToGlobalTrigger, + l1t::demo::kChannelSpecsOutputToGlobalTrigger) {} void GTTFileWriter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { using namespace edm; From c2dcf411465031dc7a8b2ee22609231440fa0783 Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Thu, 2 Nov 2023 16:03:11 +0100 Subject: [PATCH 14/24] Add GTTInterface.h --- .../interface/GTTInterface.h | 167 ++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 L1Trigger/DemonstratorTools/interface/GTTInterface.h diff --git a/L1Trigger/DemonstratorTools/interface/GTTInterface.h b/L1Trigger/DemonstratorTools/interface/GTTInterface.h new file mode 100644 index 0000000000000..3f63afe184652 --- /dev/null +++ b/L1Trigger/DemonstratorTools/interface/GTTInterface.h @@ -0,0 +1,167 @@ +#ifndef L1Trigger_DemonstratorTools_GTTInterface_h +#define L1Trigger_DemonstratorTools_GTTInterface_h + +#include + +#include "L1Trigger/DemonstratorTools/interface/LinkId.h" +#include "L1Trigger/DemonstratorTools/interface/ChannelSpec.h" +#include "L1Trigger/DemonstratorTools/interface/EventData.h" +#include "L1Trigger/DemonstratorTools/interface/FileFormat.h" +#include "L1Trigger/DemonstratorTools/interface/Frame.h" + +namespace l1t::demo { + //Global Trigger Interface Doc - https://www.overleaf.com/read/qqfdtgcybhvh#746997 + //Link 1 of GTT payload to GT + /* size_t nJetToWords ( constexpr size_t n ) { if ( n % 2 == 0 ) return n * 3 / 2; else throw an exception} */ + /* size_t nSumToWords ( constexpr size_t n ) { return n; } */ + /* size_t nTauToWords ( constexpr size_t n ) { return n * 3 / 2; } */ + /* size_t nJetToWords ( constexpr size_t nJet ) { return nJet * 3 / 2; } */ + /* namespace gttToGT1 { */ + /* //12 prompt and 12 displaced jets with 2 64-bit words each */ + /* //1 Prompt HT Miss, 1 Displaced HT Miss, 1 ET Miss with 1 64-bit word each */ + /* static constexpr size_t nPromptJets = 12; */ + /* static constexpr size_t nDisplacedJets = 12; */ + /* static constexpr size_t nPromptHTMiss = 1; */ + /* static constexpr size_t nDisplacedHTMiss = 1; */ + /* static constexpr size_t nETMiss = 1; */ + /* static constexpr size_t kPromptJetStart = 0; */ + /* static constexpr size_t kPromptJetEnd = kPromptJetStart + nPromptJets - 1; */ + /* static constexpr size_t kDisplacedJetStart = kPromptJetEnd + 1; */ + /* static constexpr size_t kDisplacedJetEnd = kDisplacedJetStart + 24 - 1; */ + /* static constexpr size_t kPromptHTMissStart = kDisplacedJetEnd + 1; */ + /* static constexpr size_t kPromptHTMissEnd = kPromptHTMissStart + 1 - 1; */ + /* static constexpr size_t kDisplacedHTMissStart = kPromptHTMissEnd + 1; */ + /* static constexpr size_t kDisplacedHTMissEnd = kDisplacedHTMissStart + 1 - 1; */ + /* static constexpr size_t kETMissStart = kDisplacedHTMissEnd + 1; */ + /* static constexpr size_t kETMissEnd = kETMissStart + 1 - 1; */ + /* static constexpr size_t kEmptyStart = kETMissEnd + 1; */ + /* static constexpr size_t kEmptyEnd = 53; */ + /* } */ + /* namespace gttToGT2 { */ + /* //12 taus with 96-bit words, or 18 64-bit words */ + /* static constexpr size_t kHadronicTauStart = 0; */ + /* static constexpr size_t kHadronicTauEnd = kHadronicTauStart + 18 - 1; */ + /* static constexpr size_t kEmptyStart = kHadronicTauEnd + 1; */ + /* static constexpr size_t kEmptyEnd = 53; */ + /* } */ + /* namespace gttToGT3 { */ + /* //12 phi meson candidates and 12 rho meson candidates with 1.5 64-bit words each */ + /* //2 B_s candidates with 1 64-bit word each */ + /* static constexpr size_t kPhiMesonStart = 0; */ + /* static constexpr size_t kPhiMesonEnd = kPhiMesonStart + 18 - 1; */ + /* static constexpr size_t kRhoMesonStart = kPhiMesonEnd + 1; */ + /* static constexpr size_t kRhoMesonEnd = kRhoMesonStart + 18 - 1; */ + /* static constexpr size_t kBsStart = kRhoMesonEnd + 1; */ + /* static constexpr size_t kBsEnd = kBsStart + 2 - 1; */ + /* static constexpr size_t kEmptyStart = kRhoMesonEnd + 1; */ + /* static constexpr size_t kEmptyEnd = 53; */ + /* } */ + /* namespace gttToGT4 { */ + /* //12 prompt isolated tracks and 12 displaced isolated tracks with 1.5 64-bit words each */ + /* //10 prompt vertices and 2 displaced vertices with 1 64-bit word each */ + /* static constexpr size_t kPromptIsoTracksStart = 0; */ + /* static constexpr size_t kPromptIsoTracksEnd = kPromptIsoTracksStart + 18 - 1; */ + /* static constexpr size_t kDisplacedIsoTracksStart = kPromptIsoTracksEnd + 1; */ + /* static constexpr size_t kDisplacedIsoTracksEnd = kDisplacedIsoTracksStart + 18 - 1; */ + /* static constexpr size_t kPromptVerticesStart = kDisplacedIsoTracksEnd + 1; */ + /* static constexpr size_t kPromptVerticesEnd = kPromptVerticesStart + 10 - 1; */ + /* static constexpr size_t kDisplacedVerticesStart = kPromptVerticesEnd + 1; */ + /* static constexpr size_t kDisplacedVerticesEnd = kDisplacedVerticesStart + 2 - 1; */ + /* static constexpr size_t kEmptyStart = kDisplacedVerticesEnd + 1; */ + /* static constexpr size_t kEmptyEnd = 53; */ + /* } */ + + // map of logical channel ID -> [TMUX period, interpacket-gap & offset; channel indices] + typedef std::map>> ChannelMap_t; + + static constexpr size_t kFramesPerTMUXPeriod = 9; + static constexpr size_t kGapLengthInput = 6; //defined in terms of nTracks * (3/2) - 3 * 54? + static constexpr size_t kGapLengthOutputToCorrelator = 44; //can be defined in terms of 54 - nVertices? + static constexpr size_t kGapLengthOutputToGlobalTriggerSums = 3; + static constexpr size_t kGapLengthOutputToGlobalTriggerTaus = 36; + static constexpr size_t kGapLengthOutputToGlobalTriggerMesons = 15; + static constexpr size_t kGapLengthOutputToGlobalTriggerVertices = 6; + static constexpr size_t kTrackTMUX = 18; //TMUX of the TrackFindingProcessors + static constexpr size_t kGTTBoardTMUX = 6; //TMUX of the GTT in the current configuration: 6 boards running 3 events in parallel, with a paired board running parallel algorithms + static constexpr size_t kMaxLinesPerFile = 1024; + + static constexpr size_t kVertexChanIndex = 0; + + // TRACKS from TFP + static const std::map> kChannelIdsInput = { + /* logical channel within time slice -> vector of channel indices (one entry per time slice) */ + /* for first link in a time slice, the channel index is 1 for 1st time slice, channel 19 in the 2nd*/ + {{"tracks", 0}, {0, 18, 36}}, + {{"tracks", 1}, {1, 19, 37}}, + {{"tracks", 2}, {2, 20, 38}}, + {{"tracks", 3}, {3, 21, 39}}, + {{"tracks", 4}, {4, 22, 40}}, + {{"tracks", 5}, {5, 23, 41}}, + {{"tracks", 6}, {6, 24, 42}}, + {{"tracks", 7}, {7, 25, 43}}, + {{"tracks", 8}, {8, 26, 44}}, + {{"tracks", 9}, {9, 27, 45}}, + {{"tracks", 10}, {10, 28, 46}}, + {{"tracks", 11}, {11, 29, 47}}, + {{"tracks", 12}, {12, 30, 48}}, + {{"tracks", 13}, {13, 31, 49}}, + {{"tracks", 14}, {14, 32, 50}}, + {{"tracks", 15}, {15, 33, 51}}, + {{"tracks", 16}, {16, 34, 52}}, + {{"tracks", 17}, {17, 35, 53}}}; + + static const ChannelMap_t kChannelMapInput = { + /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ + {{"tracks", 0}, {{kTrackTMUX, kGapLengthInput}, {0, 18, 36}}}, + {{"tracks", 1}, {{kTrackTMUX, kGapLengthInput}, {1, 19, 37}}}, + {{"tracks", 2}, {{kTrackTMUX, kGapLengthInput}, {2, 20, 38}}}, + {{"tracks", 3}, {{kTrackTMUX, kGapLengthInput}, {3, 21, 39}}}, + {{"tracks", 4}, {{kTrackTMUX, kGapLengthInput}, {4, 22, 40}}}, + {{"tracks", 5}, {{kTrackTMUX, kGapLengthInput}, {5, 23, 41}}}, + {{"tracks", 6}, {{kTrackTMUX, kGapLengthInput}, {6, 24, 42}}}, + {{"tracks", 7}, {{kTrackTMUX, kGapLengthInput}, {7, 25, 43}}}, + {{"tracks", 8}, {{kTrackTMUX, kGapLengthInput}, {8, 26, 44}}}, + {{"tracks", 9}, {{kTrackTMUX, kGapLengthInput}, {9, 27, 45}}}, + {{"tracks", 10}, {{kTrackTMUX, kGapLengthInput}, {10, 28, 46}}}, + {{"tracks", 11}, {{kTrackTMUX, kGapLengthInput}, {11, 29, 47}}}, + {{"tracks", 12}, {{kTrackTMUX, kGapLengthInput}, {12, 30, 48}}}, + {{"tracks", 13}, {{kTrackTMUX, kGapLengthInput}, {13, 31, 49}}}, + {{"tracks", 14}, {{kTrackTMUX, kGapLengthInput}, {14, 32, 50}}}, + {{"tracks", 15}, {{kTrackTMUX, kGapLengthInput}, {15, 33, 51}}}, + {{"tracks", 16}, {{kTrackTMUX, kGapLengthInput}, {16, 34, 52}}}, + {{"tracks", 17}, {{kTrackTMUX, kGapLengthInput}, {17, 35, 53}}}}; + + static const std::map kChannelSpecsInput = { + /* interface name -> {link TMUX, inter-packet gap} */ + {"tracks", {kTrackTMUX, kGapLengthInput}}}; + + //OUTPUTS to Correlator + //This is actually a ChannelMap_t... we only need the actual map below + /* static const std::map>> */ + /* kChannelSpecsOutputToCorrelator = { */ + /* static const ChannelMap_t kChannelSpecsOutputToCorrelator = { */ + /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ + /* {{"vertices", 0}, {{kGTTBoardTMUX, kGapLengthOutputToCorrelator}, {0}}}}; */ + + static const ChannelMap_t kChannelMapOutputToCorrelator = { + /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ + {{"vertices", 0}, {{kGTTBoardTMUX, kGapLengthOutputToCorrelator}, {0}}}}; + + //OUTPUTS to Global Trigger + static const std::map> kChannelIdsOutputToGlobalTrigger = { + /* logical channel within time slice -> vector of channel indices (one entry per time slice) */ + {{"sums", 0}, {0}}, + {{"taus", 1}, {1}}, + {{"mesons", 2}, {2}}, + {{"vertices", 3}, {3}}}; + + static const std::map kChannelSpecsOutputToGlobalTrigger = { + /* interface name -> {link TMUX, inter-packet gap} */ + {"sums", {kGTTBoardTMUX, kGapLengthOutputToGlobalTriggerSums}}, + {"taus", {kGTTBoardTMUX, kGapLengthOutputToGlobalTriggerTaus}}, + {"mesons", {kGTTBoardTMUX, kGapLengthOutputToGlobalTriggerMesons}}, + {"vertices", {kGTTBoardTMUX, kGapLengthOutputToGlobalTriggerVertices}}}; + +} // namespace l1t::demo + +#endif From 296a94f00e2355f1e0bede5061e97d9a30c3eb24 Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Thu, 2 Nov 2023 21:00:25 +0100 Subject: [PATCH 15/24] Add default constructor for BoardDataReader --- L1Trigger/DemonstratorTools/interface/BoardDataReader.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/L1Trigger/DemonstratorTools/interface/BoardDataReader.h b/L1Trigger/DemonstratorTools/interface/BoardDataReader.h index da180b9bbe9db..3973983eda1fa 100644 --- a/L1Trigger/DemonstratorTools/interface/BoardDataReader.h +++ b/L1Trigger/DemonstratorTools/interface/BoardDataReader.h @@ -38,6 +38,8 @@ namespace l1t::demo { const std::map>&, const std::map&); + BoardDataReader() = default; + EventData getNextEvent(); private: @@ -64,4 +66,4 @@ namespace l1t::demo { } // namespace l1t::demo -#endif \ No newline at end of file +#endif From ffb9fc942aabc685a5d45a018681a8f30866f574 Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Thu, 2 Nov 2023 21:03:15 +0100 Subject: [PATCH 16/24] Remove prototype constants, apply code-format, remove unused code --- .../interface/GTTInterface.h | 85 ++----------------- 1 file changed, 9 insertions(+), 76 deletions(-) diff --git a/L1Trigger/DemonstratorTools/interface/GTTInterface.h b/L1Trigger/DemonstratorTools/interface/GTTInterface.h index 3f63afe184652..7b831e521a9d0 100644 --- a/L1Trigger/DemonstratorTools/interface/GTTInterface.h +++ b/L1Trigger/DemonstratorTools/interface/GTTInterface.h @@ -10,83 +10,23 @@ #include "L1Trigger/DemonstratorTools/interface/Frame.h" namespace l1t::demo { - //Global Trigger Interface Doc - https://www.overleaf.com/read/qqfdtgcybhvh#746997 - //Link 1 of GTT payload to GT - /* size_t nJetToWords ( constexpr size_t n ) { if ( n % 2 == 0 ) return n * 3 / 2; else throw an exception} */ - /* size_t nSumToWords ( constexpr size_t n ) { return n; } */ - /* size_t nTauToWords ( constexpr size_t n ) { return n * 3 / 2; } */ - /* size_t nJetToWords ( constexpr size_t nJet ) { return nJet * 3 / 2; } */ - /* namespace gttToGT1 { */ - /* //12 prompt and 12 displaced jets with 2 64-bit words each */ - /* //1 Prompt HT Miss, 1 Displaced HT Miss, 1 ET Miss with 1 64-bit word each */ - /* static constexpr size_t nPromptJets = 12; */ - /* static constexpr size_t nDisplacedJets = 12; */ - /* static constexpr size_t nPromptHTMiss = 1; */ - /* static constexpr size_t nDisplacedHTMiss = 1; */ - /* static constexpr size_t nETMiss = 1; */ - /* static constexpr size_t kPromptJetStart = 0; */ - /* static constexpr size_t kPromptJetEnd = kPromptJetStart + nPromptJets - 1; */ - /* static constexpr size_t kDisplacedJetStart = kPromptJetEnd + 1; */ - /* static constexpr size_t kDisplacedJetEnd = kDisplacedJetStart + 24 - 1; */ - /* static constexpr size_t kPromptHTMissStart = kDisplacedJetEnd + 1; */ - /* static constexpr size_t kPromptHTMissEnd = kPromptHTMissStart + 1 - 1; */ - /* static constexpr size_t kDisplacedHTMissStart = kPromptHTMissEnd + 1; */ - /* static constexpr size_t kDisplacedHTMissEnd = kDisplacedHTMissStart + 1 - 1; */ - /* static constexpr size_t kETMissStart = kDisplacedHTMissEnd + 1; */ - /* static constexpr size_t kETMissEnd = kETMissStart + 1 - 1; */ - /* static constexpr size_t kEmptyStart = kETMissEnd + 1; */ - /* static constexpr size_t kEmptyEnd = 53; */ - /* } */ - /* namespace gttToGT2 { */ - /* //12 taus with 96-bit words, or 18 64-bit words */ - /* static constexpr size_t kHadronicTauStart = 0; */ - /* static constexpr size_t kHadronicTauEnd = kHadronicTauStart + 18 - 1; */ - /* static constexpr size_t kEmptyStart = kHadronicTauEnd + 1; */ - /* static constexpr size_t kEmptyEnd = 53; */ - /* } */ - /* namespace gttToGT3 { */ - /* //12 phi meson candidates and 12 rho meson candidates with 1.5 64-bit words each */ - /* //2 B_s candidates with 1 64-bit word each */ - /* static constexpr size_t kPhiMesonStart = 0; */ - /* static constexpr size_t kPhiMesonEnd = kPhiMesonStart + 18 - 1; */ - /* static constexpr size_t kRhoMesonStart = kPhiMesonEnd + 1; */ - /* static constexpr size_t kRhoMesonEnd = kRhoMesonStart + 18 - 1; */ - /* static constexpr size_t kBsStart = kRhoMesonEnd + 1; */ - /* static constexpr size_t kBsEnd = kBsStart + 2 - 1; */ - /* static constexpr size_t kEmptyStart = kRhoMesonEnd + 1; */ - /* static constexpr size_t kEmptyEnd = 53; */ - /* } */ - /* namespace gttToGT4 { */ - /* //12 prompt isolated tracks and 12 displaced isolated tracks with 1.5 64-bit words each */ - /* //10 prompt vertices and 2 displaced vertices with 1 64-bit word each */ - /* static constexpr size_t kPromptIsoTracksStart = 0; */ - /* static constexpr size_t kPromptIsoTracksEnd = kPromptIsoTracksStart + 18 - 1; */ - /* static constexpr size_t kDisplacedIsoTracksStart = kPromptIsoTracksEnd + 1; */ - /* static constexpr size_t kDisplacedIsoTracksEnd = kDisplacedIsoTracksStart + 18 - 1; */ - /* static constexpr size_t kPromptVerticesStart = kDisplacedIsoTracksEnd + 1; */ - /* static constexpr size_t kPromptVerticesEnd = kPromptVerticesStart + 10 - 1; */ - /* static constexpr size_t kDisplacedVerticesStart = kPromptVerticesEnd + 1; */ - /* static constexpr size_t kDisplacedVerticesEnd = kDisplacedVerticesStart + 2 - 1; */ - /* static constexpr size_t kEmptyStart = kDisplacedVerticesEnd + 1; */ - /* static constexpr size_t kEmptyEnd = 53; */ - /* } */ - // map of logical channel ID -> [TMUX period, interpacket-gap & offset; channel indices] typedef std::map>> ChannelMap_t; - + static constexpr size_t kFramesPerTMUXPeriod = 9; - static constexpr size_t kGapLengthInput = 6; //defined in terms of nTracks * (3/2) - 3 * 54? - static constexpr size_t kGapLengthOutputToCorrelator = 44; //can be defined in terms of 54 - nVertices? + static constexpr size_t kGapLengthInput = 6; //defined in terms of nTracks * (3/2) - 3 * 54? + static constexpr size_t kGapLengthOutputToCorrelator = 44; //can be defined in terms of 54 - nVertices? static constexpr size_t kGapLengthOutputToGlobalTriggerSums = 3; static constexpr size_t kGapLengthOutputToGlobalTriggerTaus = 36; static constexpr size_t kGapLengthOutputToGlobalTriggerMesons = 15; static constexpr size_t kGapLengthOutputToGlobalTriggerVertices = 6; - static constexpr size_t kTrackTMUX = 18; //TMUX of the TrackFindingProcessors - static constexpr size_t kGTTBoardTMUX = 6; //TMUX of the GTT in the current configuration: 6 boards running 3 events in parallel, with a paired board running parallel algorithms + static constexpr size_t kTrackTMUX = 18; //TMUX of the TrackFindingProcessors + static constexpr size_t kGTTBoardTMUX = + 6; //TMUX of the GTT in the current configuration: 6 boards running 3 events in parallel, with a paired board running parallel algorithms static constexpr size_t kMaxLinesPerFile = 1024; static constexpr size_t kVertexChanIndex = 0; - + // TRACKS from TFP static const std::map> kChannelIdsInput = { /* logical channel within time slice -> vector of channel indices (one entry per time slice) */ @@ -109,7 +49,7 @@ namespace l1t::demo { {{"tracks", 15}, {15, 33, 51}}, {{"tracks", 16}, {16, 34, 52}}, {{"tracks", 17}, {17, 35, 53}}}; - + static const ChannelMap_t kChannelMapInput = { /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ {{"tracks", 0}, {{kTrackTMUX, kGapLengthInput}, {0, 18, 36}}}, @@ -136,16 +76,9 @@ namespace l1t::demo { {"tracks", {kTrackTMUX, kGapLengthInput}}}; //OUTPUTS to Correlator - //This is actually a ChannelMap_t... we only need the actual map below - /* static const std::map>> */ - /* kChannelSpecsOutputToCorrelator = { */ - /* static const ChannelMap_t kChannelSpecsOutputToCorrelator = { */ - /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ - /* {{"vertices", 0}, {{kGTTBoardTMUX, kGapLengthOutputToCorrelator}, {0}}}}; */ - static const ChannelMap_t kChannelMapOutputToCorrelator = { /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ - {{"vertices", 0}, {{kGTTBoardTMUX, kGapLengthOutputToCorrelator}, {0}}}}; + {{"vertices", 0}, {{kGTTBoardTMUX, kGapLengthOutputToCorrelator}, {0}}}}; //OUTPUTS to Global Trigger static const std::map> kChannelIdsOutputToGlobalTrigger = { From 9884b0d76c281c299a7048130ad63610584d3613 Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Thu, 2 Nov 2023 21:03:45 +0100 Subject: [PATCH 17/24] Remove unused GTTFileWriter, now in GTTInterface.h --- .../plugins/GTTFileWriter.cc | 55 ------------------- 1 file changed, 55 deletions(-) diff --git a/L1Trigger/DemonstratorTools/plugins/GTTFileWriter.cc b/L1Trigger/DemonstratorTools/plugins/GTTFileWriter.cc index ca22ae3381bf2..69cf731a0e5ea 100644 --- a/L1Trigger/DemonstratorTools/plugins/GTTFileWriter.cc +++ b/L1Trigger/DemonstratorTools/plugins/GTTFileWriter.cc @@ -62,61 +62,6 @@ class GTTFileWriter : public edm::one::EDAnalyzer { private: // ----------constants, enums and typedefs --------- - // NOTE: At least some of the info from these constants will eventually come from config files - // static constexpr size_t kFramesPerTMUXPeriod = 9; - // static constexpr size_t kGapLengthInput = 6; - // static constexpr size_t kGapLengthOutputToCorrelator = 44; - // static constexpr size_t kGapLengthOutputToGlobalTriggerSums = 3; - // static constexpr size_t kGapLengthOutputToGlobalTriggerTaus = 36; - // static constexpr size_t kGapLengthOutputToGlobalTriggerMesons = 15; - // static constexpr size_t kGapLengthOutputToGlobalTriggerVertices = 6; - // static constexpr size_t kTrackTMUX = 18; - // static constexpr size_t kGTTBoardTMUX = 6; - // static constexpr size_t kMaxLinesPerFile = 1024; - - // const std::map> kChannelIdsInput = { - // /* logical channel within time slice -> vector of channel indices (one entry per time slice) */ - // {{"tracks", 0}, {0, 18, 36}}, - // {{"tracks", 1}, {1, 19, 37}}, - // {{"tracks", 2}, {2, 20, 38}}, - // {{"tracks", 3}, {3, 21, 39}}, - // {{"tracks", 4}, {4, 22, 40}}, - // {{"tracks", 5}, {5, 23, 41}}, - // {{"tracks", 6}, {6, 24, 42}}, - // {{"tracks", 7}, {7, 25, 43}}, - // {{"tracks", 8}, {8, 26, 44}}, - // {{"tracks", 9}, {9, 27, 45}}, - // {{"tracks", 10}, {10, 28, 46}}, - // {{"tracks", 11}, {11, 29, 47}}, - // {{"tracks", 12}, {12, 30, 48}}, - // {{"tracks", 13}, {13, 31, 49}}, - // {{"tracks", 14}, {14, 32, 50}}, - // {{"tracks", 15}, {15, 33, 51}}, - // {{"tracks", 16}, {16, 34, 52}}, - // {{"tracks", 17}, {17, 35, 53}}}; - - // const std::map kChannelSpecsInput = { - // /* interface name -> {link TMUX, inter-packet gap} */ - // {"tracks", {kTrackTMUX, kGapLengthInput}}}; - - // const std::map>> - // kChannelSpecsOutputToCorrelator = { - // /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ - // {{"vertices", 0}, {{kGTTBoardTMUX, kGapLengthOutputToCorrelator}, {0}}}}; - - // const std::map> kChannelIdsOutputToGlobalTrigger = { - // /* logical channel within time slice -> vector of channel indices (one entry per time slice) */ - // {{"sums", 0}, {0}}, - // {{"taus", 1}, {1}}, - // {{"mesons", 2}, {2}}, - // {{"vertices", 3}, {3}}}; - - // const std::map kChannelSpecsOutputToGlobalTrigger = { - // /* interface name -> {link TMUX, inter-packet gap} */ - // {"sums", {kGTTBoardTMUX, kGapLengthOutputToGlobalTriggerSums}}, - // {"taus", {kGTTBoardTMUX, kGapLengthOutputToGlobalTriggerTaus}}, - // {"mesons", {kGTTBoardTMUX, kGapLengthOutputToGlobalTriggerMesons}}, - // {"vertices", {kGTTBoardTMUX, kGapLengthOutputToGlobalTriggerVertices}}}; typedef TTTrack Track_t; typedef std::vector TrackCollection_t; From 7ba3ee585b757c0ab842156301df4765a00c8b93 Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Thu, 2 Nov 2023 21:04:57 +0100 Subject: [PATCH 18/24] Remove unused GTTFileReader constants, now in GTTInterface.h, add optional input capability and new parameters to support it. --- .../plugins/GTTFileReader.cc | 195 +++++++++--------- 1 file changed, 102 insertions(+), 93 deletions(-) diff --git a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc index 64cf0f62da4ba..f3e6db15b8ef3 100644 --- a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc +++ b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc @@ -50,43 +50,6 @@ class GTTFileReader : public edm::stream::EDProducer<> { private: // ----------constants, enums and typedefs --------- - // NOTE: At least some of the info from these constants will eventually come from config files - // static constexpr size_t kFramesPerTMUXPeriod = 9; - // static constexpr size_t kGapLength = 44; - // static constexpr size_t kGapLengthInput = 6; - // static constexpr size_t kVertexTMUX = 6; - // static constexpr size_t kGTTBoardTMUX = 6; - // static constexpr size_t kTrackTMUX = 18; - // static constexpr size_t kVertexChanIndex = 0; - static constexpr size_t kEmptyFramesOutputToCorrelator = 0; // 10 does not match current file writing configuration - static constexpr size_t kEmptyFramesInput = 0; - static constexpr size_t kEmptyFramesOutputToGlobalTrigger = 0; - - // const l1t::demo::BoardDataReader::ChannelMap_t kChannelSpecs = { - // /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ - // {{"vertices", 0}, {{kGTTBoardTMUX, kGapLengthOutputToCorrelator}, {kVertexChanIndex}}}}; - - // const l1t::demo::BoardDataReader::ChannelMap_t kChannelSpecsInput = { - // /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ - // {{"tracks", 0}, {{kTrackTMUX, kGapLengthInput}, {0, 18, 36}}}, - // {{"tracks", 1}, {{kTrackTMUX, kGapLengthInput}, {1, 19, 37}}}, - // {{"tracks", 2}, {{kTrackTMUX, kGapLengthInput}, {2, 20, 38}}}, - // {{"tracks", 3}, {{kTrackTMUX, kGapLengthInput}, {3, 21, 39}}}, - // {{"tracks", 4}, {{kTrackTMUX, kGapLengthInput}, {4, 22, 40}}}, - // {{"tracks", 5}, {{kTrackTMUX, kGapLengthInput}, {5, 23, 41}}}, - // {{"tracks", 6}, {{kTrackTMUX, kGapLengthInput}, {6, 24, 42}}}, - // {{"tracks", 7}, {{kTrackTMUX, kGapLengthInput}, {7, 25, 43}}}, - // {{"tracks", 8}, {{kTrackTMUX, kGapLengthInput}, {8, 26, 44}}}, - // {{"tracks", 9}, {{kTrackTMUX, kGapLengthInput}, {9, 27, 45}}}, - // {{"tracks", 10}, {{kTrackTMUX, kGapLengthInput}, {10, 28, 46}}}, - // {{"tracks", 11}, {{kTrackTMUX, kGapLengthInput}, {11, 29, 47}}}, - // {{"tracks", 12}, {{kTrackTMUX, kGapLengthInput}, {12, 30, 48}}}, - // {{"tracks", 13}, {{kTrackTMUX, kGapLengthInput}, {13, 31, 49}}}, - // {{"tracks", 14}, {{kTrackTMUX, kGapLengthInput}, {14, 32, 50}}}, - // {{"tracks", 15}, {{kTrackTMUX, kGapLengthInput}, {15, 33, 51}}}, - // {{"tracks", 16}, {{kTrackTMUX, kGapLengthInput}, {16, 34, 52}}}, - // {{"tracks", 17}, {{kTrackTMUX, kGapLengthInput}, {17, 35, 53}}}}; - typedef TTTrack L1Track; typedef std::vector TTTrackCollection; @@ -94,92 +57,138 @@ class GTTFileReader : public edm::stream::EDProducer<> { void produce(edm::Event&, const edm::EventSetup&) override; // ----------member data --------------------------- + const bool processOutputToCorrelator_; + const bool processInputTracks_; + const bool processOutputToGlobalTrigger_; + const size_t kEmptyFramesOutputToCorrelator_; + const size_t kEmptyFramesInputTracks_; + const size_t kEmptyFramesOutputToGlobalTrigger_; l1t::demo::BoardDataReader fileReaderOutputToCorrelator_; std::string l1VertexCollectionName_; l1t::demo::BoardDataReader fileReaderInputTracks_; std::string l1TrackCollectionName_; + l1t::demo::BoardDataReader fileReaderOutputToGlobalTrigger_; }; -// -// class implementation -// - GTTFileReader::GTTFileReader(const edm::ParameterSet& iConfig) - : fileReaderOutputToCorrelator_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), - iConfig.getParameter>("files"), - l1t::demo::kFramesPerTMUXPeriod, - l1t::demo::kGTTBoardTMUX, - kEmptyFramesOutputToCorrelator, - l1t::demo::kChannelMapOutputToCorrelator), + : processOutputToCorrelator_(iConfig.getParameter("processOutputToCorrelator")), + processInputTracks_(iConfig.getParameter("processInputTracks")), + processOutputToGlobalTrigger_(iConfig.getParameter("processOutputToGlobalTrigger")), + kEmptyFramesOutputToCorrelator_(iConfig.getUntrackedParameter("kEmptyFramesOutputToCorrelator")), + kEmptyFramesInputTracks_(iConfig.getUntrackedParameter("kEmptyFramesInputTracks")), + kEmptyFramesOutputToGlobalTrigger_( + iConfig.getUntrackedParameter("kEmptyFramesOutputToGlobalTrigger")), l1VertexCollectionName_(iConfig.getParameter("l1VertexCollectionName")), - fileReaderInputTracks_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), - iConfig.getParameter>("filesInputTracks"), - l1t::demo::kFramesPerTMUXPeriod, - l1t::demo::kGTTBoardTMUX, - kEmptyFramesInput, - l1t::demo::kChannelMapInput), l1TrackCollectionName_(iConfig.getParameter("l1TrackCollectionName")) { - produces(l1VertexCollectionName_); - produces(l1TrackCollectionName_); + if (processOutputToCorrelator_) { + fileReaderOutputToCorrelator_ = + l1t::demo::BoardDataReader(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), + iConfig.getParameter>("filesOutputToCorrelator"), + l1t::demo::kFramesPerTMUXPeriod, + l1t::demo::kGTTBoardTMUX, + kEmptyFramesOutputToCorrelator_, + l1t::demo::kChannelMapOutputToCorrelator); + produces(l1VertexCollectionName_); + } + if (processInputTracks_) { + fileReaderInputTracks_ = + l1t::demo::BoardDataReader(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), + iConfig.getParameter>("filesInputTracks"), + l1t::demo::kFramesPerTMUXPeriod, + l1t::demo::kGTTBoardTMUX, + kEmptyFramesInputTracks_, + l1t::demo::kChannelMapInput); + produces(l1TrackCollectionName_); + } + if (processOutputToGlobalTrigger_) { + // fileReaderOutputToGlobalTrigger_ = + // l1t::demo::BoardDataReader(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), + // iConfig.getParameter>("filesOutputToGlobalTrigger"), + // l1t::demo::kFramesPerTMUXPeriod, + // l1t::demo::kGTTBoardTMUX, + // kEmptyFramesOutputToGlobalTrigger_, + // l1t::demo::kChannelMapInput); + throw std::invalid_argument("Processing OutputToGlobalTrigger files has not been fully implemented and validated."); + // need to produce output collections for Prompt and Displaced Jets, HTMiss, ETMiss, Taus, Mesons, Vertices, and Isolated Tracks + } } // ------------ method called to produce the data ------------ void GTTFileReader::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { using namespace edm; using namespace l1t::demo::codecs; + if ( processOutputToCorrelator_ ) { + l1t::demo::EventData correlatorEventData(fileReaderOutputToCorrelator_.getNextEvent()); + l1t::VertexWordCollection vertices(decodeVertices(correlatorEventData.at({"vertices", 0}))); + edm::LogInfo("GTTFileReader") << vertices.size() << " vertices found"; + + iEvent.put(std::make_unique(vertices), l1VertexCollectionName_); + } // end if ( processOutputToCorrelator_ ) + + if ( processInputTracks_ ) { + l1t::demo::EventData inputEventData(fileReaderInputTracks_.getNextEvent()); + auto inputTracks = std::make_unique(); + for (size_t i = 0; i < 18; i++) { + auto iTracks = decodeTracks(inputEventData.at({"tracks", i})); + for (auto& trackword : iTracks) { + if (!trackword.getValidWord()) + continue; + L1Track track = L1Track(trackword.getValidWord(), + trackword.getRinvWord(), + trackword.getPhiWord(), + trackword.getTanlWord(), + trackword.getZ0Word(), + trackword.getD0Word(), + trackword.getChi2RPhiWord(), + trackword.getChi2RZWord(), + trackword.getBendChi2Word(), + trackword.getHitPatternWord(), + trackword.getMVAQualityWord(), + trackword.getMVAOtherWord()); + //retrieve the eta (first) and phi (second) sectors for GTT, encoded in an std::pair + auto sectors = (l1t::demo::codecs::sectorsEtaPhiFromGTTLinkID(i)); + track.setEtaSector(sectors.first); + track.setPhiSector(sectors.second); + track.trackWord_ = trackword.trackWord_; + inputTracks->push_back(track); + } //end loop over trackwoards + } // end loop over GTT input links + iEvent.put(std::move(inputTracks), l1TrackCollectionName_); + } // end if ( processInputTracks_ ) - l1t::demo::EventData correlatorEventData(fileReaderOutputToCorrelator_.getNextEvent()); - l1t::demo::EventData inputEventData(fileReaderInputTracks_.getNextEvent()); - - l1t::VertexWordCollection vertices(decodeVertices(correlatorEventData.at({"vertices", 0}))); - auto inputTracks = std::make_unique(); - for (size_t i = 0; i < 18; i++) { - auto iTracks = decodeTracks(inputEventData.at({"tracks", i})); - for (auto& trackword : iTracks) { - if (!trackword.getValidWord()) - continue; - L1Track track = L1Track(trackword.getValidWord(), - trackword.getRinvWord(), - trackword.getPhiWord(), - trackword.getTanlWord(), - trackword.getZ0Word(), - trackword.getD0Word(), - trackword.getChi2RPhiWord(), - trackword.getChi2RZWord(), - trackword.getBendChi2Word(), - trackword.getHitPatternWord(), - trackword.getMVAQualityWord(), - trackword.getMVAOtherWord()); - //retrieve the eta (first) and phi (second) sectors for GTT, encoded in an std::pair - auto sectors = (l1t::demo::codecs::sectorsEtaPhiFromGTTLinkID(i)); - track.setEtaSector(sectors.first); - track.setPhiSector(sectors.second); - track.trackWord_ = trackword.trackWord_; - inputTracks->push_back(track); - } - } - - edm::LogInfo("GTTFileReader") << vertices.size() << " vertices found"; - - iEvent.put(std::make_unique(vertices), l1VertexCollectionName_); - iEvent.put(std::move(inputTracks), l1TrackCollectionName_); } // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void GTTFileReader::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { // GTTFileReader edm::ParameterSetDescription desc; - desc.add>("files", + desc.add("processOutputToCorrelator") + ->setComment("boolean flag to load Correlator outputs via BoardDataReader and produce vertex collection"); + desc.add("processInputTracks") + ->setComment("boolean flag to load track inputs via BoardDataReader and produce a TTTrack collection"); + desc.add("processOutputToGlobalTrigger") + ->setComment( + "boolean flag to load Global Trigger outputs via BoardDataReader and produce Track Object collections"); + desc.addUntracked("kEmptyFramesOutputToCorrelator", 0) + ->setComment("empty frames to expect in OutputToCorrelator"); + desc.addUntracked("kEmptyFramesInputTracks", 0)->setComment("empty frames to expect in Track Input"); + desc.addUntracked("kEmptyFramesOutputToGlobalTrigger", 0) + ->setComment("empty frames to expect in OutputToGlobalTrigger"); + desc.add>("filesOutputToCorrelator", { "L1GTTOutputToCorrelator_0.txt", }); - desc.add("l1VertexCollectionName", "L1VerticesFirmware"); desc.add>("filesInputTracks", { "L1GTTInputFile_0.txt", }); - desc.add("l1TrackCollectionName", "Level1TTTracks"); + desc.add>("filesOutputToGlobalTrigger", + { + "L1GTTOutputToGlobalTriggerFile_0.txt", + }); desc.addUntracked("format", "APx"); + desc.add("l1VertexCollectionName", "L1VerticesFirmware"); + desc.add("l1TrackCollectionName", "Level1TTTracks"); descriptions.add("GTTFileReader", desc); } From 1931f4fae6edd68ea271ea2870404f48c1c2c3a9 Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Thu, 2 Nov 2023 21:08:17 +0100 Subject: [PATCH 19/24] Add optional input capability parameters for the GTTFileReader into the cfi file. --- .../DemonstratorTools/python/l1tGTTFileReader_cfi.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/L1Trigger/DemonstratorTools/python/l1tGTTFileReader_cfi.py b/L1Trigger/DemonstratorTools/python/l1tGTTFileReader_cfi.py index 7a8cf25d21901..8ad98ebe93d91 100644 --- a/L1Trigger/DemonstratorTools/python/l1tGTTFileReader_cfi.py +++ b/L1Trigger/DemonstratorTools/python/l1tGTTFileReader_cfi.py @@ -1,8 +1,15 @@ import FWCore.ParameterSet.Config as cms l1tGTTFileReader = cms.EDProducer('GTTFileReader', - files = cms.vstring("L1GTTOutputToCorrelatorFile_0.txt"), + processOutputToCorrelator = cms.bool(True), + processInputTracks = cms.bool(False), + processOutputToGlobalTrigger = cms.bool(False), #Not fully implemented yet, partial skeleton added + kEmptyFramesOutputToCorrelator = cms.untracked.uint32(0), + kEmptyFramesInputTracks = cms.untracked.uint32(0), + kEmptyFramesOutputToGlobalTrigger = cms.untracked.uint32(0), + filesOutputToCorrelator = cms.vstring("L1GTTOutputToCorrelatorFile_0.txt"), filesInputTracks = cms.vstring("L1GTTInputFile_0.txt"), + filesOutputToGlobalTrigger = cms.vstring("L1GTTOutputToGlobalTriggerFile_0.txt"), l1VertexCollectionName = cms.string("L1VerticesFirmware"), l1TrackCollectionName = cms.string("Level1TTTracks"), format = cms.untracked.string("APx") From 2a336c99e02cea1f32c2d72eb8a92b782f28dd1e Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Fri, 1 Dec 2023 07:55:25 +0100 Subject: [PATCH 20/24] Add GTTFileReader loading and overwriting for tracks and vertices as options to createFirmwareInputFiles_cfg.py --- .../test/gtt/createFirmwareInputFiles_cfg.py | 54 +++++++++++++++++-- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/L1Trigger/DemonstratorTools/test/gtt/createFirmwareInputFiles_cfg.py b/L1Trigger/DemonstratorTools/test/gtt/createFirmwareInputFiles_cfg.py index 4be6147bf4df0..cb51e15320174 100644 --- a/L1Trigger/DemonstratorTools/test/gtt/createFirmwareInputFiles_cfg.py +++ b/L1Trigger/DemonstratorTools/test/gtt/createFirmwareInputFiles_cfg.py @@ -25,9 +25,26 @@ VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.int, "Number of streams to run") +options.register ('tracks', + 'donotload', # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, + "Whether to load tracks from buffers and how to treat them in the processing chain ('donotload', 'load', 'overwrite')") +options.register ('vertices', + 'donotload', # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, + "Whether to load vertices from buffers and how to treat them in the processing chain ('donotload', 'load', 'overwrite')") +options.register ('readerformat', + 'EMPv2', # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, + "File format of loaded tracks and vertices (APx, EMPv2)") options.parseArguments() inputFiles = [] +inputBuffers = [] +inputTrackBuffers = [] for filePath in options.inputFiles: if filePath.endswith(".root"): inputFiles.append(filePath) @@ -36,11 +53,18 @@ filePath = filePath.replace("/", ".") inputFilesImport = getattr(__import__(filePath.strip(".py"),fromlist=["readFiles"]),"readFiles") inputFiles.extend( inputFilesImport ) + if options.vertices: + inputBuffersImport = getattr(__import__(filePath.strip(".py"),fromlist=["correlator_source"]),"correlator_source").fileNames + inputBuffers.extend( inputBuffersImport ) + if options.tracks: + inputTrackBuffersImport = getattr(__import__(filePath.strip(".py"),fromlist=["track_source"]),"track_source").fileNames + inputTrackBuffers.extend( inputTrackBuffersImport ) else: inputFiles += FileUtils.loadListFromFile(filePath) # PART 2: SETUP MAIN CMSSW PROCESS + process = cms.Process("GTTFileWriter") process.load('Configuration.Geometry.GeometryExtended2026D88Reco_cff') @@ -69,8 +93,20 @@ process.load('L1Trigger.L1TTrackMatch.l1tTrackerEmuHTMiss_cfi') process.load('L1Trigger.L1TTrackMatch.l1tTrackerEmuEtMiss_cfi') process.load('L1Trigger.DemonstratorTools.l1tGTTFileWriter_cfi') - +process.load('L1Trigger.DemonstratorTools.l1tGTTFileReader_cfi') + +process.l1tGTTFileReader.processOutputToCorrelator = cms.bool((options.vertices in ['load', 'overwrite'])) +process.l1tGTTFileReader.processInputTracks = cms.bool((options.tracks in ['load', 'overwrite'])) +process.l1tGTTFileReader.processOutputToGlobalTrigger = cms.bool(False) #NotImplemented +process.l1tGTTFileReader.filesOutputToCorrelator = inputBuffers if (options.vertices in ['load', 'overwrite']) else cms.vstring("L1GTTOutputToCorrelatorFile_0.txt") +process.l1tGTTFileReader.filesInputTracks = inputTrackBuffers if (options.tracks in ['load', 'overwrite']) else cms.vstring("L1GTTInputFile_0.txt") +process.l1tGTTFileReader.filesOutputToGlobalTrigger = cms.vstring("L1GTTOutputToGlobalTriggerFile_0.txt") +process.l1tGTTFileReader.format = cms.untracked.string(options.readerformat) + process.l1tGTTInputProducer.debug = cms.int32(options.debug) +if (options.tracks in ['overwrite']): + process.l1tGTTInputProducer.l1TracksInputTag = cms.InputTag("l1tGTTFileReader", "Level1TTTracks") + process.l1tGTTInputProducer.setTrackWordBits = cms.bool(False) process.l1tTrackSelectionProducer.processSimulatedTracks = cms.bool(False) process.l1tVertexFinderEmulator.VertexReconstruction.VxMinTrackPt = cms.double(0.0) @@ -114,10 +150,16 @@ ) process.l1tGTTFileWriter.format = cms.untracked.string(options.format) #FIXME Put all this into the default GTTFileWriter -process.l1tGTTFileWriter.tracks = cms.untracked.InputTag("l1tTTTracksFromTrackletEmulation", "Level1TTTracks") +if options.tracks == 'overwrite': + process.l1tGTTFileWriter.tracks = cms.untracked.InputTag("l1tGTTFileReader", "Level1TTTracks") +else: + process.l1tGTTFileWriter.tracks = cms.untracked.InputTag("l1tTTTracksFromTrackletEmulation", "Level1TTTracks") process.l1tGTTFileWriter.convertedTracks = cms.untracked.InputTag("l1tGTTInputProducer", "Level1TTTracksConverted") process.l1tGTTFileWriter.selectedTracks = cms.untracked.InputTag("l1tTrackSelectionProducer", "Level1TTTracksSelectedEmulation") -process.l1tGTTFileWriter.vertices = cms.untracked.InputTag("l1tVertexFinderEmulator", "L1VerticesEmulation") +if options.vertices == 'overwrite': + process.l1tGTTFileWriter.vertices = cms.untracked.InputTag("l1tGTTFileReader", "L1VerticesFirmware") +else: + process.l1tGTTFileWriter.vertices = cms.untracked.InputTag("l1tVertexFinderEmulator", "L1VerticesEmulation") process.l1tGTTFileWriter.vertexAssociatedTracks = cms.untracked.InputTag("l1tTrackVertexAssociationProducer", "Level1TTTracksSelectedAssociatedEmulation") process.l1tGTTFileWriter.jets = cms.untracked.InputTag("l1tTrackJetsEmulation","L1TrackJets") process.l1tGTTFileWriter.htmiss = cms.untracked.InputTag("l1tTrackerEmuHTMiss", "L1TrackerEmuHTMiss") @@ -130,8 +172,10 @@ process.MessageLogger.cerr.FwkReport.reportEvery = 1 process.Timing = cms.Service("Timing", summaryOnly = cms.untracked.bool(True)) - -process.p = cms.Path(process.l1tGTTFileWriter) +if options.tracks in ['load', 'overwrite'] or options.vertices in ['load', 'overwrite']: + process.p = cms.Path(process.l1tGTTFileReader * process.l1tGTTFileWriter) +else: + process.p = cms.Path(process.l1tGTTFileWriter) process.p.associate(cms.Task(process.l1tGTTInputProducer, process.l1tTrackSelectionProducer, process.l1tVertexFinderEmulator, From 91e541af0514a61998391e1e5b423580e732fb80 Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Fri, 15 Dec 2023 15:44:37 +0100 Subject: [PATCH 21/24] code-format of GTTFileReader got lost somewhere in the re-re-re-rebasing --- .../plugins/GTTFileReader.cc | 53 +++++++++---------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc index f3e6db15b8ef3..5dfd524a62e34 100644 --- a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc +++ b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc @@ -117,45 +117,44 @@ GTTFileReader::GTTFileReader(const edm::ParameterSet& iConfig) void GTTFileReader::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { using namespace edm; using namespace l1t::demo::codecs; - if ( processOutputToCorrelator_ ) { + if (processOutputToCorrelator_) { l1t::demo::EventData correlatorEventData(fileReaderOutputToCorrelator_.getNextEvent()); l1t::VertexWordCollection vertices(decodeVertices(correlatorEventData.at({"vertices", 0}))); edm::LogInfo("GTTFileReader") << vertices.size() << " vertices found"; iEvent.put(std::make_unique(vertices), l1VertexCollectionName_); - } // end if ( processOutputToCorrelator_ ) + } // end if ( processOutputToCorrelator_ ) - if ( processInputTracks_ ) { + if (processInputTracks_) { l1t::demo::EventData inputEventData(fileReaderInputTracks_.getNextEvent()); auto inputTracks = std::make_unique(); for (size_t i = 0; i < 18; i++) { auto iTracks = decodeTracks(inputEventData.at({"tracks", i})); for (auto& trackword : iTracks) { - if (!trackword.getValidWord()) - continue; - L1Track track = L1Track(trackword.getValidWord(), - trackword.getRinvWord(), - trackword.getPhiWord(), - trackword.getTanlWord(), - trackword.getZ0Word(), - trackword.getD0Word(), - trackword.getChi2RPhiWord(), - trackword.getChi2RZWord(), - trackword.getBendChi2Word(), - trackword.getHitPatternWord(), - trackword.getMVAQualityWord(), - trackword.getMVAOtherWord()); - //retrieve the eta (first) and phi (second) sectors for GTT, encoded in an std::pair - auto sectors = (l1t::demo::codecs::sectorsEtaPhiFromGTTLinkID(i)); - track.setEtaSector(sectors.first); - track.setPhiSector(sectors.second); - track.trackWord_ = trackword.trackWord_; - inputTracks->push_back(track); - } //end loop over trackwoards - } // end loop over GTT input links + if (!trackword.getValidWord()) + continue; + L1Track track = L1Track(trackword.getValidWord(), + trackword.getRinvWord(), + trackword.getPhiWord(), + trackword.getTanlWord(), + trackword.getZ0Word(), + trackword.getD0Word(), + trackword.getChi2RPhiWord(), + trackword.getChi2RZWord(), + trackword.getBendChi2Word(), + trackword.getHitPatternWord(), + trackword.getMVAQualityWord(), + trackword.getMVAOtherWord()); + //retrieve the eta (first) and phi (second) sectors for GTT, encoded in an std::pair + auto sectors = (l1t::demo::codecs::sectorsEtaPhiFromGTTLinkID(i)); + track.setEtaSector(sectors.first); + track.setPhiSector(sectors.second); + track.trackWord_ = trackword.trackWord_; + inputTracks->push_back(track); + } //end loop over trackwoards + } // end loop over GTT input links iEvent.put(std::move(inputTracks), l1TrackCollectionName_); - } // end if ( processInputTracks_ ) - + } // end if ( processInputTracks_ ) } // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ From 4d84a0311d39502b92b171e2edc7180274e98eb7 Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Sat, 13 Jan 2024 06:42:58 +0100 Subject: [PATCH 22/24] Use named constant for loop over tracks --- L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc index 5dfd524a62e34..8e12b298ea06b 100644 --- a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc +++ b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc @@ -128,7 +128,7 @@ void GTTFileReader::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { if (processInputTracks_) { l1t::demo::EventData inputEventData(fileReaderInputTracks_.getNextEvent()); auto inputTracks = std::make_unique(); - for (size_t i = 0; i < 18; i++) { + for (size_t i = 0; i < l1t::demo::kTrackTMUX; i++) { auto iTracks = decodeTracks(inputEventData.at({"tracks", i})); for (auto& trackword : iTracks) { if (!trackword.getValidWord()) From e6e14d6eccec292085bb1e468e67aef82cfeb555 Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Tue, 6 Feb 2024 06:59:38 +0100 Subject: [PATCH 23/24] add gtt to l1t::demo::gtt namespace of constants, switch from combined ChannelMap to ChannelIds and Specs maps --- .../interface/GTTInterface.h | 12 +++- .../plugins/GTTFileReader.cc | 22 +++---- .../plugins/GTTFileWriter.cc | 59 ++++++++++--------- 3 files changed, 52 insertions(+), 41 deletions(-) diff --git a/L1Trigger/DemonstratorTools/interface/GTTInterface.h b/L1Trigger/DemonstratorTools/interface/GTTInterface.h index 7b831e521a9d0..bca84920d3326 100644 --- a/L1Trigger/DemonstratorTools/interface/GTTInterface.h +++ b/L1Trigger/DemonstratorTools/interface/GTTInterface.h @@ -9,7 +9,7 @@ #include "L1Trigger/DemonstratorTools/interface/FileFormat.h" #include "L1Trigger/DemonstratorTools/interface/Frame.h" -namespace l1t::demo { +namespace l1t::demo::gtt { // map of logical channel ID -> [TMUX period, interpacket-gap & offset; channel indices] typedef std::map>> ChannelMap_t; @@ -80,6 +80,14 @@ namespace l1t::demo { /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */ {{"vertices", 0}, {{kGTTBoardTMUX, kGapLengthOutputToCorrelator}, {0}}}}; + static const std::map> kChannelIdsOutputToCorrelator = { + /* logical channel within time slice -> vector of channel indices */ + {{"vertices", 0}, {0}}}; + + static const std::map kChannelSpecsOutputToCorrelator = { + /* interface name -> {link TMUX, inter-packet gap} */ + {"vertices", {kGTTBoardTMUX, kGapLengthOutputToCorrelator}}}; + //OUTPUTS to Global Trigger static const std::map> kChannelIdsOutputToGlobalTrigger = { /* logical channel within time slice -> vector of channel indices (one entry per time slice) */ @@ -95,6 +103,6 @@ namespace l1t::demo { {"mesons", {kGTTBoardTMUX, kGapLengthOutputToGlobalTriggerMesons}}, {"vertices", {kGTTBoardTMUX, kGapLengthOutputToGlobalTriggerVertices}}}; -} // namespace l1t::demo +} // namespace l1t::demo::gtt #endif diff --git a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc index 8e12b298ea06b..5bca370208d1e 100644 --- a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc +++ b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc @@ -84,30 +84,32 @@ GTTFileReader::GTTFileReader(const edm::ParameterSet& iConfig) fileReaderOutputToCorrelator_ = l1t::demo::BoardDataReader(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), iConfig.getParameter>("filesOutputToCorrelator"), - l1t::demo::kFramesPerTMUXPeriod, - l1t::demo::kGTTBoardTMUX, + l1t::demo::gtt::kFramesPerTMUXPeriod, + l1t::demo::gtt::kGTTBoardTMUX, kEmptyFramesOutputToCorrelator_, - l1t::demo::kChannelMapOutputToCorrelator); + l1t::demo::gtt::kChannelIdsOutputToCorrelator, + l1t::demo::gtt::kChannelSpecsOutputToCorrelator); produces(l1VertexCollectionName_); } if (processInputTracks_) { fileReaderInputTracks_ = l1t::demo::BoardDataReader(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), iConfig.getParameter>("filesInputTracks"), - l1t::demo::kFramesPerTMUXPeriod, - l1t::demo::kGTTBoardTMUX, + l1t::demo::gtt::kFramesPerTMUXPeriod, + l1t::demo::gtt::kGTTBoardTMUX, kEmptyFramesInputTracks_, - l1t::demo::kChannelMapInput); + l1t::demo::gtt::kChannelIdsInput, + l1t::demo::gtt::kChannelSpecsInput); produces(l1TrackCollectionName_); } if (processOutputToGlobalTrigger_) { // fileReaderOutputToGlobalTrigger_ = // l1t::demo::BoardDataReader(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), // iConfig.getParameter>("filesOutputToGlobalTrigger"), - // l1t::demo::kFramesPerTMUXPeriod, - // l1t::demo::kGTTBoardTMUX, + // l1t::demo::gtt::kFramesPerTMUXPeriod, + // l1t::demo::gtt::kGTTBoardTMUX, // kEmptyFramesOutputToGlobalTrigger_, - // l1t::demo::kChannelMapInput); + // l1t::demo::gtt::kChannelMapInput); throw std::invalid_argument("Processing OutputToGlobalTrigger files has not been fully implemented and validated."); // need to produce output collections for Prompt and Displaced Jets, HTMiss, ETMiss, Taus, Mesons, Vertices, and Isolated Tracks } @@ -128,7 +130,7 @@ void GTTFileReader::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { if (processInputTracks_) { l1t::demo::EventData inputEventData(fileReaderInputTracks_.getNextEvent()); auto inputTracks = std::make_unique(); - for (size_t i = 0; i < l1t::demo::kTrackTMUX; i++) { + for (size_t i = 0; i < l1t::demo::gtt::kTrackTMUX; i++) { auto iTracks = decodeTracks(inputEventData.at({"tracks", i})); for (auto& trackword : iTracks) { if (!trackword.getValidWord()) diff --git a/L1Trigger/DemonstratorTools/plugins/GTTFileWriter.cc b/L1Trigger/DemonstratorTools/plugins/GTTFileWriter.cc index 69cf731a0e5ea..009a8a6de2202 100644 --- a/L1Trigger/DemonstratorTools/plugins/GTTFileWriter.cc +++ b/L1Trigger/DemonstratorTools/plugins/GTTFileWriter.cc @@ -111,51 +111,52 @@ GTTFileWriter::GTTFileWriter(const edm::ParameterSet& iConfig) fileWriterInputTracks_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), iConfig.getUntrackedParameter("inputFilename"), iConfig.getUntrackedParameter("fileExtension"), - l1t::demo::kFramesPerTMUXPeriod, - l1t::demo::kGTTBoardTMUX, - l1t::demo::kMaxLinesPerFile, - l1t::demo::kChannelIdsInput, - l1t::demo::kChannelSpecsInput), + l1t::demo::gtt::kFramesPerTMUXPeriod, + l1t::demo::gtt::kGTTBoardTMUX, + l1t::demo::gtt::kMaxLinesPerFile, + l1t::demo::gtt::kChannelIdsInput, + l1t::demo::gtt::kChannelSpecsInput), fileWriterConvertedTracks_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), iConfig.getUntrackedParameter("inputConvertedFilename"), iConfig.getUntrackedParameter("fileExtension"), - l1t::demo::kFramesPerTMUXPeriod, - l1t::demo::kGTTBoardTMUX, - l1t::demo::kMaxLinesPerFile, - l1t::demo::kChannelIdsInput, - l1t::demo::kChannelSpecsInput), + l1t::demo::gtt::kFramesPerTMUXPeriod, + l1t::demo::gtt::kGTTBoardTMUX, + l1t::demo::gtt::kMaxLinesPerFile, + l1t::demo::gtt::kChannelIdsInput, + l1t::demo::gtt::kChannelSpecsInput), fileWriterSelectedTracks_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), iConfig.getUntrackedParameter("selectedTracksFilename"), iConfig.getUntrackedParameter("fileExtension"), - l1t::demo::kFramesPerTMUXPeriod, - l1t::demo::kGTTBoardTMUX, - l1t::demo::kMaxLinesPerFile, - l1t::demo::kChannelIdsInput, - l1t::demo::kChannelSpecsInput), + l1t::demo::gtt::kFramesPerTMUXPeriod, + l1t::demo::gtt::kGTTBoardTMUX, + l1t::demo::gtt::kMaxLinesPerFile, + l1t::demo::gtt::kChannelIdsInput, + l1t::demo::gtt::kChannelSpecsInput), fileWriterVertexAssociatedTracks_( l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), iConfig.getUntrackedParameter("vertexAssociatedTracksFilename"), iConfig.getUntrackedParameter("fileExtension"), - l1t::demo::kFramesPerTMUXPeriod, - l1t::demo::kGTTBoardTMUX, - l1t::demo::kMaxLinesPerFile, - l1t::demo::kChannelIdsInput, - l1t::demo::kChannelSpecsInput), + l1t::demo::gtt::kFramesPerTMUXPeriod, + l1t::demo::gtt::kGTTBoardTMUX, + l1t::demo::gtt::kMaxLinesPerFile, + l1t::demo::gtt::kChannelIdsInput, + l1t::demo::gtt::kChannelSpecsInput), fileWriterOutputToCorrelator_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), iConfig.getUntrackedParameter("outputCorrelatorFilename"), iConfig.getUntrackedParameter("fileExtension"), - l1t::demo::kFramesPerTMUXPeriod, - l1t::demo::kGTTBoardTMUX, - l1t::demo::kMaxLinesPerFile, - l1t::demo::kChannelMapOutputToCorrelator), + l1t::demo::gtt::kFramesPerTMUXPeriod, + l1t::demo::gtt::kGTTBoardTMUX, + l1t::demo::gtt::kMaxLinesPerFile, + l1t::demo::gtt::kChannelIdsOutputToCorrelator, + l1t::demo::gtt::kChannelSpecsOutputToCorrelator), fileWriterOutputToGlobalTrigger_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), iConfig.getUntrackedParameter("outputGlobalTriggerFilename"), iConfig.getUntrackedParameter("fileExtension"), - l1t::demo::kFramesPerTMUXPeriod, - l1t::demo::kGTTBoardTMUX, - l1t::demo::kMaxLinesPerFile, - l1t::demo::kChannelIdsOutputToGlobalTrigger, - l1t::demo::kChannelSpecsOutputToGlobalTrigger) {} + l1t::demo::gtt::kFramesPerTMUXPeriod, + l1t::demo::gtt::kGTTBoardTMUX, + l1t::demo::gtt::kMaxLinesPerFile, + l1t::demo::gtt::kChannelIdsOutputToGlobalTrigger, + l1t::demo::gtt::kChannelSpecsOutputToGlobalTrigger) {} void GTTFileWriter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { using namespace edm; From 4c0b06b058e366208f300da9ac5e82bf6e2598d5 Mon Sep 17 00:00:00 2001 From: Nick Manganelli Date: Wed, 7 Feb 2024 05:54:28 +0100 Subject: [PATCH 24/24] Switch to std::optional and remove default constructor for BoardDataReader --- .../interface/BoardDataReader.h | 2 -- .../plugins/GTTFileReader.cc | 30 +++++++++---------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/L1Trigger/DemonstratorTools/interface/BoardDataReader.h b/L1Trigger/DemonstratorTools/interface/BoardDataReader.h index 3973983eda1fa..c574cdeee32b8 100644 --- a/L1Trigger/DemonstratorTools/interface/BoardDataReader.h +++ b/L1Trigger/DemonstratorTools/interface/BoardDataReader.h @@ -38,8 +38,6 @@ namespace l1t::demo { const std::map>&, const std::map&); - BoardDataReader() = default; - EventData getNextEvent(); private: diff --git a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc index 5bca370208d1e..d9ce88f96b3c6 100644 --- a/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc +++ b/L1Trigger/DemonstratorTools/plugins/GTTFileReader.cc @@ -63,11 +63,11 @@ class GTTFileReader : public edm::stream::EDProducer<> { const size_t kEmptyFramesOutputToCorrelator_; const size_t kEmptyFramesInputTracks_; const size_t kEmptyFramesOutputToGlobalTrigger_; - l1t::demo::BoardDataReader fileReaderOutputToCorrelator_; + std::optional fileReaderOutputToCorrelator_ = std::nullopt; std::string l1VertexCollectionName_; - l1t::demo::BoardDataReader fileReaderInputTracks_; + std::optional fileReaderInputTracks_ = std::nullopt; std::string l1TrackCollectionName_; - l1t::demo::BoardDataReader fileReaderOutputToGlobalTrigger_; + std::optional fileReaderOutputToGlobalTrigger_ = std::nullopt; }; GTTFileReader::GTTFileReader(const edm::ParameterSet& iConfig) @@ -87,8 +87,7 @@ GTTFileReader::GTTFileReader(const edm::ParameterSet& iConfig) l1t::demo::gtt::kFramesPerTMUXPeriod, l1t::demo::gtt::kGTTBoardTMUX, kEmptyFramesOutputToCorrelator_, - l1t::demo::gtt::kChannelIdsOutputToCorrelator, - l1t::demo::gtt::kChannelSpecsOutputToCorrelator); + l1t::demo::gtt::kChannelMapOutputToCorrelator); produces(l1VertexCollectionName_); } if (processInputTracks_) { @@ -98,18 +97,17 @@ GTTFileReader::GTTFileReader(const edm::ParameterSet& iConfig) l1t::demo::gtt::kFramesPerTMUXPeriod, l1t::demo::gtt::kGTTBoardTMUX, kEmptyFramesInputTracks_, - l1t::demo::gtt::kChannelIdsInput, - l1t::demo::gtt::kChannelSpecsInput); + l1t::demo::gtt::kChannelMapInput); produces(l1TrackCollectionName_); } if (processOutputToGlobalTrigger_) { // fileReaderOutputToGlobalTrigger_ = // l1t::demo::BoardDataReader(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter("format")), - // iConfig.getParameter>("filesOutputToGlobalTrigger"), - // l1t::demo::gtt::kFramesPerTMUXPeriod, - // l1t::demo::gtt::kGTTBoardTMUX, - // kEmptyFramesOutputToGlobalTrigger_, - // l1t::demo::gtt::kChannelMapInput); + // iConfig.getParameter>("filesOutputToGlobalTrigger"), + // l1t::demo::gtt::kFramesPerTMUXPeriod, + // l1t::demo::gtt::kGTTBoardTMUX, + // kEmptyFramesOutputToGlobalTrigger_, + // l1t::demo::gtt::kChannelMapInput); throw std::invalid_argument("Processing OutputToGlobalTrigger files has not been fully implemented and validated."); // need to produce output collections for Prompt and Displaced Jets, HTMiss, ETMiss, Taus, Mesons, Vertices, and Isolated Tracks } @@ -119,16 +117,16 @@ GTTFileReader::GTTFileReader(const edm::ParameterSet& iConfig) void GTTFileReader::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { using namespace edm; using namespace l1t::demo::codecs; - if (processOutputToCorrelator_) { - l1t::demo::EventData correlatorEventData(fileReaderOutputToCorrelator_.getNextEvent()); + if (processOutputToCorrelator_ && fileReaderOutputToCorrelator_) { + l1t::demo::EventData correlatorEventData(fileReaderOutputToCorrelator_.value().getNextEvent()); l1t::VertexWordCollection vertices(decodeVertices(correlatorEventData.at({"vertices", 0}))); edm::LogInfo("GTTFileReader") << vertices.size() << " vertices found"; iEvent.put(std::make_unique(vertices), l1VertexCollectionName_); } // end if ( processOutputToCorrelator_ ) - if (processInputTracks_) { - l1t::demo::EventData inputEventData(fileReaderInputTracks_.getNextEvent()); + if (processInputTracks_ && fileReaderInputTracks_) { + l1t::demo::EventData inputEventData(fileReaderInputTracks_.value().getNextEvent()); auto inputTracks = std::make_unique(); for (size_t i = 0; i < l1t::demo::gtt::kTrackTMUX; i++) { auto iTracks = decodeTracks(inputEventData.at({"tracks", i}));