33 ap_uint<64> encodeLayer1(
const EGIsoObjEmu &egiso)
const;
36 std::vector<ap_uint<64>> encodeLayer1(
const std::vector<EGIsoObjEmu> &
photons)
const;
37 std::vector<ap_uint<64>> encodeLayer1(
const std::vector<EGIsoEleObjEmu> &
electrons)
const;
39 void encodeLayer1EgObjs(
unsigned int nObj,
41 const std::vector<EGIsoObjEmu> &
photons,
42 const std::vector<EGIsoEleObjEmu> &
electrons)
const;
46 void endJob()
override;
62 for (
const auto &conf : confs) {
63 const auto &producer_tag = conf.getParameter<
edm::InputTag>(
"pfProducer");
64 tokensAndRegions_.push_back(std::make_pair(
65 prod->consumes<
T>(
edm::InputTag(producer_tag.label(), producer_tag.instance(), producer_tag.process())),
66 conf.getParameter<std::vector<int>>(
"regions")));
81 nEvPerFile_(conf.getParameter<uint32_t>(
"eventsPerFile")),
85 std::map<l1t::demo::LinkId, std::pair<l1t::demo::ChannelSpec, std::vector<size_t>>> channelSpecs;
87 for (
const auto &channelConf : conf.
getParameter<std::vector<edm::ParameterSet>>(
"channels")) {
88 unsigned int inTMUX = channelConf.getParameter<uint32_t>(
"TMUX");
89 unsigned int eventGap =
90 inTMUX *
nFramesPerBX - channelConf.getParameter<uint32_t>(
"nWords");
93 std::vector<uint32_t> chns = channelConf.getParameter<std::vector<uint32_t>>(
"channels");
96 unsigned
int chId = channelConf.getParameter<uint32_t>("id");
99 std::vector<size_t>(std::begin(chns), std::end(chns)));
110 }
else if (inTMUX == 18) {
119 }
else if (
interface ==
"eglayer1Endcap") {
130 dataWriter_ = std::make_unique<l1t::demo::BoardDataWriter>(
146 dataWriter_->addEvent(eventData);
148 if (enventIndex_ % nEvPerFile_ == 0)
149 dataWriter_->flush();
152 void flush() { dataWriter_->flush(); }
156 return region2link_.at(
region);
167 template <
class TT,
class T>
171 std::unique_ptr<TT> &
out)
const {
173 for (
const auto &tokenAndRegions :
instance.tokensAndRegions()) {
175 populate(
out,
handle, tokenAndRegions.second, constituentsPtrs);
179 template <
class TT,
class T>
182 const std::vector<int> &
regions,
185 for (
unsigned int iBoard = 0, nBoard =
in->nRegions(); iBoard < nBoard; ++iBoard) {
187 int regionID =
regions[iBoard];
192 convertToEmu(
obj, constituentsPtrs,
out->at(regionID));
199 const std::vector<int> &
regions,
201 for (
int bx =
in->getFirstBX();
bx <=
in->getLastBX();
bx++) {
202 for (
auto egee_itr =
in->begin(
bx); egee_itr !=
in->end(
bx); egee_itr++) {
203 out->push_back(
bx, *egee_itr);
208 template <
class Tout,
class Tin>
212 const std::vector<Tin> emulated)
const {
213 auto egobjs = std::make_unique<Tout>();
214 for (
const auto &emu : emulated) {
217 auto obj = convertFromEmu(emu, constituentsPtrs);
218 egobjs->push_back(
obj);
247 tkEGInstanceLabel_(conf.getParameter<
std::
string>(
"egStaInstanceLabel")),
248 tkEmInstanceLabel_(conf.getParameter<
std::
string>(
"tkEmInstanceLabel")),
249 tkEleInstanceLabel_(conf.getParameter<
std::
string>(
"tkEleInstanceLabel")),
253 l2EgPuppiIsoAlgo_(conf.getParameter<
edm::
ParameterSet>(
"puppiIsoParametersTkEm")),
254 l2ElePuppiIsoAlgo_(conf.getParameter<
edm::
ParameterSet>(
"puppiIsoParametersTkEle")),
255 doInPtrn_(conf.getParameter<
bool>(
"writeInPattern")),
256 doOutPtrn_(conf.getParameter<
bool>(
"writeOutPattern")),
258 outPtrnWrt_(nullptr) {
275 ret(EGIsoObjEmu::BITWIDTH, 0) = egiso.
pack();
280 ap_uint<128>
ret = 0;
281 ret(EGIsoEleObjEmu::BITWIDTH, 0) = egiso.
pack();
286 std::vector<ap_uint<64>>
ret;
288 for (
const auto &phot :
photons) {
295 std::vector<ap_uint<64>>
ret;
299 ret.push_back(eleword(63, 0));
300 ret.push_back(eleword(127, 64));
307 const std::vector<EGIsoObjEmu> &
photons,
308 const std::vector<EGIsoEleObjEmu> &
electrons)
const {
310 encoded_photons.resize(nObj, {0});
312 encoded_eles.resize(2 * nObj, {0});
314 std::copy(encoded_photons.begin(), encoded_photons.end(), std::back_inserter(
data));
315 std::copy(encoded_eles.begin(), encoded_eles.end(), std::back_inserter(
data));
321 auto outEgs = std::make_unique<BXVector<l1t::EGamma>>();
331 std::map<unsigned int, l1t::demo::LinkId> regio2link;
334 for (
unsigned int ireg = 0; ireg <
regions->size(); ireg++) {
335 const auto &linkData =
inPtrnWrt_->region2Link(ireg);
336 std::vector<ap_uint<64>>
data;
338 if (inData.
has(linkData.linkId))
339 data = inData.
at(linkData.linkId);
341 data.resize(
data.size() + linkData.nTrailingWords, {0});
342 inData.
add(linkData.linkId,
data);
347 std::vector<EGIsoObjEmu> out_photons_emu;
348 std::vector<EGIsoEleObjEmu> out_eles_emu;
384 constituentsPtrs.push_back(std::make_pair(tkele.
egCaloPtr(), tkele.
trkPtr()));
385 emu.
src_idx = constituentsPtrs.size() - 1;
402 emu.
src_idx = constituentsPtrs.size() - 1;
414 for (
const auto &l1PFCand : l1PFCands) {
416 obj.initFromBits(l1PFCand.encodedPuppi64());
417 puppiObjs.emplace_back(
obj);
425 const auto gteg = egiso.
toGT();
430 constituentsPtrs[egiso.
src_idx].first,
431 egiso.
floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIso),
432 egiso.
floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIsoPV));
434 tkem.setPFIsol(egiso.
floatRelIso(l1ct::EGIsoObjEmu::IsoType::PfIso));
435 tkem.setPFIsolPV(egiso.
floatRelIso(l1ct::EGIsoObjEmu::IsoType::PfIsoPV));
436 tkem.setPuppiIsol(egiso.
floatRelIso(l1ct::EGIsoObjEmu::IsoType::PuppiIso));
445 const auto gteg = egele.
toGT();
450 constituentsPtrs[egele.
src_idx].first,
451 constituentsPtrs[egele.
src_idx].second,
452 egele.
floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::TkIso));
454 tkele.setPFIsol(egele.
floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PfIso));
455 tkele.setPuppiIsol(egele.
floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PuppiIso));
std::unique_ptr< l1t::demo::BoardDataWriter > dataWriter_
l1t::TkEm convertFromEmu(const l1ct::EGIsoObjEmu &emu, const ConstituentPtrVector &constituentsPtrs) const
std::vector< ap_uint< 64 > > encodeLayer2EgObjs(const std::vector< EGIsoObjEmu > &photons, const std::vector< EGIsoEleObjEmu > &electrons) const
std::string tkEGInstanceLabel_
float floatPhi(phi_t phi)
T getParameter(std::string const &) const
void convertToPuppi(const l1t::PFCandidateCollection &l1PFCands, l1ct::PuppiObjs &puppiObjs) const
l1gt::Electron toGT() const
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Logical ID for link within any given time slice (e.g. ["tracks", 0] -> ["tracks", 17] for links from ...
std::vector< std::pair< edm::Ptr< l1t::L1Candidate >, edm::Ptr< L1TTTrackType > > > ConstituentPtrVector
float floatEta(eta_t eta)
void setHwIso(IsoType type, iso_t value)
double pt() const final
transverse momentum
const l1t::PFTrack * srcTrack
static PFTauRenderPlugin instance
ret
prodAgent to be discontinued
std::vector< l1t::PFCandidate > PFCandidateCollection
PatternWriter(const edm::ParameterSet &conf)
ap_uint< BITWIDTH > pack() const
std::vector< PuppiObj > PuppiObjs
std::unique_ptr< PatternWriter > outPtrnWrt_
void convertToEmu(const l1t::TkElectron &tkele, ConstituentPtrVector &constituentsPtrs, l1ct::OutputBoard &boarOut) const
FileFormat parseFileFormat(const std::string &)
std::vector< EGIsoEleObjEmu > egelectron
const l1t::PFCluster * srcCluster
void add(const LinkId &, const std::vector< ap_uint< 64 >> &)
float floatIDScore() const
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
edm::EDGetTokenT< std::vector< l1t::PFCandidate > > pfObjsToken_
float floatRelIso(IsoType type) const
void populate(std::unique_ptr< BXVector< l1t::EGamma >> &out, const edm::Handle< BXVector< l1t::EGamma >> &in, const std::vector< int > ®ions, ConstituentPtrVector &constituentsPtrs) const
TTTrack< Ref_Phase2TrackerDigi_ > L1TTTrackType
float floatRelIso(IsoType type) const
void run(const std::vector< l1ct::OutputBoard > &in, std::vector< EGIsoObjEmu > &out_photons, std::vector< EGIsoEleObjEmu > &out_eles) const
PFInstanceInputs< l1t::TkElectronRegionalOutput > tkEleInputs_
~L1TCtL2EgProducer() override
unsigned int nInputRegions() const
const std::vector< ap_uint< 64 > > & at(const LinkId &) const
ap_uint< 64 > encodeLayer1(const EGIsoObjEmu &egiso) const
void populate(std::unique_ptr< T > &out, const edm::Handle< TT > &in, const std::vector< int > ®ions, ConstituentPtrVector &constituentsPtrs) const
ap_uint< N > egBinaryWord() const
void setHwIso(IsoType type, iso_t value)
void encodeLayer1EgObjs(unsigned int nObj, std::vector< ap_uint< 64 >> &data, const std::vector< EGIsoObjEmu > &photons, const std::vector< EGIsoEleObjEmu > &electrons) const
ap_uint< BITWIDTH > pack() const
void initFromBits(const ap_uint< BITWIDTH > &src)
unsigned int nInputObjPerRegion() const
PFInstanceInputs< l1t::TkEmRegionalOutput > tkEmInputs_
l1gt::Photon toGT() const
const edm::Ptr< L1Candidate > & egCaloPtr() const
#define DEFINE_FWK_MODULE(type)
l1ct::L2EgSorterEmulator l2egsorter
std::string tkEleInstanceLabel_
void merge(const PFInstanceInputs< T > &instance, edm::Event &iEvent, ConstituentPtrVector &constituentsPtrs, std::unique_ptr< TT > &out) const
Class to store the L1 Track Trigger tracks.
std::unique_ptr< PatternWriter > inPtrnWrt_
void initFromBits(const ap_uint< BITWIDTH > &src)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
std::vector< EGIsoObjEmu > egphoton
char data[epos_bytes_allocation]
l1ct::L1EGPuppiIsoAlgo l2ElePuppiIsoAlgo_
const edm::Ptr< L1TTTrackType > & trkPtr() const
const l1t::PFCluster * srcCluster
L1TCtL2EgProducer(const edm::ParameterSet &)
l1ct::L2EgEncoderEmulator l2encoder
std::vector< RegionLinkMetadata > region2link_
PFInstanceInputs< BXVector< l1t::EGamma > > tkEGInputs_
void run(const EGIsoObjsEmu &l1EGs, const PuppiObjs &l1PFCands, EGIsoObjsEmu &outL1EGs, z0_t z0=0) const
Class representing information phase-2 ATCA I/O data corresponding to a single event, with logical channel IDs (essentially string-uint pairs, e.g. tracks-0 to tracks-17).
void putEgObjects(edm::Event &iEvent, const ConstituentPtrVector &constituentsPtrs, const std::string &label, const std::vector< Tin > emulated) const
void addEvent(const l1t::demo::EventData &eventData)
const RegionLinkMetadata & region2Link(unsigned int region) const
bool has(const LinkId &) const
l1ct::L1EGPuppiIsoAlgo l2EgPuppiIsoAlgo_
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
std::string tkEmInstanceLabel_