CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
DeregionizerProducer Class Reference
Inheritance diagram for DeregionizerProducer:
edm::stream::EDProducer<>

Public Member Functions

 DeregionizerProducer (const edm::ParameterSet &)
 
 ~DeregionizerProducer () override
 
- Public Member Functions inherited from edm::stream::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
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void hwToEdm_ (const std::vector< l1ct::PuppiObjEmu > &hwOut, std::vector< l1t::PFCandidate > &edmOut) const
 
void produce (edm::Event &, const edm::EventSetup &) override
 
void setRefs_ (l1t::PFCandidate &pf, const l1ct::PuppiObjEmu &p) const
 

Private Attributes

std::vector< uint32_t > boardOrder_
 
std::unordered_map< const l1t::PFCandidate *, l1t::PFClusterRefclusterRefMap_
 
edm::ParameterSet config_
 
l1ct::DeregionizerEmulator emulator_
 
l1ct::DeregionizerInput input_
 
std::vector< edm::ParameterSetlinkConfigs_
 
std::unordered_map< const l1t::PFCandidate *, l1t::PFCandidate::MuonRefmuonRefMap_
 
const unsigned int nInputFramesPerBX_
 
std::vector< uint32_t > nLinksPuppi_
 
std::vector< uint32_t > nOutputFramesPerBX_
 
std::vector< uint32_t > nPuppiFramesPerRegion_
 
std::vector< uint32_t > nPuppiPerRegion_
 
std::vector< std::vector< uint32_t > > outputRegions_
 
const unsigned int tmuxFactor_ = 6
 
edm::EDGetTokenT< l1t::PFCandidateRegionalOutputtoken_
 
std::unordered_map< const l1t::PFCandidate *, l1t::PFTrackReftrackRefMap_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 16 of file DeregionizerProducer.cc.

Constructor & Destructor Documentation

◆ DeregionizerProducer()

DeregionizerProducer::DeregionizerProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 42 of file DeregionizerProducer.cc.

43  : config_(iConfig),
44  token_(consumes<l1t::PFCandidateRegionalOutput>(iConfig.getParameter<edm::InputTag>("RegionalPuppiCands"))),
45  linkConfigs_(iConfig.getParameter<std::vector<edm::ParameterSet>>("linkConfigs")),
46  nInputFramesPerBX_(iConfig.getParameter<uint32_t>("nInputFramesPerBX")),
47  emulator_(iConfig),
49  produces<l1t::PFCandidateCollection>("Puppi");
50  produces<l1t::PFCandidateCollection>("TruncatedPuppi");
51 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
l1ct::DeregionizerEmulator emulator_
edm::ParameterSet config_
edm::EDGetTokenT< l1t::PFCandidateRegionalOutput > token_
const unsigned int nInputFramesPerBX_
std::vector< edm::ParameterSet > linkConfigs_
l1ct::DeregionizerInput input_

◆ ~DeregionizerProducer()

DeregionizerProducer::~DeregionizerProducer ( )
override

Definition at line 53 of file DeregionizerProducer.cc.

53 {}

Member Function Documentation

◆ fillDescriptions()

void DeregionizerProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 177 of file DeregionizerProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, and edm::ParameterSetDescription::setAllowAnything().

177  {
179  desc.add<edm::InputTag>("RegionalPuppiCands", edm::InputTag("l1tLayer1", "PuppiRegional"));
180  desc.add<unsigned int>("nPuppiFinalBuffer", 128);
181  desc.add<unsigned int>("nPuppiPerClk", 6);
182  desc.add<unsigned int>("nPuppiFirstBuffers", 12);
183  desc.add<unsigned int>("nPuppiSecondBuffers", 32);
184  desc.add<unsigned int>("nPuppiThirdBuffers", 64);
185  desc.add<unsigned int>("nInputFramesPerBX", 9);
186  edm::ParameterSetDescription linkConfigDummyValidator;
187  linkConfigDummyValidator.setAllowAnything();
188  desc.addVPSet("linkConfigs", linkConfigDummyValidator);
189  descriptions.add("DeregionizerProducer", desc);
190 }
void setAllowAnything()
allow any parameter label/value pairs
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ hwToEdm_()

