CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | 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
 

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 noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

typedef std::vector< std::pair< edm::Ptr< l1t::L1Candidate >, edm::Ptr< L1TTTrackType > > > ConstituentPtrVector
 
typedef TTTrack< Ref_Phase2TrackerDigi_L1TTTrackType
 

Private Member Functions

l1t::TkEm convertFromEmu (const l1ct::EGIsoObjEmu &emu, const ConstituentPtrVector &constituentsPtrs) const
 
l1t::TkElectron convertFromEmu (const l1ct::EGIsoEleObjEmu &emu, const ConstituentPtrVector &constituentsPtrs) const
 
void convertToEmu (const l1t::TkElectron &tkele, ConstituentPtrVector &constituentsPtrs, l1ct::OutputBoard &boarOut) const
 
void convertToEmu (const l1t::TkEm &tkele, ConstituentPtrVector &constituentsPtrs, l1ct::OutputBoard &boarOut) const
 
void convertToPuppi (const l1t::PFCandidateCollection &l1PFCands, l1ct::PuppiObjs &puppiObjs) 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
 
void encodeLayer1EgObjs (unsigned int nObj, std::vector< ap_uint< 64 >> &data, 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, ConstituentPtrVector &constituentsPtrs, 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 > &regions, ConstituentPtrVector &constituentsPtrs) const
 
void populate (std::unique_ptr< BXVector< l1t::EGamma >> &out, const edm::Handle< BXVector< l1t::EGamma >> &in, const std::vector< int > &regions, ConstituentPtrVector &constituentsPtrs) const
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
template<class Tout , class Tin >
void putEgObjects (edm::Event &iEvent, const ConstituentPtrVector &constituentsPtrs, const std::string &label, const std::vector< Tin > emulated) const
 

Private Attributes

bool doInPtrn_
 
bool doOutPtrn_
 
std::unique_ptr< PatternWriterinPtrnWrt_
 
l1ct::L1EGPuppiIsoAlgo l2EgPuppiIsoAlgo_
 
l1ct::L2EgSorterEmulator l2egsorter
 
l1ct::L1EGPuppiIsoAlgo l2ElePuppiIsoAlgo_
 
l1ct::L2EgEncoderEmulator l2encoder
 
std::unique_ptr< PatternWriteroutPtrnWrt_
 
edm::EDGetTokenT< std::vector< l1t::PFCandidate > > pfObjsToken_
 
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
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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 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.

Member Typedef Documentation

◆ ConstituentPtrVector

Definition at line 49 of file L1TCtL2EgProducer.cc.

◆ L1TTTrackType

Definition at line 48 of file L1TCtL2EgProducer.cc.

Constructor & Destructor Documentation

◆ L1TCtL2EgProducer()

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

Definition at line 243 of file L1TCtL2EgProducer.cc.

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

244  : tkEGInputs_(this, conf.getParameter<std::vector<edm::ParameterSet>>("tkEgs")),
245  tkEmInputs_(this, conf.getParameter<std::vector<edm::ParameterSet>>("tkEms")),
246  tkEleInputs_(this, conf.getParameter<std::vector<edm::ParameterSet>>("tkElectrons")),
247  tkEGInstanceLabel_(conf.getParameter<std::string>("egStaInstanceLabel")),
248  tkEmInstanceLabel_(conf.getParameter<std::string>("tkEmInstanceLabel")),
249  tkEleInstanceLabel_(conf.getParameter<std::string>("tkEleInstanceLabel")),
250  l2egsorter(conf.getParameter<edm::ParameterSet>("sorter")),
251  l2encoder(conf.getParameter<edm::ParameterSet>("encoder")),
252  pfObjsToken_(consumes<std::vector<l1t::PFCandidate>>(conf.getParameter<edm::InputTag>("l1PFObjects"))),
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")),
257  inPtrnWrt_(nullptr),
258  outPtrnWrt_(nullptr) {
259  produces<BXVector<l1t::EGamma>>(tkEGInstanceLabel_);
260  produces<l1t::TkEmCollection>(tkEmInstanceLabel_);
261  produces<l1t::TkElectronCollection>(tkEleInstanceLabel_);
262 
263  if (doInPtrn_) {
264  inPtrnWrt_ = std::make_unique<PatternWriter>(conf.getParameter<edm::ParameterSet>("inPatternFile"));
265  }
266  if (doOutPtrn_) {
267  outPtrnWrt_ = std::make_unique<PatternWriter>(conf.getParameter<edm::ParameterSet>("outPatternFile"));
268  }
269 }
std::string tkEGInstanceLabel_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::unique_ptr< PatternWriter > outPtrnWrt_
edm::EDGetTokenT< std::vector< l1t::PFCandidate > > pfObjsToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
PFInstanceInputs< l1t::TkElectronRegionalOutput > tkEleInputs_
PFInstanceInputs< l1t::TkEmRegionalOutput > tkEmInputs_
l1ct::L2EgSorterEmulator l2egsorter
std::string tkEleInstanceLabel_
std::unique_ptr< PatternWriter > inPtrnWrt_
l1ct::L1EGPuppiIsoAlgo l2ElePuppiIsoAlgo_
l1ct::L2EgEncoderEmulator l2encoder
PFInstanceInputs< BXVector< l1t::EGamma > > tkEGInputs_
l1ct::L1EGPuppiIsoAlgo l2EgPuppiIsoAlgo_
std::string tkEmInstanceLabel_

