1 #include <unordered_map> 27 std::unordered_map<const l1t::PFCandidate *, l1t::PFClusterRef>
clusterRefMap_;
28 std::unordered_map<const l1t::PFCandidate *, l1t::PFTrackRef>
trackRefMap_;
29 std::unordered_map<const l1t::PFCandidate *, l1t::PFCandidate::MuonRef>
muonRefMap_;
32 void hwToEdm_(
const std::vector<l1ct::PuppiObjEmu> &hwOut, std::vector<l1t::PFCandidate> &edmOut)
const;
40 produces<l1t::PFCandidateCollection>(
"Puppi");
41 produces<l1t::PFCandidateCollection>(
"TruncatedPuppi");
51 auto deregColl = std::make_unique<l1t::PFCandidateCollection>();
52 auto truncColl = std::make_unique<l1t::PFCandidateCollection>();
58 std::vector<float> regionEtas, regionPhis;
60 std::vector<l1ct::PuppiObjEmu> hwOut;
61 std::vector<l1t::PFCandidate> edmOut;
62 std::vector<l1ct::PuppiObjEmu> hwTruncOut;
63 std::vector<l1t::PFCandidate> edmTruncOut;
65 LogDebug(
"DeregionizerProducer") <<
"\nRegional Puppi Candidates";
66 for (
unsigned int iReg = 0, nReg =
src->nRegions(); iReg < nReg; ++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" 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();
89 if (!tempOutputRegion.
puppi.empty()) {
90 regionEtas.push_back(
eta);
91 regionPhis.push_back(
phi);
103 deregColl->swap(edmOut);
104 truncColl->swap(edmTruncOut);
111 std::vector<l1t::PFCandidate> &edmOut)
const {
112 for (
const auto &hwPuppi : hwOut) {
115 if (hwPuppi.hwId.charged()) {
116 if (hwPuppi.hwId.isMuon()) {
119 }
else if (hwPuppi.hwId.isElectron()) {
126 mass = hwPuppi.hwId.isPhoton() ? 0.0 : 0.5;
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());
138 edmOut.back().setHwPuppiWeight(hwPuppi.hwPuppiW());
139 edmOut.back().setHwEmID(hwPuppi.hwEmID());
141 edmOut.back().setEncodedPuppi64(hwPuppi.pack().to_uint64());
150 throw cms::Exception(
"CorruptData") <<
"Invalid cluster pointer in PF candidate id " <<
p.intId() <<
" pt " 151 <<
p.floatPt() <<
" eta " <<
p.floatEta() <<
" phi " <<
p.floatPhi();
153 pf.setPFCluster(
match->second);
158 throw cms::Exception(
"CorruptData") <<
"Invalid track pointer in PF candidate id " <<
p.intId() <<
" pt " 159 <<
p.floatPt() <<
" eta " <<
p.floatEta() <<
" phi " <<
p.floatPhi();
166 throw cms::Exception(
"CorruptData") <<
"Invalid muon pointer in PF candidate id " <<
p.intId() <<
" pt " 167 <<
p.floatPt() <<
" eta " <<
p.floatEta() <<
" phi " <<
p.floatPhi();
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);
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
l1ct::DeregionizerEmulator emulator_
const l1t::PFCandidate * srcCand
void produce(edm::Event &, const edm::EventSetup &) override
std::unordered_map< const l1t::PFCandidate *, l1t::PFCandidate::MuonRef > muonRefMap_
std::vector< PuppiObjEmu > puppi
std::unordered_map< const l1t::PFCandidate *, l1t::PFTrackRef > trackRefMap_
void run(const DeregionizerInput in, std::vector< l1ct::PuppiObjEmu > &out, std::vector< l1ct::PuppiObjEmu > &truncated)
void setRefs_(l1t::PFCandidate &pf, const l1ct::PuppiObjEmu &p) const
#define DEFINE_FWK_MODULE(type)
edm::ParameterSet config_
edm::EDGetTokenT< l1t::PFCandidateRegionalOutput > token_
void hwToEdm_(const std::vector< l1ct::PuppiObjEmu > &hwOut, std::vector< l1t::PFCandidate > &edmOut) const
l1t::RegionalOutput< l1t::PFCandidateCollection > PFCandidateRegionalOutput
void initFromBits(const ap_uint< BITWIDTH > &src)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
DeregionizerProducer(const edm::ParameterSet &)
~DeregionizerProducer() override
std::unordered_map< const l1t::PFCandidate *, l1t::PFClusterRef > clusterRefMap_