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 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
 
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
 
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, 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 > &links, ConstituentPtrVector &constituentsPtrs) const
 
void populate (std::unique_ptr< BXVector< l1t::EGamma >> &out, const edm::Handle< BXVector< l1t::EGamma >> &in, const std::vector< int > &links, 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 48 of file L1TCtL2EgProducer.cc.

◆ L1TTTrackType

Definition at line 47 of file L1TCtL2EgProducer.cc.

Constructor & Destructor Documentation

◆ L1TCtL2EgProducer()

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

Definition at line 188 of file L1TCtL2EgProducer.cc.

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

189  : tkEGInputs_(this, conf.getParameter<std::vector<edm::ParameterSet>>("tkEgs")),
190  tkEmInputs_(this, conf.getParameter<std::vector<edm::ParameterSet>>("tkEms")),
191  tkEleInputs_(this, conf.getParameter<std::vector<edm::ParameterSet>>("tkElectrons")),
192  tkEGInstanceLabel_(conf.getParameter<std::string>("egStaInstanceLabel")),
193  tkEmInstanceLabel_(conf.getParameter<std::string>("tkEmInstanceLabel")),
194  tkEleInstanceLabel_(conf.getParameter<std::string>("tkEleInstanceLabel")),
195  l2egsorter(conf.getParameter<edm::ParameterSet>("sorter")),
196  l2encoder(conf.getParameter<edm::ParameterSet>("encoder")),
197  pfObjsToken_(consumes<std::vector<l1t::PFCandidate>>(conf.getParameter<edm::InputTag>("l1PFObjects"))),
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")),
202  inPtrnWrt_(nullptr),
203  outPtrnWrt_(nullptr) {
204  produces<BXVector<l1t::EGamma>>(tkEGInstanceLabel_);
205  produces<l1t::TkEmCollection>(tkEmInstanceLabel_);
206  produces<l1t::TkElectronCollection>(tkEleInstanceLabel_);
207 
208  if (doInPtrn_) {
209  inPtrnWrt_ = std::make_unique<PatternWriter>(conf.getParameter<edm::ParameterSet>("inPatternFile"));
210  }
211  if (doOutPtrn_) {
212  outPtrnWrt_ = std::make_unique<PatternWriter>(conf.getParameter<edm::ParameterSet>("outPatternFile"));
213  }
214 }
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 216 of file L1TCtL2EgProducer.cc.

216 {}

Member Function Documentation

◆ convertFromEmu() [1/2]

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

Definition at line 361 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().

362  {
363  // std::cout << "[convertFromEmu] TkEm pt: " << egiso.hwPt << " eta: " << egiso.hwEta << " phi: " << egiso.hwPhi << " staidx: " << egiso.src_idx << std::endl;
364  // NOTE: the TkEM object is created with the accuracy as in GT object (not the Correlator internal one)!
365  const auto gteg = egiso.toGT();
367  l1gt::Scales::floatPt(gteg.v3.pt), l1gt::Scales::floatEta(gteg.v3.eta), l1gt::Scales::floatPhi(gteg.v3.phi), 0.);
368  // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso
370  constituentsPtrs[egiso.src_idx].first,
371  egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIso),
372  egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIsoPV));
373  tkem.setHwQual(gteg.quality);
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));
377  tkem.setEgBinaryWord(gteg.pack(), l1t::TkEm::HWEncoding::GT);
378  return tkem;
379 }
float floatPhi(phi_t phi)
Definition: gt_datatypes.h:48
float floatEta(eta_t eta)
Definition: gt_datatypes.h:47
void setHwQual(int qual)
Definition: L1Candidate.h:31
Definition: TkEm.h:23
float floatPt(pt_t pt)
Definition: gt_datatypes.h:46
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 381 of file L1TCtL2EgProducer.cc.

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

