CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
L1TCtL2EgProducer Class Reference
Inheritance diagram for L1TCtL2EgProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

class  PatternWriter
 
class  PFInstanceInputs
 
struct  RefRemapper
 

Public Member Functions

 L1TCtL2EgProducer (const edm::ParameterSet &)
 
 ~L1TCtL2EgProducer () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

l1t::TkEm convertFromEmu (const l1ct::EGIsoObjEmu &emu, const RefRemapper &refRemapper) const
 
l1t::TkElectron convertFromEmu (const l1ct::EGIsoEleObjEmu &emu, const RefRemapper &refRemapper) const
 
void convertToEmu (const l1t::TkElectron &tkele, RefRemapper &refRemapper, l1ct::OutputBoard &boarOut) const
 
void convertToEmu (const l1t::TkEm &tkele, RefRemapper &refRemapper, l1ct::OutputBoard &boarOut) const
 
ap_uint< 64 > encodeLayer1 (const EGIsoObjEmu &egiso) const
 
ap_uint< 128 > encodeLayer1 (const EGIsoEleObjEmu &egiso) const
 
std::vector< ap_uint< 64 > > encodeLayer1 (const std::vector< EGIsoObjEmu > &photons) const
 
std::vector< ap_uint< 64 > > encodeLayer1 (const std::vector< EGIsoEleObjEmu > &electrons) const
 
std::vector< ap_uint< 64 > > encodeLayer1EgObjs (unsigned int nObj, const std::vector< EGIsoObjEmu > &photons, const std::vector< EGIsoEleObjEmu > &electrons) const
 
void endJob () override
 
template<class TT , class T >
void merge (const PFInstanceInputs< T > &instance, edm::Event &iEvent, RefRemapper &refRemapper, std::unique_ptr< TT > &out) const
 
template<class TT , class T >
void populate (std::unique_ptr< T > &out, const edm::Handle< TT > &in, const std::vector< int > &links, RefRemapper &refRemapper) const
 
void populate (std::unique_ptr< BXVector< l1t::EGamma >> &out, const edm::Handle< BXVector< l1t::EGamma >> &in, const std::vector< int > &links, RefRemapper &refRemapper) const
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
template<class Tout , class Tin >
void putEgObjects (edm::Event &iEvent, const RefRemapper &refRemapper, const std::string &label, const std::vector< Tin > emulated) const
 
template<class TT >
void remapRefs (edm::Event &iEvent, std::unique_ptr< TT > &out, RefRemapper &refRemapper) const
 
void remapRefs (edm::Event &iEvent, std::unique_ptr< BXVector< l1t::EGamma >> &out, RefRemapper &refRemapper) const
 

Private Attributes

bool doInPtrn_
 
bool doOutPtrn_
 
std::unique_ptr< PatternWriterinPtrnWrt_
 
l1ct::L2EgSorterEmulator l2egsorter
 
l1ct::L2EgEncoderEmulator l2encoder
 
std::unique_ptr< PatternWriteroutPtrnWrt_
 
PFInstanceInputs< BXVector< l1t::EGamma > > tkEGInputs_
 
std::string tkEGInstanceLabel_
 
PFInstanceInputs< l1t::TkElectronRegionalOutputtkEleInputs_
 
std::string tkEleInstanceLabel_
 
PFInstanceInputs< l1t::TkEmRegionalOutputtkEmInputs_
 
std::string tkEmInstanceLabel_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 27 of file L1TCtL2EgProducer.cc.

Constructor & Destructor Documentation

◆ L1TCtL2EgProducer()

L1TCtL2EgProducer::L1TCtL2EgProducer ( const edm::ParameterSet conf)
explicit

Definition at line 203 of file L1TCtL2EgProducer.cc.

References doInPtrn_, doOutPtrn_, edm::ParameterSet::getParameter(), inPtrnWrt_, outPtrnWrt_, tkEGInstanceLabel_, tkEleInstanceLabel_, and tkEmInstanceLabel_.

