CMS 3D CMS Logo

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

Public Member Functions

 DeepBoostedJetTagInfoProducer (const edm::ParameterSet &)
 
 ~DeepBoostedJetTagInfoProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Types

typedef edm::View< reco::CandidateCandidateView
 
typedef std::vector< reco::DeepBoostedJetTagInfoDeepBoostedJetTagInfoCollection
 
typedef reco::VertexCompositePtrCandidateCollection SVCollection
 
typedef reco::VertexCollection VertexCollection
 

Private Member Functions

void beginStream (edm::StreamID) override
 
void endStream () override
 
void fillParticleFeatures (DeepBoostedJetFeatures &fts, const reco::Jet &jet)
 
void fillSVFeatures (DeepBoostedJetFeatures &fts, const reco::Jet &jet)
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

const bool flip_ip_sign_
 
const bool include_neutrals_
 
const double jet_radius_
 
edm::EDGetTokenT< edm::View< reco::Jet > > jet_token_
 
const double max_jet_eta_
 
const double max_sip3dsig_
 
const double min_jet_pt_
 
const double min_pt_for_track_properties_
 
const double min_puppi_wgt_
 
edm::EDGetTokenT< CandidateViewpfcand_token_
 
edm::Handle< CandidateViewpfcands_
 
edm::Handle< edm::ValueMap< float > > puppi_value_map_
 
edm::EDGetTokenT< edm::ValueMap< float > > puppi_value_map_token_
 
const reco::Vertexpv_ = 0
 
edm::Handle< edm::Association< VertexCollection > > pvas_
 
edm::EDGetTokenT< edm::Association< VertexCollection > > pvas_token_
 
edm::Handle< edm::ValueMap< int > > pvasq_value_map_
 
edm::EDGetTokenT< edm::ValueMap< int > > pvasq_value_map_token_
 
const bool sort_by_sip2dsig_
 
edm::EDGetTokenT< SVCollectionsv_token_
 
edm::Handle< SVCollectionsvs_
 
edm::ESHandle< TransientTrackBuildertrack_builder_
 
bool use_puppi_value_map_
 
const bool use_puppiP4_
 
bool use_pvasq_value_map_
 
edm::EDGetTokenT< VertexCollectionvtx_token_
 
edm::Handle< VertexCollectionvtxs_
 

Static Private Attributes

static const std::vector< std::string > particle_features_
 
static const std::vector< std::string > sv_features_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 27 of file DeepBoostedJetTagInfoProducer.cc.

Member Typedef Documentation

Definition at line 38 of file DeepBoostedJetTagInfoProducer.cc.

Definition at line 35 of file DeepBoostedJetTagInfoProducer.cc.

Definition at line 36 of file DeepBoostedJetTagInfoProducer.cc.

Definition at line 37 of file DeepBoostedJetTagInfoProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 103 of file DeepBoostedJetTagInfoProducer.cc.

References edm::ParameterSet::getParameter(), puppi_value_map_token_, pvas_token_, pvasq_value_map_token_, use_puppi_value_map_, and use_pvasq_value_map_.

104  : jet_radius_(iConfig.getParameter<double>("jet_radius")),
105  min_jet_pt_(iConfig.getParameter<double>("min_jet_pt")),
106  max_jet_eta_(iConfig.getParameter<double>("max_jet_eta")),
107  min_pt_for_track_properties_(iConfig.getParameter<double>("min_pt_for_track_properties")),
108  use_puppiP4_(iConfig.getParameter<bool>("use_puppiP4")),
109  include_neutrals_(iConfig.getParameter<bool>("include_neutrals")),
110  sort_by_sip2dsig_(iConfig.getParameter<bool>("sort_by_sip2dsig")),
111  min_puppi_wgt_(iConfig.getParameter<double>("min_puppi_wgt")),
112  flip_ip_sign_(iConfig.getParameter<bool>("flip_ip_sign")),
113  max_sip3dsig_(iConfig.getParameter<double>("sip3dSigMax")),
114  jet_token_(consumes<edm::View<reco::Jet>>(iConfig.getParameter<edm::InputTag>("jets"))),
115  vtx_token_(consumes<VertexCollection>(iConfig.getParameter<edm::InputTag>("vertices"))),
116  sv_token_(consumes<SVCollection>(iConfig.getParameter<edm::InputTag>("secondary_vertices"))),
117  pfcand_token_(consumes<CandidateView>(iConfig.getParameter<edm::InputTag>("pf_candidates"))),
118  use_puppi_value_map_(false),
119  use_pvasq_value_map_(false) {
120  const auto &puppi_value_map_tag = iConfig.getParameter<edm::InputTag>("puppi_value_map");
121  if (!puppi_value_map_tag.label().empty()) {
122  puppi_value_map_token_ = consumes<edm::ValueMap<float>>(puppi_value_map_tag);
123  use_puppi_value_map_ = true;
124  }
125 
126  const auto &pvas_tag = iConfig.getParameter<edm::InputTag>("vertex_associator");
127  if (!pvas_tag.label().empty()) {
128  pvasq_value_map_token_ = consumes<edm::ValueMap<int>>(pvas_tag);
129  pvas_token_ = consumes<edm::Association<VertexCollection>>(pvas_tag);
130  use_pvasq_value_map_ = true;
131  }
132 
133  produces<DeepBoostedJetTagInfoCollection>();
134 }
T getParameter(std::string const &) const
edm::EDGetTokenT< VertexCollection > vtx_token_
edm::EDGetTokenT< CandidateView > pfcand_token_
edm::EDGetTokenT< SVCollection > sv_token_
edm::EDGetTokenT< edm::View< reco::Jet > > jet_token_
edm::EDGetTokenT< edm::Association< VertexCollection > > pvas_token_
edm::EDGetTokenT< edm::ValueMap< int > > pvasq_value_map_token_
edm::EDGetTokenT< edm::ValueMap< float > > puppi_value_map_token_
DeepBoostedJetTagInfoProducer::~DeepBoostedJetTagInfoProducer ( )
override

