diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc index 0aebfc3b78ebf..951bfb0bafe84 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc @@ -44,6 +44,7 @@ #include "L1Trigger/Phase2L1ParticleFlow/src/newfirmware/pf/pfalgo_common_ref.h" #include "L1Trigger/Phase2L1ParticleFlow/src/newfirmware/pf/pfalgo_common_ref.cpp" #include "L1Trigger/Phase2L1ParticleFlow/src/newfirmware/egamma/pftkegsorter_ref.h" +#include "L1Trigger/Phase2L1ParticleFlow/src/L1TCorrelatorLayer1PatternFileWriter.h" #include "DataFormats/L1TCorrelator/interface/TkElectron.h" #include "DataFormats/L1TCorrelator/interface/TkElectronFwd.h" @@ -90,6 +91,8 @@ class L1TCorrelatorLayer1Producer : public edm::stream::EDProducer<> { const std::string regionDumpName_; bool writeRawHgcalCluster_; std::fstream fRegionDump_; + std::vector patternWriterConfigs_; + std::vector> patternWriters_; // region of interest debugging float debugEta_, debugPhi_, debugR_; @@ -101,6 +104,7 @@ class L1TCorrelatorLayer1Producer : public edm::stream::EDProducer<> { // main methods void beginStream(edm::StreamID) override; + void endStream() override; void produce(edm::Event &, const edm::EventSetup &) override; void addUInt(unsigned int value, std::string iLabel, edm::Event &iEvent); @@ -171,6 +175,8 @@ L1TCorrelatorLayer1Producer::L1TCorrelatorLayer1Producer(const edm::ParameterSet l1tkegsorter_(nullptr), regionDumpName_(iConfig.getUntrackedParameter("dumpFileName", "")), writeRawHgcalCluster_(iConfig.getUntrackedParameter("writeRawHgcalCluster", false)), + patternWriterConfigs_(iConfig.getUntrackedParameter>( + "patternWriters", std::vector())), debugEta_(iConfig.getUntrackedParameter("debugEta", 0)), debugPhi_(iConfig.getUntrackedParameter("debugPhi", 0)), debugR_(iConfig.getUntrackedParameter("debugR", -1)) { @@ -290,6 +296,22 @@ void L1TCorrelatorLayer1Producer::beginStream(edm::StreamID id) { << "Job running with multiple streams, but dump file will have only events on stream zero."; } } + if (!patternWriterConfigs_.empty()) { + if (id == 0) { + for (const auto &pset : patternWriterConfigs_) { + patternWriters_.emplace_back(std::make_unique(pset, event_)); + } + } else { + edm::LogWarning("L1TCorrelatorLayer1Producer") + << "Job running with multiple streams, but pattern files will be written only on stream zero."; + } + } +} + +void L1TCorrelatorLayer1Producer::endStream() { + for (auto &writer : patternWriters_) { + writer->flush(); + } } // ------------ method called to produce the data ------------ @@ -473,6 +495,9 @@ void L1TCorrelatorLayer1Producer::produce(edm::Event &iEvent, const edm::EventSe if (fRegionDump_.is_open()) { event_.write(fRegionDump_); } + for (auto &writer : patternWriters_) { + writer->write(event_); + } // finally clear the regions event_.clear(); diff --git a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py new file mode 100644 index 0000000000000..6a856e48db502 --- /dev/null +++ b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py @@ -0,0 +1,165 @@ +import FWCore.ParameterSet.Config as cms + +eventsPerFile_ = 12 +gttLatency_ = 156+120 +gttNumberOfPVs_ = 10 + +##################################################################################################################### +## Barrel configurations: 54 regions, 6 puppi output links, only write out the layer 1 outputs for now +barrelWriterOutputOnly_ = cms.PSet( + partition = cms.string("Barrel"), + outputLinksPuppi = cms.vuint32(*range(6)), + outputLinkEgamma = cms.int32(6), + nEgammaObjectsOut = cms.uint32(16), + nOutputFramesPerBX = cms.uint32(9), + fileFormat = cms.string("EMP"), + maxLinesPerOutputFile = cms.uint32(1024), + eventsPerFile = cms.uint32(eventsPerFile_), +) +## Barrel (54) split in 3 eta slices +barrelWriterOutputOnlyEtaConfigs = [ + barrelWriterOutputOnly_.clone( + outputRegions = cms.vuint32(*[18*ie+i for i in range(18)]), + outputFileName = cms.string("l1BarrelEta%d-outputs-ideal" % (ie+1)), + outputBoard = cms.int32(-1), ## can't output e/gamma in eta split regions + outputLinkEgamma = cms.int32(-1), ## since the boards are defined in phi regions + ) for ie in range(3) +] +## Barrel (54) split in 3 phi slices +barrelWriterOutputOnlyPhiConfigs = [ + barrelWriterOutputOnly_.clone( + outputRegions = cms.vuint32(*[3*ip+9*ie+i for ie in range(6) for i in range(3) ]), + outputBoard = cms.int32(ip), + outputFileName = cms.string("l1BarrelPhi%d-outputs-ideal" % (ip+1)) + ) for ip in range(3) +] +## Barrel9 (27) split in phi eta slices +barrel9WriterOutputOnlyPhiConfigs = [ + barrelWriterOutputOnly_.clone( + outputRegions = cms.vuint32(*[3*ip+9*ie+i for ie in range(3) for i in range(3) ]), + outputBoard = cms.int32(ip), + outputFileName = cms.string("l1Barrel9Phi%d-outputs-ideal" % (ip+1)) + ) for ip in range(3) +] + +barrelWriterConfigs = barrelWriterOutputOnlyPhiConfigs # + barrelWriterOutputOnlyEtaConfigs +barrel9WriterConfigs = [] #barrel9WriterOutputOnlyPhiConfigs + + +##################################################################################################################### +## HGcal configuration: write out both inputs and outputs +hgcalWriterConfig_ = cms.PSet( + partition = cms.string("HGCal"), + outputRegions = cms.vuint32(*[i+9 for i in range(9)]), + outputBoard = cms.int32(1), + nEgammaObjectsOut = cms.uint32(16), + nInputFramesPerBX = cms.uint32(9), + nOutputFramesPerBX = cms.uint32(9), + fileFormat = cms.string("EMP"), + maxLinesPerInputFile = cms.uint32(1024), + maxLinesPerOutputFile = cms.uint32(1024), + eventsPerFile = cms.uint32(eventsPerFile_), + tfTimeSlices = cms.VPSet(*[cms.PSet(tfSectors = cms.VPSet()) for i in range(3)]), + hgcTimeSlices = cms.VPSet(*[cms.PSet(hgcSectors = cms.VPSet()) for i in range(3)]), + gmtTimeSlices = cms.VPSet(cms.PSet(),cms.PSet(),cms.PSet()), + gmtNumberOfMuons = cms.uint32(12), + gttLink = cms.int32(-1), + gttLatency = cms.uint32(gttLatency_), + gttNumberOfPVs = cms.uint32(gttNumberOfPVs_) +) +## Ideal configuration: 27 input links from tf, 36 from hgc, 3 from gmt, 1 from gtt, in this order; output 3 puppi + 1 e/gamma +hgcalPosIdealWriterConfig = hgcalWriterConfig_.clone() +for t in range(3): + hgcalPosIdealWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(-1)) for i in range(9) ] # neg + hgcalPosIdealWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t)) for i in range(9) ] # pos + hgcalPosIdealWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(-1,-1,-1,-1)) for i in range(3) ] # neg + hgcalPosIdealWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*[27+12*i+4*t+j for j in range(4)])) for i in range(3) ] # pos + hgcalPosIdealWriterConfig.gmtTimeSlices[t].gmtLink = cms.int32(27+36+t) +hgcalPosIdealWriterConfig.gttLink = 27+36+3 +hgcalPosIdealWriterConfig.outputLinksPuppi = cms.vuint32(0,1,2) +hgcalPosIdealWriterConfig.outputLinkEgamma = cms.int32(5) +hgcalPosIdealWriterConfig.inputFileName = cms.string("l1HGCalPos-inputs-ideal") +hgcalPosIdealWriterConfig.outputFileName = cms.string("l1HGCalPos-outputs-ideal") +hgcalNegIdealWriterConfig = hgcalPosIdealWriterConfig.clone( + inputFileName = "", + outputFileName = "l1HGCalNeg-outputs-ideal", + outputRegions = [i for i in range(9)], + outputBoard = 0, +) +## Current configuration for VU9P at B904 for layer1 - layer2 tests with puppi and e/gamma outputs on links 56-59 +hgcalPosVU9PB904egWriterConfig = hgcalWriterConfig_.clone() +for t in range(3): + hgcalPosVU9PB904egWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(-1)) for i in range(9) ] # neg + hgcalPosVU9PB904egWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*2)) for i in range(4) ] # pos, left quads + hgcalPosVU9PB904egWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*25)) for i in range(5) ] # pos, right quads + hgcalPosVU9PB904egWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(-1,-1,-1,-1)) for i in range(3) ] # neg + hgcalPosVU9PB904egWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*[4*11+12*i+4*t+j for j in range(4)])) for i in range(3) ] # pos + hgcalPosVU9PB904egWriterConfig.gmtTimeSlices[t].gmtLink = cms.int32(4+t) +hgcalPosVU9PB904egWriterConfig.gttLink = 4+3 +hgcalPosVU9PB904egWriterConfig.outputLinksPuppi = cms.vuint32(56,57,58) +hgcalPosVU9PB904egWriterConfig.outputLinkEgamma = cms.int32(59) +hgcalPosVU9PB904egWriterConfig.inputFileName = cms.string("l1HGCalPos-inputs-vu9p_B904eg") +hgcalPosVU9PB904egWriterConfig.outputFileName = cms.string("l1HGCalPos-outputs-vu9p_B904eg") +## Current configuration for VU13P +hgcalPosVU13PWriterConfig = hgcalWriterConfig_.clone() +for t in range(3): + hgcalPosVU13PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(-1)) for i in range(9) ] # neg + hgcalPosVU13PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*0)) for i in range(5) ] # pos, left quads + hgcalPosVU13PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*28)) for i in range(4) ] # pos, right quads + hgcalPosVU13PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(-1,-1,-1,-1)) for i in range(3) ] # neg + for isec,q0 in (0,12),(1,17),(2,20): + hgcalPosVU13PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*[4*q0+4*t+j for j in range(4)])) ] # pos + hgcalPosVU13PWriterConfig.gmtTimeSlices[t].gmtLink = cms.int32(4*27+t) +hgcalPosVU13PWriterConfig.gttLink = 4*27+3 +hgcalPosVU13PWriterConfig.outputLinksPuppi = cms.vuint32(0,1,2) +hgcalPosVU13PWriterConfig.outputLinkEgamma = cms.int32(3) +hgcalPosVU13PWriterConfig.inputFileName = cms.string("l1HGCalPos-inputs-vu13p") +hgcalPosVU13PWriterConfig.outputFileName = cms.string("l1HGCalPos-outputs-vu13p") +## Enable both + +## Enable both + +hgcalWriterConfigs = [ + hgcalPosIdealWriterConfig, + hgcalNegIdealWriterConfig, + hgcalPosVU9PB904egWriterConfig, + hgcalPosVU13PWriterConfig +] + +##################################################################################################################### +## Forward HGCal configuration: only outputs for now, 18 regions, 12 candidates x region, 4 output fibers +hgcalNoTKWriterOutputOnlyConfig = cms.PSet( + partition = cms.string("HGCalNoTk"), + outputRegions = cms.vuint32(*range(18)), + nOutputFramesPerBX = cms.uint32(9), + fileFormat = cms.string("EMP"), + maxLinesPerOutputFile = cms.uint32(1024), + eventsPerFile = cms.uint32(eventsPerFile_), + outputLinksPuppi = cms.vuint32(0,1,2,4), + outputFileName = cms.string("l1HGCalNoTk-outputs-ideal") +) + +hgcalNoTKWriterConfigs = [ + hgcalNoTKWriterOutputOnlyConfig +] + +##################################################################################################################### +## HF configuration: not enabled for the moment +##################################################################################################################### +## HF configuration not realistic, 3 links per endcap, write out the layer 1 outputs for now +hfWriterOutputOnly_ = cms.PSet( + partition = cms.string("HF"), + outputLinksPuppi = cms.vuint32(*range(3)), + nOutputFramesPerBX = cms.uint32(9), + fileFormat = cms.string("EMP"), + maxLinesPerOutputFile = cms.uint32(1024), + eventsPerFile = cms.uint32(eventsPerFile_), +) +hfWriterConfigs = [ + hfWriterOutputOnly_.clone( + outputRegions = cms.vuint32(*[9*ie+i for i in range(9)]), + outputFileName = cms.string("l1HF%s-outputs-ideal" % ("Pos" if ie else "Neg")), + ) for ie in range(2) +] + + diff --git a/L1Trigger/Phase2L1ParticleFlow/src/L1TCorrelatorLayer1PatternFileWriter.cc b/L1Trigger/Phase2L1ParticleFlow/src/L1TCorrelatorLayer1PatternFileWriter.cc new file mode 100644 index 0000000000000..750afdbe148ea --- /dev/null +++ b/L1Trigger/Phase2L1ParticleFlow/src/L1TCorrelatorLayer1PatternFileWriter.cc @@ -0,0 +1,355 @@ +#include "L1TCorrelatorLayer1PatternFileWriter.h" +#include "FWCore/Utilities/interface/Exception.h" +#include + +L1TCorrelatorLayer1PatternFileWriter::L1TCorrelatorLayer1PatternFileWriter(const edm::ParameterSet& iConfig, + const l1ct::Event& eventTemplate) + : partition_(parsePartition(iConfig.getParameter("partition"))), + writeInputs_(iConfig.existsAs("inputFileName") && + !iConfig.getParameter("inputFileName").empty()), + writeOutputs_(iConfig.existsAs("outputFileName") && + !iConfig.getParameter("outputFileName").empty()), + outputBoard_(-1), + outputLinkEgamma_(-1), + fileFormat_(iConfig.getParameter("fileFormat")), + eventsPerFile_(iConfig.getParameter("eventsPerFile")), + eventIndex_(0) { + if (writeInputs_) { + nInputFramesPerBX_ = iConfig.getParameter("nInputFramesPerBX"); + + if (partition_ == Partition::Barrel || partition_ == Partition::HGCal) { + configTimeSlices(iConfig, "tf", eventTemplate.raw.track.size(), tfTimeslices_, tfLinksFactor_); + channelSpecsInput_["tf"] = {tmuxFactor_ * tfTimeslices_, tfTimeslices_}; + } + if (partition_ == Partition::Barrel) { + auto sectorConfig = iConfig.getParameter>("gctSectors"); + if (sectorConfig.size() != gctSectors_) + throw cms::Exception("Configuration", "Bad number of GCT sectors"); + for (unsigned int iS = 0; iS < gctSectors_; ++iS) { + auto linksEcal = sectorConfig[iS].getParameter>("gctLinksEcal"); + auto linksHad = sectorConfig[iS].getParameter>("gctLinksHad"); + if (linksEcal.size() != gctLinksEcal_ || linksHad.size() != gctLinksHad_) + throw cms::Exception("Configuration", "Bad number of GCT links"); + unsigned int iLink = 0; + for (unsigned int i = 0; i < gctLinksHad_; ++i, ++iLink) { + if (linksHad[i] != -1) + channelIdsInput_[l1t::demo::LinkId{"gct", iLink + 10 * iS}].push_back(linksHad[i]); + } + for (unsigned int i = 0; i < gctLinksEcal_; ++i) { + if (linksEcal[i] != -1) + channelIdsInput_[l1t::demo::LinkId{"gct", iLink + 10 * iS}].push_back(linksEcal[i]); + } + channelSpecsInput_["gct"] = {tmuxFactor_ * gctTimeslices_, 0}; + } + } + if (partition_ == Partition::HGCal || partition_ == Partition::HGCalNoTk) { + configTimeSlices(iConfig, "hgc", eventTemplate.raw.hgcalcluster.size(), hgcTimeslices_, hgcLinksFactor_); + channelSpecsInput_["hgc"] = {tmuxFactor_ * hgcTimeslices_, hgcTimeslices_}; + } + if (partition_ == Partition::Barrel || partition_ == Partition::HGCal || partition_ == Partition::HGCalNoTk) { + configTimeSlices(iConfig, "gmt", 1, gmtTimeslices_, gmtLinksFactor_); + gmtNumberOfMuons_ = iConfig.getParameter("gmtNumberOfMuons"); + channelSpecsInput_["gmt"] = {tmuxFactor_ * gmtTimeslices_, + gmtTimeslices_ * nInputFramesPerBX_ * tmuxFactor_ - gmtNumberOfMuons_}; + } + if (partition_ == Partition::Barrel || partition_ == Partition::HGCal) { + configTimeSlices(iConfig, "gtt", 1, gttTimeslices_, gttLinksFactor_); + gttLatency_ = iConfig.getParameter("gttLatency"); + gttNumberOfPVs_ = iConfig.getParameter("gttNumberOfPVs"); + channelSpecsInput_["gtt"] = l1t::demo::ChannelSpec{tmuxFactor_, gttTimeslices_, gttLatency_}; + } + inputFileWriter_ = + std::make_unique(l1t::demo::parseFileFormat(fileFormat_), + iConfig.getParameter("inputFileName"), + nInputFramesPerBX_, + tmuxFactor_, + iConfig.getParameter("maxLinesPerInputFile"), + channelIdsInput_, + channelSpecsInput_); + } + + if (writeOutputs_) { + nOutputFramesPerBX_ = iConfig.getParameter("nOutputFramesPerBX"); + + outputRegions_ = iConfig.getParameter>("outputRegions"); + outputLinksPuppi_ = iConfig.getParameter>("outputLinksPuppi"); + for (unsigned int i = 0; i < outputLinksPuppi_.size(); ++i) { + channelIdsOutput_[l1t::demo::LinkId{"puppi", i}].push_back(outputLinksPuppi_[i]); + } + channelSpecsOutput_["puppi"] = {tmuxFactor_, 0}; + nPuppiFramesPerRegion_ = (nOutputFramesPerBX_ * tmuxFactor_) / outputRegions_.size(); + if (partition_ == Partition::Barrel || partition_ == Partition::HGCal) { + outputBoard_ = iConfig.getParameter("outputBoard"); + outputLinkEgamma_ = iConfig.getParameter("outputLinkEgamma"); + nEgammaObjectsOut_ = iConfig.getParameter("nEgammaObjectsOut"); + if (outputLinkEgamma_ != -1) { + channelIdsOutput_[l1t::demo::LinkId{"egamma", 0}].push_back(outputLinkEgamma_); + channelSpecsOutput_["egamma"] = {tmuxFactor_, nOutputFramesPerBX_ * tmuxFactor_ - 3 * nEgammaObjectsOut_}; + } + } + if ((outputBoard_ == -1) != (outputLinkEgamma_ == -1)) { + throw cms::Exception("Configuration", "Inconsistent configuration of outputLinkEgamma, outputBoard"); + } + outputFileWriter_ = + std::make_unique(l1t::demo::parseFileFormat(fileFormat_), + iConfig.getParameter("outputFileName"), + nOutputFramesPerBX_, + tmuxFactor_, + iConfig.getParameter("maxLinesPerOutputFile"), + channelIdsOutput_, + channelSpecsOutput_); + } +} + +L1TCorrelatorLayer1PatternFileWriter::~L1TCorrelatorLayer1PatternFileWriter() {} + +void L1TCorrelatorLayer1PatternFileWriter::write(const l1ct::Event& event) { + if (writeInputs_) { + l1t::demo::EventData inputs; + if (partition_ == Partition::Barrel || partition_ == Partition::HGCal) { + writeTF(event, inputs); + } + if (partition_ == Partition::Barrel) { + writeBarrelGCT(event, inputs); + } + if (partition_ == Partition::HGCal || partition_ == Partition::HGCalNoTk) { + writeHGC(event, inputs); + } + if (partition_ == Partition::Barrel || partition_ == Partition::HGCal || partition_ == Partition::HGCalNoTk) { + writeGMT(event, inputs); + } + if (partition_ == Partition::Barrel || partition_ == Partition::HGCal) { + writeGTT(event, inputs); + } + inputFileWriter_->addEvent(inputs); + } + + if (writeOutputs_) { + l1t::demo::EventData outputs; + writePuppi(event, outputs); + if (outputLinkEgamma_ != -1) + writeEgamma(event, outputs); + outputFileWriter_->addEvent(outputs); + } + + eventIndex_++; + if (eventIndex_ % eventsPerFile_ == 0) { + if (writeInputs_) + inputFileWriter_->flush(); + if (writeOutputs_) + outputFileWriter_->flush(); + } +} + +L1TCorrelatorLayer1PatternFileWriter::Partition L1TCorrelatorLayer1PatternFileWriter::parsePartition( + const std::string& partition) { + if (partition == "Barrel") + return Partition::Barrel; + if (partition == "HGCal") + return Partition::HGCal; + if (partition == "HGCalNoTk") + return Partition::HGCalNoTk; + if (partition == "HF") + return Partition::HF; + throw cms::Exception("Configuration", "Unsupported partition_ '" + partition + "'\n"); +} + +void L1TCorrelatorLayer1PatternFileWriter::configTimeSlices(const edm::ParameterSet& iConfig, + const std::string& prefix, + unsigned int nSectors, + unsigned int nTimeSlices, + unsigned int linksFactor) { + if (nTimeSlices > 1) { + auto timeSliceConfig = iConfig.getParameter>(prefix + "TimeSlices"); + if (timeSliceConfig.size() != nTimeSlices) + throw cms::Exception("Configuration") + << "Mismatched number of " << prefix << "TimeSlices, expected " << nTimeSlices << std::endl; + for (unsigned int iT = 0; iT < nTimeSlices; ++iT) { + configSectors(timeSliceConfig[iT], prefix, nSectors, linksFactor); + } + } else { + configSectors(iConfig, prefix, nSectors, linksFactor); + } +} + +void L1TCorrelatorLayer1PatternFileWriter::configSectors(const edm::ParameterSet& iConfig, + const std::string& prefix, + unsigned int nSectors, + unsigned int linksFactor) { + if (nSectors > 1) { + auto sectorConfig = iConfig.getParameter>(prefix + "Sectors"); + if (sectorConfig.size() != nSectors) + throw cms::Exception("Configuration") + << "Mismatched number of " << prefix << "Sectors, expected " << nSectors << std::endl; + for (unsigned int iS = 0; iS < nSectors; ++iS) { + configLinks(sectorConfig[iS], prefix, linksFactor, linksFactor > 1 ? iS * 10 : iS); + } + } else { + configLinks(iConfig, prefix, linksFactor, 0); + } +} +void L1TCorrelatorLayer1PatternFileWriter::configLinks(const edm::ParameterSet& iConfig, + const std::string& prefix, + unsigned int linksFactor, + unsigned int offset) { + if (linksFactor > 1) { + auto links = iConfig.getParameter>(prefix + "Links"); + if (links.size() != linksFactor) + throw cms::Exception("Configuration") + << "Mismatched number of " << prefix << "Links, expected " << linksFactor << std::endl; + for (unsigned int i = 0; i < linksFactor; ++i) { + if (links[i] != -1) { + channelIdsInput_[l1t::demo::LinkId{prefix, i + offset}].push_back(links[i]); + } + } + } else { + auto link = iConfig.getParameter(prefix + "Link"); + if (link != -1) { + channelIdsInput_[l1t::demo::LinkId{prefix, offset}].push_back(link); + } + } +} + +void L1TCorrelatorLayer1PatternFileWriter::writeTF(const l1ct::Event& event, l1t::demo::EventData& out) { + for (unsigned int iS = 0, nS = event.raw.track.size(); iS < nS; ++iS) { + l1t::demo::LinkId key{"tf", iS}; + if (channelIdsInput_.count(key) == 0) + continue; + std::vector> ret; + std::vector> tracks = event.raw.track[iS].obj; + if (tracks.empty()) + tracks.emplace_back(0); + for (unsigned int i = 0, n = tracks.size(); i < n; ++i) { + const ap_uint<96>& packedtk = tracks[i]; + if (i % 2 == 0) { + ret.emplace_back(packedtk(63, 0)); + ret.emplace_back(0); + ret.back()(31, 0) = packedtk(95, 64); + } else { + ret.back()(63, 32) = packedtk(31, 0); + ret.emplace_back(packedtk(95, 32)); + } + } + out.add(key, ret); + } +} + +void L1TCorrelatorLayer1PatternFileWriter::writeHGC(const l1ct::Event& event, l1t::demo::EventData& out) { + assert(hgcLinksFactor_ == 4); // this piece of code won't really work otherwise + std::vector> ret[hgcLinksFactor_]; + for (unsigned int iS = 0, nS = event.raw.hgcalcluster.size(); iS < nS; ++iS) { + l1t::demo::LinkId key0{"hgc", iS * 10}; + if (channelIdsInput_.count(key0) == 0) + continue; + for (unsigned int il = 0; il < hgcLinksFactor_; ++il) { + // put header word and (dummy) towers + ret[il].resize(31); + ap_uint<64>& head64 = ret[il][0]; + head64(63, 48) = 0xABC0; // Magic + head64(47, 38) = 0; // Opaque + head64(39, 32) = (eventIndex_ % 3) * 6; // TM slice + head64(31, 24) = iS; // Sector + head64(23, 16) = il; // link + head64(15, 0) = eventIndex_ % 3564; // BX + for (unsigned int j = 0; j < 30; ++j) { + ret[il][j + 1] = 4 * j + il; + } + } + for (auto clust : event.raw.hgcalcluster[iS].obj) { + for (unsigned int il = 0; il < hgcLinksFactor_; ++il) { + ret[il].push_back(clust(64 * il + 63, 64 * il)); + } + } + for (unsigned int il = 0; il < hgcLinksFactor_; ++il) { + out.add(l1t::demo::LinkId{"hgc", iS * 10 + il}, ret[il]); + } + } +} + +void L1TCorrelatorLayer1PatternFileWriter::writeBarrelGCT(const l1ct::Event& event, l1t::demo::EventData& out) { + std::vector> ret; + for (unsigned int iS = 0; iS < gctSectors_; ++iS) { + l1t::demo::LinkId key0{"gct", iS * 10}; + if (channelIdsInput_.count(key0) == 0) + continue; + const auto& had = event.decoded.hadcalo[iS]; + const auto& ecal = event.decoded.emcalo[iS]; + unsigned int iLink = 0, nHad = had.size(), nEcal = ecal.size(); + for (unsigned int i = 0; i < gctLinksHad_; ++i, ++iLink) { + ret.clear(); + for (unsigned int iHad = i; i < nHad; iHad += gctLinksHad_) { + ret.emplace_back(had[iHad].pack()); + } + if (ret.empty()) + ret.emplace_back(0); + out.add(l1t::demo::LinkId{"gct", iS * 10 + iLink}, ret); + } + for (unsigned int i = 0; i < gctLinksEcal_; ++i, ++iLink) { + ret.clear(); + for (unsigned int iEcal = i; i < nEcal; iEcal += gctLinksEcal_) { + ret.emplace_back(ecal[iEcal].pack()); + } + if (ret.empty()) + ret.emplace_back(0); + out.add(l1t::demo::LinkId{"gct", iS * 10 + iLink}, ret); + } + } +} + +void L1TCorrelatorLayer1PatternFileWriter::writeGMT(const l1ct::Event& event, l1t::demo::EventData& out) { + l1t::demo::LinkId key{"gmt", 0}; + if (channelIdsInput_.count(key) == 0) + return; + std::vector> muons = event.raw.muon.obj; + muons.resize(gmtNumberOfMuons_, ap_uint<64>(0)); + out.add(key, muons); +} + +void L1TCorrelatorLayer1PatternFileWriter::writeGTT(const l1ct::Event& event, l1t::demo::EventData& out) { + l1t::demo::LinkId key{"gtt", 0}; + if (channelIdsInput_.count(key) == 0) + return; + std::vector> pvs = event.pvs_emu; + pvs.resize(gttNumberOfPVs_, ap_uint<64>(0)); + out.add(key, pvs); +} + +void L1TCorrelatorLayer1PatternFileWriter::writePuppi(const l1ct::Event& event, l1t::demo::EventData& out) { + unsigned int n = outputLinksPuppi_.size(); + std::vector>> links(n); + for (auto ir : outputRegions_) { + auto puppi = event.out[ir].puppi; + unsigned int npuppi = puppi.size(); + for (unsigned int i = 0; i < n * nPuppiFramesPerRegion_; ++i) { + links[i / nPuppiFramesPerRegion_].push_back(i < npuppi ? puppi[i].pack() : ap_uint(0)); + } + } + for (unsigned int i = 0; i < n; ++i) { + out.add(l1t::demo::LinkId{"puppi", i}, links[i]); + } +} + +void L1TCorrelatorLayer1PatternFileWriter::writeEgamma(const l1ct::Event& event, l1t::demo::EventData& out) { + std::vector> ret; + const auto& pho = event.board_out[outputBoard_].egphoton; + const auto& ele = event.board_out[outputBoard_].egelectron; + ret.reserve(3 * nEgammaObjectsOut_); + for (const auto& p : pho) { + ret.emplace_back(p.pack()); + } + ret.resize(nEgammaObjectsOut_, ap_uint<64>(0)); + for (const auto& p : ele) { + ap_uint<128> dword = p.pack(); + ret.push_back(dword(63, 0)); + ret.push_back(dword(127, 64)); + } + ret.resize(3 * nEgammaObjectsOut_, ap_uint<64>(0)); + out.add(l1t::demo::LinkId{"egamma", 0}, ret); +} + +void L1TCorrelatorLayer1PatternFileWriter::flush() { + if (inputFileWriter_) + inputFileWriter_->flush(); + if (outputFileWriter_) + outputFileWriter_->flush(); +} diff --git a/L1Trigger/Phase2L1ParticleFlow/src/L1TCorrelatorLayer1PatternFileWriter.h b/L1Trigger/Phase2L1ParticleFlow/src/L1TCorrelatorLayer1PatternFileWriter.h new file mode 100644 index 0000000000000..1a790b681f0c7 --- /dev/null +++ b/L1Trigger/Phase2L1ParticleFlow/src/L1TCorrelatorLayer1PatternFileWriter.h @@ -0,0 +1,76 @@ +#ifndef L1Trigger_Phase2L1ParticleFlow_L1TCorrelatorLayer1PatternFileWriter_h +#define L1Trigger_Phase2L1ParticleFlow_L1TCorrelatorLayer1PatternFileWriter_h + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "L1Trigger/DemonstratorTools/interface/BoardDataWriter.h" +#include "L1Trigger/DemonstratorTools/interface/utilities.h" + +#include "L1Trigger/Phase2L1ParticleFlow/src/newfirmware/dataformats/layer1_emulator.h" + +class L1TCorrelatorLayer1PatternFileWriter { +public: + L1TCorrelatorLayer1PatternFileWriter(const edm::ParameterSet& iConfig, const l1ct::Event& eventTemplate); + ~L1TCorrelatorLayer1PatternFileWriter(); + + void write(const l1ct::Event& event); + void flush(); + +private: + enum class Partition { Barrel, HGCal, HGCalNoTk, HF }; + + Partition partition_; + const unsigned int tmuxFactor_ = 6; // not really configurable in current architecture + bool writeInputs_, writeOutputs_; + std::map> channelIdsInput_, channelIdsOutput_; + std::map channelSpecsInput_, channelSpecsOutput_; + + const unsigned int tfTimeslices_ = 3, tfLinksFactor_ = 1; // not really configurable in current architecture + const unsigned int hgcTimeslices_ = 3, hgcLinksFactor_ = 4; // not really configurable in current architecture + const unsigned int gctTimeslices_ = 1, gctSectors_ = 3; // not really configurable in current architecture + const unsigned int gctLinksEcal_ = 1, gctLinksHad_ = 2; // could be made configurable later + const unsigned int gmtTimeslices_ = 3, gmtLinksFactor_ = 1; // not really configurable in current architecture + const unsigned int gttTimeslices_ = 1, gttLinksFactor_ = 1; // not really configurable in current architecture + uint32_t gmtNumberOfMuons_; + uint32_t gttNumberOfPVs_; + uint32_t gttLatency_; + + std::vector outputRegions_, outputLinksPuppi_; + unsigned int nPuppiFramesPerRegion_; + int32_t outputBoard_, outputLinkEgamma_; + uint32_t nEgammaObjectsOut_; + + // Common stuff related to the format + uint32_t nInputFramesPerBX_, nOutputFramesPerBX_; + const std::string fileFormat_; + + // final helper + const uint32_t eventsPerFile_; + uint32_t eventIndex_; + std::unique_ptr inputFileWriter_, outputFileWriter_; + + static Partition parsePartition(const std::string& partition); + + void configTimeSlices(const edm::ParameterSet& iConfig, + const std::string& prefix, + unsigned int nSectors, + unsigned int nTimeSlices, + unsigned int linksFactor); + void configSectors(const edm::ParameterSet& iConfig, + const std::string& prefix, + unsigned int nSectors, + unsigned int linksFactor); + void configLinks(const edm::ParameterSet& iConfig, + const std::string& prefix, + unsigned int linksFactor, + unsigned int offset); + + void writeTF(const l1ct::Event& event, l1t::demo::EventData& out); + void writeBarrelGCT(const l1ct::Event& event, l1t::demo::EventData& out); + void writeHGC(const l1ct::Event& event, l1t::demo::EventData& out); + void writeGMT(const l1ct::Event& event, l1t::demo::EventData& out); + void writeGTT(const l1ct::Event& event, l1t::demo::EventData& out); + void writePuppi(const l1ct::Event& event, l1t::demo::EventData& out); + void writeEgamma(const l1ct::Event& event, l1t::demo::EventData& out); +}; + +#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/test/.gitignore b/L1Trigger/Phase2L1ParticleFlow/test/.gitignore new file mode 100644 index 0000000000000..26f0a8dafc043 --- /dev/null +++ b/L1Trigger/Phase2L1ParticleFlow/test/.gitignore @@ -0,0 +1,2 @@ +*.txt +*.dump diff --git a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ctLayer1_dumpFiles_cfg.py b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ctLayer1_dumpFiles_cfg.py index d4101f95efc50..ea57e8b3a4ec6 100644 --- a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ctLayer1_dumpFiles_cfg.py +++ b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ctLayer1_dumpFiles_cfg.py @@ -1,8 +1,6 @@ import FWCore.ParameterSet.Config as cms from Configuration.StandardSequences.Eras import eras -produceEGStage2Pattern = False - process = cms.Process("RESP", eras.Phase2C9) process.load('Configuration.StandardSequences.Services_cff') @@ -41,14 +39,15 @@ process.L1SAMuonsGmt = standaloneMuons.clone() process.l1ctLayer1Barrel9 = process.l1ctLayer1Barrel.clone() +process.l1ctLayer1Barrel9.puAlgo.nFinalSort = 32 process.l1ctLayer1Barrel9.regions[0].etaBoundaries = [ -1.5, -0.5, 0.5, 1.5 ] process.l1ctLayer1Barrel9.boards=cms.VPSet( cms.PSet( - regions=cms.vuint32(list(range(0, 3)) + [x+9 for x in range(0, 3)] + [x+18 for x in range(0, 3)])), + regions=cms.vuint32(*[0+9*ie+i for ie in range(3) for i in range(3)])), cms.PSet( - regions=cms.vuint32(list(range(3, 6)) + [x+9 for x in range(3, 6)] + [x+18 for x in range(3, 6)])), + regions=cms.vuint32(*[3+9*ie+i for ie in range(3) for i in range(3)])), cms.PSet( - regions=cms.vuint32(list(range(6, 9)) + [x+9 for x in range(6, 9)] + [x+18 for x in range(6, 9)])), + regions=cms.vuint32(*[6+9*ie+i for ie in range(3) for i in range(3)])), ) process.runPF = cms.Path( @@ -61,19 +60,13 @@ process.l1ctLayer1Barrel9 + process.l1ctLayer1HGCal + process.l1ctLayer1HGCalNoTK + - process.l1ctLayer1HF + - process.l1ctLayer1 + - process.l1ctLayer2EG - ) - -if produceEGStage2Pattern: - process.l1ctLayer2EG.writeInPattern = True - process.l1ctLayer2EG.writeOutPattern = True - -process.source.fileNames = [ '/store/cmst3/group/l1tr/gpetrucc/11_1_0/NewInputs110X/110121.done/TTbar_PU200/inputs110X_%d.root' % i for i in (1,3,7,8,9) ] -process.pfClustersFromCombinedCaloHCal.phase2barrelCaloTowers = [cms.InputTag("L1EGammaClusterEmuProducer",)] + process.l1ctLayer1HF +) for det in "Barrel", "Barrel9", "HGCal", "HGCalNoTK", "HF": l1pf = getattr(process, 'l1ctLayer1'+det) l1pf.dumpFileName = cms.untracked.string("TTbar_PU200_"+det+".dump") + +process.source.fileNames = [ '/store/cmst3/group/l1tr/gpetrucc/11_1_0/NewInputs110X/110121.done/TTbar_PU200/inputs110X_%d.root' % i for i in (1,3,7,8,9) ] +process.pfClustersFromCombinedCaloHCal.phase2barrelCaloTowers = [cms.InputTag("L1EGammaClusterEmuProducer",)] diff --git a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ctLayer1_patternFiles_fromRAW_cfg.py b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ctLayer1_dumpFiles_fromRAW_cfg.py similarity index 100% rename from L1Trigger/Phase2L1ParticleFlow/test/make_l1ctLayer1_patternFiles_fromRAW_cfg.py rename to L1Trigger/Phase2L1ParticleFlow/test/make_l1ctLayer1_dumpFiles_fromRAW_cfg.py diff --git a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_patternFiles_cfg.py b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_patternFiles_cfg.py new file mode 100644 index 0000000000000..304f72e73d37c --- /dev/null +++ b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_patternFiles_cfg.py @@ -0,0 +1,99 @@ +import FWCore.ParameterSet.Config as cms +from Configuration.StandardSequences.Eras import eras + +process = cms.Process("RESP", eras.Phase2C9) + +process.load('Configuration.StandardSequences.Services_cff') +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") +process.load("FWCore.MessageLogger.MessageLogger_cfi") +process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True), allowUnscheduled = cms.untracked.bool(False) ) +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1000)) +process.MessageLogger.cerr.FwkReport.reportEvery = 1 + +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('file:inputs110X.root'), + inputCommands = cms.untracked.vstring("keep *", + "drop l1tPFClusters_*_*_*", + "drop l1tPFTracks_*_*_*", + "drop l1tPFCandidates_*_*_*") +) + +process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2026D49_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('SimCalorimetry.HcalTrigPrimProducers.hcaltpdigi_cff') # needed to read HCal TPs +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '123X_mcRun4_realistic_v3', '') + +process.load("L1Trigger.Phase2L1ParticleFlow.l1ParticleFlow_cff") +process.load('L1Trigger.Phase2L1ParticleFlow.l1ctLayer1_cff') +process.load('L1Trigger.Phase2L1ParticleFlow.l1ctLayer2EG_cff') +process.load('L1Trigger.L1TTrackMatch.L1GTTInputProducer_cfi') +process.load('L1Trigger.VertexFinder.VertexProducer_cff') +process.L1VertexFinderEmulator = process.VertexProducer.clone() +process.L1VertexFinderEmulator.VertexReconstruction.Algorithm = "fastHistoEmulation" +process.L1VertexFinderEmulator.l1TracksInputTag = cms.InputTag("L1GTTInputProducer", "Level1TTTracksConverted") +from L1Trigger.Phase2L1GMT.gmt_cfi import standaloneMuons +process.L1SAMuonsGmt = standaloneMuons.clone() + +from L1Trigger.Phase2L1ParticleFlow.L1SeedConePFJetProducer_cfi import L1SeedConePFJetEmulatorProducer +from L1Trigger.Phase2L1ParticleFlow.DeregionizerProducer_cfi import DeregionizerProducer +from L1Trigger.Phase2L1ParticleFlow.l1ctJetFileWriter_cfi import l1ctSeededConeJetFileWriter +process.l1ctLayer2Deregionizer = DeregionizerProducer.clone() +process.l1ctLayer2SeedConeJets = L1SeedConePFJetEmulatorProducer.clone(L1PFObject = cms.InputTag('l1ctLayer2Deregionizer', 'Puppi')) +process.l1ctLayer2SeedConeJetWriter = l1ctSeededConeJetFileWriter.clone(jets = "l1ctLayer2SeedConeJets") + +process.l1ctLayer1Barrel9 = process.l1ctLayer1Barrel.clone() +process.l1ctLayer1Barrel9.puAlgo.nFinalSort = 32 +process.l1ctLayer1Barrel9.regions[0].etaBoundaries = [ -1.5, -0.5, 0.5, 1.5 ] +process.l1ctLayer1Barrel9.boards=cms.VPSet( + cms.PSet( + regions=cms.vuint32(*[0+9*ie+i for ie in range(3) for i in range(3)])), + cms.PSet( + regions=cms.vuint32(*[3+9*ie+i for ie in range(3) for i in range(3)])), + cms.PSet( + regions=cms.vuint32(*[6+9*ie+i for ie in range(3) for i in range(3)])), + ) + +from L1Trigger.Phase2L1ParticleFlow.l1ctLayer1_patternWriters_cff import * +process.l1ctLayer1Barrel.patternWriters = cms.untracked.VPSet(*barrelWriterConfigs) +#process.l1ctLayer1Barrel9.patternWriters = cms.untracked.VPSet(*barrel9WriterConfigs) # not enabled for now +process.l1ctLayer1HGCal.patternWriters = cms.untracked.VPSet(*hgcalWriterConfigs) +process.l1ctLayer1HGCalNoTK.patternWriters = cms.untracked.VPSet(*hgcalNoTKWriterConfigs) +process.l1ctLayer1HF.patternWriters = cms.untracked.VPSet(*hfWriterConfigs) + +process.runPF = cms.Path( + process.L1SAMuonsGmt + + process.L1GTTInputProducer + + process.L1VertexFinderEmulator + + process.pfTracksFromL1Tracks + + process.l1ParticleFlow_calo + + process.l1ctLayer1Barrel + + #process.l1ctLayer1Barrel9 + + process.l1ctLayer1HGCal + + process.l1ctLayer1HGCalNoTK + + process.l1ctLayer1HF + + process.l1ctLayer1 + + process.l1ctLayer2EG + + process.l1ctLayer2Deregionizer + + process.l1ctLayer2SeedConeJets + + process.l1ctLayer2SeedConeJetWriter + ) + + +##################################################################################################################### +## Layer 2 e/gamma + +process.l1ctLayer2EG.writeInPattern = True +process.l1ctLayer2EG.writeOutPattern = True +process.l1ctLayer2EG.inPatternFile.maxLinesPerFile = eventsPerFile_*54 +process.l1ctLayer2EG.outPatternFile.maxLinesPerFile = eventsPerFile_*54 + +##################################################################################################################### +## Layer 2 seeded-cone jets +process.l1ctLayer2SeedConeJetWriter.maxLinesPerFile = eventsPerFile_*54 + +process.source.fileNames = [ '/store/cmst3/group/l1tr/gpetrucc/11_1_0/NewInputs110X/110121.done/TTbar_PU200/inputs110X_%d.root' % i for i in (1,3,7,8,9) ] +process.pfClustersFromCombinedCaloHCal.phase2barrelCaloTowers = [cms.InputTag("L1EGammaClusterEmuProducer",)] diff --git a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_patternFiles_fromRAW_cfg.py b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_patternFiles_fromRAW_cfg.py new file mode 100644 index 0000000000000..f3b79f0e67227 --- /dev/null +++ b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_patternFiles_fromRAW_cfg.py @@ -0,0 +1,100 @@ +import FWCore.ParameterSet.Config as cms +from Configuration.StandardSequences.Eras import eras + +process = cms.Process("RESP", eras.Phase2C9) + +process.load('Configuration.StandardSequences.Services_cff') +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") +process.load("FWCore.MessageLogger.MessageLogger_cfi") +process.options = cms.untracked.PSet( + wantSummary = cms.untracked.bool(True), + numberOfThreads = cms.untracked.uint32(2), + numberOfStreams = cms.untracked.uint32(1), +) +process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(100)) +process.MessageLogger.cerr.FwkReport.reportEvery = 1 + +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('/store/mc/Phase2HLTTDRWinter20DIGI/TT_TuneCP5_14TeV-powheg-pythia8/GEN-SIM-DIGI-RAW/PU200_110X_mcRun4_realistic_v3-v2/110000/005E74D6-B50E-674E-89E6-EAA9A617B476.root',) +) + +process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2026D49_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '123X_mcRun4_realistic_v3', '') + +process.load('SimCalorimetry.HcalTrigPrimProducers.hcaltpdigi_cff') # needed to read HCal TPs +process.load('CalibCalorimetry.CaloTPG.CaloTPGTranscoder_cfi') +process.load('Configuration.StandardSequences.SimL1Emulator_cff') +process.load('L1Trigger.TrackTrigger.TrackTrigger_cff') +process.load("L1Trigger.TrackFindingTracklet.L1HybridEmulationTracks_cff") +process.load("L1Trigger.TrackerDTC.ProducerES_cff") +process.load("L1Trigger.TrackerDTC.ProducerED_cff") +process.load("RecoVertex.BeamSpotProducer.BeamSpot_cfi") + +from L1Trigger.Phase2L1ParticleFlow.L1SeedConePFJetProducer_cfi import L1SeedConePFJetEmulatorProducer +from L1Trigger.Phase2L1ParticleFlow.DeregionizerProducer_cfi import DeregionizerProducer +from L1Trigger.Phase2L1ParticleFlow.l1ctJetFileWriter_cfi import l1ctSeededConeJetFileWriter +process.l1ctLayer2Deregionizer = DeregionizerProducer.clone() +process.l1ctLayer2SeedConeJets = L1SeedConePFJetEmulatorProducer.clone(L1PFObject = cms.InputTag('l1ctLayer2Deregionizer', 'Puppi')) +process.l1ctLayer2SeedConeJetWriter = l1ctSeededConeJetFileWriter.clone(jets = "l1ctLayer2SeedConeJets") + +process.l1ctLayer1Barrel9 = process.l1ctLayer1Barrel.clone() +process.l1ctLayer1Barrel9.puAlgo.nFinalSort = 32 +process.l1ctLayer1Barrel9.regions[0].etaBoundaries = [ -1.5, -0.5, 0.5, 1.5 ] +process.l1ctLayer1Barrel9.boards=cms.VPSet( + cms.PSet( + regions=cms.vuint32(*[0+9*ie+i for ie in range(3) for i in range(3)])), + cms.PSet( + regions=cms.vuint32(*[3+9*ie+i for ie in range(3) for i in range(3)])), + cms.PSet( + regions=cms.vuint32(*[6+9*ie+i for ie in range(3) for i in range(3)])), + ) + +from L1Trigger.Phase2L1ParticleFlow.l1ctLayer1_patternWriters_cff import * +process.l1ctLayer1Barrel.patternWriters = cms.untracked.VPSet(*barrelWriterConfigs) +#process.l1ctLayer1Barrel9.patternWriters = cms.untracked.VPSet(*barrel9WriterConfigs) # not enabled for now +process.l1ctLayer1HGCal.patternWriters = cms.untracked.VPSet(*hgcalWriterConfigs) +process.l1ctLayer1HGCalNoTK.patternWriters = cms.untracked.VPSet(*hgcalNoTKWriterConfigs) +process.l1ctLayer1HF.patternWriters = cms.untracked.VPSet(*hfWriterConfigs) + +process.pfInputsTask = cms.Task( + process.TTClustersFromPhase2TrackerDigis, + process.TTStubsFromPhase2TrackerDigis, + process.TrackerDTCProducer, + process.offlineBeamSpot, + process.TTTracksFromTrackletEmulation, + process.SimL1EmulatorTask +) +process.runPF = cms.Path( + process.l1ctLayer1Barrel + + #process.l1ctLayer1Barrel9 + + process.l1ctLayer1HGCal + + process.l1ctLayer1HGCalNoTK + + process.l1ctLayer1HF + + process.l1ctLayer1 + + process.l1ctLayer2EG + + process.l1ctLayer2Deregionizer + + process.l1ctLayer2SeedConeJets + + process.l1ctLayer2SeedConeJetWriter + ) +process.runPF.associate(process.pfInputsTask) +process.schedule = cms.Schedule(process.runPF) + + +##################################################################################################################### +## Layer 2 e/gamma + +process.l1ctLayer2EG.writeInPattern = True +process.l1ctLayer2EG.writeOutPattern = True +process.l1ctLayer2EG.inPatternFile.maxLinesPerFile = eventsPerFile_*54 +process.l1ctLayer2EG.outPatternFile.maxLinesPerFile = eventsPerFile_*54 + +##################################################################################################################### +## Layer 2 seeded-cone jets +process.l1ctLayer2SeedConeJetWriter.maxLinesPerFile = eventsPerFile_*54