204  : tkEGInputs_(this, conf.getParameter<std::vector<edm::ParameterSet>>("tkEgs")),
205  tkEmInputs_(this, conf.getParameter<std::vector<edm::ParameterSet>>("tkEms")),
206  tkEleInputs_(this, conf.getParameter<std::vector<edm::ParameterSet>>("tkElectrons")),
207  tkEGInstanceLabel_(conf.getParameter<std::string>("egStaInstanceLabel")),
208  tkEmInstanceLabel_(conf.getParameter<std::string>("tkEmInstanceLabel")),
209  tkEleInstanceLabel_(conf.getParameter<std::string>("tkEleInstanceLabel")),
210  l2egsorter(conf.getParameter<edm::ParameterSet>("sorter")),
211  l2encoder(conf.getParameter<edm::ParameterSet>("encoder")),
212  doInPtrn_(conf.getParameter<bool>("writeInPattern")),
213  doOutPtrn_(conf.getParameter<bool>("writeOutPattern")),
214  inPtrnWrt_(nullptr),
215  outPtrnWrt_(nullptr) {
216  produces<BXVector<l1t::EGamma>>(tkEGInstanceLabel_);
217  produces<l1t::TkEmCollection>(tkEmInstanceLabel_);
218  produces<l1t::TkElectronCollection>(tkEleInstanceLabel_);
219 
220  if (doInPtrn_) {
221  inPtrnWrt_ = std::make_unique<PatternWriter>(conf.getParameter<edm::ParameterSet>("inPatternFile"));
222  }
223  if (doOutPtrn_) {
224  outPtrnWrt_ = std::make_unique<PatternWriter>(conf.getParameter<edm::ParameterSet>("outPatternFile"));
225  }
226 }
std::string tkEGInstanceLabel_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unique_ptr< PatternWriter > outPtrnWrt_
PFInstanceInputs< l1t::TkElectronRegionalOutput > tkEleInputs_
PFInstanceInputs< l1t::TkEmRegionalOutput > tkEmInputs_
l1ct::L2EgSorterEmulator l2egsorter
std::string tkEleInstanceLabel_
std::unique_ptr< PatternWriter > inPtrnWrt_
l1ct::L2EgEncoderEmulator l2encoder
PFInstanceInputs< BXVector< l1t::EGamma > > tkEGInputs_
std::string tkEmInstanceLabel_

◆ ~L1TCtL2EgProducer()

L1TCtL2EgProducer::~L1TCtL2EgProducer ( )
override

Definition at line 228 of file L1TCtL2EgProducer.cc.

228 {}

Member Function Documentation

◆ convertFromEmu() [1/2]

l1t::TkEm L1TCtL2EgProducer::convertFromEmu ( const l1ct::EGIsoObjEmu emu,
const RefRemapper refRemapper 
) const
private

Definition at line 365 of file L1TCtL2EgProducer.cc.

References l1gt::Scales::floatEta(), l1gt::Scales::floatPhi(), l1gt::Scales::floatPt(), l1ct::EGIsoObjEmu::floatRelIso(), L1TCtL2EgProducer::RefRemapper::origRefAndPtr, l1t::L1Candidate::setHwQual(), l1ct::EGIsoObjEmu::sta_idx, and l1ct::EGIsoObj::toGT().

365  {
366  // std::cout << "[convertFromEmu] TkEm pt: " << egiso.hwPt << " eta: " << egiso.hwEta << " phi: " << egiso.hwPhi << " staidx: " << egiso.sta_idx << std::endl;
367  // NOTE: the TkEM object is created with the accuracy as in GT object (not the Correlator internal one)!
368  const auto gteg = egiso.toGT();
370  l1gt::Scales::floatPt(gteg.v3.pt), l1gt::Scales::floatEta(gteg.v3.eta), l1gt::Scales::floatPhi(gteg.v3.phi), 0.);
371  // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso
373  refRemapper.origRefAndPtr[egiso.sta_idx].first,
374  egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIso),
375  egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIsoPV));
376  tkem.setHwQual(gteg.quality);
377  tkem.setPFIsol(egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::PfIso));
378  tkem.setPFIsolPV(egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::PfIsoPV));
379  tkem.setEgBinaryWord(gteg.pack());
380  return tkem;
381 }
float floatPhi(phi_t phi)
Definition: gt_datatypes.h:46
float floatEta(eta_t eta)
Definition: gt_datatypes.h:45
void setHwQual(int qual)
Definition: L1Candidate.h:31
Definition: TkEm.h:20
float floatPt(pt_t pt)
Definition: gt_datatypes.h:44
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38

