CMS 3D CMS Logo

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

Public Member Functions

 L1NNTauProducer (const edm::ParameterSet &, const tensorflow::SessionCache *)
 
 ~L1NNTauProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< tensorflow::SessionCache > >
 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)
 
static void globalEndJob (const tensorflow::SessionCache *)
 
static std::unique_ptr< tensorflow::SessionCacheinitializeGlobalCache (const edm::ParameterSet &)
 

Private Member Functions

void addTau (const l1t::PFCandidate &iCand, const l1t::PFCandidateCollection &iParts, std::unique_ptr< PFTauCollection > &outputTaus)
 
void makeTau_HW (const l1t::PFCandidate &seed, l1t::PFCandidateCollection &parts, std::unique_ptr< l1t::PFTauCollection > &iTaus)
 
void process_HW (const l1t::PFCandidateCollection &parts, std::unique_ptr< l1t::PFTauCollection > &iTaus)
 
void process_SW (const l1t::PFCandidateCollection &parts, std::unique_ptr< l1t::PFTauCollection > &iTaus)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 

Private Attributes

double fConeSize_
 
const bool fDebug
 
const bool fEMSeed
 
const bool fHW
 
edm::EDGetTokenT< vector< l1t::PFCandidate > > fL1PFToken_
 
int fMaxTaus_
 
int fNParticles_
 
double fSeedPt_
 
std::unique_ptr< TauNNIdfTauNNId_
 
std::unique_ptr< TauNNIdHWfTauNNIdHW_
 
double fTauSize_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< tensorflow::SessionCache > >
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 22 of file L1NNTauProducer.cc.

Constructor & Destructor Documentation

◆ L1NNTauProducer()

L1NNTauProducer::L1NNTauProducer ( const edm::ParameterSet cfg,
const tensorflow::SessionCache cache 
)
explicit

Definition at line 60 of file L1NNTauProducer.cc.

References utilities::cache(), looper::cfg, fHW, fNParticles_, fTauNNId_, fTauNNIdHW_, and AlCaHLTBitMon_QueryRunRegistry::string.

61  : fSeedPt_(cfg.getParameter<double>("seedpt")),
62  fConeSize_(cfg.getParameter<double>("conesize")),
63  fTauSize_(cfg.getParameter<double>("tausize")),
64  fMaxTaus_(cfg.getParameter<int>("maxtaus")),
65  fNParticles_(cfg.getParameter<int>("nparticles")),
66  fHW(cfg.getParameter<bool>("HW")),
67  fEMSeed(cfg.getParameter<bool>("emseed")),
68  fDebug(cfg.getParameter<bool>("debug")),
69  fL1PFToken_(consumes<vector<l1t::PFCandidate>>(cfg.getParameter<edm::InputTag>("L1PFObjects"))) {
70  std::string lNNFile = cfg.getParameter<std::string>("NNFileName"); //,"L1Trigger/Phase2L1Taus/data/tau_3layer.pb");
71  if (fHW) {
72  fTauNNIdHW_ = std::make_unique<TauNNIdHW>();
73  fTauNNIdHW_->initialize("input_1:0", fNParticles_);
74  } else {
75  fTauNNId_ = std::make_unique<TauNNId>(lNNFile.find("v0") == std::string::npos ? "input_1:0" : "dense_1_input:0",
76  cache->getSession(),
77  lNNFile,
78  fNParticles_);
79  }
80  produces<l1t::PFTauCollection>("L1PFTausNN");
81 }
std::unique_ptr< TauNNIdHW > fTauNNIdHW_
edm::EDGetTokenT< vector< l1t::PFCandidate > > fL1PFToken_
std::unique_ptr< TauNNId > fTauNNId_
def cache(function)
Definition: utilities.py:3
const bool fEMSeed

◆ ~L1NNTauProducer()

L1NNTauProducer::~L1NNTauProducer ( )
override

Definition at line 339 of file L1NNTauProducer.cc.

339 {}

Member Function Documentation

◆ addTau()

