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
 
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 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
 
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, 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::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.

Constructor & Destructor Documentation

◆ L1TCtL2EgProducer()

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

Definition at line 208 of file L1TCtL2EgProducer.cc.

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

209  : tkEGInputs_(this, conf.getParameter<std::vector<edm::ParameterSet>>("tkEgs")),
210  tkEmInputs_(this, conf.getParameter<std::vector<edm::ParameterSet>>("tkEms")),
211  tkEleInputs_(this, conf.getParameter<std::vector<edm::ParameterSet>>("tkElectrons")),
212  tkEGInstanceLabel_(conf.getParameter<std::string>("egStaInstanceLabel")),
213  tkEmInstanceLabel_(conf.getParameter<std::string>("tkEmInstanceLabel")),
214  tkEleInstanceLabel_(conf.getParameter<std::string>("tkEleInstanceLabel")),
215  l2egsorter(conf.getParameter<edm::ParameterSet>("sorter")),
216  l2encoder(conf.getParameter<edm::ParameterSet>("encoder")),
217  pfObjsToken_(consumes<std::vector<l1t::PFCandidate>>(conf.getParameter<edm::InputTag>("l1PFObjects"))),
218  l2EgPuppiIsoAlgo_(conf.getParameter<edm::ParameterSet>("puppiIsoParametersTkEm")),
219  l2ElePuppiIsoAlgo_(conf.getParameter<edm::ParameterSet>("puppiIsoParametersTkEle")),
220  doInPtrn_(conf.getParameter<bool>("writeInPattern")),
221  doOutPtrn_(conf.getParameter<bool>("writeOutPattern")),
222  inPtrnWrt_(nullptr),
223  outPtrnWrt_(nullptr) {
224  produces<BXVector<l1t::EGamma>>(tkEGInstanceLabel_);
225  produces<l1t::TkEmCollection>(tkEmInstanceLabel_);
226  produces<l1t::TkElectronCollection>(tkEleInstanceLabel_);
227 
228  if (doInPtrn_) {
229  inPtrnWrt_ = std::make_unique<PatternWriter>(conf.getParameter<edm::ParameterSet>("inPatternFile"));
230  }
231  if (doOutPtrn_) {
232  outPtrnWrt_ = std::make_unique<PatternWriter>(conf.getParameter<edm::ParameterSet>("outPatternFile"));
233  }
234 }
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 236 of file L1TCtL2EgProducer.cc.

236 {}

Member Function Documentation

◆ convertFromEmu() [1/2]

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

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

391  {
392  // std::cout << "[convertFromEmu] TkEm pt: " << egiso.hwPt << " eta: " << egiso.hwEta << " phi: " << egiso.hwPhi << " staidx: " << egiso.sta_idx << std::endl;
393  // NOTE: the TkEM object is created with the accuracy as in GT object (not the Correlator internal one)!
394  const auto gteg = egiso.toGT();
396  l1gt::Scales::floatPt(gteg.v3.pt), l1gt::Scales::floatEta(gteg.v3.eta), l1gt::Scales::floatPhi(gteg.v3.phi), 0.);
397  // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso
399  refRemapper.origRefAndPtr[egiso.sta_idx].first,
400  egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIso),
401  egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIsoPV));
402  tkem.setHwQual(gteg.quality);
403  tkem.setPFIsol(egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::PfIso));
404  tkem.setPFIsolPV(egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::PfIsoPV));
405  tkem.setPuppiIsol(egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::PuppiIso));
406  tkem.setEgBinaryWord(gteg.pack());
407  return tkem;
408 }
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:20
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 RefRemapper refRemapper 
) const
private

Definition at line 410 of file L1TCtL2EgProducer.cc.

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

411  {
412  // std::cout << "[convertFromEmu] TkEle pt: " << egele.hwPt << " eta: " << egele.hwEta << " phi: " << egele.hwPhi << " staidx: " << egele.sta_idx << std::endl;
413  // NOTE: the TkElectron object is created with the accuracy as in GT object (not the Correlator internal one)!
414  const auto gteg = egele.toGT();
416  l1gt::Scales::floatPt(gteg.v3.pt), l1gt::Scales::floatEta(gteg.v3.eta), l1gt::Scales::floatPhi(gteg.v3.phi), 0.);
417  // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso
419  refRemapper.origRefAndPtr[egele.sta_idx].first,
420  refRemapper.origRefAndPtr[egele.sta_idx].second,
421  egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::TkIso));
422  tkele.setHwQual(gteg.quality);
423  tkele.setPFIsol(egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PfIso));
424  tkele.setPuppiIsol(egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PuppiIso));
425  tkele.setEgBinaryWord(gteg.pack());
426  tkele.setIdScore(egele.idScore);
427  return tkele;
428 }
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,
RefRemapper refRemapper,
l1ct::OutputBoard boarOut 
) const
private