Definition at line 136 of file DeepBoostedJetTagInfoProducer.cc.

136 {}

Member Function Documentation

void DeepBoostedJetTagInfoProducer::beginStream ( edm::StreamID  )
inlineoverrideprivate

Definition at line 40 of file DeepBoostedJetTagInfoProducer.cc.

40 {}
void DeepBoostedJetTagInfoProducer::endStream ( )
inlineoverrideprivate

Definition at line 42 of file DeepBoostedJetTagInfoProducer.cc.

References metsig::jet.

42 {}
void DeepBoostedJetTagInfoProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 138 of file DeepBoostedJetTagInfoProducer.cc.

References edm::ConfigurationDescriptions::add(), and edm::ParameterSetDescription::add().

138  {
139  // pfDeepBoostedJetTagInfos
141  desc.add<double>("jet_radius", 0.8);
142  desc.add<double>("min_jet_pt", 150);
143  desc.add<double>("max_jet_eta", 99);
144  desc.add<double>("min_pt_for_track_properties", -1);
145  desc.add<bool>("use_puppiP4", true);
146  desc.add<bool>("include_neutrals", true);
147  desc.add<bool>("sort_by_sip2dsig", false);
148  desc.add<double>("min_puppi_wgt", 0.01);
149  desc.add<bool>("flip_ip_sign", false);
150  desc.add<double>("sip3dSigMax", -1);
151  desc.add<edm::InputTag>("vertices", edm::InputTag("offlinePrimaryVertices"));
152  desc.add<edm::InputTag>("secondary_vertices", edm::InputTag("inclusiveCandidateSecondaryVertices"));
153  desc.add<edm::InputTag>("pf_candidates", edm::InputTag("particleFlow"));
154  desc.add<edm::InputTag>("jets", edm::InputTag("ak8PFJetsPuppi"));
155  desc.add<edm::InputTag>("puppi_value_map", edm::InputTag("puppi"));
156  desc.add<edm::InputTag>("vertex_associator", edm::InputTag("primaryVertexAssociation", "original"));
157  descriptions.add("pfDeepBoostedJetTagInfos", desc);
158 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void DeepBoostedJetTagInfoProducer::fillParticleFeatures ( DeepBoostedJetFeatures fts,
const reco::Jet jet 
)
private

Definition at line 226 of file DeepBoostedJetTagInfoProducer.cc.

References a, funct::abs(), b, btagbtvdeep::TrackInfoBuilder::buildTrackInfo(), EnergyCorrector::c, reco::TrackBase::covariance(), reco::CompositePtrCandidate::daughterPtrVector(), BPhysicsValidation_cfi::daughters, reco::deltaPhi(), reco::deltaR(), PVValHelper::dxy, PVValHelper::dz, reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), Exception, btagbtvdeep::DeepBoostedJetFeatures::fill(), flip_ip_sign_, btagbtvdeep::TrackInfoBuilder::getTrackEtaRel(), btagbtvdeep::TrackInfoBuilder::getTrackJetDistVal(), btagbtvdeep::TrackInfoBuilder::getTrackPParRatio(), btagbtvdeep::TrackInfoBuilder::getTrackPtRatio(), btagbtvdeep::TrackInfoBuilder::getTrackSip2dSig(), btagbtvdeep::TrackInfoBuilder::getTrackSip2dVal(), btagbtvdeep::TrackInfoBuilder::getTrackSip3dSig(), btagbtvdeep::TrackInfoBuilder::getTrackSip3dVal(), mps_fire::i, include_neutrals_, infinity, edm::errors::InvalidReference, metsig::jet, jet_radius_, edm::Ptr< T >::key(), cmsBatch::log, btagbtvdeep::lost_inner_hits_from_pfcand(), max_sip3dsig_, min_pt_for_track_properties_, min_puppi_wgt_, btagbtvdeep::mindrsvpfcand(), reco::LeafCandidate::momentum(), dataset::name, reco::TrackBase::normalizedChi2(), reco::CompositePtrCandidate::numberOfDaughters(), p1, p2, particle_features_, pfcands_, reco::Vertex::position(), reco::LeafCandidate::pt(), pv_, reco::LeafCandidate::px(), reco::LeafCandidate::py(), reco::LeafCandidate::pz(), btagbtvdeep::quality_from_pfcand(), btagbtvdeep::DeepBoostedJetFeatures::reserve(), jetUpdater_cfi::sort, sort_by_sip2dsig_, svs_, track_builder_, use_puppi_value_map_, use_puppiP4_, use_pvasq_value_map_, and btagbtvdeep::vtx_ass_from_pfcand().