void L1NNTauProducer::addTau ( const l1t::PFCandidate iCand,
const l1t::PFCandidateCollection iParts,
std::unique_ptr< PFTauCollection > &  outputTaus 
)
private

Definition at line 142 of file L1NNTauProducer.cc.

References l1t::PFCandidate::ChargedHadron, reco::deltaR2(), PVValHelper::dxy, l1t::PFCandidate::Electron, fConeSize_, fSeedPt_, fTauNNId_, fTauSize_, mps_fire::i, dqmiolumiharvest::j, mkfit::NN, l1t::PFCandidate::Photon, jetUpdater_cfi::sort, and HLTMuonOfflineAnalyzer_cfi::z0.

Referenced by process_SW().

144  {
145  l1t::PFCandidateCollection pfTauCands;
146  math::PtEtaPhiMLorentzVector lTot(0, 0, 0, 0);
147  math::PtEtaPhiMLorentzVector lCand(0, 0, 0, 0);
148  int lId = 0;
149  float z0 = 0;
150  float dxy = 0;
151  for (const auto& l1PFCand : iParts) {
152  if (reco::deltaR2(iCand, l1PFCand) > fConeSize_ * fConeSize_)
153  continue;
154  math::PtEtaPhiMLorentzVector pVec(l1PFCand.pt(), l1PFCand.eta(), l1PFCand.phi(), 0);
155  lTot += pVec;
156  if (reco::deltaR2(iCand, l1PFCand) < fTauSize_ * fTauSize_ &&
157  (l1PFCand.id() == l1t::PFCandidate::Electron || l1PFCand.id() == l1t::PFCandidate::ChargedHadron ||
158  l1PFCand.id() == l1t::PFCandidate::Photon)) {
159  lId++;
160  lCand += pVec;
161  if (z0 == 0 && l1PFCand.id() == l1t::PFCandidate::ChargedHadron) {
162  z0 = l1PFCand.z0();
163  dxy = l1PFCand.dxy();
164  }
165  }
166  pfTauCands.push_back(l1PFCand);
167  }
168  if (lTot.Pt() < fSeedPt_)
169  return;
170  std::sort(
171  pfTauCands.begin(), pfTauCands.end(), [](l1t::PFCandidate i, l1t::PFCandidate j) { return (i.pt() > j.pt()); });
172  float NN = fTauNNId_->compute(iCand, pfTauCands);
173  float* lNNVector = fTauNNId_->NNVectorVar();
174  math::PtEtaPhiMLorentzVector tempP4(lCand.Pt(), lCand.Eta(), lCand.Phi(), lCand.M() * lCand.M());
175  l1t::PFTau l1PFTau(tempP4, lNNVector, NN, 0, lId);
176  l1PFTau.setZ0(z0);
177  l1PFTau.setDxy(dxy);
178  outputTaus->push_back(l1PFTau);
179 }
std::vector< l1t::PFCandidate > PFCandidateCollection
Definition: PFCandidate.h:86
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
std::unique_ptr< TauNNId > fTauNNId_
constexpr Matriplex::idx_t NN
Definition: Matrix.h:43
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16

◆ fillDescriptions()

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

Definition at line 180 of file L1NNTauProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