◆ convertFromEmu() [2/2]

l1t::TkElectron L1TCtL2EgProducer::convertFromEmu ( const l1ct::EGIsoEleObjEmu emu,
const RefRemapper refRemapper 
) const
private

Definition at line 383 of file L1TCtL2EgProducer.cc.

References l1gt::Scales::floatEta(), l1gt::Scales::floatPhi(), l1gt::Scales::floatPt(), l1ct::EGIsoEleObjEmu::floatRelIso(), L1TCtL2EgProducer::RefRemapper::origRefAndPtr, l1t::L1Candidate::setHwQual(), l1ct::EGIsoEleObjEmu::sta_idx, and l1ct::EGIsoEleObj::toGT().

384  {
385  // std::cout << "[convertFromEmu] TkEle pt: " << egele.hwPt << " eta: " << egele.hwEta << " phi: " << egele.hwPhi << " staidx: " << egele.sta_idx << std::endl;
386  // NOTE: the TkElectron object is created with the accuracy as in GT object (not the Correlator internal one)!
387  const auto gteg = egele.toGT();
389  l1gt::Scales::floatPt(gteg.v3.pt), l1gt::Scales::floatEta(gteg.v3.eta), l1gt::Scales::floatPhi(gteg.v3.phi), 0.);
390  // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso
392  refRemapper.origRefAndPtr[egele.sta_idx].first,
393  refRemapper.origRefAndPtr[egele.sta_idx].second,
394  egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::TkIso));
395  tkele.setHwQual(gteg.quality);
396  tkele.setPFIsol(egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PfIso));
397  tkele.setEgBinaryWord(gteg.pack());
398  return tkele;
399 }
float floatPhi(phi_t phi)
Definition: gt_datatypes.h:46
float floatEta(eta_t eta)
Definition: gt_datatypes.h:45
void setHwQual(int qual)
Definition: L1Candidate.h:31
float floatPt(pt_t pt)
Definition: gt_datatypes.h:44
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38

◆ convertToEmu() [1/2]

void L1TCtL2EgProducer::convertToEmu ( const l1t::TkElectron tkele,
RefRemapper refRemapper,
l1ct::OutputBoard boarOut 
) const
private

Definition at line 321 of file L1TCtL2EgProducer.cc.

References l1t::TkEm::egBinaryWord(), l1ct::OutputBoard::egelectron, l1t::TkEm::EGRef(), l1ct::EGIsoEleObj::initFromBits(), l1ct::Scales::makeIso(), L1TCtL2EgProducer::RefRemapper::old2newRefMap, L1TCtL2EgProducer::RefRemapper::origRefAndPtr, l1t::TkEm::pfIsol(), reco::LeafCandidate::pt(), l1ct::EGIsoEleObjEmu::setHwIso(), l1ct::EGIsoEleObjEmu::srcCluster, l1ct::EGIsoEleObjEmu::srcTrack, l1ct::EGIsoEleObjEmu::sta_idx, l1t::TkEm::trkIsol(), and l1t::TkElectron::trkPtr().