Referenced by produce().

226  {
227  // require the input to be a pat::Jet
228  const auto *patJet = dynamic_cast<const pat::Jet *>(&jet);
229  if (!patJet) {
230  throw edm::Exception(edm::errors::InvalidReference) << "Input is not a pat::Jet.";
231  }
232 
233  // do nothing if jet does not have constituents
234  if (jet.numberOfDaughters() == 0)
235  return;
236 
237  // some jet properties
238  math::XYZVector jet_dir = jet.momentum().Unit();
239  GlobalVector jet_ref_track_dir(jet.px(), jet.py(), jet.pz());
240  const float etasign = jet.eta() > 0 ? 1 : -1;
241 
242  std::map<reco::CandidatePtr::key_type, float> puppi_wgt_cache;
243  auto puppiWgt = [&](const reco::CandidatePtr &cand) {
244  const auto *pack_cand = dynamic_cast<const pat::PackedCandidate *>(&(*cand));
245  const auto *reco_cand = dynamic_cast<const reco::PFCandidate *>(&(*cand));
246  float wgt = 1.;
247  if (pack_cand) {
248  wgt = pack_cand->puppiWeight();
249  } else if (reco_cand) {
250  if (use_puppi_value_map_) {
251  wgt = (*puppi_value_map_)[cand];
252  } else {
253  throw edm::Exception(edm::errors::InvalidReference) << "Puppi value map is missing";
254  }
255  } else {
256  throw edm::Exception(edm::errors::InvalidReference) << "Cannot convert to either pat::PackedCandidate or "
257  "reco::PFCandidate";
258  }
259  puppi_wgt_cache[cand.key()] = wgt;
260  return wgt;
261  };
262 
263  std::vector<reco::CandidatePtr> daughters;
264  for (const auto &dau : jet.daughterPtrVector()) {
265  // remove particles w/ extremely low puppi weights
266  // [Note] use jet daughters here to get the puppiWgt correctly
267  if ((puppiWgt(dau)) < min_puppi_wgt_)
268  continue;
269  // from here: get the original reco/packed candidate not scaled by the puppi weight
270  auto cand = pfcands_->ptrAt(dau.key());
271  // charged candidate selection (for Higgs Interaction Net)
272  if (!include_neutrals_ && (cand->charge() == 0 || cand->pt() < min_pt_for_track_properties_))
273  continue;
274  // only when computing the nagative tagger: remove charged candidates with high sip3d
275  if (flip_ip_sign_ && cand->charge()) {
277  trkinfo.buildTrackInfo(&(*cand), jet_dir, jet_ref_track_dir, *pv_);
278  if (trkinfo.getTrackSip3dSig() > max_sip3dsig_)
279  continue;
280  }
281  daughters.push_back(cand);
282  }
283 
284  std::vector<btagbtvdeep::SortingClass<reco::CandidatePtr>> c_sorted;
285  if (sort_by_sip2dsig_) {
286  // sort charged pf candidates by 2d impact parameter significance
287  for (const auto &cand : daughters) {
289  trkinfo.buildTrackInfo(&(*cand), jet_dir, jet_ref_track_dir, *pv_);
290  c_sorted.emplace_back(cand,
291  trkinfo.getTrackSip2dSig(),
293  cand->pt() / jet.pt());
295  }
296  for (unsigned int i = 0; i < c_sorted.size(); i++) {
297  const auto &c = c_sorted.at(i);
298  const auto &cand = c.get();
299  daughters.at(i) = cand;
300  }
301  } else {
302  if (use_puppiP4_) {
303  // sort by Puppi-weighted pt
304  std::sort(daughters.begin(),
305  daughters.end(),
306  [&puppi_wgt_cache](const reco::CandidatePtr &a, const reco::CandidatePtr &b) {
307  return puppi_wgt_cache.at(a.key()) * a->pt() > puppi_wgt_cache.at(b.key()) * b->pt();
308  });
309  } else {
310  // sort by original pt (not Puppi-weighted)
311  std::sort(daughters.begin(), daughters.end(), [](const auto &a, const auto &b) { return a->pt() > b->pt(); });
312  }
313  }
314 
315  // reserve space
316  for (const auto &name : particle_features_) {
317  fts.reserve(name, daughters.size());
318  }
319 
320  auto useTrackProperties = [&](const reco::PFCandidate *reco_cand) {
321  const auto *trk = reco_cand->bestTrack();
322  return trk != nullptr && trk->pt() > min_pt_for_track_properties_;
323  };
324 
325  for (const auto &cand : daughters) {
326  const auto *packed_cand = dynamic_cast<const pat::PackedCandidate *>(&(*cand));
327  const auto *reco_cand = dynamic_cast<const reco::PFCandidate *>(&(*cand));
328 
329  if (!include_neutrals_ &&
330  ((packed_cand && !packed_cand->hasTrackDetails()) || (reco_cand && !useTrackProperties(reco_cand))))
331  continue;
332 
333  const float ip_sign = flip_ip_sign_ ? -1 : 1;
334 
335  auto candP4 = use_puppiP4_ ? puppi_wgt_cache.at(cand.key()) * cand->p4() : cand->p4();
336  if (packed_cand) {
337  float hcal_fraction = 0.;
338  if (packed_cand->pdgId() == 1 || packed_cand->pdgId() == 130) {
339  hcal_fraction = packed_cand->hcalFraction();
340  } else if (packed_cand->isIsolatedChargedHadron()) {
341  hcal_fraction = packed_cand->rawHcalFraction();
342  }
343 
344  fts.fill("pfcand_hcalFrac", hcal_fraction);
345  fts.fill("pfcand_VTX_ass", packed_cand->pvAssociationQuality());
346  fts.fill("pfcand_lostInnerHits", packed_cand->lostInnerHits());
347  fts.fill("pfcand_quality", packed_cand->bestTrack() ? packed_cand->bestTrack()->qualityMask() : 0);
348 
349  fts.fill("pfcand_charge", packed_cand->charge());
350  fts.fill("pfcand_isEl", std::abs(packed_cand->pdgId()) == 11);
351  fts.fill("pfcand_isMu", std::abs(packed_cand->pdgId()) == 13);
352  fts.fill("pfcand_isChargedHad", std::abs(packed_cand->pdgId()) == 211);
353  fts.fill("pfcand_isGamma", std::abs(packed_cand->pdgId()) == 22);
354  fts.fill("pfcand_isNeutralHad", std::abs(packed_cand->pdgId()) == 130);
355 
356  // impact parameters
357  fts.fill("pfcand_dz", ip_sign * packed_cand->dz());
358  fts.fill("pfcand_dxy", ip_sign * packed_cand->dxy());
359  fts.fill("pfcand_dzsig", packed_cand->bestTrack() ? ip_sign * packed_cand->dz() / packed_cand->dzError() : 0);
360  fts.fill("pfcand_dxysig", packed_cand->bestTrack() ? ip_sign * packed_cand->dxy() / packed_cand->dxyError() : 0);
361 
362  } else if (reco_cand) {
363  // get vertex association quality
364  int pv_ass_quality = 0; // fallback value
365  float vtx_ass = 0;
366  if (use_pvasq_value_map_) {
367  pv_ass_quality = (*pvasq_value_map_)[cand];
368  const reco::VertexRef &PV_orig = (*pvas_)[cand];
369  vtx_ass = vtx_ass_from_pfcand(*reco_cand, pv_ass_quality, PV_orig);
370  } else {
371  throw edm::Exception(edm::errors::InvalidReference) << "Vertex association missing";
372  }
373 
374  fts.fill("pfcand_hcalFrac", reco_cand->hcalEnergy() / (reco_cand->ecalEnergy() + reco_cand->hcalEnergy()));
375  fts.fill("pfcand_VTX_ass", vtx_ass);
376  fts.fill("pfcand_lostInnerHits", useTrackProperties(reco_cand) ? lost_inner_hits_from_pfcand(*reco_cand) : 0);
377  fts.fill("pfcand_quality", useTrackProperties(reco_cand) ? quality_from_pfcand(*reco_cand) : 0);
378 
379  fts.fill("pfcand_charge", reco_cand->charge());
380  fts.fill("pfcand_isEl", std::abs(reco_cand->pdgId()) == 11);
381  fts.fill("pfcand_isMu", std::abs(reco_cand->pdgId()) == 13);
382  fts.fill("pfcand_isChargedHad", std::abs(reco_cand->pdgId()) == 211);
383  fts.fill("pfcand_isGamma", std::abs(reco_cand->pdgId()) == 22);
384  fts.fill("pfcand_isNeutralHad", std::abs(reco_cand->pdgId()) == 130);
385 
386  // impact parameters
387  const auto *trk = reco_cand->bestTrack();
388  float dz = trk ? ip_sign * trk->dz(pv_->position()) : 0;
389  float dxy = trk ? ip_sign * trk->dxy(pv_->position()) : 0;
390  fts.fill("pfcand_dz", dz);
391  fts.fill("pfcand_dzsig", trk ? dz / trk->dzError() : 0);
392  fts.fill("pfcand_dxy", dxy);
393  fts.fill("pfcand_dxysig", trk ? dxy / trk->dxyError() : 0);
394  }
395 
396  // basic kinematics
397  fts.fill("pfcand_puppiw", puppi_wgt_cache.at(cand.key()));
398  fts.fill("pfcand_phirel", reco::deltaPhi(candP4, jet));
399  fts.fill("pfcand_etarel", etasign * (candP4.eta() - jet.eta()));
400  fts.fill("pfcand_deltaR", reco::deltaR(candP4, jet));
401  fts.fill("pfcand_abseta", std::abs(candP4.eta()));
402 
403  fts.fill("pfcand_ptrel_log", std::log(candP4.pt() / jet.pt()));
404  fts.fill("pfcand_ptrel", candP4.pt() / jet.pt());
405  fts.fill("pfcand_erel_log", std::log(candP4.energy() / jet.energy()));
406  fts.fill("pfcand_erel", candP4.energy() / jet.energy());
407  fts.fill("pfcand_pt_log", std::log(candP4.pt()));
408 
409  fts.fill("pfcand_mask", 1);
410  fts.fill("pfcand_pt_log_nopuppi", std::log(cand->pt()));
411  fts.fill("pfcand_e_log_nopuppi", std::log(cand->energy()));
412 
414  fts.fill("pfcand_drminsv", drminpfcandsv);
415 
416  // subjets
417  if (patJet->nSubjetCollections() > 0) {
418  auto subjets = patJet->subjets();
419  std::sort(subjets.begin(), subjets.end(), [](const edm::Ptr<pat::Jet> &p1, const edm::Ptr<pat::Jet> &p2) {
420  return p1->pt() > p2->pt();
421  }); // sort by pt
422  fts.fill("pfcand_drsubjet1", !subjets.empty() ? reco::deltaR(*cand, *subjets.at(0)) : -1);
423  fts.fill("pfcand_drsubjet2", subjets.size() > 1 ? reco::deltaR(*cand, *subjets.at(1)) : -1);
424  } else {
425  fts.fill("pfcand_drsubjet1", -1);
426  fts.fill("pfcand_drsubjet2", -1);
427  }
428 
429  const reco::Track *trk = nullptr;
430  if (packed_cand) {
431  trk = packed_cand->bestTrack();
432  } else if (reco_cand && useTrackProperties(reco_cand)) {
433  trk = reco_cand->bestTrack();
434  }
435  if (trk) {
436  fts.fill("pfcand_normchi2", std::floor(trk->normalizedChi2()));
437 
438  // track covariance
439  auto cov = [&](unsigned i, unsigned j) { return trk->covariance(i, j); };
440  fts.fill("pfcand_dptdpt", cov(0, 0));
441  fts.fill("pfcand_detadeta", cov(1, 1));
442  fts.fill("pfcand_dphidphi", cov(2, 2));
443  fts.fill("pfcand_dxydxy", cov(3, 3));
444  fts.fill("pfcand_dzdz", cov(4, 4));
445  fts.fill("pfcand_dxydz", cov(3, 4));
446  fts.fill("pfcand_dphidxy", cov(2, 3));
447  fts.fill("pfcand_dlambdadz", cov(1, 4));
448 
450  trkinfo.buildTrackInfo(&(*cand), jet_dir, jet_ref_track_dir, *pv_);
451  fts.fill("pfcand_btagEtaRel", trkinfo.getTrackEtaRel());
452  fts.fill("pfcand_btagPtRatio", trkinfo.getTrackPtRatio());
453  fts.fill("pfcand_btagPParRatio", trkinfo.getTrackPParRatio());
454  fts.fill("pfcand_btagSip2dVal", ip_sign * trkinfo.getTrackSip2dVal());
455  fts.fill("pfcand_btagSip2dSig", ip_sign * trkinfo.getTrackSip2dSig());
456  fts.fill("pfcand_btagSip3dVal", ip_sign * trkinfo.getTrackSip3dVal());
457  fts.fill("pfcand_btagSip3dSig", ip_sign * trkinfo.getTrackSip3dSig());
458  fts.fill("pfcand_btagJetDistVal", trkinfo.getTrackJetDistVal());
459  } else {
460  fts.fill("pfcand_normchi2", 999);
461 
462  fts.fill("pfcand_dptdpt", 0);
463  fts.fill("pfcand_detadeta", 0);
464  fts.fill("pfcand_dphidphi", 0);
465  fts.fill("pfcand_dxydxy", 0);
466  fts.fill("pfcand_dzdz", 0);
467  fts.fill("pfcand_dxydz", 0);
468  fts.fill("pfcand_dphidxy", 0);
469  fts.fill("pfcand_dlambdadz", 0);
470 
471  fts.fill("pfcand_btagEtaRel", 0);
472  fts.fill("pfcand_btagPtRatio", 0);
473  fts.fill("pfcand_btagPParRatio", 0);
474  fts.fill("pfcand_btagSip2dVal", 0);
475  fts.fill("pfcand_btagSip2dSig", 0);
476  fts.fill("pfcand_btagSip3dVal", 0);
477  fts.fill("pfcand_btagSip3dSig", 0);
478  fts.fill("pfcand_btagJetDistVal", 0);
479  }
480  }
481 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
float quality_from_pfcand(const reco::PFCandidate &pfcand)
double eta() const final
momentum pseudorapidity
key_type key() const
Definition: Ptr.h:185
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
Definition: TrackBase.h:600
static const std::vector< std::string > particle_features_
double px() const final
x coordinate of momentum vector
double pt() const final
transverse momentum
const Point & position() const
position
Definition: Vertex.h:109
virtual const daughters & daughterPtrVector() const
references to daughtes
size_t numberOfDaughters() const override
number of daughters
Vector momentum() const final
spatial momentum vector
edm::ESHandle< TransientTrackBuilder > track_builder_
float mindrsvpfcand(const std::vector< reco::VertexCompositePtrCandidate > &svs, const reco::Candidate *cand, float mindr=0.4)
Definition: deep_helpers.cc:73
void reserve(const std::string &name, unsigned capacity)
double pz() const final
z coordinate of momentum vector
CovarianceMatrix covariance() const
return track covariance matrix
Definition: TrackBase.h:782
double energy() const final
energy
const double infinity
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float vtx_ass_from_pfcand(const reco::PFCandidate &pfcand, int pv_ass_quality, const reco::VertexRef &pv)
Definition: deep_helpers.cc:90
double p2[4]
Definition: TauolaWrapper.h:90
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
double b
Definition: hdecay.h:120
double py() const final
y coordinate of momentum vector
Analysis-level calorimeter jet class.
Definition: Jet.h:80
void fill(const std::string &name, float value)
float lost_inner_hits_from_pfcand(const reco::PFCandidate &pfcand)
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
double p1[4]
Definition: TauolaWrapper.h:89
double a
Definition: hdecay.h:121
void DeepBoostedJetTagInfoProducer::fillSVFeatures ( DeepBoostedJetFeatures fts,
const reco::Jet jet 
)
private

Definition at line 483 of file DeepBoostedJetTagInfoProducer.cc.

References funct::abs(), DEFINE_FWK_MODULE, reco::deltaPhi(), reco::deltaR(), reco::deltaR2(), PVValHelper::dxy, reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), f, btagbtvdeep::DeepBoostedJetFeatures::fill(), flip_ip_sign_, jet_radius_, cmsBatch::log, dataset::name, reco::LeafCandidate::pt(), pv_, btagbtvdeep::DeepBoostedJetFeatures::reserve(), jetUpdater_cfi::sort, pfDeepBoostedJetPreprocessParams_cfi::sv, sv_features_, btagbtvdeep::sv_vertex_comparator(), svs_, btagbtvdeep::vertexD3d(), btagbtvdeep::vertexDdotP(), and btagbtvdeep::vertexDxy().