Definition at line 336 of file L1TCtL2EgProducer.cc.

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

338  {
339  EGIsoEleObjEmu emu;
340  emu.initFromBits(tkele.egBinaryWord<EGIsoEleObj::BITWIDTH>());
341  emu.srcCluster = nullptr;
342  emu.srcTrack = nullptr;
343  auto refEg = tkele.EGRef();
344  const auto newref = refRemapper.old2newRefMap.find(refEg);
345  if (newref != refRemapper.old2newRefMap.end()) {
346  refEg = newref->second;
347  }
348  refRemapper.origRefAndPtr.push_back(std::make_pair(refEg, tkele.trkPtr()));
349  emu.sta_idx = refRemapper.origRefAndPtr.size() - 1;
350  // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso
351  emu.setHwIso(EGIsoEleObjEmu::IsoType::TkIso, l1ct::Scales::makeIso(tkele.trkIsol() * tkele.pt()));
352  emu.setHwIso(EGIsoEleObjEmu::IsoType::PfIso, l1ct::Scales::makeIso(tkele.pfIsol() * tkele.pt()));
353  emu.setHwIso(EGIsoEleObjEmu::IsoType::PuppiIso, l1ct::Scales::makeIso(tkele.puppiIsol() * tkele.pt()));
354  // std::cout << "[convertToEmu] TkEle pt: " << emu.hwPt << " eta: " << emu.hwEta << " phi: " << emu.hwPhi << " staidx: " << emu.sta_idx << std::endl;
355  // FIXME: this is temporary while waiting to move the BDT score to the FW object
356  emu.idScore = tkele.idScore();
357  boarOut.egelectron.push_back(emu);
358 }
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:206
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 idScore() const
Definition: TkElectron.h:42
float pfIsol() const
Definition: TkEm.h:43
float puppiIsol() const
Definition: TkEm.h:45

◆ convertToEmu() [2/2]

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

Definition at line 360 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(), l1t::TkEm::puppiIsol(), l1ct::EGIsoObjEmu::setHwIso(), l1ct::EGIsoObjEmu::srcCluster, l1ct::EGIsoObjEmu::sta_idx, l1t::TkEm::trkIsol(), and l1t::TkEm::trkIsolPV().

362  {
363  EGIsoObjEmu emu;
364  emu.initFromBits(tkem.egBinaryWord<EGIsoObj::BITWIDTH>());
365  emu.srcCluster = nullptr;
366  auto refEg = tkem.EGRef();
367  const auto newref = refRemapper.old2newRefMap.find(refEg);
368  if (newref != refRemapper.old2newRefMap.end()) {
369  refEg = newref->second;
370  }
371  refRemapper.origRefAndPtr.push_back(std::make_pair(refEg, edm::Ptr<RefRemapper::L1TTTrackType>(nullptr, 0)));
372  emu.sta_idx = refRemapper.origRefAndPtr.size() - 1;
373  // NOTE: The emulator and FW data-format stores absolute iso while the CMSSW object stores relative iso
374  emu.setHwIso(EGIsoObjEmu::IsoType::TkIso, l1ct::Scales::makeIso(tkem.trkIsol() * tkem.pt()));
375  emu.setHwIso(EGIsoObjEmu::IsoType::PfIso, l1ct::Scales::makeIso(tkem.pfIsol() * tkem.pt()));
376  emu.setHwIso(EGIsoObjEmu::IsoType::PuppiIso, l1ct::Scales::makeIso(tkem.puppiIsol() * tkem.pt()));
377  emu.setHwIso(EGIsoObjEmu::IsoType::TkIsoPV, l1ct::Scales::makeIso(tkem.trkIsolPV() * tkem.pt()));
378  emu.setHwIso(EGIsoObjEmu::IsoType::PfIsoPV, l1ct::Scales::makeIso(tkem.pfIsolPV() * tkem.pt()));
379  // std::cout << "[convertToEmu] TkEM pt: " << emu.hwPt << " eta: " << emu.hwEta << " phi: " << emu.hwPhi << " staidx: " << emu.sta_idx << std::endl;
380  boarOut.egphoton.push_back(emu);
381 }
const l1t::PFCluster * srcCluster
iso_t makeIso(float iso)
Definition: datatypes.h:206
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 383 of file L1TCtL2EgProducer.cc.