323  {
324  EGIsoEleObjEmu emu;
325  emu.initFromBits(tkele.egBinaryWord<EGIsoEleObj::BITWIDTH>());
326  emu.srcCluster = nullptr;
327  emu.srcTrack = nullptr;
328  auto refEg = tkele.EGRef();
329  const auto newref = refRemapper.old2newRefMap.find(refEg);
330  if (newref != refRemapper.old2newRefMap.end()) {
331  refEg = newref->second;
332  }
333  refRemapper.origRefAndPtr.push_back(std::make_pair(refEg, tkele.trkPtr()));
334  emu.sta_idx = refRemapper.origRefAndPtr.size() - 1;
335  // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso
336  emu.setHwIso(EGIsoEleObjEmu::IsoType::TkIso, l1ct::Scales::makeIso(tkele.trkIsol() * tkele.pt()));
337  emu.setHwIso(EGIsoEleObjEmu::IsoType::PfIso, l1ct::Scales::makeIso(tkele.pfIsol() * tkele.pt()));
338  // std::cout << "[convertToEmu] TkEle pt: " << emu.hwPt << " eta: " << emu.hwEta << " phi: " << emu.hwPhi << " staidx: " << emu.sta_idx << std::endl;
339 
340  boarOut.egelectron.push_back(emu);
341 }
void setHwIso(IsoType type, iso_t value)
double pt() const final
transverse momentum
float trkIsol() const
Definition: TkEm.h:41
const l1t::PFTrack * srcTrack
std::vector< EGIsoEleObjEmu > egelectron
iso_t makeIso(float iso)
Definition: datatypes.h:194
const edm::Ref< EGammaBxCollection > & EGRef() const
Definition: TkEm.h:33
ap_uint< N > egBinaryWord() const
Definition: TkEm.h:66
void initFromBits(const ap_uint< BITWIDTH > &src)
Definition: egamma.h:144
const edm::Ptr< L1TTTrackType > & trkPtr() const
Definition: TkElectron.h:38
const l1t::PFCluster * srcCluster
float pfIsol() const
Definition: TkEm.h:43

◆ convertToEmu() [2/2]

void L1TCtL2EgProducer::convertToEmu ( const l1t::TkEm tkele,
RefRemapper refRemapper,
l1ct::OutputBoard boarOut 
) const
private

Definition at line 343 of file L1TCtL2EgProducer.cc.

References l1t::TkEm::egBinaryWord(), l1ct::OutputBoard::egphoton, l1t::TkEm::EGRef(), l1ct::EGIsoObj::initFromBits(), l1ct::Scales::makeIso(), L1TCtL2EgProducer::RefRemapper::old2newRefMap, L1TCtL2EgProducer::RefRemapper::origRefAndPtr, l1t::TkEm::pfIsol(), l1t::TkEm::pfIsolPV(), reco::LeafCandidate::pt(), l1ct::EGIsoObjEmu::setHwIso(), l1ct::EGIsoObjEmu::srcCluster, l1ct::EGIsoObjEmu::sta_idx, l1t::TkEm::trkIsol(), and l1t::TkEm::trkIsolPV().

345  {
346  EGIsoObjEmu emu;
347  emu.initFromBits(tkem.egBinaryWord<EGIsoObj::BITWIDTH>());
348  emu.srcCluster = nullptr;
349  auto refEg = tkem.EGRef();
350  const auto newref = refRemapper.old2newRefMap.find(refEg);
351  if (newref != refRemapper.old2newRefMap.end()) {
352  refEg = newref->second;
353  }
354  refRemapper.origRefAndPtr.push_back(std::make_pair(refEg, edm::Ptr<RefRemapper::L1TTTrackType>(nullptr, 0)));
355  emu.sta_idx = refRemapper.origRefAndPtr.size() - 1;
356  // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso
357  emu.setHwIso(EGIsoObjEmu::IsoType::TkIso, l1ct::Scales::makeIso(tkem.trkIsol() * tkem.pt()));
358  emu.setHwIso(EGIsoObjEmu::IsoType::PfIso, l1ct::Scales::makeIso(tkem.pfIsol() * tkem.pt()));
359  emu.setHwIso(EGIsoObjEmu::IsoType::TkIsoPV, l1ct::Scales::makeIso(tkem.trkIsolPV() * tkem.pt()));
360  emu.setHwIso(EGIsoObjEmu::IsoType::PfIsoPV, l1ct::Scales::makeIso(tkem.pfIsolPV() * tkem.pt()));
361  // std::cout << "[convertToEmu] TkEM pt: " << emu.hwPt << " eta: " << emu.hwEta << " phi: " << emu.hwPhi << " staidx: " << emu.sta_idx << std::endl;
362  boarOut.egphoton.push_back(emu);
363 }
const l1t::PFCluster * srcCluster
iso_t makeIso(float iso)
Definition: datatypes.h:194
void setHwIso(IsoType type, iso_t value)
void initFromBits(const ap_uint< BITWIDTH > &src)
Definition: egamma.h:61
std::vector< EGIsoObjEmu > egphoton