382  {
383  // std::cout << "[convertFromEmu] TkEle pt: " << egele.hwPt << " eta: " << egele.hwEta << " phi: " << egele.hwPhi << " staidx: " << egele.src_idx << std::endl;
384  // NOTE: the TkElectron object is created with the accuracy as in GT object (not the Correlator internal one)!
385  const auto gteg = egele.toGT();
387  l1gt::Scales::floatPt(gteg.v3.pt), l1gt::Scales::floatEta(gteg.v3.eta), l1gt::Scales::floatPhi(gteg.v3.phi), 0.);
388  // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso
390  constituentsPtrs[egele.src_idx].first,
391  constituentsPtrs[egele.src_idx].second,
392  egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::TkIso));
393  tkele.setHwQual(gteg.quality);
394  tkele.setPFIsol(egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PfIso));
395  tkele.setPuppiIsol(egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PuppiIso));
396  tkele.setEgBinaryWord(gteg.pack(), l1t::TkElectron::HWEncoding::GT);
397  tkele.setIdScore(egele.floatIDScore());
398  tkele.setCharge(egele.intCharge());
399  return tkele;
400 }
float floatPhi(phi_t phi)
Definition: gt_datatypes.h:48
float floatEta(eta_t eta)
Definition: gt_datatypes.h:47
void setHwQual(int qual)
Definition: L1Candidate.h:31
float floatPt(pt_t pt)
Definition: gt_datatypes.h:46
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,
ConstituentPtrVector constituentsPtrs,
l1ct::OutputBoard boarOut 
) const
private

Definition at line 316 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().

318  {
319  EGIsoEleObjEmu emu;
320  emu.initFromBits(tkele.egBinaryWord<EGIsoEleObj::BITWIDTH>());
321  emu.srcCluster = nullptr;
322  emu.srcTrack = nullptr;
323 
324  constituentsPtrs.push_back(std::make_pair(tkele.egCaloPtr(), tkele.trkPtr()));
325  emu.src_idx = constituentsPtrs.size() - 1;
326 
327  // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso
328  emu.setHwIso(EGIsoEleObjEmu::IsoType::TkIso, l1ct::Scales::makeIso(tkele.trkIsol() * tkele.pt()));
329  emu.setHwIso(EGIsoEleObjEmu::IsoType::PfIso, l1ct::Scales::makeIso(tkele.pfIsol() * tkele.pt()));
330  emu.setHwIso(EGIsoEleObjEmu::IsoType::PuppiIso, l1ct::Scales::makeIso(tkele.puppiIsol() * tkele.pt()));
331  // std::cout << "[convertToEmu] TkEle pt: " << emu.hwPt << " eta: " << emu.hwEta << " phi: " << emu.hwPhi << " staidx: " << emu.src_idx << std::endl;
332  boarOut.egelectron.push_back(emu);
333 }
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:205
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 335 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().

337  {
338  EGIsoObjEmu emu;
339  emu.initFromBits(tkem.egBinaryWord<EGIsoObj::BITWIDTH>());
340  emu.srcCluster = nullptr;
341  constituentsPtrs.push_back(std::make_pair(tkem.egCaloPtr(), edm::Ptr<L1TTTrackType>()));
342  emu.src_idx = constituentsPtrs.size() - 1;
343  // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso
344  emu.setHwIso(EGIsoObjEmu::IsoType::TkIso, l1ct::Scales::makeIso(tkem.trkIsol() * tkem.pt()));
345  emu.setHwIso(EGIsoObjEmu::IsoType::PfIso, l1ct::Scales::makeIso(tkem.pfIsol() * tkem.pt()));
346  emu.setHwIso(EGIsoObjEmu::IsoType::PuppiIso, l1ct::Scales::makeIso(tkem.puppiIsol() * tkem.pt()));
347  emu.setHwIso(EGIsoObjEmu::IsoType::TkIsoPV, l1ct::Scales::makeIso(tkem.trkIsolPV() * tkem.pt()));
348  emu.setHwIso(EGIsoObjEmu::IsoType::PfIsoPV, l1ct::Scales::makeIso(tkem.pfIsolPV() * tkem.pt()));
349  // std::cout << "[convertToEmu] TkEM pt: " << emu.hwPt << " eta: " << emu.hwEta << " phi: " << emu.hwPhi << " staidx: " << emu.src_idx << std::endl;
350  boarOut.egphoton.push_back(emu);
351 }
const l1t::PFCluster * srcCluster
iso_t makeIso(float iso)
Definition: datatypes.h:205
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 353 of file L1TCtL2EgProducer.cc.

References getGTfromDQMFile::obj.

Referenced by produce().

353  {
354  for (const auto &l1PFCand : l1PFCands) {
356  obj.initFromBits(l1PFCand.encodedPuppi64());
357  puppiObjs.emplace_back(obj);
358  }
359 }