References getGTfromDQMFile::obj.

Referenced by produce().

383  {
384  for (const auto &l1PFCand : l1PFCands) {
386  obj.initFromBits(l1PFCand.encodedPuppi64());
387  puppiObjs.emplace_back(obj);
388  }
389 }

◆ encodeLayer1() [1/4]

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

Definition at line 238 of file L1TCtL2EgProducer.cc.

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

Referenced by encodeLayer1(), and encodeLayer1EgObjs().

238  {
239  ap_uint<64> ret = 0;
240  ret(EGIsoObjEmu::BITWIDTH, 0) = egiso.pack();
241  return ret;
242 }
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 244 of file L1TCtL2EgProducer.cc.

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

244  {
245  ap_uint<128> ret = 0;
246  ret(EGIsoEleObjEmu::BITWIDTH, 0) = egiso.pack();
247  return ret;
248 }
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 250 of file L1TCtL2EgProducer.cc.

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

250  {
251  std::vector<ap_uint<64>> ret;
252  ret.reserve(photons.size());
253  for (const auto &phot : photons) {
254  ret.push_back(encodeLayer1(phot));
255  }
256  return ret;
257 }
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 259 of file L1TCtL2EgProducer.cc.

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

259  {
260  std::vector<ap_uint<64>> ret;
261  ret.reserve(2 * electrons.size());
262  for (const auto &ele : electrons) {
263  auto eleword = encodeLayer1(ele);
264  ret.push_back(eleword(63, 0));
265  ret.push_back(eleword(127, 64));
266  }
267  return ret;
268 }
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 270 of file L1TCtL2EgProducer.cc.

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

Referenced by produce().

272  {
273  std::vector<ap_uint<64>> ret;
274  auto encoded_photons = encodeLayer1(photons);
275  encoded_photons.resize(nObj, {0});
276  auto encoded_eles = encodeLayer1(electrons);
277  encoded_eles.resize(2 * nObj, {0});
278 
279  std::copy(encoded_photons.begin(), encoded_photons.end(), std::back_inserter(ret));
280  std::copy(encoded_eles.begin(), encoded_eles.end(), std::back_inserter(ret));
281 
282  return ret;
283 }
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 328 of file L1TCtL2EgProducer.cc.

References doInPtrn_, doOutPtrn_, inPtrnWrt_, and outPtrnWrt_.

328  {
329  // Writing pending events to file before exiting
330  if (doOutPtrn_)
331  outPtrnWrt_->flush();
332  if (doInPtrn_)
333  inPtrnWrt_->flush();
334 }
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 116 of file L1TCtL2EgProducer.cc.

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

Referenced by produce().

119  {
121  for (const auto &tokenAndChannel : instance.tokensAndChannels()) {
122  iEvent.getByToken(tokenAndChannel.first, handle);
123  populate(out, handle, tokenAndChannel.second, refRemapper);
124  }
125  remapRefs(iEvent, out, refRemapper);
126  }
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 140 of file L1TCtL2EgProducer.cc.

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

143  {
144  assert(links.size() == in->nRegions());
145  for (unsigned int iBoard = 0, nBoard = in->nRegions(); iBoard < nBoard; ++iBoard) {
146  auto region = in->region(iBoard);
147  int linkID = links[iBoard];
148  if (linkID < 0)
149  continue;
150  // std::cout << "Board eta: " << in->eta(iBoard) << " phi: " << in->phi(iBoard) << " link: " << linkID << std::endl;
151  for (const auto &obj : region) {
152  convertToEmu(obj, refRemapper, out->at(linkID));
153  }
154  }
155  }
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 157 of file L1TCtL2EgProducer.cc.

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

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

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 285 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_.

