Skip to content

Commit

Permalink
Add SC8 jets. Rename SC jets to SC4. Add multiple outputs to jet file…
Browse files Browse the repository at this point in the history
… writer

Fix merge issues
  • Loading branch information
thesps committed Oct 20, 2023
1 parent 9a7cd3a commit 92ea3ea
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 46 deletions.
61 changes: 42 additions & 19 deletions L1Trigger/Phase2L1ParticleFlow/plugins/L1CTJetFileWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class L1CTJetFileWriter : public edm::one::EDAnalyzer<edm::one::SharedResources>

private:
// ----------constants, enums and typedefs ---------
std::vector<edm::ParameterSet> collections_;
unsigned nJets_;
size_t nFramesPerBX_;
size_t ctl2BoardTMUX_;
Expand All @@ -41,43 +42,53 @@ class L1CTJetFileWriter : public edm::one::EDAnalyzer<edm::one::SharedResources>
void endJob() override;
std::vector<ap_uint<64>> encodeJets(const std::vector<l1t::PFJet> jets);

edm::EDGetTokenT<edm::View<l1t::PFJet>> jetsToken_;
l1t::demo::BoardDataWriter fileWriterOutputToGT_;
std::vector<edm::EDGetTokenT<edm::View<l1t::PFJet>>> jetsTokens_;
};

L1CTJetFileWriter::L1CTJetFileWriter(const edm::ParameterSet& iConfig)
: nJets_(iConfig.getParameter<unsigned>("nJets")),
:
collections_(iConfig.getUntrackedParameter<std::vector<edm::ParameterSet>>("collections",
std::vector<edm::ParameterSet>())),
nJets_(iConfig.getParameter<unsigned>("nJets")),
nFramesPerBX_(iConfig.getParameter<unsigned>("nFramesPerBX")),
ctl2BoardTMUX_(iConfig.getParameter<unsigned>("TMUX")),
gapLengthOutput_(ctl2BoardTMUX_ * nFramesPerBX_ - 2 * nJets_),
gapLengthOutput_(ctl2BoardTMUX_ * nFramesPerBX_ - 2 * nJets_ * collections_.size()),
maxLinesPerFile_(iConfig.getParameter<unsigned>("maxLinesPerFile")),
channelSpecsOutputToGT_{{{"jets", 0}, {{ctl2BoardTMUX_, gapLengthOutput_}, {0}}}},
jetsToken_(consumes<edm::View<l1t::PFJet>>(iConfig.getParameter<edm::InputTag>("jets"))),
fileWriterOutputToGT_(l1t::demo::parseFileFormat(iConfig.getParameter<std::string>("format")),
iConfig.getParameter<std::string>("outputFilename"),
iConfig.getParameter<std::string>("outputFileExtension"),
nFramesPerBX_,
ctl2BoardTMUX_,
maxLinesPerFile_,
channelSpecsOutputToGT_) {}
channelSpecsOutputToGT_) {
for(const auto &pset : collections_){
jetsTokens_.push_back(consumes<edm::View<l1t::PFJet>>(pset.getParameter<edm::InputTag>("jets")));
}
}

void L1CTJetFileWriter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
using namespace edm;

// 1) Encode jet information onto vectors containing link data
// TODO remove the sort here and sort the input collection where it's created
const edm::View<l1t::PFJet>& jets = iEvent.get(jetsToken_);
std::vector<l1t::PFJet> sortedJets;
sortedJets.reserve(jets.size());
std::copy(jets.begin(), jets.end(), std::back_inserter(sortedJets));

std::stable_sort(
sortedJets.begin(), sortedJets.end(), [](l1t::PFJet i, l1t::PFJet j) { return (i.hwPt() > j.hwPt()); });
const auto outputJets(encodeJets(sortedJets));

// 2) Pack jet information into 'event data' object, and pass that to file writer
// 1) Pack collections in otder they're specified. jets then sums within collection
std::vector<ap_uint<64>> link_words;
for(const auto &token : jetsTokens_){
// 2) Encode jet information onto vectors containing link data
// TODO remove the sort here and sort the input collection where it's created
const edm::View<l1t::PFJet>& jets = iEvent.get(token);
std::vector<l1t::PFJet> sortedJets;
sortedJets.reserve(jets.size());
std::copy(jets.begin(), jets.end(), std::back_inserter(sortedJets));

std::stable_sort(
sortedJets.begin(), sortedJets.end(), [](l1t::PFJet i, l1t::PFJet j) { return (i.hwPt() > j.hwPt()); });
const auto outputJets(encodeJets(sortedJets));
link_words.insert(link_words.end(), outputJets.begin(), outputJets.end());
}
// 3) Pack jet information into 'event data' object, and pass that to file writer
l1t::demo::EventData eventDataJets;
eventDataJets.add({"jets", 0}, outputJets);
eventDataJets.add({"jets", 0}, link_words);
fileWriterOutputToGT_.addEvent(eventDataJets);
}