Referenced by produce().

483  {
484  std::vector<const reco::VertexCompositePtrCandidate *> jetSVs;
485  for (const auto &sv : *svs_) {
486  if (reco::deltaR2(sv, jet) < jet_radius_ * jet_radius_) {
487  jetSVs.push_back(&sv);
488  }
489  }
490  // sort by dxy significance
491  std::sort(jetSVs.begin(),
492  jetSVs.end(),
494  return sv_vertex_comparator(*sva, *svb, *pv_);
495  });
496 
497  // reserve space
498  for (const auto &name : sv_features_) {
499  fts.reserve(name, jetSVs.size());
500  }
501 
502  const float etasign = jet.eta() > 0 ? 1 : -1;
503 
504  for (const auto *sv : jetSVs) {
505  // basic kinematics
506  fts.fill("sv_mask", 1);
507  fts.fill("sv_phirel", reco::deltaPhi(*sv, jet));
508  fts.fill("sv_etarel", etasign * (sv->eta() - jet.eta()));
509  fts.fill("sv_deltaR", reco::deltaR(*sv, jet));
510  fts.fill("sv_abseta", std::abs(sv->eta()));
511  fts.fill("sv_mass", sv->mass());
512 
513  fts.fill("sv_ptrel_log", std::log(sv->pt() / jet.pt()));
514  fts.fill("sv_ptrel", sv->pt() / jet.pt());
515  fts.fill("sv_erel_log", std::log(sv->energy() / jet.energy()));
516  fts.fill("sv_erel", sv->energy() / jet.energy());
517  fts.fill("sv_pt_log", std::log(sv->pt()));
518  fts.fill("sv_pt", sv->pt());
519 
520  // sv properties
521  fts.fill("sv_ntracks", sv->numberOfDaughters());
522  fts.fill("sv_normchi2", sv->vertexNormalizedChi2());
523 
524  const auto &dxy = vertexDxy(*sv, *pv_);
525  fts.fill("sv_dxy", dxy.value());
526  fts.fill("sv_dxysig", dxy.significance());
527 
528  const auto &d3d = vertexD3d(*sv, *pv_);
529  fts.fill("sv_d3d", d3d.value());
530  fts.fill("sv_d3dsig", d3d.significance());
531 
532  fts.fill("sv_costhetasvpv", (flip_ip_sign_ ? -1.f : 1.f) * vertexDdotP(*sv, *pv_));
533  }
534 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
static const std::vector< std::string > sv_features_
double eta() const final
momentum pseudorapidity
float vertexDdotP(const reco::VertexCompositePtrCandidate &sv, const reco::Vertex &pv)
Definition: deep_helpers.cc:66
Measurement1D vertexD3d(const reco::VertexCompositePtrCandidate &svcand, const reco::Vertex &pv)
Definition: deep_helpers.cc:58
double pt() const final
transverse momentum
void reserve(const std::string &name, unsigned capacity)
Measurement1D vertexDxy(const reco::VertexCompositePtrCandidate &svcand, const reco::Vertex &pv)
Definition: deep_helpers.cc:50
double energy() const final
energy
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
bool sv_vertex_comparator(const SVType &sva, const SVType &svb, const PVType &pv)
Definition: deep_helpers.h:43
void fill(const std::string &name, float value)
void DeepBoostedJetTagInfoProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 160 of file DeepBoostedJetTagInfoProducer.cc.