285  {
286  RefRemapper refmapper;
287 
288  auto outEgs = std::make_unique<BXVector<l1t::EGamma>>();
289  merge(tkEGInputs_, iEvent, refmapper, outEgs);
290  iEvent.put(std::move(outEgs), tkEGInstanceLabel_);
291 
292  auto boards = std::make_unique<std::vector<l1ct::OutputBoard>>(l2egsorter.nInputBoards());
293 
294  merge(tkEleInputs_, iEvent, refmapper, boards);
295  merge(tkEmInputs_, iEvent, refmapper, boards);
296 
297  if (doInPtrn_) {
298  l1t::demo::EventData inData;
299  for (unsigned int ibrd = 0; ibrd < boards->size(); ibrd++) {
300  inData.add(
301  {"eglayer1", ibrd},
302  encodeLayer1EgObjs(l2egsorter.nInputObjPerBoard(), (*boards)[ibrd].egphoton, (*boards)[ibrd].egelectron));
303  }
304  inPtrnWrt_->addEvent(inData);
305  }
306 
307  std::vector<EGIsoObjEmu> out_photons_emu;
308  std::vector<EGIsoEleObjEmu> out_eles_emu;
309  l2egsorter.run(*boards, out_photons_emu, out_eles_emu);
310 
311  // PUPPI isolation
312  auto &pfObjs = iEvent.get(pfObjsToken_);
313  l1ct::PuppiObjs puppiObjs;
314  convertToPuppi(pfObjs, puppiObjs);
315  l2EgPuppiIsoAlgo_.run(out_photons_emu, puppiObjs);
316  l2ElePuppiIsoAlgo_.run(out_eles_emu, puppiObjs);
317 
318  if (doOutPtrn_) {
319  l1t::demo::EventData outData;
320  outData.add({"eglayer2", 0}, l2encoder.encodeLayer2EgObjs(out_photons_emu, out_eles_emu));
321  outPtrnWrt_->addEvent(outData);
322  }
323 
324  putEgObjects<l1t::TkEmCollection>(iEvent, refmapper, tkEmInstanceLabel_, out_photons_emu);
325  putEgObjects<l1t::TkElectronCollection>(iEvent, refmapper, tkEleInstanceLabel_, out_eles_emu);
326 }
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
void merge(const PFInstanceInputs< T > &instance, edm::Event &iEvent, RefRemapper &refRemapper, std::unique_ptr< TT > &out) const
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_
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 RefRemapper refRemapper,
const std::string &  label,
const std::vector< Tin >  emulated 
) const
inlineprivate

Definition at line 174 of file L1TCtL2EgProducer.cc.

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

177  {
178  auto egobjs = std::make_unique<Tout>();
179  for (const auto &emu : emulated) {
180  if (emu.hwPt == 0)
181  continue;
182  auto obj = convertFromEmu(emu, refRemapper);
183  egobjs->push_back(obj);
184  }
185  iEvent.put(std::move(egobjs), label);
186  }
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 129 of file L1TCtL2EgProducer.cc.

129 {}

◆ 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 202 of file L1TCtL2EgProducer.cc.

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

◆ doOutPtrn_

bool L1TCtL2EgProducer::doOutPtrn_
private

Definition at line 203 of file L1TCtL2EgProducer.cc.

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

◆ inPtrnWrt_

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

Definition at line 204 of file L1TCtL2EgProducer.cc.

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

◆ l2EgPuppiIsoAlgo_

l1ct::L1EGPuppiIsoAlgo L1TCtL2EgProducer::l2EgPuppiIsoAlgo_
private

Definition at line 200 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ l2egsorter

l1ct::L2EgSorterEmulator L1TCtL2EgProducer::l2egsorter
private

Definition at line 197 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ l2ElePuppiIsoAlgo_

l1ct::L1EGPuppiIsoAlgo L1TCtL2EgProducer::l2ElePuppiIsoAlgo_
private

Definition at line 201 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ l2encoder

l1ct::L2EgEncoderEmulator L1TCtL2EgProducer::l2encoder
private

Definition at line 198 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ outPtrnWrt_

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

Definition at line 205 of file L1TCtL2EgProducer.cc.

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

◆ pfObjsToken_

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

Definition at line 199 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ tkEGInputs_

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

Definition at line 191 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ tkEGInstanceLabel_

std::string L1TCtL2EgProducer::tkEGInstanceLabel_
private

Definition at line 194 of file L1TCtL2EgProducer.cc.

Referenced by L1TCtL2EgProducer(), and produce().

◆ tkEleInputs_

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

Definition at line 193 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ tkEleInstanceLabel_

std::string L1TCtL2EgProducer::tkEleInstanceLabel_
private

Definition at line 196 of file L1TCtL2EgProducer.cc.

Referenced by L1TCtL2EgProducer(), and produce().

◆ tkEmInputs_

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

Definition at line 192 of file L1TCtL2EgProducer.cc.

Referenced by produce().

◆ tkEmInstanceLabel_

std::string L1TCtL2EgProducer::tkEmInstanceLabel_
private

Definition at line 195 of file L1TCtL2EgProducer.cc.

Referenced by L1TCtL2EgProducer(), and produce().