◆ ~L1TCtL2EgProducer()

L1TCtL2EgProducer::~L1TCtL2EgProducer ( )
override

Definition at line 271 of file L1TCtL2EgProducer.cc.

271 {}

Member Function Documentation

◆ convertFromEmu() [1/2]

l1t::TkEm L1TCtL2EgProducer::convertFromEmu ( const l1ct::EGIsoObjEmu emu,
const ConstituentPtrVector constituentsPtrs 
) const
private

Definition at line 421 of file L1TCtL2EgProducer.cc.

References l1gt::Scales::floatEta(), l1gt::Scales::floatPhi(), l1gt::Scales::floatPt(), l1ct::EGIsoObjEmu::floatRelIso(), l1t::TkEm::GT, l1t::L1Candidate::setHwQual(), l1ct::EGIsoObjEmu::src_idx, and l1ct::EGIsoObj::toGT().

422  {
423  // std::cout << "[convertFromEmu] TkEm pt: " << egiso.hwPt << " eta: " << egiso.hwEta << " phi: " << egiso.hwPhi << " staidx: " << egiso.src_idx << std::endl;
424  // NOTE: the TkEM object is created with the accuracy as in GT object (not the Correlator internal one)!
425  const auto gteg = egiso.toGT();
427  l1gt::Scales::floatPt(gteg.v3.pt), l1gt::Scales::floatEta(gteg.v3.eta), l1gt::Scales::floatPhi(gteg.v3.phi), 0.);
428  // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso
430  constituentsPtrs[egiso.src_idx].first,
431  egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIso),
432  egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIsoPV));
433  tkem.setHwQual(gteg.qualityFlags);
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));
437  tkem.setEgBinaryWord(gteg.pack(), l1t::TkEm::HWEncoding::GT);
438  return tkem;
439 }
float floatPhi(phi_t phi)
Definition: gt_datatypes.h:49
float floatEta(eta_t eta)
Definition: gt_datatypes.h:48
void setHwQual(int qual)
Definition: L1Candidate.h:31
Definition: TkEm.h:23
float floatPt(pt_t pt)
Definition: gt_datatypes.h:47
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 ConstituentPtrVector constituentsPtrs 
) const
private

Definition at line 441 of file L1TCtL2EgProducer.cc.

References l1gt::Scales::floatEta(), l1ct::EGIsoEleObj::floatIDScore(), l1gt::Scales::floatPhi(), l1gt::Scales::floatPt(), l1ct::EGIsoEleObjEmu::floatRelIso(), l1gt::Scales::floatZ0(), l1t::TkEm::GT, l1ct::EGIsoEleObj::intCharge(), l1t::L1Candidate::setHwQual(), l1ct::EGIsoEleObjEmu::src_idx, and l1ct::EGIsoEleObj::toGT().