◆ encodeLayer1() [1/4]

ap_uint< 64 > L1TCtL2EgProducer::encodeLayer1 ( const EGIsoObjEmu egiso) const
private

Definition at line 230 of file L1TCtL2EgProducer.cc.

References l1ct::EGIsoObj::pack(), and runTheMatrix::ret.

Referenced by encodeLayer1(), and encodeLayer1EgObjs().

230  {
231  ap_uint<64> ret = 0;
232  ret(EGIsoObjEmu::BITWIDTH, 0) = egiso.pack();
233  return ret;
234 }
ret
prodAgent to be discontinued
ap_uint< BITWIDTH > pack() const
Definition: egamma.h:45

◆ encodeLayer1() [2/4]

ap_uint< 128 > L1TCtL2EgProducer::encodeLayer1 ( const EGIsoEleObjEmu egiso) const
private

Definition at line 236 of file L1TCtL2EgProducer.cc.

References l1ct::EGIsoEleObj::pack(), and runTheMatrix::ret.

236  {
237  ap_uint<128> ret = 0;
238  ret(EGIsoEleObjEmu::BITWIDTH, 0) = egiso.pack();
239  return ret;
240 }
ret
prodAgent to be discontinued
ap_uint< BITWIDTH > pack() const
Definition: egamma.h:124

◆ encodeLayer1() [3/4]

std::vector< ap_uint< 64 > > L1TCtL2EgProducer::encodeLayer1 ( const std::vector< EGIsoObjEmu > &  photons) const
private

Definition at line 242 of file L1TCtL2EgProducer.cc.

References encodeLayer1(), BPHMonitor_cfi::photons, and runTheMatrix::ret.

242  {
243  std::vector<ap_uint<64>> ret;
244  ret.reserve(photons.size());
245  for (const auto &phot : photons) {
246  ret.push_back(encodeLayer1(phot));
247  }
248  return ret;
249 }
ret
prodAgent to be discontinued
ap_uint< 64 > encodeLayer1(const EGIsoObjEmu &egiso) const

◆ encodeLayer1() [4/4]

std::vector< ap_uint< 64 > > L1TCtL2EgProducer::encodeLayer1 ( const std::vector< EGIsoEleObjEmu > &  electrons) const
private

Definition at line 251 of file L1TCtL2EgProducer.cc.

References pwdgSkimBPark_cfi::electrons, encodeLayer1(), and runTheMatrix::ret.

251  {
252  std::vector<ap_uint<64>> ret;
253  ret.reserve(2 * electrons.size());
254  for (const auto &ele : electrons) {
255  auto eleword = encodeLayer1(ele);
256  ret.push_back(eleword(63, 0));
257  ret.push_back(eleword(127, 64));
258  }
259  return ret;
260 }
ret
prodAgent to be discontinued
ap_uint< 64 > encodeLayer1(const EGIsoObjEmu &egiso) const

◆ encodeLayer1EgObjs()

std::vector< ap_uint< 64 > > L1TCtL2EgProducer::encodeLayer1EgObjs ( unsigned int  nObj,
const std::vector< EGIsoObjEmu > &  photons,
const std::vector< EGIsoEleObjEmu > &  electrons 
) const
private

Definition at line 262 of file L1TCtL2EgProducer.cc.

References filterCSVwithJSON::copy, pwdgSkimBPark_cfi::electrons, encodeLayer1(), BPHMonitor_cfi::photons, and runTheMatrix::ret.

Referenced by produce().

264  {
265  std::vector<ap_uint<64>> ret;
266  auto encoded_photons = encodeLayer1(photons);
267  encoded_photons.resize(nObj, {0});
268  auto encoded_eles = encodeLayer1(electrons);
269  encoded_eles.resize(2 * nObj, {0});
270 
271  std::copy(encoded_photons.begin(), encoded_photons.end(), std::back_inserter(ret));
272  std::copy(encoded_eles.begin(), encoded_eles.end(), std::back_inserter(ret));
273 
274  return ret;
275 }
ret
prodAgent to be discontinued
ap_uint< 64 > encodeLayer1(const EGIsoObjEmu &egiso) const