void DeregionizerProducer::hwToEdm_ ( const std::vector< l1ct::PuppiObjEmu > &  hwOut,
std::vector< l1t::PFCandidate > &  edmOut 
) const
private

Definition at line 114 of file DeregionizerProducer.cc.

References l1t::PFCandidate::ChargedHadron, l1t::PFCandidate::Electron, EgHLTOffHistBins_cfi::mass, l1t::PFCandidate::Muon, l1t::PFCandidate::NeutralHadron, l1t::PFCandidate::Photon, and setRefs_().

Referenced by produce().

115  {
116  for (const auto &hwPuppi : hwOut) {
118  float mass = 0.13f;
119  if (hwPuppi.hwId.charged()) {
120  if (hwPuppi.hwId.isMuon()) {
122  mass = 0.105;
123  } else if (hwPuppi.hwId.isElectron()) {
125  mass = 0.005;
126  } else
128  } else {
129  type = hwPuppi.hwId.isPhoton() ? l1t::PFCandidate::Photon : l1t::PFCandidate::NeutralHadron;
130  mass = hwPuppi.hwId.isPhoton() ? 0.0 : 0.5;
131  }
132  reco::Particle::PolarLorentzVector p4(hwPuppi.floatPt(), hwPuppi.floatEta(), hwPuppi.floatPhi(), mass);
133  edmOut.emplace_back(
134  type, hwPuppi.intCharge(), p4, hwPuppi.floatPuppiW(), hwPuppi.intPt(), hwPuppi.intEta(), hwPuppi.intPhi());
135  if (hwPuppi.hwId.charged()) {
136  edmOut.back().setZ0(hwPuppi.floatZ0());
137  edmOut.back().setDxy(hwPuppi.floatDxy());
138  edmOut.back().setHwZ0(hwPuppi.hwZ0());
139  edmOut.back().setHwDxy(hwPuppi.hwDxy());
140  edmOut.back().setHwTkQuality(hwPuppi.hwTkQuality());
141  } else {
142  edmOut.back().setHwPuppiWeight(hwPuppi.hwPuppiW());
143  edmOut.back().setHwEmID(hwPuppi.hwEmID());
144  }
145  edmOut.back().setEncodedPuppi64(hwPuppi.pack().to_uint64());
146  setRefs_(edmOut.back(), hwPuppi);
147  }
148 }
void setRefs_(l1t::PFCandidate &pf, const l1ct::PuppiObjEmu &p) const
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Particle.h:23

◆ produce()

void DeregionizerProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 55 of file DeregionizerProducer.cc.

References clusterRefMap_, emulator_, PVValHelper::eta, hwToEdm_(), mps_fire::i, iEvent, l1ct::PuppiObj::initFromBits(), input_, LogDebug, eostools::move(), muonRefMap_, dqmiodumpmetadata::n, l1ct::DeregionizerInput::orderInputs(), l1ctLayer1_patternWriters_cff::outputRegions, phi, l1ct::OutputRegion::puppi, nano_mu_digi_cff::region, l1ct::DeregionizerEmulator::run(), TrackRefitter_38T_cff::src, l1ct::PuppiObjEmu::srcCand, token_, and trackRefMap_.