442  {
443  // std::cout << "[convertFromEmu] TkEle pt: " << egele.hwPt << " eta: " << egele.hwEta << " phi: " << egele.hwPhi << " staidx: " << egele.src_idx << std::endl;
444  // NOTE: the TkElectron object is created with the accuracy as in GT object (not the Correlator internal one)!
445  const auto gteg = egele.toGT();
447  l1gt::Scales::floatPt(gteg.v3.pt), l1gt::Scales::floatEta(gteg.v3.eta), l1gt::Scales::floatPhi(gteg.v3.phi), 0.);
448  // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso
450  constituentsPtrs[egele.src_idx].first,
451  constituentsPtrs[egele.src_idx].second,
452  egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::TkIso));
453  tkele.setHwQual(gteg.qualityFlags);
454  tkele.setPFIsol(egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PfIso));
455  tkele.setPuppiIsol(egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PuppiIso));
456  tkele.setEgBinaryWord(gteg.pack(), l1t::TkElectron::HWEncoding::GT);
457  tkele.setIdScore(egele.floatIDScore());
458  tkele.setCharge(egele.intCharge());
459  tkele.setTrkzVtx(l1gt::Scales::floatZ0(gteg.z0));
460  return tkele;
461 }
float floatPhi(phi_t phi)
Definition: gt_datatypes.h:49
float floatEta(eta_t eta)
Definition: gt_datatypes.h:48
void setHwQual(int qual)
Definition: L1Candidate.h:31
float floatPt(pt_t pt)
Definition: gt_datatypes.h:47
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
float floatZ0(z0_t z0)
Definition: gt_datatypes.h:50
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38

◆ convertToEmu() [1/2]

void L1TCtL2EgProducer::convertToEmu ( const l1t::TkElectron tkele,
ConstituentPtrVector constituentsPtrs,
l1ct::OutputBoard boarOut 
) const
private

Definition at line 376 of file L1TCtL2EgProducer.cc.

References l1t::TkEm::egBinaryWord(), l1t::TkEm::egCaloPtr(), l1ct::OutputBoard::egelectron, l1ct::EGIsoEleObj::initFromBits(), l1ct::Scales::makeIso(), l1t::TkEm::pfIsol(), reco::LeafCandidate::pt(), l1t::TkEm::puppiIsol(), l1ct::EGIsoEleObjEmu::setHwIso(), l1ct::EGIsoEleObjEmu::src_idx, l1ct::EGIsoEleObjEmu::srcCluster, l1ct::EGIsoEleObjEmu::srcTrack, l1t::TkEm::trkIsol(), and l1t::TkElectron::trkPtr().

378  {
379  EGIsoEleObjEmu emu;
380  emu.initFromBits(tkele.egBinaryWord<EGIsoEleObj::BITWIDTH>());
381  emu.srcCluster = nullptr;
382  emu.srcTrack = nullptr;
383 
384  constituentsPtrs.push_back(std::make_pair(tkele.egCaloPtr(), tkele.trkPtr()));
385  emu.src_idx = constituentsPtrs.size() - 1;
386 
387  // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso
388  emu.setHwIso(EGIsoEleObjEmu::IsoType::TkIso, l1ct::Scales::makeIso(tkele.trkIsol() * tkele.pt()));
389  emu.setHwIso(EGIsoEleObjEmu::IsoType::PfIso, l1ct::Scales::makeIso(tkele.pfIsol() * tkele.pt()));
390  emu.setHwIso(EGIsoEleObjEmu::IsoType::PuppiIso, l1ct::Scales::makeIso(tkele.puppiIsol() * tkele.pt()));
391  // std::cout << "[convertToEmu] TkEle pt: " << emu.hwPt << " eta: " << emu.hwEta << " phi: " << emu.hwPhi << " staidx: " << emu.src_idx << std::endl;
392  boarOut.egelectron.push_back(emu);
393 }
void setHwIso(IsoType type, iso_t value)
double pt() const final
transverse momentum
float trkIsol() const
Definition: TkEm.h:37
const l1t::PFTrack * srcTrack
std::vector< EGIsoEleObjEmu > egelectron
iso_t makeIso(float iso)
Definition: datatypes.h:207
ap_uint< N > egBinaryWord() const
Definition: TkEm.h:70
void initFromBits(const ap_uint< BITWIDTH > &src)
Definition: egamma.h:149
const edm::Ptr< L1Candidate > & egCaloPtr() const
Definition: TkEm.h:35
const edm::Ptr< L1TTTrackType > & trkPtr() const
Definition: TkElectron.h:39
const l1t::PFCluster * srcCluster
float pfIsol() const
Definition: TkEm.h:39
float puppiIsol() const
Definition: TkEm.h:41