180  {
181  // L1NNTauProducer
183  desc.add<std::string>("NNFileName", "L1Trigger/Phase2L1ParticleFlow/data/tau_3layer.pb");
184  desc.add<double>("tausize", 0.1);
185  desc.add<int>("maxtaus", 5);
186  desc.add<int>("nparticles", 10);
187  desc.add<double>("conesize", 0.4);
188  desc.add<double>("seedpt", 20);
189  desc.add<bool>("HW", true);
190  desc.add<bool>("emseed", true);
191  desc.add<bool>("debug", false);
192  desc.add<edm::InputTag>("L1PFObjects", edm::InputTag("L1PFProducer", "l1pfCandidates"));
193  descriptions.add("L1NNTauProducer", desc);
194 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ globalEndJob()

static void L1NNTauProducer::globalEndJob ( const tensorflow::SessionCache )
inlinestatic

Definition at line 29 of file L1NNTauProducer.cc.

29 {};

◆ initializeGlobalCache()

std::unique_ptr< tensorflow::SessionCache > L1NNTauProducer::initializeGlobalCache ( const edm::ParameterSet cfg)
static

Definition at line 83 of file L1NNTauProducer.cc.

References looper::cfg, edm::FileInPath::fullPath(), HLT_2024v14_cff::graphPath, and AlCaHLTBitMon_QueryRunRegistry::string.

83  {
84  std::string graphPath = edm::FileInPath(cfg.getParameter<std::string>("NNFileName")).fullPath();
85  return std::make_unique<tensorflow::SessionCache>(graphPath);
86 }
std::string fullPath() const
Definition: FileInPath.cc:161

◆ makeTau_HW()

void L1NNTauProducer::makeTau_HW ( const l1t::PFCandidate seed,
l1t::PFCandidateCollection parts,
std::unique_ptr< l1t::PFTauCollection > &  iTaus 
)
private

Definition at line 196 of file L1NNTauProducer.cc.

References l1t::PFCandidate::ChargedHadron, PVValHelper::dxy, l1t::PFCandidate::Electron, PVValHelper::eta, L1TauEmu::etaphi_base, l1gt::Scales::floatEta(), l1gt::Scales::floatPhi(), l1gt::Scales::floatPt(), fSeedPt_, fTauNNIdHW_, fTauSize_, l1ct::Tau::hwCharge, l1ct::Tau::hwEta, l1ct::Tau::hwPhi, l1ct::Tau::hwPt, l1ct::Tau::hwRawId, l1ct::Tau::hwSeedPt, l1ct::Tau::hwSeedZ0, l1ct::Tau::hwType, L1TauEmu::inCone(), l1ct::Scales::makeGlbEta(), l1ct::Scales::makeGlbPhi(), EgHLTOffHistBins_cfi::mass, Tau_NN_Result::nn_id, Tau_NN_Result::nn_pt_correction, l1gt::Tau::pack(), phi, l1t::PFCandidate::Photon, DiDispStaMuonMonitor_cfi::pt, fileCollector::seed, l1t::PFTau::set_encodedTau(), l1t::PFTau::setDxy(), l1t::PFTau::setZ0(), l1ct::Tau::toGT(), and HLTMuonOfflineAnalyzer_cfi::z0.

Referenced by process_HW().

198  {
199  // Seed Cone Jet algorithm with ap_fixed types and hardware emulation
200  L1TauEmu::detaphi_t rCone2 =
202  unsigned lId = 0;
203 
204  input2_t p1_tot = 0;
205  input2_t p1x_tot = 0;
206  input2_t p1y_tot = 0;
207  input2_t p1z_tot = 0;
208 
209  input_t e1ta_1 = seed.eta();
210  input_t p1hi_1 = seed.phi();
211  L1TauEmu::pt_t pt = 0;
212  L1TauEmu::z0_t z0 = 0;
213  L1TauEmu::dxy_t dxy = 0;
214 
215  // Reconstruct the Tau Cone
216  for (unsigned i0 = 0; i0 < parts.size(); i0++) {
217  if (L1TauEmu::inCone(seed, (parts[i0]), rCone2)) {
219  parts[i0].id() == l1t::PFCandidate::Photon) {
220  lId++;
221  pt = pt + L1TauEmu::pt_t(parts[i0].pt());
222 
223  input2_t d1eta = input_t(parts[i0].eta()) - e1ta_1;
224  input2_t d1phi = input_t(parts[i0].phi()) - p1hi_1;
225  input2_t d1r2 = d1eta * d1eta + d1phi * d1phi;
226  input2_t tmppt = input_t(parts[i0].pt());
227  input2_t half = 0.5;
228  p1z_tot = p1z_tot + tmppt * (1 - d1r2 * half);
229  p1y_tot = p1y_tot + tmppt * d1phi;
230  p1x_tot = p1x_tot + tmppt * d1eta;
231  p1_tot = p1_tot + tmppt;
232 
233  if (z0 == 0 && parts[i0].id() == l1t::PFCandidate::ChargedHadron) {
234  z0 = parts[i0].hwZ0();
235  dxy = parts[i0].hwDxy();
236  }
237  }
238  }
239  }
240 
241  //Compute the mass
242  input2_t tmpmass1 = (p1_tot * p1_tot - p1x_tot * p1x_tot - p1y_tot * p1y_tot - p1z_tot * p1z_tot);
243  if (tmpmass1 < 0)
244  tmpmass1 = 0;
245  L1TauEmu::pt_t mass = l1ct::pt_t(tmpmass1);
246 
247  if (pt < fSeedPt_)
248  return;
249 
250  // Tau NN Inference
251  Tau_NN_Result NN_ouput = fTauNNIdHW_->compute(seed, parts);
252 
253  // Needed for making PFTau
254  input_t* lNNVector = fTauNNIdHW_->NNVectorVar();
255  float pNNVec[80];
256  for (unsigned i0 = 0; i0 < 80; i0++)
257  pNNVec[i0] = float(lNNVector[i0]);
258 
259  //Firmware Tau
260  l1ct::Tau l1ctTau;
261  l1ctTau.hwPt = l1ct::pt_t(pt * NN_ouput.nn_pt_correction); //l1gt is <16,11> and currently <16,14>
262  l1ctTau.hwEta = l1ct::Scales::makeGlbEta(seed.eta()); // seed.eta() and seed.phi() are in physical coordinates
263  l1ctTau.hwPhi = l1ct::Scales::makeGlbPhi(seed.phi());
264 
265  l1ctTau.hwSeedPt = seed.pt();
266  l1ctTau.hwSeedZ0 = seed.hwZ0();
267  l1ctTau.hwCharge = seed.charge();
268 
269  l1ctTau.hwType = l1ct::Tau::type_t(lId);
270  l1ctTau.hwRawId = ap_uint<10>(NN_ouput.nn_id * 1024); //NN Output is ap_fixed<16, 6> so need to cast.
271 
272  //Convert to GT format and pack to encodedTau of PFTau
273  l1gt::Tau l1gtTau = l1ctTau.toGT();
274  l1gt::PackedTau packed_Tau = l1gtTau.pack();
275 
276  //Make PFTau
277  //Save pt, eta and phi in gt scales
279  l1gt::Scales::floatEta(l1gtTau.v3.eta),
280  l1gt::Scales::floatPhi(l1gtTau.v3.phi),
281  float(mass));
282 
283  l1t::PFTau l1PFTau(tempP4, pNNVec, NN_ouput.nn_id, 0, lId);
284  l1PFTau.setZ0(float(z0) * 0.05); //L1TauEmu::z0_base);
285  l1PFTau.setDxy(float(dxy) * 0.05); //L1TauEmu::dxy_base);
286 
287  l1PFTau.set_encodedTau(packed_Tau);
288 
289  iTaus->push_back(l1PFTau);
290 }
glbeta_t makeGlbEta(float eta)
Definition: datatypes.h:201
float floatPhi(phi_t phi)
Definition: gt_datatypes.h:48
float floatEta(eta_t eta)
Definition: gt_datatypes.h:47
result_t nn_id
Definition: TauNNIdHW.h:19
static constexpr float etaphi_base
Definition: TauNNIdHW.h:27
std::unique_ptr< TauNNIdHW > fTauNNIdHW_
ap_fixed< 24, 12 > input2_t
Definition: defines.h:28
glbphi_t makeGlbPhi(float phi)
Definition: datatypes.h:204
ap_fixed< 12, 6 > detaphi_t
Definition: TauNNIdHW.h:30
type_t hwType
Definition: taus.h:21
std::array< uint64_t, 2 > PackedTau
Definition: gt_datatypes.h:38
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
ap_fixed< 16, 6 > input_t
Definition: defines.h:27
ap_uint< 2 > type_t
Definition: taus.h:11
float floatPt(pt_t pt)
Definition: gt_datatypes.h:46
bool hwCharge
Definition: taus.h:20
glbphi_t hwPhi
Definition: taus.h:17
pt_t hwPt
Definition: taus.h:15
Definition: taus.h:10
z0_t hwSeedZ0
Definition: taus.h:19
ap_ufixed< 14, 12, AP_TRN, AP_SAT > pt_t
Definition: datatypes.h:10
pt_t hwSeedPt
Definition: taus.h:18
l1gt::Tau toGT() const
Definition: taus.h:108
glbeta_t hwEta
Definition: taus.h:16
ap_ufixed< 16, 14 > pt_t
Definition: TauNNIdHW.h:28
ap_int< 10 > z0_t
Definition: TauNNIdHW.h:34
ap_int< 8 > dxy_t
Definition: TauNNIdHW.h:33
PackedTau pack() const
Definition: gt_datatypes.h:218
bool inCone(l1t::PFCandidate seed, l1t::PFCandidate part, detaphi_t cone2)
Definition: TauNNIdHW.h:123
result_t nn_pt_correction
Definition: TauNNIdHW.h:18
rawid_t hwRawId
Definition: taus.h:22