◆ endJob()

void L1TCtL2EgProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::global::EDProducerBase.

Definition at line 313 of file L1TCtL2EgProducer.cc.

References doInPtrn_, doOutPtrn_, inPtrnWrt_, and outPtrnWrt_.

313  {
314  // Writing pending events to file before exiting
315  if (doOutPtrn_)
316  outPtrnWrt_->flush();
317  if (doInPtrn_)
318  inPtrnWrt_->flush();
319 }
std::unique_ptr< PatternWriter > outPtrnWrt_
std::unique_ptr< PatternWriter > inPtrnWrt_

◆ merge()

template<class TT , class T >
void L1TCtL2EgProducer::merge ( const PFInstanceInputs< T > &  instance,
edm::Event iEvent,
RefRemapper refRemapper,
std::unique_ptr< TT > &  out 
) const
inlineprivate

Definition at line 114 of file L1TCtL2EgProducer.cc.

References patZpeak::handle, iEvent, instance, and MillePedeFileConverter_cfg::out.

Referenced by produce().

117  {
119  for (const auto &tokenAndChannel : instance.tokensAndChannels()) {
120  iEvent.getByToken(tokenAndChannel.first, handle);
121  populate(out, handle, tokenAndChannel.second, refRemapper);
122  }
123  remapRefs(iEvent, out, refRemapper);
124  }
static PFTauRenderPlugin instance
void remapRefs(edm::Event &iEvent, std::unique_ptr< TT > &out, RefRemapper &refRemapper) const
int iEvent
Definition: GenABIO.cc:224
void populate(std::unique_ptr< T > &out, const edm::Handle< TT > &in, const std::vector< int > &links, RefRemapper &refRemapper) const

◆ populate() [1/2]

template<class TT , class T >
void L1TCtL2EgProducer::populate ( std::unique_ptr< T > &  out,
const edm::Handle< TT > &  in,
const std::vector< int > &  links,
RefRemapper refRemapper 
) const
inlineprivate

Definition at line 138 of file L1TCtL2EgProducer.cc.

References cms::cuda::assert(), recoMuon::in, electronStore::links, getGTfromDQMFile::obj, MillePedeFileConverter_cfg::out, and HLT_2022v14_cff::region.

141  {
142  assert(links.size() == in->nRegions());
143  for (unsigned int iBoard = 0, nBoard = in->nRegions(); iBoard < nBoard; ++iBoard) {
144  auto region = in->region(iBoard);
145  int linkID = links[iBoard];
146  if (linkID < 0)
147  continue;
148  // std::cout << "Board eta: " << in->eta(iBoard) << " phi: " << in->phi(iBoard) << " link: " << linkID << std::endl;
149  for (const auto &obj : region) {
150  convertToEmu(obj, refRemapper, out->at(linkID));
151  }
152  }
153  }
assert(be >=bs)
void convertToEmu(const l1t::TkElectron &tkele, RefRemapper &refRemapper, l1ct::OutputBoard &boarOut) const

◆ populate() [2/2]

void L1TCtL2EgProducer::populate ( std::unique_ptr< BXVector< l1t::EGamma >> &  out,
const edm::Handle< BXVector< l1t::EGamma >> &  in,
const std::vector< int > &  links,
RefRemapper refRemapper 
) const
inlineprivate

Definition at line 155 of file L1TCtL2EgProducer.cc.

References simKBmtfDigis_cfi::bx, heavyIonCSV_trainingSettings::idx, recoMuon::in, L1TCtL2EgProducer::RefRemapper::oldRefs, MillePedeFileConverter_cfg::out, and BXVector< T >::push_back().

158  {
159  edm::Ref<BXVector<l1t::EGamma>>::key_type idx = 0;
160  for (int bx = in->getFirstBX(); bx <= in->getLastBX(); bx++) {
161  for (auto egee_itr = in->begin(bx); egee_itr != in->end(bx); egee_itr++) {
162  out->push_back(bx, *egee_itr);
163  // this to ensure that the old ref and the new object have the same
164  // index in the BXVector collection so that we can still match them no
165  // matter which BX we will insert next
166  refRemapper.oldRefs.push_back(bx, edm::Ref<BXVector<l1t::EGamma>>(in, idx++));
167  }
168  }
169  }