◆ convertToEmu() [2/2]

void L1TCtL2EgProducer::convertToEmu ( const l1t::TkEm tkele,
ConstituentPtrVector constituentsPtrs,
l1ct::OutputBoard boarOut 
) const
private

Definition at line 395 of file L1TCtL2EgProducer.cc.

References l1t::TkEm::egBinaryWord(), l1t::TkEm::egCaloPtr(), l1ct::OutputBoard::egphoton, l1ct::EGIsoObj::initFromBits(), l1ct::Scales::makeIso(), l1t::TkEm::pfIsol(), l1t::TkEm::pfIsolPV(), reco::LeafCandidate::pt(), l1t::TkEm::puppiIsol(), l1ct::EGIsoObjEmu::setHwIso(), l1ct::EGIsoObjEmu::src_idx, l1ct::EGIsoObjEmu::srcCluster, l1t::TkEm::trkIsol(), and l1t::TkEm::trkIsolPV().

397  {
398  EGIsoObjEmu emu;
399  emu.initFromBits(tkem.egBinaryWord<EGIsoObj::BITWIDTH>());
400  emu.srcCluster = nullptr;
401  constituentsPtrs.push_back(std::make_pair(tkem.egCaloPtr(), edm::Ptr<L1TTTrackType>()));
402  emu.src_idx = constituentsPtrs.size() - 1;
403  // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso
404  emu.setHwIso(EGIsoObjEmu::IsoType::TkIso, l1ct::Scales::makeIso(tkem.trkIsol() * tkem.pt()));
405  emu.setHwIso(EGIsoObjEmu::IsoType::PfIso, l1ct::Scales::makeIso(tkem.pfIsol() * tkem.pt()));
406  emu.setHwIso(EGIsoObjEmu::IsoType::PuppiIso, l1ct::Scales::makeIso(tkem.puppiIsol() * tkem.pt()));
407  emu.setHwIso(EGIsoObjEmu::IsoType::TkIsoPV, l1ct::Scales::makeIso(tkem.trkIsolPV() * tkem.pt()));
408  emu.setHwIso(EGIsoObjEmu::IsoType::PfIsoPV, l1ct::Scales::makeIso(tkem.pfIsolPV() * tkem.pt()));
409  // std::cout << "[convertToEmu] TkEM pt: " << emu.hwPt << " eta: " << emu.hwEta << " phi: " << emu.hwPhi << " staidx: " << emu.src_idx << std::endl;
410  boarOut.egphoton.push_back(emu);
411 }
const l1t::PFCluster * srcCluster
iso_t makeIso(float iso)
Definition: datatypes.h:207
void setHwIso(IsoType type, iso_t value)
void initFromBits(const ap_uint< BITWIDTH > &src)
Definition: egamma.h:61
std::vector< EGIsoObjEmu > egphoton

◆ convertToPuppi()

void L1TCtL2EgProducer::convertToPuppi ( const l1t::PFCandidateCollection l1PFCands,
l1ct::PuppiObjs puppiObjs 
) const
private

Definition at line 413 of file L1TCtL2EgProducer.cc.

References getGTfromDQMFile::obj.

Referenced by produce().

413  {
414  for (const auto &l1PFCand : l1PFCands) {
416  obj.initFromBits(l1PFCand.encodedPuppi64());
417  puppiObjs.emplace_back(obj);
418  }
419 }

◆ encodeLayer1() [1/4]

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

Definition at line 273 of file L1TCtL2EgProducer.cc.

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

Referenced by encodeLayer1(), and encodeLayer1EgObjs().

273  {
274  ap_uint<64> ret = 0;
275  ret(EGIsoObjEmu::BITWIDTH, 0) = egiso.pack();
276  return ret;
277 }
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 279 of file L1TCtL2EgProducer.cc.

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

279  {
280  ap_uint<128> ret = 0;
281  ret(EGIsoEleObjEmu::BITWIDTH, 0) = egiso.pack();
282  return ret;
283 }
ret
prodAgent to be discontinued
ap_uint< BITWIDTH > pack() const
Definition: egamma.h:128

