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::unordered_map< const l1t::PFCandidate *, l1t::PFClusterRefclusterRefMap_
 
edm::ParameterSet config_
 
l1ct::DeregionizerEmulator emulator_
 
std::unordered_map< const l1t::PFCandidate *, l1t::PFCandidate::MuonRefmuonRefMap_
 
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 36 of file DeregionizerProducer.cc.

37  : config_(iConfig),
38  token_(consumes<l1t::PFCandidateRegionalOutput>(iConfig.getParameter<edm::InputTag>("RegionalPuppiCands"))),
39  emulator_(iConfig) {
40  produces<l1t::PFCandidateCollection>("Puppi");
41  produces<l1t::PFCandidateCollection>("TruncatedPuppi");
42 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
l1ct::DeregionizerEmulator emulator_
edm::ParameterSet config_
edm::EDGetTokenT< l1t::PFCandidateRegionalOutput > token_

◆ ~DeregionizerProducer()

DeregionizerProducer::~DeregionizerProducer ( )
override

Definition at line 44 of file DeregionizerProducer.cc.

44 {}

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 173 of file DeregionizerProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and HLT_2022v15_cff::InputTag.

173  {
174  // DeregionizerProducer
176  desc.add<edm::InputTag>("RegionalPuppiCands", edm::InputTag("l1tLayer1", "PuppiRegional"));
177  desc.add<unsigned int>("nPuppiFinalBuffer", 128);
178  desc.add<unsigned int>("nPuppiPerClk", 6);
179  desc.add<unsigned int>("nPuppiFirstBuffers", 12);
180  desc.add<unsigned int>("nPuppiSecondBuffers", 32);
181  desc.add<unsigned int>("nPuppiThirdBuffers", 64);
182  descriptions.add("DeregionizerProducer", desc);
183  // or use the following to generate the label from the module's C++ type
184  //descriptions.addWithDefaultLabel(desc);
185 }
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 110 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().

111  {
112  for (const auto &hwPuppi : hwOut) {
114  float mass = 0.13f;
115  if (hwPuppi.hwId.charged()) {
116  if (hwPuppi.hwId.isMuon()) {
118  mass = 0.105;
119  } else if (hwPuppi.hwId.isElectron()) {
121  mass = 0.005;
122  } else
124  } else {
125  type = hwPuppi.hwId.isPhoton() ? l1t::PFCandidate::Photon : l1t::PFCandidate::NeutralHadron;
126  mass = hwPuppi.hwId.isPhoton() ? 0.0 : 0.5;
127  }
128  reco::Particle::PolarLorentzVector p4(hwPuppi.floatPt(), hwPuppi.floatEta(), hwPuppi.floatPhi(), mass);
129  edmOut.emplace_back(
130  type, hwPuppi.intCharge(), p4, hwPuppi.floatPuppiW(), hwPuppi.intPt(), hwPuppi.intEta(), hwPuppi.intPhi());
131  if (hwPuppi.hwId.charged()) {
132  edmOut.back().setZ0(hwPuppi.floatZ0());
133  edmOut.back().setDxy(hwPuppi.floatDxy());
134  edmOut.back().setHwZ0(hwPuppi.hwZ0());
135  edmOut.back().setHwDxy(hwPuppi.hwDxy());
136  edmOut.back().setHwTkQuality(hwPuppi.hwTkQuality());
137  } else {
138  edmOut.back().setHwPuppiWeight(hwPuppi.hwPuppiW());
139  edmOut.back().setHwEmID(hwPuppi.hwEmID());
140  }
141  edmOut.back().setEncodedPuppi64(hwPuppi.pack().to_uint64());
142  setRefs_(edmOut.back(), hwPuppi);
143  }
144 }
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 46 of file DeregionizerProducer.cc.

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

46  {
47  clusterRefMap_.clear();
48  trackRefMap_.clear();
49  muonRefMap_.clear();
50 
51  auto deregColl = std::make_unique<l1t::PFCandidateCollection>();
52  auto truncColl = std::make_unique<l1t::PFCandidateCollection>();
53 
55 
56  iEvent.getByToken(token_, src);
57 
58  std::vector<float> regionEtas, regionPhis;
59  std::vector<l1ct::OutputRegion> outputRegions;
60  std::vector<l1ct::PuppiObjEmu> hwOut;
61  std::vector<l1t::PFCandidate> edmOut;
62  std::vector<l1ct::PuppiObjEmu> hwTruncOut;
63  std::vector<l1t::PFCandidate> edmTruncOut;
64 
65  LogDebug("DeregionizerProducer") << "\nRegional Puppi Candidates";
66  for (unsigned int iReg = 0, nReg = src->nRegions(); iReg < nReg; ++iReg) {
67  l1ct::OutputRegion tempOutputRegion;
68 
69  auto region = src->region(iReg);
70  float eta = src->eta(iReg);
71  float phi = src->phi(iReg);
72  LogDebug("DeregionizerProducer") << "\nRegion " << iReg << "\n"
73  << "Eta = " << eta << " and Phi = " << phi << "\n"
74  << "###########";
75  for (int i = 0, n = region.size(); i < n; ++i) {
76  l1ct::PuppiObjEmu tempPuppi;
77  const l1t::PFCandidate &cand = region[i];
78  clusterRefMap_[&cand] = cand.pfCluster();
79  trackRefMap_[&cand] = cand.pfTrack();
80  muonRefMap_[&cand] = cand.muon();
81 
82  tempPuppi.initFromBits(cand.encodedPuppi64());
83  tempPuppi.srcCand = &cand;
84  tempOutputRegion.puppi.push_back(tempPuppi);
85  LogDebug("DeregionizerProducer") << "pt[" << i << "] = " << tempOutputRegion.puppi.back().hwPt << ", eta[" << i
86  << "] = " << tempOutputRegion.puppi.back().floatEta() << ", phi[" << i
87  << "] = " << tempOutputRegion.puppi.back().floatPhi();
88  }
89  if (!tempOutputRegion.puppi.empty()) {
90  regionEtas.push_back(eta);
91  regionPhis.push_back(phi);
92  outputRegions.push_back(tempOutputRegion);
93  }
94  }
95 
97 
98  emulator_.run(in, hwOut, hwTruncOut);
99 
100  DeregionizerProducer::hwToEdm_(hwOut, edmOut);
101  DeregionizerProducer::hwToEdm_(hwTruncOut, edmTruncOut);
102 
103  deregColl->swap(edmOut);
104  truncColl->swap(edmTruncOut);
105 
106  iEvent.put(std::move(deregColl), "Puppi");
107  iEvent.put(std::move(truncColl), "TruncatedPuppi");
108 }
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_
void run(const DeregionizerInput in, std::vector< l1ct::PuppiObjEmu > &out, std::vector< l1ct::PuppiObjEmu > &truncated)
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
std::unordered_map< const l1t::PFCandidate *, l1t::PFClusterRef > clusterRefMap_
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)