◆ encodeLayer1() [1/4]

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

Definition at line 218 of file L1TCtL2EgProducer.cc.

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

Referenced by encodeLayer1(), and encodeLayer1EgObjs().

218  {
219  ap_uint<64> ret = 0;
220  ret(EGIsoObjEmu::BITWIDTH, 0) = egiso.pack();
221  return ret;
222 }
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 224 of file L1TCtL2EgProducer.cc.

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

224  {
225  ap_uint<128> ret = 0;
226  ret(EGIsoEleObjEmu::BITWIDTH, 0) = egiso.pack();
227  return ret;
228 }
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 230 of file L1TCtL2EgProducer.cc.

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

230  {
231  std::vector<ap_uint<64>> ret;
232  ret.reserve(photons.size());
233  for (const auto &phot : photons) {
234  ret.push_back(encodeLayer1(phot));
235  }
236  return ret;
237 }
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 239 of file L1TCtL2EgProducer.cc.

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

239  {
240  std::vector<ap_uint<64>> ret;
241  ret.reserve(2 * electrons.size());
242  for (const auto &ele : electrons) {
243  auto eleword = encodeLayer1(ele);
244  ret.push_back(eleword(63, 0));
245  ret.push_back(eleword(127, 64));
246  }
247  return ret;
248 }
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 250 of file L1TCtL2EgProducer.cc.

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

Referenced by produce().

252  {
253  std::vector<ap_uint<64>> ret;
254  auto encoded_photons = encodeLayer1(photons);
255  encoded_photons.resize(nObj, {0});
256  auto encoded_eles = encodeLayer1(electrons);
257  encoded_eles.resize(2 * nObj, {0});
258 
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));
261 
262  return ret;
263 }
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 308 of file L1TCtL2EgProducer.cc.

References doInPtrn_, doOutPtrn_, inPtrnWrt_, and outPtrnWrt_.

308  {
309  // Writing pending events to file before exiting
310  if (doOutPtrn_)
311  outPtrnWrt_->flush();
312  if (doInPtrn_)
313  inPtrnWrt_->flush();
314 }
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 113 of file L1TCtL2EgProducer.cc.

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

Referenced by produce().

116  {
118  for (const auto &tokenAndChannel : instance.tokensAndChannels()) {
119  iEvent.getByToken(tokenAndChannel.first, handle);
120  populate(out, handle, tokenAndChannel.second, constituentsPtrs);
121  }
122  }
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 > &links, 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 > &  links,
ConstituentPtrVector constituentsPtrs 
) const
inlineprivate

Definition at line 125 of file L1TCtL2EgProducer.cc.

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

128  {
129  assert(links.size() == in->nRegions());
130  for (unsigned int iBoard = 0, nBoard = in->nRegions(); iBoard < nBoard; ++iBoard) {
131  auto region = in->region(iBoard);
132  int linkID = links[iBoard];
133  if (linkID < 0)
134  continue;
135  // std::cout << "Board eta: " << in->eta(iBoard) << " phi: " << in->phi(iBoard) << " link: " << linkID << std::endl;
136  for (const auto &obj : region) {
137  convertToEmu(obj, constituentsPtrs, out->at(linkID));
138  }
139  }
140  }
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 > &  links,
ConstituentPtrVector constituentsPtrs 
) const
inlineprivate

Definition at line 142 of file L1TCtL2EgProducer.cc.

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

145  {
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);
149  }
150  }
151  }

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 265 of file L1TCtL2EgProducer.cc.

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