◆ encodeLayer1() [3/4]

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

Definition at line 285 of file L1TCtL2EgProducer.cc.

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

285  {
286  std::vector<ap_uint<64>> ret;
287  ret.reserve(photons.size());
288  for (const auto &phot : photons) {
289  ret.push_back(encodeLayer1(phot));
290  }
291  return ret;
292 }
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 294 of file L1TCtL2EgProducer.cc.

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

294  {
295  std::vector<ap_uint<64>> ret;
296  ret.reserve(2 * electrons.size());
297  for (const auto &ele : electrons) {
298  auto eleword = encodeLayer1(ele);
299  ret.push_back(eleword(63, 0));
300  ret.push_back(eleword(127, 64));
301  }
302  return ret;
303 }
ret
prodAgent to be discontinued
ap_uint< 64 > encodeLayer1(const EGIsoObjEmu &egiso) const

◆ encodeLayer1EgObjs()

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

Definition at line 305 of file L1TCtL2EgProducer.cc.

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

Referenced by produce().

308  {
309  auto encoded_photons = encodeLayer1(photons);
310  encoded_photons.resize(nObj, {0});
311  auto encoded_eles = encodeLayer1(electrons);
312  encoded_eles.resize(2 * nObj, {0});
313 
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));
316 }
ap_uint< 64 > encodeLayer1(const EGIsoObjEmu &egiso) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ endJob()

void L1TCtL2EgProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::global::EDProducerBase.

Definition at line 368 of file L1TCtL2EgProducer.cc.

References doInPtrn_, doOutPtrn_, inPtrnWrt_, and outPtrnWrt_.

368  {
369  // Writing pending events to file before exiting
370  if (doOutPtrn_)
371  outPtrnWrt_->flush();
372  if (doInPtrn_)
373  inPtrnWrt_->flush();
374 }
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,
ConstituentPtrVector constituentsPtrs,
std::unique_ptr< TT > &  out 
) const
inlineprivate

Definition at line 168 of file L1TCtL2EgProducer.cc.

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

Referenced by produce().

171  {
173  for (const auto &tokenAndRegions : instance.tokensAndRegions()) {
174  iEvent.getByToken(tokenAndRegions.first, handle);
175  populate(out, handle, tokenAndRegions.second, constituentsPtrs);
176  }
177  }
static PFTauRenderPlugin instance
int iEvent
Definition: GenABIO.cc:224
void populate(std::unique_ptr< T > &out, const edm::Handle< TT > &in, const std::vector< int > &regions, ConstituentPtrVector &constituentsPtrs) 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 > &  regions,
ConstituentPtrVector constituentsPtrs 
) const
inlineprivate

Definition at line 180 of file L1TCtL2EgProducer.cc.

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

183  {
184  assert(regions.size() == in->nRegions());
185  for (unsigned int iBoard = 0, nBoard = in->nRegions(); iBoard < nBoard; ++iBoard) {
186  auto region = in->region(iBoard);
187  int regionID = regions[iBoard];
188  if (regionID < 0)
189  continue;
190  // std::cout << "Board eta: " << in->eta(iBoard) << " phi: " << in->phi(iBoard) << " link: " << regionID << std::endl;
191  for (const auto &obj : region) {
192  convertToEmu(obj, constituentsPtrs, out->at(regionID));
193  }
194  }
195  }
void convertToEmu(const l1t::TkElectron &tkele, ConstituentPtrVector &constituentsPtrs, l1ct::OutputBoard &boarOut) const
assert(be >=bs)

◆ populate() [2/2]

void L1TCtL2EgProducer::populate ( std::unique_ptr< BXVector< l1t::EGamma >> &  out,
const edm::Handle< BXVector< l1t::EGamma >> &  in,
const std::vector< int > &  regions,
ConstituentPtrVector constituentsPtrs 
) const
inlineprivate

Definition at line 197 of file L1TCtL2EgProducer.cc.

References nano_mu_digi_cff::bx, recoMuon::in, and MillePedeFileConverter_cfg::out.

200  {
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);
204  }
205  }
206  }

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 318 of file L1TCtL2EgProducer.cc.