References funct::abs(), btagbtvdeep::DeepBoostedJetFeatures::add(), btagbtvdeep::DeepBoostedJetFeatures::check_consistency(), postprocess-scan-build::features, fillParticleFeatures(), fillSVFeatures(), edm::EventSetup::get(), edm::Event::getByToken(), edm::Event::getHandle(), metsig::jet, jet_token_, fwrapper::jets, max_jet_eta_, min_jet_pt_, eostools::move(), dataset::name, particle_features_, pfcand_token_, pfcands_, puppi_value_map_, puppi_value_map_token_, edm::Event::put(), pv_, pvas_, pvas_token_, pvasq_value_map_, pvasq_value_map_token_, sv_features_, sv_token_, svs_, track_builder_, use_puppi_value_map_, use_pvasq_value_map_, vtx_token_, and vtxs_.

160  {
161  auto output_tag_infos = std::make_unique<DeepBoostedJetTagInfoCollection>();
162 
163  auto jets = iEvent.getHandle(jet_token_);
164 
165  iEvent.getByToken(vtx_token_, vtxs_);
166  if (vtxs_->empty()) {
167  // produce empty TagInfos in case no primary vertex
168  iEvent.put(std::move(output_tag_infos));
169  return; // exit event
170  }
171  // primary vertex
172  pv_ = &vtxs_->at(0);
173 
174  iEvent.getByToken(sv_token_, svs_);
175 
177 
178  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", track_builder_);
179 
180  if (use_puppi_value_map_) {
182  }
183 
184  if (use_pvasq_value_map_) {
186  iEvent.getByToken(pvas_token_, pvas_);
187  }
188 
189  for (std::size_t jet_n = 0; jet_n < jets->size(); jet_n++) {
190  const auto &jet = (*jets)[jet_n];
191  edm::RefToBase<reco::Jet> jet_ref(jets, jet_n);
192 
193  // create jet features
195  // declare all the feature variables (init as empty vector)
196  for (const auto &name : particle_features_) {
197  features.add(name);
198  }
199  for (const auto &name : sv_features_) {
200  features.add(name);
201  }
202 
203  // fill values only if above pt threshold and has daughters, otherwise left
204  // empty
205  bool fill_vars = true;
206  if (jet.pt() < min_jet_pt_ || std::abs(jet.eta()) > max_jet_eta_)
207  fill_vars = false;
208  if (jet.numberOfDaughters() == 0)
209  fill_vars = false;
210 
211  if (fill_vars) {
212  fillParticleFeatures(features, jet);
213  fillSVFeatures(features, jet);
214 
215  features.check_consistency(particle_features_);
216  features.check_consistency(sv_features_);
217  }
218 
219  // this should always be done even if features are not filled
220  output_tag_infos->emplace_back(features, jet_ref);
221  }
222 
223  iEvent.put(std::move(output_tag_infos));
224 }
static const std::vector< std::string > sv_features_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
static const std::vector< std::string > particle_features_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void fillParticleFeatures(DeepBoostedJetFeatures &fts, const reco::Jet &jet)
edm::EDGetTokenT< VertexCollection > vtx_token_
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:539
edm::ESHandle< TransientTrackBuilder > track_builder_
vector< PseudoJet > jets
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void check_consistency(const std::vector< std::string > &names) const
edm::Handle< edm::ValueMap< int > > pvasq_value_map_
void add(const std::string &name)
edm::EDGetTokenT< CandidateView > pfcand_token_
edm::EDGetTokenT< SVCollection > sv_token_
edm::Handle< edm::Association< VertexCollection > > pvas_
T get() const
Definition: EventSetup.h:71
edm::EDGetTokenT< edm::View< reco::Jet > > jet_token_
edm::Handle< edm::ValueMap< float > > puppi_value_map_
edm::EDGetTokenT< edm::Association< VertexCollection > > pvas_token_
edm::Handle< VertexCollection > vtxs_
edm::EDGetTokenT< edm::ValueMap< int > > pvasq_value_map_token_
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< edm::ValueMap< float > > puppi_value_map_token_
void fillSVFeatures(DeepBoostedJetFeatures &fts, const reco::Jet &jet)