◆ process_HW()

void L1NNTauProducer::process_HW ( const l1t::PFCandidateCollection parts,
std::unique_ptr< l1t::PFTauCollection > &  iTaus 
)
private

Definition at line 292 of file L1NNTauProducer.cc.

References funct::abs(), l1t::PFCandidate::ChargedHadron, l1t::PFCandidate::Electron, L1TauEmu::etaphi_base, fConeSize_, fEMSeed, fMaxTaus_, mps_fire::i, L1TauEmu::inCone(), dqmiolumiharvest::j, makeTau_HW(), l1t::PFCandidate::Photon, fileCollector::seed, HLT_2024v14_cff::seeds, jetUpdater_cfi::sort, track_trigger_eta_max, HcalDetIdTransform::transform(), parallelization::uint, and edmIntegrityCheck::work.

Referenced by produce().

293  {
294  // The fixed point algorithm emulation
295  using namespace L1TauEmu;
296  std::vector<l1t::PFCandidate> work;
297  work.resize(parts.size());
298  std::transform(parts.begin(), parts.end(), work.begin(), [](const l1t::PFCandidate& part) { return part; });
299  std::sort(work.begin(), work.end(), [](l1t::PFCandidate i, l1t::PFCandidate j) {
300  return (l1ct::pt_t(i.pt()) > l1ct::pt_t(j.pt()));
301  });
302 
303  std::vector<l1t::PFCandidate> seeds;
305  if (fEMSeed)
306  lSeed = l1t::PFCandidate::Photon;
307  std::copy_if(work.begin(), work.end(), std::back_inserter(seeds), [&](const l1t::PFCandidate& part) {
309  part.id() == lSeed) &&
311  });
312  // It would be nice to transform the inputs to the etaphi_base of the FW here, as in the line below
313  // However the phi may wrap around if the etaphi_base > 1, so don't do it...
314  //std::for_each(work.begin(), work.end(), [](l1t::PFCandidate& x){x.setP4(math::PtEtaPhiMLorentzVector(pt_t(x.pt()), etaphi_t(x.eta()*etaphi_base), etaphi_t(x.phi()*etaphi_base), x.mass()));});
316 
317  iTaus->reserve(fMaxTaus_);
318  while (!seeds.empty() && iTaus->size() < unsigned(fMaxTaus_)) {
319  // Take the first (highest pt) candidate as a seed
320  l1t::PFCandidate seed = seeds.at(0);
321  // Get the particles within a _coneSize of the seed
322  std::vector<l1t::PFCandidate> particlesInCone;
323  std::copy_if(work.begin(), work.end(), std::back_inserter(particlesInCone), [&](l1t::PFCandidate& part) {
324  return inCone(seed, part, rCone2);
325  });
326  makeTau_HW(seed, particlesInCone, iTaus);
327  // remove the clustered particles
328  work.erase(std::remove_if(
329  work.begin(), work.end(), [&](const l1t::PFCandidate& part) { return inCone(seed, part, rCone2); }),
330  work.end());
331 
332  seeds.erase(
333  std::remove_if(
334  seeds.begin(), seeds.end(), [&](const l1t::PFCandidate& part) { return inCone(seed, part, rCone2); }),
335  seeds.end());
336  }
337 }
static constexpr float track_trigger_eta_max
static constexpr float etaphi_base
Definition: TauNNIdHW.h:27
ap_fixed< 12, 6 > detaphi_t
Definition: TauNNIdHW.h:30
void makeTau_HW(const l1t::PFCandidate &seed, l1t::PFCandidateCollection &parts, std::unique_ptr< l1t::PFTauCollection > &iTaus)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ap_ufixed< 14, 12, AP_TRN, AP_SAT > pt_t
Definition: datatypes.h:10
part
Definition: HCALResponse.h:20
const bool fEMSeed
bool inCone(l1t::PFCandidate seed, l1t::PFCandidate part, detaphi_t cone2)
Definition: TauNNIdHW.h:123
unsigned transform(const HcalDetId &id, unsigned transformCode)