265  {
266  ConstituentPtrVector constituents;
267 
268  auto outEgs = std::make_unique<BXVector<l1t::EGamma>>();
269  merge(tkEGInputs_, iEvent, constituents, outEgs);
270  iEvent.put(std::move(outEgs), tkEGInstanceLabel_);
271 
272  auto boards = std::make_unique<std::vector<l1ct::OutputBoard>>(l2egsorter.nInputBoards());
273 
274  merge(tkEleInputs_, iEvent, constituents, boards);
275  merge(tkEmInputs_, iEvent, constituents, boards);
276 
277  if (doInPtrn_) {
278  l1t::demo::EventData inData;
279  for (unsigned int ibrd = 0; ibrd < boards->size(); ibrd++) {
280  inData.add(
281  {"eglayer1", ibrd},
282  encodeLayer1EgObjs(l2egsorter.nInputObjPerBoard(), (*boards)[ibrd].egphoton, (*boards)[ibrd].egelectron));
283  }
284  inPtrnWrt_->addEvent(inData);
285  }
286 
287  std::vector<EGIsoObjEmu> out_photons_emu;
288  std::vector<EGIsoEleObjEmu> out_eles_emu;
289  l2egsorter.run(*boards, out_photons_emu, out_eles_emu);
290 
291  // PUPPI isolation
292  auto &pfObjs = iEvent.get(pfObjsToken_);
293  l1ct::PuppiObjs puppiObjs;
294  convertToPuppi(pfObjs, puppiObjs);
295  l2EgPuppiIsoAlgo_.run(out_photons_emu, puppiObjs);
296  l2ElePuppiIsoAlgo_.run(out_eles_emu, puppiObjs);
297 
298  if (doOutPtrn_) {
299  l1t::demo::EventData outData;
300  outData.add({"eglayer2", 0}, l2encoder.encodeLayer2EgObjs(out_photons_emu, out_eles_emu));
301  outPtrnWrt_->addEvent(outData);
302  }
303 
304  putEgObjects<l1t::TkEmCollection>(iEvent, constituents, tkEmInstanceLabel_, out_photons_emu);
305  putEgObjects<l1t::TkElectronCollection>(iEvent, constituents, tkEleInstanceLabel_, out_eles_emu);
306 }
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 nInputBoards() const
PFInstanceInputs< l1t::TkEmRegionalOutput > tkEmInputs_
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
std::unique_ptr< PatternWriter > inPtrnWrt_
l1ct::L1EGPuppiIsoAlgo l2ElePuppiIsoAlgo_
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).
Definition: EventData.h:28
def move(src, dest)
Definition: eostools.py:511
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 154 of file L1TCtL2EgProducer.cc.

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

157  {
158  auto egobjs = std::make_unique<Tout>();
159  for (const auto &emu : emulated) {
160  if (emu.hwPt == 0)
161  continue;
162  auto obj = convertFromEmu(emu, constituentsPtrs);
163  egobjs->push_back(obj);
164  }
165  iEvent.put(std::move(egobjs), label);
166  }
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 182 of file L1TCtL2EgProducer.cc.

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

◆ doOutPtrn_

bool L1TCtL2EgProducer::doOutPtrn_
private

Definition at line 183 of file L1TCtL2EgProducer.cc.

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

◆ inPtrnWrt_

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

Definition at line 184 of file L1TCtL2EgProducer.cc.

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

◆ l2EgPuppiIsoAlgo_

l1ct::L1EGPuppiIsoAlgo L1TCtL2EgProducer::l2EgPuppiIsoAlgo_
private

Definition at line 180 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ l2egsorter

l1ct::L2EgSorterEmulator L1TCtL2EgProducer::l2egsorter
private

Definition at line 177 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ l2ElePuppiIsoAlgo_

l1ct::L1EGPuppiIsoAlgo L1TCtL2EgProducer::l2ElePuppiIsoAlgo_
private

Definition at line 181 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ l2encoder

l1ct::L2EgEncoderEmulator L1TCtL2EgProducer::l2encoder
private

Definition at line 178 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ outPtrnWrt_

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

Definition at line 185 of file L1TCtL2EgProducer.cc.

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

◆ pfObjsToken_

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

Definition at line 179 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ tkEGInputs_

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

Definition at line 171 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ tkEGInstanceLabel_

std::string L1TCtL2EgProducer::tkEGInstanceLabel_
private

Definition at line 174 of file L1TCtL2EgProducer.cc.

Referenced by L1TCtL2EgProducer(), and produce().

◆ tkEleInputs_

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

Definition at line 173 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ tkEleInstanceLabel_

std::string L1TCtL2EgProducer::tkEleInstanceLabel_
private

Definition at line 176 of file L1TCtL2EgProducer.cc.

Referenced by L1TCtL2EgProducer(), and produce().

◆ tkEmInputs_

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

Definition at line 172 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ tkEmInstanceLabel_

std::string L1TCtL2EgProducer::tkEmInstanceLabel_
private

Definition at line 175 of file L1TCtL2EgProducer.cc.

Referenced by L1TCtL2EgProducer(), and produce().