References l1t::demo::EventData::add(), l1t::demo::EventData::at(), convertToPuppi(), data, doInPtrn_, doOutPtrn_, encodeLayer1EgObjs(), l1ct::L2EgEncoderEmulator::encodeLayer2EgObjs(), l1t::demo::EventData::has(), iEvent, inPtrnWrt_, l2EgPuppiIsoAlgo_, l2egsorter, l2ElePuppiIsoAlgo_, l2encoder, merge(), eostools::move(), l1ct::L2EgSorterEmulator::nInputObjPerRegion(), l1ct::L2EgSorterEmulator::nInputRegions(), outPtrnWrt_, pfObjsToken_, l1ct::L1EGPuppiIsoAlgo::run(), l1ct::L2EgSorterEmulator::run(), tkEGInputs_, tkEGInstanceLabel_, tkEleInputs_, tkEleInstanceLabel_, tkEmInputs_, and tkEmInstanceLabel_.

318  {
319  ConstituentPtrVector constituents;
320 
321  auto outEgs = std::make_unique<BXVector<l1t::EGamma>>();
322  merge(tkEGInputs_, iEvent, constituents, outEgs);
323  iEvent.put(std::move(outEgs), tkEGInstanceLabel_);
324 
325  auto regions = std::make_unique<std::vector<l1ct::OutputBoard>>(l2egsorter.nInputRegions());
326 
327  merge(tkEleInputs_, iEvent, constituents, regions);
328  merge(tkEmInputs_, iEvent, constituents, regions);
329 
330  if (doInPtrn_) {
331  std::map<unsigned int, l1t::demo::LinkId> regio2link;
332 
333  l1t::demo::EventData inData;
334  for (unsigned int ireg = 0; ireg < regions->size(); ireg++) {
335  const auto &linkData = inPtrnWrt_->region2Link(ireg);
336  std::vector<ap_uint<64>> data;
337 
338  if (inData.has(linkData.linkId))
339  data = inData.at(linkData.linkId);
340  encodeLayer1EgObjs(l2egsorter.nInputObjPerRegion(), data, (*regions)[ireg].egphoton, (*regions)[ireg].egelectron);
341  data.resize(data.size() + linkData.nTrailingWords, {0});
342  inData.add(linkData.linkId, data);
343  }
344  inPtrnWrt_->addEvent(inData);
345  }
346 
347  std::vector<EGIsoObjEmu> out_photons_emu;
348  std::vector<EGIsoEleObjEmu> out_eles_emu;
349  l2egsorter.run(*regions, out_photons_emu, out_eles_emu);
350 
351  // PUPPI isolation
352  auto &pfObjs = iEvent.get(pfObjsToken_);
353  l1ct::PuppiObjs puppiObjs;
354  convertToPuppi(pfObjs, puppiObjs);
355  l2EgPuppiIsoAlgo_.run(out_photons_emu, puppiObjs);
356  l2ElePuppiIsoAlgo_.run(out_eles_emu, puppiObjs);
357 
358  if (doOutPtrn_) {
359  l1t::demo::EventData outData;
360  outData.add({"eglayer2", 0}, l2encoder.encodeLayer2EgObjs(out_photons_emu, out_eles_emu));
361  outPtrnWrt_->addEvent(outData);
362  }
363 
364  putEgObjects<l1t::TkEmCollection>(iEvent, constituents, tkEmInstanceLabel_, out_photons_emu);
365  putEgObjects<l1t::TkElectronCollection>(iEvent, constituents, tkEleInstanceLabel_, out_eles_emu);
366 }
std::vector< ap_uint< 64 > > encodeLayer2EgObjs(const std::vector< EGIsoObjEmu > &photons, const std::vector< EGIsoEleObjEmu > &electrons) const
std::string tkEGInstanceLabel_
void convertToPuppi(const l1t::PFCandidateCollection &l1PFCands, l1ct::PuppiObjs &puppiObjs) const
std::vector< std::pair< edm::Ptr< l1t::L1Candidate >, edm::Ptr< L1TTTrackType > > > ConstituentPtrVector
std::vector< PuppiObj > PuppiObjs
std::unique_ptr< PatternWriter > outPtrnWrt_
void add(const LinkId &, const std::vector< ap_uint< 64 >> &)
Definition: EventData.cc:14
edm::EDGetTokenT< std::vector< l1t::PFCandidate > > pfObjsToken_
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 nInputRegions() const
const std::vector< ap_uint< 64 > > & at(const LinkId &) const
Definition: EventData.cc:21
void encodeLayer1EgObjs(unsigned int nObj, std::vector< ap_uint< 64 >> &data, const std::vector< EGIsoObjEmu > &photons, const std::vector< EGIsoEleObjEmu > &electrons) const
unsigned int nInputObjPerRegion() const
PFInstanceInputs< l1t::TkEmRegionalOutput > tkEmInputs_
l1ct::L2EgSorterEmulator l2egsorter
std::string tkEleInstanceLabel_
void merge(const PFInstanceInputs< T > &instance, edm::Event &iEvent, ConstituentPtrVector &constituentsPtrs, std::unique_ptr< TT > &out) const
std::unique_ptr< PatternWriter > inPtrnWrt_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
l1ct::L1EGPuppiIsoAlgo l2ElePuppiIsoAlgo_
l1ct::L2EgEncoderEmulator l2encoder
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).
Definition: EventData.h:28
def move(src, dest)
Definition: eostools.py:511
bool has(const LinkId &) const
Definition: EventData.cc:23
l1ct::L1EGPuppiIsoAlgo l2EgPuppiIsoAlgo_
std::string tkEmInstanceLabel_