55  {
56  clusterRefMap_.clear();
57  trackRefMap_.clear();
58  muonRefMap_.clear();
59 
60  auto deregColl = std::make_unique<l1t::PFCandidateCollection>();
61  auto truncColl = std::make_unique<l1t::PFCandidateCollection>();
62 
64 
65  iEvent.getByToken(token_, src);
66 
67  std::vector<l1ct::OutputRegion> outputRegions;
68  std::vector<l1ct::PuppiObjEmu> hwOut;
69  std::vector<l1t::PFCandidate> edmOut;
70  std::vector<l1ct::PuppiObjEmu> hwTruncOut;
71  std::vector<l1t::PFCandidate> edmTruncOut;
72 
73  LogDebug("DeregionizerProducer") << "\nRegional Puppi Candidates";
74  for (unsigned int iReg = 0, nReg = src->nRegions(); iReg < nReg; ++iReg) {
75  l1ct::OutputRegion tempOutputRegion;
76 
77  auto region = src->region(iReg);
78  float eta = src->eta(iReg);
79  float phi = src->phi(iReg);
80  LogDebug("DeregionizerProducer") << "\nRegion " << iReg << "\n"
81  << "Eta = " << eta << " and Phi = " << phi << "\n"
82  << "###########";
83  for (int i = 0, n = region.size(); i < n; ++i) {
84  l1ct::PuppiObjEmu tempPuppi;
85  const l1t::PFCandidate &cand = region[i];
86  clusterRefMap_[&cand] = cand.pfCluster();
87  trackRefMap_[&cand] = cand.pfTrack();
88  muonRefMap_[&cand] = cand.muon();
89 
90  tempPuppi.initFromBits(cand.encodedPuppi64());
91  tempPuppi.srcCand = &cand;
92  tempOutputRegion.puppi.push_back(tempPuppi);
93  LogDebug("DeregionizerProducer") << "pt[" << i << "] = " << tempOutputRegion.puppi.back().hwPt << ", eta[" << i
94  << "] = " << tempOutputRegion.puppi.back().floatEta() << ", phi[" << i
95  << "] = " << tempOutputRegion.puppi.back().floatPhi();
96  }
97  outputRegions.push_back(tempOutputRegion);
98  }
99 
100  std::vector<std::vector<std::vector<l1ct::PuppiObjEmu>>> layer2In = input_.orderInputs(outputRegions);
101 
102  emulator_.run(layer2In, hwOut, hwTruncOut);
103 
104  DeregionizerProducer::hwToEdm_(hwOut, edmOut);
105  DeregionizerProducer::hwToEdm_(hwTruncOut, edmTruncOut);
106 
107  deregColl->swap(edmOut);
108  truncColl->swap(edmTruncOut);
109 
110  iEvent.put(std::move(deregColl), "Puppi");
111  iEvent.put(std::move(truncColl), "TruncatedPuppi");
112 }
std::vector< std::vector< std::vector< l1ct::PuppiObjEmu > > > orderInputs(const std::vector< l1ct::OutputRegion > &inputRegions) const
l1ct::DeregionizerEmulator emulator_
const l1t::PFCandidate * srcCand
std::unordered_map< const l1t::PFCandidate *, l1t::PFCandidate::MuonRef > muonRefMap_
std::vector< PuppiObjEmu > puppi
int iEvent
Definition: GenABIO.cc:224
std::unordered_map< const l1t::PFCandidate *, l1t::PFTrackRef > trackRefMap_
edm::EDGetTokenT< l1t::PFCandidateRegionalOutput > token_
void hwToEdm_(const std::vector< l1ct::PuppiObjEmu > &hwOut, std::vector< l1t::PFCandidate > &edmOut) const
void initFromBits(const ap_uint< BITWIDTH > &src)
Definition: puppi.h:171
l1ct::DeregionizerInput input_
std::unordered_map< const l1t::PFCandidate *, l1t::PFClusterRef > clusterRefMap_
def move(src, dest)
Definition: eostools.py:511
void run(std::vector< std::vector< std::vector< l1ct::PuppiObjEmu >>> in, std::vector< l1ct::PuppiObjEmu > &out, std::vector< l1ct::PuppiObjEmu > &truncated)
#define LogDebug(id)

◆ setRefs_()

void DeregionizerProducer::setRefs_ ( l1t::PFCandidate pf,
const l1ct::PuppiObjEmu p 
) const
private

Definition at line 150 of file DeregionizerProducer.cc.

References clusterRefMap_, Exception, match(), muonRefMap_, AlCaHLTBitMon_ParallelJobs::p, packedPFCandidateRefMixer_cfi::pf, and trackRefMap_.

Referenced by hwToEdm_().

