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 std::vector<ap_uint<64>> encodeLayer1EgObjs(
unsigned int nObj,
40 const std::vector<EGIsoObjEmu> &
photons,
41 const std::vector<EGIsoEleObjEmu> &
electrons)
const;
45 void endJob()
override;
61 for (
const auto &conf : confs) {
62 const auto &producer_tag = conf.getParameter<
edm::InputTag>(
"pfProducer");
63 tokensAndChannels_.push_back(std::make_pair(
64 prod->consumes<
T>(
edm::InputTag(producer_tag.label(), producer_tag.instance(), producer_tag.process())),
65 conf.getParameter<std::vector<int>>(
"channels")));
80 std::map<l1t::demo::LinkId, std::pair<l1t::demo::ChannelSpec, std::vector<size_t>>> channelSpecs;
82 for (
const auto &channelConf : conf.
getParameter<std::vector<edm::ParameterSet>>(
"channels")) {
83 unsigned int inTMUX = channelConf.getParameter<uint32_t>(
"TMUX");
84 unsigned int eventGap =
85 inTMUX *
nFramesPerBX - channelConf.getParameter<uint32_t>(
"nWords");
87 std::vector<uint32_t> chns = channelConf.getParameter<std::vector<uint32_t>>(
"channels");
89 channelConf.getParameter<uint32_t>(
"id")}] =
91 std::vector<size_t>(std::begin(chns), std::end(chns)));
94 dataWriter_ = std::make_unique<l1t::demo::BoardDataWriter>(
106 void flush() { dataWriter_->flush(); }
112 template <
class TT,
class T>
116 std::unique_ptr<TT> &
out)
const {
118 for (
const auto &tokenAndChannel :
instance.tokensAndChannels()) {
120 populate(
out,
handle, tokenAndChannel.second, constituentsPtrs);
124 template <
class TT,
class T>
127 const std::vector<int> &
links,
130 for (
unsigned int iBoard = 0, nBoard =
in->nRegions(); iBoard < nBoard; ++iBoard) {
132 int linkID =
links[iBoard];
137 convertToEmu(
obj, constituentsPtrs,
out->at(linkID));
144 const std::vector<int> &
links,
146 for (
int bx =
in->getFirstBX();
bx <=
in->getLastBX();
bx++) {
147 for (
auto egee_itr =
in->begin(
bx); egee_itr !=
in->end(
bx); egee_itr++) {
148 out->push_back(
bx, *egee_itr);
153 template <
class Tout,
class Tin>
157 const std::vector<Tin> emulated)
const {
158 auto egobjs = std::make_unique<Tout>();
159 for (
const auto &emu : emulated) {
162 auto obj = convertFromEmu(emu, constituentsPtrs);
163 egobjs->push_back(
obj);
192 tkEGInstanceLabel_(conf.getParameter<
std::
string>(
"egStaInstanceLabel")),
193 tkEmInstanceLabel_(conf.getParameter<
std::
string>(
"tkEmInstanceLabel")),
194 tkEleInstanceLabel_(conf.getParameter<
std::
string>(
"tkEleInstanceLabel")),
198 l2EgPuppiIsoAlgo_(conf.getParameter<
edm::
ParameterSet>(
"puppiIsoParametersTkEm")),
199 l2ElePuppiIsoAlgo_(conf.getParameter<
edm::
ParameterSet>(
"puppiIsoParametersTkEle")),
200 doInPtrn_(conf.getParameter<
bool>(
"writeInPattern")),
201 doOutPtrn_(conf.getParameter<
bool>(
"writeOutPattern")),
203 outPtrnWrt_(nullptr) {
220 ret(EGIsoObjEmu::BITWIDTH, 0) = egiso.
pack();
225 ap_uint<128>
ret = 0;
226 ret(EGIsoEleObjEmu::BITWIDTH, 0) = egiso.
pack();
231 std::vector<ap_uint<64>>
ret;
233 for (
const auto &phot :
photons) {
240 std::vector<ap_uint<64>>
ret;
244 ret.push_back(eleword(63, 0));
245 ret.push_back(eleword(127, 64));
251 const std::vector<EGIsoObjEmu> &
photons,
252 const std::vector<EGIsoEleObjEmu> &
electrons)
const {
253 std::vector<ap_uint<64>>
ret;
255 encoded_photons.resize(nObj, {0});
257 encoded_eles.resize(2 * nObj, {0});
259 std::copy(encoded_photons.begin(), encoded_photons.end(), std::back_inserter(
ret));
260 std::copy(encoded_eles.begin(), encoded_eles.end(), std::back_inserter(
ret));
268 auto outEgs = std::make_unique<BXVector<l1t::EGamma>>();
279 for (
unsigned int ibrd = 0; ibrd <
boards->size(); ibrd++) {
287 std::vector<EGIsoObjEmu> out_photons_emu;
288 std::vector<EGIsoEleObjEmu> out_eles_emu;
324 constituentsPtrs.push_back(std::make_pair(tkele.
egCaloPtr(), tkele.
trkPtr()));
325 emu.
src_idx = constituentsPtrs.size() - 1;
342 emu.
src_idx = constituentsPtrs.size() - 1;
354 for (
const auto &l1PFCand : l1PFCands) {
356 obj.initFromBits(l1PFCand.encodedPuppi64());
357 puppiObjs.emplace_back(
obj);
365 const auto gteg = egiso.
toGT();
370 constituentsPtrs[egiso.
src_idx].first,
371 egiso.
floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIso),
372 egiso.
floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIsoPV));
374 tkem.setPFIsol(egiso.
floatRelIso(l1ct::EGIsoObjEmu::IsoType::PfIso));
375 tkem.setPFIsolPV(egiso.
floatRelIso(l1ct::EGIsoObjEmu::IsoType::PfIsoPV));
376 tkem.setPuppiIsol(egiso.
floatRelIso(l1ct::EGIsoObjEmu::IsoType::PuppiIso));
385 const auto gteg = egele.
toGT();
390 constituentsPtrs[egele.
src_idx].first,
391 constituentsPtrs[egele.
src_idx].second,
392 egele.
floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::TkIso));
394 tkele.setPFIsol(egele.
floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PfIso));
395 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
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
ap_uint< 64 > encodeLayer1(const EGIsoObjEmu &egiso) const
void populate(std::unique_ptr< T > &out, const edm::Handle< TT > &in, const std::vector< int > &links, ConstituentPtrVector &constituentsPtrs) const
ap_uint< N > egBinaryWord() const
void setHwIso(IsoType type, iso_t value)
ap_uint< BITWIDTH > pack() const
void initFromBits(const ap_uint< BITWIDTH > &src)
unsigned int nInputBoards() const
PFInstanceInputs< l1t::TkEmRegionalOutput > tkEmInputs_
l1gt::Photon toGT() const
const edm::Ptr< L1Candidate > & egCaloPtr() const
#define DEFINE_FWK_MODULE(type)
void populate(std::unique_ptr< BXVector< l1t::EGamma >> &out, const edm::Handle< BXVector< l1t::EGamma >> &in, const std::vector< int > &links, ConstituentPtrVector &constituentsPtrs) const
l1ct::L2EgSorterEmulator l2egsorter
unsigned int nInputObjPerBoard() const
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
l1ct::L1EGPuppiIsoAlgo l2ElePuppiIsoAlgo_
const edm::Ptr< L1TTTrackType > & trkPtr() const
const l1t::PFCluster * srcCluster
L1TCtL2EgProducer(const edm::ParameterSet &)
l1ct::L2EgEncoderEmulator l2encoder
std::vector< ap_uint< 64 > > encodeLayer1EgObjs(unsigned int nObj, const std::vector< EGIsoObjEmu > &photons, const std::vector< EGIsoEleObjEmu > &electrons) const
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)
l1ct::L1EGPuppiIsoAlgo l2EgPuppiIsoAlgo_
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
std::string tkEmInstanceLabel_