◆ produce()

void L1TCtL2EgProducer::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup  
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 277 of file L1TCtL2EgProducer.cc.

References l1t::demo::EventData::add(), l1ctLayer1_cff::boards, doInPtrn_, doOutPtrn_, encodeLayer1EgObjs(), l1ct::L2EgEncoderEmulator::encodeLayer2EgObjs(), iEvent, inPtrnWrt_, l2egsorter, l2encoder, merge(), eostools::move(), l1ct::L2EgSorterEmulator::nInputBoards(), l1ct::L2EgSorterEmulator::nInputObjPerBoard(), outPtrnWrt_, l1ct::L2EgSorterEmulator::run(), tkEGInputs_, tkEGInstanceLabel_, tkEleInputs_, tkEleInstanceLabel_, tkEmInputs_, and tkEmInstanceLabel_.

277  {
278  RefRemapper refmapper;
279 
280  auto outEgs = std::make_unique<BXVector<l1t::EGamma>>();
281  merge(tkEGInputs_, iEvent, refmapper, outEgs);
282  iEvent.put(std::move(outEgs), tkEGInstanceLabel_);
283 
284  auto boards = std::make_unique<std::vector<l1ct::OutputBoard>>(l2egsorter.nInputBoards());
285 
286  merge(tkEleInputs_, iEvent, refmapper, boards);
287  merge(tkEmInputs_, iEvent, refmapper, boards);
288 
289  if (doInPtrn_) {
290  l1t::demo::EventData inData;
291  for (unsigned int ibrd = 0; ibrd < boards->size(); ibrd++) {
292  inData.add(
293  {"eglayer1", ibrd},
294  encodeLayer1EgObjs(l2egsorter.nInputObjPerBoard(), (*boards)[ibrd].egphoton, (*boards)[ibrd].egelectron));
295  }
296  inPtrnWrt_->addEvent(inData);
297  }
298 
299  std::vector<EGIsoObjEmu> out_photons_emu;
300  std::vector<EGIsoEleObjEmu> out_eles_emu;
301  l2egsorter.run(*boards, out_photons_emu, out_eles_emu);
302 
303  if (doOutPtrn_) {
304  l1t::demo::EventData outData;
305  outData.add({"eglayer2", 0}, l2encoder.encodeLayer2EgObjs(out_photons_emu, out_eles_emu));
306  outPtrnWrt_->addEvent(outData);
307  }
308 
309  putEgObjects<l1t::TkEmCollection>(iEvent, refmapper, tkEmInstanceLabel_, out_photons_emu);
310  putEgObjects<l1t::TkElectronCollection>(iEvent, refmapper, tkEleInstanceLabel_, out_eles_emu);
311 }
std::vector< ap_uint< 64 > > encodeLayer2EgObjs(const std::vector< EGIsoObjEmu > &photons, const std::vector< EGIsoEleObjEmu > &electrons) const
std::string tkEGInstanceLabel_
void merge(const PFInstanceInputs< T > &instance, edm::Event &iEvent, RefRemapper &refRemapper, std::unique_ptr< TT > &out) const
std::unique_ptr< PatternWriter > outPtrnWrt_
void add(const LinkId &, const std::vector< ap_uint< 64 >> &)
Definition: EventData.cc:14
void run(const std::vector< l1ct::OutputBoard > &in, std::vector< EGIsoObjEmu > &out_photons, std::vector< EGIsoEleObjEmu > &out_eles) const
PFInstanceInputs< l1t::TkElectronRegionalOutput > tkEleInputs_
int iEvent
Definition: GenABIO.cc:224
unsigned int nInputBoards() const
PFInstanceInputs< l1t::TkEmRegionalOutput > tkEmInputs_
l1ct::L2EgSorterEmulator l2egsorter
unsigned int nInputObjPerBoard() const
std::string tkEleInstanceLabel_
std::unique_ptr< PatternWriter > inPtrnWrt_
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_
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).
Definition: EventData.h:28
def move(src, dest)
Definition: eostools.py:511
std::string tkEmInstanceLabel_