Member Data Documentation

const bool DeepBoostedJetTagInfoProducer::flip_ip_sign_
private

Definition at line 55 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by fillParticleFeatures(), and fillSVFeatures().

const bool DeepBoostedJetTagInfoProducer::include_neutrals_
private

Definition at line 52 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by fillParticleFeatures().

const double DeepBoostedJetTagInfoProducer::jet_radius_
private

Definition at line 47 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by fillParticleFeatures(), and fillSVFeatures().

edm::EDGetTokenT<edm::View<reco::Jet> > DeepBoostedJetTagInfoProducer::jet_token_
private

Definition at line 58 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by produce().

const double DeepBoostedJetTagInfoProducer::max_jet_eta_
private

Definition at line 49 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by produce().

const double DeepBoostedJetTagInfoProducer::max_sip3dsig_
private

Definition at line 56 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by fillParticleFeatures().

const double DeepBoostedJetTagInfoProducer::min_jet_pt_
private

Definition at line 48 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by produce().

const double DeepBoostedJetTagInfoProducer::min_pt_for_track_properties_
private

Definition at line 50 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by fillParticleFeatures().

const double DeepBoostedJetTagInfoProducer::min_puppi_wgt_
private

Definition at line 54 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by fillParticleFeatures().

const std::vector< std::string > DeepBoostedJetTagInfoProducer::particle_features_
staticprivate
Initial value:
{
"pfcand_puppiw", "pfcand_hcalFrac", "pfcand_VTX_ass", "pfcand_lostInnerHits",
"pfcand_quality", "pfcand_charge", "pfcand_isEl", "pfcand_isMu",
"pfcand_isChargedHad", "pfcand_isGamma", "pfcand_isNeutralHad", "pfcand_phirel",
"pfcand_etarel", "pfcand_deltaR", "pfcand_abseta", "pfcand_ptrel_log",
"pfcand_erel_log", "pfcand_pt_log", "pfcand_drminsv", "pfcand_drsubjet1",
"pfcand_drsubjet2", "pfcand_normchi2", "pfcand_dz", "pfcand_dzsig",
"pfcand_dxy", "pfcand_dxysig", "pfcand_dptdpt", "pfcand_detadeta",
"pfcand_dphidphi", "pfcand_dxydxy", "pfcand_dzdz", "pfcand_dxydz",
"pfcand_dphidxy", "pfcand_dlambdadz", "pfcand_btagEtaRel", "pfcand_btagPtRatio",
"pfcand_btagPParRatio", "pfcand_btagSip2dVal", "pfcand_btagSip2dSig", "pfcand_btagSip3dVal",
"pfcand_btagSip3dSig", "pfcand_btagJetDistVal", "pfcand_mask", "pfcand_pt_log_nopuppi",
"pfcand_e_log_nopuppi", "pfcand_ptrel", "pfcand_erel"}