◆ process_SW()

void L1NNTauProducer::process_SW ( const l1t::PFCandidateCollection parts,
std::unique_ptr< l1t::PFTauCollection > &  iTaus 
)
private

Definition at line 106 of file L1NNTauProducer.cc.

References funct::abs(), addTau(), l1t::PFCandidate::ChargedHadron, reco::deltaR2(), l1t::PFCandidate::Electron, fConeSize_, fMaxTaus_, mps_fire::i, testProducerWithPsetDescEmpty_cfi::i1, dqmiolumiharvest::j, eostools::move(), boostedElectronIsolation_cff::pfChargedHadrons, jetUpdater_cfi::sort, and track_trigger_eta_max.

Referenced by produce().

107  {
108  std::vector<unique_ptr<l1t::PFCandidate>> pfChargedHadrons;
109  std::vector<unique_ptr<l1t::PFCandidate>> pfChargedHadrons_sort_v;
110  std::vector<unique_ptr<l1t::PFCandidate>> pfChargedHadrons_seeds_v;
111  for (const auto& l1PFCand : parts)
112  if ((l1PFCand.id() == l1t::PFCandidate::ChargedHadron || l1PFCand.id() == l1t::PFCandidate::Electron) &&
113  std::abs(l1PFCand.eta()) < track_trigger_eta_max)
114  pfChargedHadrons_sort_v.push_back(std::make_unique<l1t::PFCandidate>(l1PFCand));
115 
116  if (pfChargedHadrons_sort_v.empty())
117  return;
118  std::sort(
119  pfChargedHadrons_sort_v.begin(),
120  pfChargedHadrons_sort_v.end(),
121  [](std::unique_ptr<l1t::PFCandidate>& i, std::unique_ptr<l1t::PFCandidate>& j) { return (i->pt() > j->pt()); });
122 
123  pfChargedHadrons_seeds_v.push_back(std::move(pfChargedHadrons_sort_v[0]));
124  for (unsigned int i0 = 1; i0 < pfChargedHadrons_sort_v.size(); i0++) {
125  bool pMatch = false;
126  for (unsigned int i1 = 0; i1 < pfChargedHadrons_seeds_v.size(); i1++) {
127  if (reco::deltaR2(*(pfChargedHadrons_seeds_v[i1]), *(pfChargedHadrons_sort_v[i0])) < fConeSize_ * fConeSize_)
128  pMatch = true;
129  }
130  if (pMatch)
131  continue;
132  pfChargedHadrons_seeds_v.push_back(std::move(pfChargedHadrons_sort_v[i0]));
133  if (int(pfChargedHadrons_seeds_v.size()) > fMaxTaus_ - 1)
134  break;
135  }
136  for (unsigned int i0 = 0; i0 < pfChargedHadrons_seeds_v.size(); i0++) {
137  addTau(*(pfChargedHadrons_seeds_v[i0]), parts, iTaus);
138  }
139 }
static constexpr float track_trigger_eta_max
void addTau(const l1t::PFCandidate &iCand, const l1t::PFCandidateCollection &iParts, std::unique_ptr< PFTauCollection > &outputTaus)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
def move(src, dest)
Definition: eostools.py:511