◆ putEgObjects()

template<class Tout , class Tin >
void L1TCtL2EgProducer::putEgObjects ( edm::Event iEvent,
const RefRemapper refRemapper,
const std::string &  label,
const std::vector< Tin >  emulated 
) const
inlineprivate

Definition at line 172 of file L1TCtL2EgProducer.cc.

References iEvent, label, eostools::move(), and getGTfromDQMFile::obj.

175  {
176  auto egobjs = std::make_unique<Tout>();
177  for (const auto &emu : emulated) {
178  if (emu.hwPt == 0)
179  continue;
180  auto obj = convertFromEmu(emu, refRemapper);
181  egobjs->push_back(obj);
182  }
183  iEvent.put(std::move(egobjs), label);
184  }
char const * label
int iEvent
Definition: GenABIO.cc:224
l1t::TkEm convertFromEmu(const l1ct::EGIsoObjEmu &emu, const RefRemapper &refRemapper) const
def move(src, dest)
Definition: eostools.py:511

◆ remapRefs() [1/2]

template<class TT >
void L1TCtL2EgProducer::remapRefs ( edm::Event iEvent,
std::unique_ptr< TT > &  out,
RefRemapper refRemapper 
) const
inlineprivate

Definition at line 127 of file L1TCtL2EgProducer.cc.

127 {}

◆ remapRefs() [2/2]

void L1TCtL2EgProducer::remapRefs ( edm::Event iEvent,
std::unique_ptr< BXVector< l1t::EGamma >> &  out,
RefRemapper refRemapper 
) const
inlineprivate

Member Data Documentation

◆ doInPtrn_

bool L1TCtL2EgProducer::doInPtrn_
private

Definition at line 197 of file L1TCtL2EgProducer.cc.

Referenced by endJob(), L1TCtL2EgProducer(), and produce().

◆ doOutPtrn_

bool L1TCtL2EgProducer::doOutPtrn_
private

Definition at line 198 of file L1TCtL2EgProducer.cc.

Referenced by endJob(), L1TCtL2EgProducer(), and produce().

◆ inPtrnWrt_

std::unique_ptr<PatternWriter> L1TCtL2EgProducer::inPtrnWrt_
private

Definition at line 199 of file L1TCtL2EgProducer.cc.

Referenced by endJob(), L1TCtL2EgProducer(), and produce().

◆ l2egsorter

l1ct::L2EgSorterEmulator L1TCtL2EgProducer::l2egsorter
private

Definition at line 195 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ l2encoder

l1ct::L2EgEncoderEmulator L1TCtL2EgProducer::l2encoder
private

Definition at line 196 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ outPtrnWrt_

std::unique_ptr<PatternWriter> L1TCtL2EgProducer::outPtrnWrt_
private

Definition at line 200 of file L1TCtL2EgProducer.cc.

Referenced by endJob(), L1TCtL2EgProducer(), and produce().

◆ tkEGInputs_

PFInstanceInputs<BXVector<l1t::EGamma> > L1TCtL2EgProducer::tkEGInputs_
private

Definition at line 189 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ tkEGInstanceLabel_

std::string L1TCtL2EgProducer::tkEGInstanceLabel_
private

Definition at line 192 of file L1TCtL2EgProducer.cc.

Referenced by L1TCtL2EgProducer(), and produce().

◆ tkEleInputs_

PFInstanceInputs<l1t::TkElectronRegionalOutput> L1TCtL2EgProducer::tkEleInputs_
private

Definition at line 191 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ tkEleInstanceLabel_

std::string L1TCtL2EgProducer::tkEleInstanceLabel_
private

Definition at line 194 of file L1TCtL2EgProducer.cc.

Referenced by L1TCtL2EgProducer(), and produce().

◆ tkEmInputs_

PFInstanceInputs<l1t::TkEmRegionalOutput> L1TCtL2EgProducer::tkEmInputs_
private

Definition at line 190 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ tkEmInstanceLabel_

std::string L1TCtL2EgProducer::tkEmInstanceLabel_
private

Definition at line 193 of file L1TCtL2EgProducer.cc.

Referenced by L1TCtL2EgProducer(), and produce().