Expand Down Expand Up @@ -107,7 +118,19 @@ void L1CTJetFileWriter::fillDescriptions(edm::ConfigurationDescriptions& descrip
//The following says we do not know what parameters are allowed so do no validation
// Please change this to state exactly what you do use, even if it is no parameters
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("jets");
{
edm::ParameterSetDescription vpsd1;
vpsd1.add<edm::InputTag>("jets", edm::InputTag("scPFL1PuppiEmulatorCorrected"));
std::vector<edm::ParameterSet> temp1;
temp1.reserve(1);
{
edm::ParameterSet temp2;
temp2.addParameter<edm::InputTag>("jets", edm::InputTag("scPFL1PuppiEmulatorCorrected"));
temp1.push_back(temp2);
}
desc.addVPSetUntracked("collections", vpsd1, temp1);
}
//desc.add<std::vector<edm::ParameterSet>>("collections");
desc.add<std::string>("outputFilename");
desc.add<std::string>("outputFileExtension", "txt");
desc.add<uint32_t>("nJets", 12);
Expand Down
11 changes: 11 additions & 0 deletions L1Trigger/Phase2L1ParticleFlow/python/l1ctJetFileWriter_cfi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import FWCore.ParameterSet.Config as cms

l1ctSeededConeJetFileWriter = cms.EDAnalyzer('L1CTJetFileWriter',
collections = cms.untracked.VPSet([cms.PSet(jets = cms.InputTag("scPFL1PuppiEmulatorCorrected"))]),
nJets = cms.uint32(12),
nFramesPerBX = cms.uint32(9), # 360 MHz clock or 25 Gb/s link
TMUX = cms.uint32(6),
maxLinesPerFile = cms.uint32(1024),
outputFilename = cms.string("L1CTSCJetsPatterns"),
format = cms.string("EMP")
)
52 changes: 25 additions & 27 deletions L1Trigger/Phase2L1ParticleFlow/python/l1pfJetMet_cff.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import FWCore.ParameterSet.Config as cms

from L1Trigger.Phase2L1ParticleFlow.l1SeedConePFJetProducer_cfi import l1SeedConePFJetProducer
from L1Trigger.Phase2L1ParticleFlow.l1SeedConePFJetEmulatorProducer_cfi import l1SeedConePFJetEmulatorProducer
from L1Trigger.Phase2L1ParticleFlow.l1tDeregionizerProducer_cfi import l1tDeregionizerProducer as l1tLayer2Deregionizer, l1tDeregionizerProducerExtended as l1tLayer2DeregionizerExtended
l1tSCPFL1PF = l1SeedConePFJetProducer.clone(L1PFObjects = 'l1tLayer1:PF')
l1tSCPFL1Puppi = l1SeedConePFJetProducer.clone()
l1tSCPFL1PuppiEmulator = l1SeedConePFJetEmulatorProducer.clone(L1PFObjects = 'l1tLayer2Deregionizer:Puppi')
l1tSCPFL1PuppiCorrectedEmulator = l1SeedConePFJetEmulatorProducer.clone(L1PFObjects = 'l1tLayer2Deregionizer:Puppi',
doCorrections = True,
correctorFile = "L1Trigger/Phase2L1ParticleFlow/data/jecs/jecs_20220308.root",
correctorDir = "L1PuppiSC4EmuJets")
from L1Trigger.Phase2L1ParticleFlow.L1SeedConePFJetProducer_cfi import L1SeedConePFJetProducer, L1SeedConePFJetEmulatorProducer
from L1Trigger.Phase2L1ParticleFlow.DeregionizerProducer_cfi import DeregionizerProducer as l1ctLayer2Deregionizer, DeregionizerProducerExtended as l1ctLayer2DeregionizerExtended
sc4PFL1PF = L1SeedConePFJetProducer.clone(L1PFObjects = 'l1ctLayer1:PF')
sc4PFL1Puppi = L1SeedConePFJetProducer.clone()
sc4PFL1PuppiEmulator = L1SeedConePFJetEmulatorProducer.clone(L1PFObject = cms.InputTag('l1ctLayer2Deregionizer', 'Puppi'))
sc4PFL1PuppiCorrectedEmulator = L1SeedConePFJetEmulatorProducer.clone(L1PFObject = cms.InputTag('l1ctLayer2Deregionizer', 'Puppi'),
doCorrections = cms.bool(True),
correctorFile = cms.string("L1Trigger/Phase2L1ParticleFlow/data/jecs/jecs_20220308.root"),
correctorDir = cms.string('L1PuppiSC4EmuJets'))
sc8PFL1PuppiCorrectedEmulator = L1SeedConePFJetEmulatorProducer.clone(L1PFObject = cms.InputTag('l1ctLayer2Deregionizer', 'Puppi'),
coneSize = cms.double(0.8),
doCorrections = cms.bool(True),
correctorFile = cms.string("L1Trigger/Phase2L1ParticleFlow/data/jecs/jecs_20220308.root"),
correctorDir = cms.string('L1PuppiSC4EmuJets'))

_correctedJets = cms.EDProducer("L1TCorrectedPFJetProducer",
jets = cms.InputTag("_tag_"),
Expand All @@ -25,26 +28,21 @@
from Configuration.Eras.Modifier_phase2_hgcalV11_cff import phase2_hgcalV11
phase2_hgcalV11.toModify(_correctedJets, correctorFile = "L1Trigger/Phase2L1ParticleFlow/data/jecs/jecs_20220308.root")

from L1Trigger.Phase2L1ParticleFlow.l1tMHTPFProducer_cfi import l1tMHTPFProducer
l1tSCPFL1PuppiCorrectedEmulatorMHT = l1tMHTPFProducer.clone(jets = 'l1tSCPFL1PuppiCorrectedEmulator')

L1TPFJetsTask = cms.Task(
l1tLayer2Deregionizer, l1tSCPFL1PF, l1tSCPFL1Puppi, l1tSCPFL1PuppiEmulator, l1tSCPFL1PuppiCorrectedEmulator, l1tSCPFL1PuppiCorrectedEmulatorMHT
)
from L1Trigger.Phase2L1ParticleFlow.L1MHTPFProducer_cfi import L1MHTPFProducer
sc4PFL1PuppiCorrectedEmulatorMHT = L1MHTPFProducer.clone(jets = cms.InputTag("sc4PFL1PuppiCorrectedEmulator"))
sc8PFL1PuppiCorrectedEmulatorMHT = L1MHTPFProducer.clone(jets = cms.InputTag("sc8PFL1PuppiCorrectedEmulator"))

l1tSCPFL1PuppiExtended = l1SeedConePFJetProducer.clone(L1PFObjects = 'l1tLayer1Extended:Puppi')
l1tSCPFL1PuppiExtendedEmulator = l1SeedConePFJetEmulatorProducer.clone(L1PFObjects = 'l1tLayer2DeregionizerExtended:Puppi')
l1tSCPFL1PuppiExtendedCorrectedEmulator = l1SeedConePFJetEmulatorProducer.clone(L1PFObjects = 'l1tLayer2DeregionizerExtended:Puppi',
doCorrections = True,
correctorFile = "L1Trigger/Phase2L1ParticleFlow/data/jecs/jecs_20220308.root",
correctorDir = "L1PuppiSC4EmuJets")
sc4PFL1PuppiExtended = sc4PFL1Puppi.clone(L1PFObjects = 'l1ctLayer1Extended:Puppi')
sc4PFL1PuppiExtendedEmulator = sc4PFL1PuppiEmulator.clone(L1PFObjects = cms.InputTag('l1ctLayer2DeregionizerExtended', 'Puppi'))
sc4PFL1PuppiExtendedCorrectedEmulator = _correctedJets.clone(jets = 'sc4PFL1PuppiExtendedEmulator', correctorDir = 'L1PuppiSC4EmuDeregJets')

L1TPFJetsTask = cms.Task(
l1tLayer2Deregionizer, l1tSCPFL1PF, l1tSCPFL1Puppi, l1tSCPFL1PuppiEmulator, l1tSCPFL1PuppiCorrectedEmulator, l1tSCPFL1PuppiCorrectedEmulatorMHT
l1PFJetsTask = cms.Task(
l1ctLayer2Deregionizer, sc4PFL1PF, sc4PFL1Puppi, sc4PFL1PuppiEmulator, sc4PFL1PuppiCorrectedEmulator, sc4PFL1PuppiCorrectedEmulatorMHT,
sc8PFL1PuppiCorrectedEmulator, sc8PFL1PuppiCorrectedEmulatorMHT
)

L1TPFJetsExtendedTask = cms.Task(
l1tLayer2DeregionizerExtended, l1tSCPFL1PuppiExtended, l1tSCPFL1PuppiExtendedEmulator, l1tSCPFL1PuppiExtendedCorrectedEmulator
l1PFJetsExtendedTask = cms.Task(
l1ctLayer2DeregionizerExtended, sc4PFL1PuppiExtended, sc4PFL1PuppiExtendedEmulator, sc4PFL1PuppiExtendedCorrectedEmulator
)

L1TPFJetsEmulationTask = cms.Task(
Expand Down

0 comments on commit 92ea3ea

Please sign in to comment.