◆ produce()

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

Definition at line 88 of file L1NNTauProducer.cc.

References fHW, fL1PFToken_, mps_fire::i, iEvent, dqmiolumiharvest::j, eostools::move(), process_HW(), process_SW(), and jetUpdater_cfi::sort.

88  {
90  iEvent.getByToken(fL1PFToken_, l1PFCandidates);
91  auto lTaus = std::make_unique<l1t::PFTauCollection>();
92 
93  if (fHW) {
94  process_HW(*l1PFCandidates, lTaus);
95  } else {
96  process_SW(*l1PFCandidates, lTaus);
97  }
98 
99  if (lTaus->empty()) {
100  PFTau dummy;
101  lTaus->push_back(dummy);
102  }
103  std::sort(lTaus->begin(), lTaus->end(), [](l1t::PFTau i, l1t::PFTau j) { return (i.pt() > j.pt()); });
104  iEvent.put(std::move(lTaus), "L1PFTausNN");
105 }
edm::EDGetTokenT< vector< l1t::PFCandidate > > fL1PFToken_
int iEvent
Definition: GenABIO.cc:224
void process_HW(const l1t::PFCandidateCollection &parts, std::unique_ptr< l1t::PFTauCollection > &iTaus)
void process_SW(const l1t::PFCandidateCollection &parts, std::unique_ptr< l1t::PFTauCollection > &iTaus)
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ fConeSize_