◆ setRefs_()

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

Definition at line 146 of file DeregionizerProducer.cc.

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

Referenced by hwToEdm_().

146  {
147  if (p.srcCand) {
148  auto match = clusterRefMap_.find(p.srcCand);
149  if (match == clusterRefMap_.end()) {
150  throw cms::Exception("CorruptData") << "Invalid cluster pointer in PF candidate id " << p.intId() << " pt "
151  << p.floatPt() << " eta " << p.floatEta() << " phi " << p.floatPhi();
152  }
153  pf.setPFCluster(match->second);
154  }
155  if (p.srcCand) {
156  auto match = trackRefMap_.find(p.srcCand);
157  if (match == trackRefMap_.end()) {
158  throw cms::Exception("CorruptData") << "Invalid track pointer in PF candidate id " << p.intId() << " pt "
159  << p.floatPt() << " eta " << p.floatEta() << " phi " << p.floatPhi();
160  }
161  pf.setPFTrack(match->second);
162  }
163  if (p.srcCand) {
164  auto match = muonRefMap_.find(p.srcCand);
165  if (match == muonRefMap_.end()) {
166  throw cms::Exception("CorruptData") << "Invalid muon pointer in PF candidate id " << p.intId() << " pt "
167  << p.floatPt() << " eta " << p.floatEta() << " phi " << p.floatPhi();
168  }
169  pf.setMuon(match->second);
170  }
171 }
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

◆ clusterRefMap_

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

Definition at line 27 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 25 of file DeregionizerProducer.cc.

Referenced by produce().

◆ muonRefMap_

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

Definition at line 29 of file DeregionizerProducer.cc.

Referenced by produce(), and setRefs_().

◆ 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 28 of file DeregionizerProducer.cc.

Referenced by produce(), and setRefs_().