Definition at line 78 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by fillParticleFeatures(), and produce().

edm::EDGetTokenT<CandidateView> DeepBoostedJetTagInfoProducer::pfcand_token_
private

Definition at line 61 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by produce().

edm::Handle<CandidateView> DeepBoostedJetTagInfoProducer::pfcands_
private

Definition at line 72 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by fillParticleFeatures(), and produce().

edm::Handle<edm::ValueMap<float> > DeepBoostedJetTagInfoProducer::puppi_value_map_
private

Definition at line 74 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by produce().

edm::EDGetTokenT<edm::ValueMap<float> > DeepBoostedJetTagInfoProducer::puppi_value_map_token_
private

Definition at line 66 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by DeepBoostedJetTagInfoProducer(), and produce().

const reco::Vertex* DeepBoostedJetTagInfoProducer::pv_ = 0
private

Definition at line 80 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by fillParticleFeatures(), fillSVFeatures(), and produce().

edm::Handle<edm::Association<VertexCollection> > DeepBoostedJetTagInfoProducer::pvas_
private

Definition at line 76 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by produce().

edm::EDGetTokenT<edm::Association<VertexCollection> > DeepBoostedJetTagInfoProducer::pvas_token_
private

Definition at line 68 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by DeepBoostedJetTagInfoProducer(), and produce().