double L1NNTauProducer::fConeSize_
private

Definition at line 48 of file L1NNTauProducer.cc.

Referenced by addTau(), process_HW(), and process_SW().

◆ fDebug

const bool L1NNTauProducer::fDebug
private

Definition at line 54 of file L1NNTauProducer.cc.

◆ fEMSeed

const bool L1NNTauProducer::fEMSeed
private

Definition at line 53 of file L1NNTauProducer.cc.

Referenced by process_HW().

◆ fHW

const bool L1NNTauProducer::fHW
private

Definition at line 52 of file L1NNTauProducer.cc.

Referenced by L1NNTauProducer(), and produce().

◆ fL1PFToken_

edm::EDGetTokenT<vector<l1t::PFCandidate> > L1NNTauProducer::fL1PFToken_
private

Definition at line 55 of file L1NNTauProducer.cc.

Referenced by produce().

◆ fMaxTaus_

int L1NNTauProducer::fMaxTaus_
private

Definition at line 50 of file L1NNTauProducer.cc.

Referenced by process_HW(), and process_SW().

◆ fNParticles_

int L1NNTauProducer::fNParticles_
private

Definition at line 51 of file L1NNTauProducer.cc.

Referenced by L1NNTauProducer().

◆ fSeedPt_

double L1NNTauProducer::fSeedPt_
private

Definition at line 47 of file L1NNTauProducer.cc.

Referenced by addTau(), and makeTau_HW().

◆ fTauNNId_

std::unique_ptr<TauNNId> L1NNTauProducer::fTauNNId_
private

Definition at line 29 of file L1NNTauProducer.cc.

Referenced by addTau(), and L1NNTauProducer().

◆ fTauNNIdHW_

std::unique_ptr<TauNNIdHW> L1NNTauProducer::fTauNNIdHW_
private

Definition at line 34 of file L1NNTauProducer.cc.

Referenced by L1NNTauProducer(), and makeTau_HW().

◆ fTauSize_

double L1NNTauProducer::fTauSize_
private

Definition at line 49 of file L1NNTauProducer.cc.

Referenced by addTau(), and makeTau_HW().