◆ putEgObjects()

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

Definition at line 209 of file L1TCtL2EgProducer.cc.

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

212  {
213  auto egobjs = std::make_unique<Tout>();
214  for (const auto &emu : emulated) {
215  if (emu.hwPt == 0)
216  continue;
217  auto obj = convertFromEmu(emu, constituentsPtrs);
218  egobjs->push_back(obj);
219  }
220  iEvent.put(std::move(egobjs), label);
221  }
l1t::TkEm convertFromEmu(const l1ct::EGIsoObjEmu &emu, const ConstituentPtrVector &constituentsPtrs) const
char const * label
int iEvent
Definition: GenABIO.cc:224
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ doInPtrn_

bool L1TCtL2EgProducer::doInPtrn_
private

Definition at line 237 of file L1TCtL2EgProducer.cc.

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

◆ doOutPtrn_

bool L1TCtL2EgProducer::doOutPtrn_
private

Definition at line 238 of file L1TCtL2EgProducer.cc.

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

◆ inPtrnWrt_

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

Definition at line 239 of file L1TCtL2EgProducer.cc.

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

◆ l2EgPuppiIsoAlgo_

l1ct::L1EGPuppiIsoAlgo L1TCtL2EgProducer::l2EgPuppiIsoAlgo_
private

Definition at line 235 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ l2egsorter

l1ct::L2EgSorterEmulator L1TCtL2EgProducer::l2egsorter
private

Definition at line 232 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ l2ElePuppiIsoAlgo_

l1ct::L1EGPuppiIsoAlgo L1TCtL2EgProducer::l2ElePuppiIsoAlgo_
private

Definition at line 236 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ l2encoder

l1ct::L2EgEncoderEmulator L1TCtL2EgProducer::l2encoder
private

Definition at line 233 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ outPtrnWrt_

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

Definition at line 240 of file L1TCtL2EgProducer.cc.

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

◆ pfObjsToken_

edm::EDGetTokenT<std::vector<l1t::PFCandidate> > L1TCtL2EgProducer::pfObjsToken_
private

Definition at line 234 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ tkEGInputs_

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

Definition at line 226 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ tkEGInstanceLabel_

std::string L1TCtL2EgProducer::tkEGInstanceLabel_
private

Definition at line 229 of file L1TCtL2EgProducer.cc.

Referenced by L1TCtL2EgProducer(), and produce().

◆ tkEleInputs_

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

Definition at line 228 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ tkEleInstanceLabel_

std::string L1TCtL2EgProducer::tkEleInstanceLabel_
private

Definition at line 231 of file L1TCtL2EgProducer.cc.

Referenced by L1TCtL2EgProducer(), and produce().

◆ tkEmInputs_

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

Definition at line 227 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ tkEmInstanceLabel_

std::string L1TCtL2EgProducer::tkEmInstanceLabel_
private

Definition at line 230 of file L1TCtL2EgProducer.cc.

Referenced by L1TCtL2EgProducer(), and produce().