CMS 3D CMS Logo

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

Public Member Functions

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

Private Member Functions

l1t::PFJet makeJet_SW (const std::vector< edm::Ptr< l1t::PFCandidate >> &parts) const
 
std::vector< l1t::PFJetprocessEvent_HW (std::vector< edm::Ptr< l1t::PFCandidate >> &parts) const
 
std::vector< l1t::PFJetprocessEvent_SW (std::vector< edm::Ptr< l1t::PFCandidate >> &parts) const
 
void produce (edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
 

Static Private Member Functions

static std::pair< std::vector< L1SCJetEmu::Particle >, std::unordered_map< const l1t::PFCandidate *, edm::Ptr< l1t::PFCandidate > > > convertEDMToHW (std::vector< edm::Ptr< l1t::PFCandidate >> &edmParticles)
 
static std::vector< l1t::PFJetconvertHWToEDM (std::vector< L1SCJetEmu::Jet > hwJets, std::unordered_map< const l1t::PFCandidate *, edm::Ptr< l1t::PFCandidate >> constituentMap)
 

Private Attributes

float coneSize
 ///////////////// /// More...
 
bool debug
 
L1SCJetEmu emulator
 
bool HW
 
edm::EDGetTokenT< std::vector< l1t::PFCandidate > > l1PFToken
 
unsigned nJets
 

Additional Inherited Members

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

Detailed Description

Definition at line 20 of file L1SeedConePFJetProducer.cc.

Constructor & Destructor Documentation

◆ L1SeedConePFJetProducer()

L1SeedConePFJetProducer::L1SeedConePFJetProducer ( const edm::ParameterSet cfg)
explicit

Definition at line 52 of file L1SeedConePFJetProducer.cc.

53  : coneSize(cfg.getParameter<double>("coneSize")),
54  nJets(cfg.getParameter<unsigned>("nJets")),
55  HW(cfg.getParameter<bool>("HW")),
56  debug(cfg.getParameter<bool>("debug")),
58  l1PFToken(consumes<std::vector<l1t::PFCandidate>>(cfg.getParameter<edm::InputTag>("L1PFObjects"))) {
59  produces<l1t::PFJetCollection>();
60 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
float coneSize
///////////////// ///
edm::EDGetTokenT< std::vector< l1t::PFCandidate > > l1PFToken

◆ ~L1SeedConePFJetProducer()

L1SeedConePFJetProducer::~L1SeedConePFJetProducer ( )
override

Definition at line 89 of file L1SeedConePFJetProducer.cc.

89 {}

Member Function Documentation

◆ convertEDMToHW()

std::pair< std::vector< L1SCJetEmu::Particle >, std::unordered_map< const l1t::PFCandidate *, edm::Ptr< l1t::PFCandidate > > > L1SeedConePFJetProducer::convertEDMToHW ( std::vector< edm::Ptr< l1t::PFCandidate >> &  edmParticles)
staticprivate

Definition at line 163 of file L1SeedConePFJetProducer.cc.

References reco::LeafCandidate::get(), l1ct::PuppiObj::initFromBits(), and l1ct::PuppiObjEmu::srcCand.

Referenced by processEvent_HW().

163  {
164  std::vector<l1ct::PuppiObjEmu> hwParticles;
165  std::unordered_map<const l1t::PFCandidate*, edm::Ptr<l1t::PFCandidate>> candidateMap;
166  std::for_each(edmParticles.begin(), edmParticles.end(), [&](edm::Ptr<l1t::PFCandidate>& edmParticle) {
167  l1ct::PuppiObjEmu particle;
168  particle.initFromBits(edmParticle->encodedPuppi64());
169  particle.srcCand = edmParticle.get();
170  candidateMap.insert(std::make_pair(edmParticle.get(), edmParticle));
171  hwParticles.push_back(particle);
172  });
173  return std::make_pair(hwParticles, candidateMap);
174 }
T get() const
get a component
const l1t::PFCandidate * srcCand
void initFromBits(const ap_uint< BITWIDTH > &src)
Definition: puppi.h:171

◆ convertHWToEDM()

std::vector< l1t::PFJet > L1SeedConePFJetProducer::convertHWToEDM ( std::vector< L1SCJetEmu::Jet hwJets,
std::unordered_map< const l1t::PFCandidate *, edm::Ptr< l1t::PFCandidate >>  constituentMap 
)
staticprivate

Definition at line 176 of file L1SeedConePFJetProducer.cc.

References l1t::gtJet, and metsig::jet.

Referenced by processEvent_HW().

178  {
179  std::vector<l1t::PFJet> edmJets;
180  std::for_each(hwJets.begin(), hwJets.end(), [&](L1SCJetEmu::Jet jet) {
181  l1t::PFJet edmJet(
182  jet.floatPt(), jet.floatEta(), jet.floatPhi(), /*mass=*/0., jet.intPt(), jet.intEta(), jet.intPhi());
183  // get back the references to the constituents
184  std::vector<edm::Ptr<l1t::PFCandidate>> constituents;
185  std::for_each(jet.constituents.begin(), jet.constituents.end(), [&](auto constituent) {
186  edmJet.addConstituent(constituentMap[constituent.srcCand]);
187  });
188  l1gt::Jet gtJet = jet.toGT();
189  edmJet.setEncodedJet(jet.toGT().pack());
190  edmJets.push_back(edmJet);
191  });
192  return edmJets;
193 }

◆ makeJet_SW()

l1t::PFJet L1SeedConePFJetProducer::makeJet_SW ( const std::vector< edm::Ptr< l1t::PFCandidate >> &  parts) const
private

Definition at line 91 of file L1SeedConePFJetProducer.cc.

References a, b, reco::deltaPhi(), PVValHelper::eta, metsig::jet, phi, DiDispStaMuonMonitor_cfi::pt, fileCollector::seed, and HcalDetIdTransform::transform().

Referenced by processEvent_SW().

91  {
92  l1t::PFCandidate seed = *parts.at(0);
93 
94  auto sumpt = [](float a, const edm::Ptr<l1t::PFCandidate>& b) { return a + b->pt(); };
95 
96  // Sum the pt
97  float pt = std::accumulate(parts.begin(), parts.end(), 0., sumpt);
98 
99  // pt weighted d eta
100  std::vector<float> pt_deta;
101  pt_deta.resize(parts.size());
102  std::transform(parts.begin(), parts.end(), pt_deta.begin(), [&seed, &pt](const edm::Ptr<l1t::PFCandidate>& part) {
103  return (part->pt() / pt) * (part->eta() - seed.eta());
104  });
105  // Accumulate the pt weighted etas. Init to the seed eta, start accumulating at begin()+1 to skip seed
106  float eta = std::accumulate(pt_deta.begin() + 1, pt_deta.end(), seed.eta());
107 
108  // pt weighted d phi
109  std::vector<float> pt_dphi;
110  pt_dphi.resize(parts.size());
111  std::transform(parts.begin(), parts.end(), pt_dphi.begin(), [&seed, &pt](const edm::Ptr<l1t::PFCandidate>& part) {
112  return (part->pt() / pt) * reco::deltaPhi(part->phi(), seed.phi());
113  });
114  // Accumulate the pt weighted phis. Init to the seed phi, start accumulating at begin()+1 to skip seed
115  float phi = std::accumulate(pt_dphi.begin() + 1, pt_dphi.end(), seed.phi());
116 
117  l1t::PFJet jet(pt, eta, phi);
118  for (auto it = parts.begin(); it != parts.end(); it++) {
119  jet.addConstituent(*it);
120  }
121 
122  return jet;
123 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
part
Definition: HCALResponse.h:20
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
unsigned transform(const HcalDetId &id, unsigned transformCode)

◆ processEvent_HW()

std::vector< l1t::PFJet > L1SeedConePFJetProducer::processEvent_HW ( std::vector< edm::Ptr< l1t::PFCandidate >> &  parts) const
private

Definition at line 153 of file L1SeedConePFJetProducer.cc.

References convertEDMToHW(), convertHWToEDM(), L1SCJetEmu::emulateEvent(), emulator, PDWG_EXODelayedJetMET_cff::jets, ecalTrigSettings_cff::particles, and edmIntegrityCheck::work.

Referenced by produce().

153  {
154  // The fixed point emulator
155  // Convert the EDM format to the hardware format, and call the standalone emulator
156  std::pair<std::vector<L1SCJetEmu::Particle>, std::unordered_map<const l1t::PFCandidate*, edm::Ptr<l1t::PFCandidate>>>
158  std::vector<L1SCJetEmu::Jet> jets = emulator.emulateEvent(particles.first);
159  return convertHWToEDM(jets, particles.second);
160 }
static std::vector< l1t::PFJet > convertHWToEDM(std::vector< L1SCJetEmu::Jet > hwJets, std::unordered_map< const l1t::PFCandidate *, edm::Ptr< l1t::PFCandidate >> constituentMap)
std::vector< Jet > emulateEvent(std::vector< Particle > &parts) const
static std::pair< std::vector< L1SCJetEmu::Particle >, std::unordered_map< const l1t::PFCandidate *, edm::Ptr< l1t::PFCandidate > > > convertEDMToHW(std::vector< edm::Ptr< l1t::PFCandidate >> &edmParticles)

◆ processEvent_SW()

std::vector< l1t::PFJet > L1SeedConePFJetProducer::processEvent_SW ( std::vector< edm::Ptr< l1t::PFCandidate >> &  parts) const
private

Definition at line 125 of file L1SeedConePFJetProducer.cc.

References coneSize, mps_fire::i, dqmiolumiharvest::j, PDWG_EXODelayedJetMET_cff::jets, makeJet_SW(), nJets, fileCollector::seed, and edmIntegrityCheck::work.

Referenced by produce().

125  {
126  // The floating point algorithm simulation
127  std::stable_sort(work.begin(), work.end(), [](edm::Ptr<l1t::PFCandidate> i, edm::Ptr<l1t::PFCandidate> j) {
128  return (i->pt() > j->pt());
129  });
130  std::vector<l1t::PFJet> jets;
131  jets.reserve(nJets);
132  while (!work.empty() && jets.size() < nJets) {
133  // Take the first (highest pt) candidate as a seed
135  // Get the particles within a _coneSize of the seed
136  std::vector<edm::Ptr<l1t::PFCandidate>> particlesInCone;
137  std::copy_if(
138  work.begin(), work.end(), std::back_inserter(particlesInCone), [&](const edm::Ptr<l1t::PFCandidate>& part) {
139  return reco::deltaR<l1t::PFCandidate, l1t::PFCandidate>(*seed, *part) <= coneSize;
140  });
141  jets.push_back(makeJet_SW(particlesInCone));
142  // remove the clustered particles
143  work.erase(std::remove_if(work.begin(),
144  work.end(),
145  [&](const edm::Ptr<l1t::PFCandidate>& part) {
146  return reco::deltaR<l1t::PFCandidate, l1t::PFCandidate>(*seed, *part) <= coneSize;
147  }),
148  work.end());
149  }
150  return jets;
151 }
l1t::PFJet makeJet_SW(const std::vector< edm::Ptr< l1t::PFCandidate >> &parts) const
part
Definition: HCALResponse.h:20
float coneSize
///////////////// ///

◆ produce()

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

///////////////// /// MANDATORY METHODS ///

Implements edm::global::EDProducerBase.

Definition at line 62 of file L1SeedConePFJetProducer.cc.

References HW, mps_fire::i, iEvent, dqmiolumiharvest::j, PDWG_EXODelayedJetMET_cff::jets, l1PFToken, eostools::move(), ecalTrigSettings_cff::particles, processEvent_HW(), processEvent_SW(), and jetUpdater_cfi::sort.

64  {
65  std::unique_ptr<l1t::PFJetCollection> newPFJetCollection(new l1t::PFJetCollection);
66 
68  iEvent.getByToken(l1PFToken, l1PFCandidates);
69 
70  std::vector<edm::Ptr<l1t::PFCandidate>> particles;
71  for (unsigned i = 0; i < (*l1PFCandidates).size(); i++) {
72  particles.push_back(edm::Ptr<l1t::PFCandidate>(l1PFCandidates, i));
73  }
74 
75  std::vector<l1t::PFJet> jets;
76  if (HW) {
78  } else {
80  }
81 
82  std::sort(jets.begin(), jets.end(), [](l1t::PFJet i, l1t::PFJet j) { return (i.pt() > j.pt()); });
83  newPFJetCollection->swap(jets);
84  iEvent.put(std::move(newPFJetCollection));
85 }
std::vector< l1t::PFJet > processEvent_SW(std::vector< edm::Ptr< l1t::PFCandidate >> &parts) const
std::vector< l1t::PFJet > PFJetCollection
Definition: PFJet.h:49
int iEvent
Definition: GenABIO.cc:224
std::vector< l1t::PFJet > processEvent_HW(std::vector< edm::Ptr< l1t::PFCandidate >> &parts) const
edm::EDGetTokenT< std::vector< l1t::PFCandidate > > l1PFToken
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ coneSize

float L1SeedConePFJetProducer::coneSize
private

///////////////// ///

Definition at line 31 of file L1SeedConePFJetProducer.cc.

Referenced by processEvent_SW().

◆ debug

bool L1SeedConePFJetProducer::debug
private

◆ emulator

L1SCJetEmu L1SeedConePFJetProducer::emulator
private

Definition at line 35 of file L1SeedConePFJetProducer.cc.

Referenced by processEvent_HW().

◆ HW

bool L1SeedConePFJetProducer::HW
private

Definition at line 33 of file L1SeedConePFJetProducer.cc.

Referenced by produce().

◆ l1PFToken

edm::EDGetTokenT<std::vector<l1t::PFCandidate> > L1SeedConePFJetProducer::l1PFToken
private

Definition at line 36 of file L1SeedConePFJetProducer.cc.

Referenced by produce().

◆ nJets

unsigned L1SeedConePFJetProducer::nJets
private

Definition at line 32 of file L1SeedConePFJetProducer.cc.

Referenced by processEvent_SW().