edm::Handle<edm::ValueMap<int> > DeepBoostedJetTagInfoProducer::pvasq_value_map_
private

Definition at line 75 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by produce().

edm::EDGetTokenT<edm::ValueMap<int> > DeepBoostedJetTagInfoProducer::pvasq_value_map_token_
private

Definition at line 67 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by DeepBoostedJetTagInfoProducer(), and produce().

const bool DeepBoostedJetTagInfoProducer::sort_by_sip2dsig_
private

Definition at line 53 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by fillParticleFeatures().

const std::vector< std::string > DeepBoostedJetTagInfoProducer::sv_features_
staticprivate
Initial value:
{
"sv_mask", "sv_ptrel", "sv_erel", "sv_phirel", "sv_etarel", "sv_deltaR", "sv_abseta",
"sv_mass", "sv_ptrel_log", "sv_erel_log", "sv_pt_log", "sv_pt", "sv_ntracks", "sv_normchi2",
"sv_dxy", "sv_dxysig", "sv_d3d", "sv_d3dsig", "sv_costhetasvpv",
}

Definition at line 79 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by fillSVFeatures(), and produce().

edm::EDGetTokenT<SVCollection> DeepBoostedJetTagInfoProducer::sv_token_
private

Definition at line 60 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by produce().

edm::Handle<SVCollection> DeepBoostedJetTagInfoProducer::svs_
private

Definition at line 71 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by fillParticleFeatures(), fillSVFeatures(), and produce().

edm::ESHandle<TransientTrackBuilder> DeepBoostedJetTagInfoProducer::track_builder_
private

Definition at line 73 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by fillParticleFeatures(), and produce().

bool DeepBoostedJetTagInfoProducer::use_puppi_value_map_
private
const bool DeepBoostedJetTagInfoProducer::use_puppiP4_
private

Definition at line 51 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by fillParticleFeatures().

bool DeepBoostedJetTagInfoProducer::use_pvasq_value_map_
private
edm::EDGetTokenT<VertexCollection> DeepBoostedJetTagInfoProducer::vtx_token_
private

Definition at line 59 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by produce().

edm::Handle<VertexCollection> DeepBoostedJetTagInfoProducer::vtxs_
private

Definition at line 70 of file DeepBoostedJetTagInfoProducer.cc.

Referenced by produce().