150  {
151  if (p.srcCand) {
152  auto match = clusterRefMap_.find(p.srcCand);
153  if (match == clusterRefMap_.end()) {
154  throw cms::Exception("CorruptData") << "Invalid cluster pointer in PF candidate id " << p.intId() << " pt "
155  << p.floatPt() << " eta " << p.floatEta() << " phi " << p.floatPhi();
156  }
157  pf.setPFCluster(match->second);
158  }
159  if (p.srcCand) {
160  auto match = trackRefMap_.find(p.srcCand);
161  if (match == trackRefMap_.end()) {
162  throw cms::Exception("CorruptData") << "Invalid track pointer in PF candidate id " << p.intId() << " pt "
163  << p.floatPt() << " eta " << p.floatEta() << " phi " << p.floatPhi();
164  }
165  pf.setPFTrack(match->second);
166  }
167  if (p.srcCand) {
168  auto match = muonRefMap_.find(p.srcCand);
169  if (match == muonRefMap_.end()) {
170  throw cms::Exception("CorruptData") << "Invalid muon pointer in PF candidate id " << p.intId() << " pt "
171  << p.floatPt() << " eta " << p.floatEta() << " phi " << p.floatPhi();
172  }
173  pf.setMuon(match->second);
174  }
175 }
std::unordered_map< const l1t::PFCandidate *, l1t::PFCandidate::MuonRef > muonRefMap_
std::unordered_map< const l1t::PFCandidate *, l1t::PFTrackRef > trackRefMap_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
std::unordered_map< const l1t::PFCandidate *, l1t::PFClusterRef > clusterRefMap_

Member Data Documentation

◆ boardOrder_

std::vector<uint32_t> DeregionizerProducer::boardOrder_
private

Definition at line 29 of file DeregionizerProducer.cc.

◆ clusterRefMap_

std::unordered_map<const l1t::PFCandidate *, l1t::PFClusterRef> DeregionizerProducer::clusterRefMap_
private

Definition at line 33 of file DeregionizerProducer.cc.

Referenced by produce(), and setRefs_().

◆ config_

edm::ParameterSet DeregionizerProducer::config_
private

Definition at line 23 of file DeregionizerProducer.cc.

◆ emulator_

l1ct::DeregionizerEmulator DeregionizerProducer::emulator_
private

Definition at line 27 of file DeregionizerProducer.cc.

Referenced by produce().

◆ input_

l1ct::DeregionizerInput DeregionizerProducer::input_
private

Definition at line 28 of file DeregionizerProducer.cc.

Referenced by produce().

◆ linkConfigs_

std::vector<edm::ParameterSet> DeregionizerProducer::linkConfigs_
private

Definition at line 25 of file DeregionizerProducer.cc.

◆ muonRefMap_

std::unordered_map<const l1t::PFCandidate *, l1t::PFCandidate::MuonRef> DeregionizerProducer::muonRefMap_
private

Definition at line 35 of file DeregionizerProducer.cc.

Referenced by produce(), and setRefs_().

◆ nInputFramesPerBX_

const unsigned int DeregionizerProducer::nInputFramesPerBX_
private

Definition at line 26 of file DeregionizerProducer.cc.

◆ nLinksPuppi_

std::vector<uint32_t> DeregionizerProducer::nLinksPuppi_
private

Definition at line 29 of file DeregionizerProducer.cc.

◆ nOutputFramesPerBX_

std::vector<uint32_t> DeregionizerProducer::nOutputFramesPerBX_
private

Definition at line 29 of file DeregionizerProducer.cc.

◆ nPuppiFramesPerRegion_

std::vector<uint32_t> DeregionizerProducer::nPuppiFramesPerRegion_
private

Definition at line 29 of file DeregionizerProducer.cc.

◆ nPuppiPerRegion_

std::vector<uint32_t> DeregionizerProducer::nPuppiPerRegion_
private

Definition at line 29 of file DeregionizerProducer.cc.

◆ outputRegions_

std::vector<std::vector<uint32_t> > DeregionizerProducer::outputRegions_
private

Definition at line 30 of file DeregionizerProducer.cc.

◆ tmuxFactor_

const unsigned int DeregionizerProducer::tmuxFactor_ = 6
private

Definition at line 31 of file DeregionizerProducer.cc.

◆ token_

edm::EDGetTokenT<l1t::PFCandidateRegionalOutput> DeregionizerProducer::token_
private

Definition at line 24 of file DeregionizerProducer.cc.

Referenced by produce().

◆ trackRefMap_

std::unordered_map<const l1t::PFCandidate *, l1t::PFTrackRef> DeregionizerProducer::trackRefMap_
private

Definition at line 34 of file DeregionizerProducer.cc.

Referenced by produce(), and setRefs_().