CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
SoftLepton Class Reference

#include <RecoBTag/SoftLepton/src/SoftLepton.cc>

Inheritance diagram for SoftLepton:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  TrackCompare
 

Public Types

using LeptonIds = std::map< unsigned int, float >
 
using Leptons = std::map< edm::RefToBase< reco::Track >, LeptonIds, TrackCompare >
 
- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 SoftLepton (const edm::ParameterSet &iConfig)
 
reco::SoftLeptonTagInfo tag (const edm::RefToBase< reco::Jet > &jet, const reco::TrackRefVector &tracks, const Leptons &leptons, const reco::Vertex &primaryVertex, const TransientTrackBuilder &builder) const
 
- Public Member Functions inherited from edm::global::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
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Protected Member Functions

GlobalVector refineJetAxis (const edm::RefToBase< reco::Jet > &jet, const reco::TrackRefVector &tracks, const edm::RefToBase< reco::Track > &exclude=edm::RefToBase< reco::Track >()) const
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Static Protected Member Functions

static double boostedPPar (const math::XYZVector &vector, const math::XYZVector &axis)
 
static double relativeEta (const math::XYZVector &vector, const math::XYZVector &axis)
 

Private Member Functions

void produce (edm::StreamID, edm::Event &event, const edm::EventSetup &setup) const final
 

Private Attributes

const double m_chi2Cut
 
const double m_deltaRCut
 
const edm::InputTag m_jets
 
const edm::InputTag m_leptonCands
 
const edm::InputTag m_leptonId
 
const edm::InputTag m_leptons
 
const muon::SelectionType m_muonSelection
 
const unsigned int m_refineJetAxis
 
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecordtoken_builder
 
const edm::EDGetTokenT< edm::View< reco::Electron > > token_electrons
 
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > token_gsfElectrons
 
const edm::EDGetTokenT< edm::View< reco::Jet > > token_jets
 
const edm::EDGetTokenT< reco::JetTracksAssociationCollectiontoken_jtas
 
const edm::EDGetTokenT< edm::ValueMap< float > > token_leptonCands
 
const edm::EDGetTokenT< edm::ValueMap< float > > token_leptonId
 
const edm::EDGetTokenT< edm::View< reco::Muon > > token_muons
 
const edm::EDGetTokenT< reco::PFCandidateCollectiontoken_pfElectrons
 
const edm::EDGetTokenT< reco::VertexCollectiontoken_primaryVertex
 
const edm::EDPutTokenT< reco::SoftLeptonTagInfoCollectiontoken_put
 
const edm::EDGetTokenT< edm::View< reco::Track > > token_tracks
 

Static Private Attributes

static const reco::Vertex s_nominalBeamSpot
 

Detailed Description

Description: CMSSW EDProducer for soft lepton b tagging.

Implementation: The actual tagging is performed by SoftLeptonAlgorithm.

Definition at line 65 of file SoftLepton.cc.

Member Typedef Documentation

◆ LeptonIds

using SoftLepton::LeptonIds = std::map<unsigned int, float>

Definition at line 77 of file SoftLepton.cc.

◆ Leptons

Definition at line 78 of file SoftLepton.cc.

Constructor & Destructor Documentation

◆ SoftLepton()

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

Definition at line 165 of file SoftLepton.cc.

166  : m_jets(iConfig.getParameter<edm::InputTag>("jets")),
167  token_jtas(mayConsume<reco::JetTracksAssociationCollection>(m_jets)),
169  token_primaryVertex(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("primaryVertex"))),
170  m_leptons(iConfig.getParameter<edm::InputTag>("leptons")),
171  token_gsfElectrons(mayConsume<GsfElectronView>(m_leptons)),
172  token_electrons(mayConsume<ElectronView>(m_leptons)),
173  token_pfElectrons(mayConsume<reco::PFCandidateCollection>(m_leptons)),
174  token_muons(mayConsume<MuonView>(m_leptons)),
176  m_leptonCands(iConfig.getParameter<edm::InputTag>("leptonCands")),
178  m_leptonId(iConfig.getParameter<edm::InputTag>("leptonId")),
180  token_builder(esConsumes(edm::ESInputTag("", "TransientTrackBuilder"))),
181  token_put(produces()),
182  m_refineJetAxis(iConfig.getParameter<unsigned int>("refineJetAxis")),
183  m_deltaRCut(iConfig.getParameter<double>("leptonDeltaRCut")),
184  m_chi2Cut(iConfig.getParameter<double>("leptonChi2Cut")),
185  m_muonSelection((muon::SelectionType)iConfig.getParameter<unsigned int>("muonSelection")) {}
const edm::EDGetTokenT< reco::PFCandidateCollection > token_pfElectrons
Definition: SoftLepton.cc:109
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > token_builder
Definition: SoftLepton.cc:118
const double m_deltaRCut
Definition: SoftLepton.cc:123
const edm::EDGetTokenT< edm::ValueMap< float > > token_leptonCands
Definition: SoftLepton.cc:113
const edm::EDGetTokenT< edm::ValueMap< float > > token_leptonId
Definition: SoftLepton.cc:115
const edm::EDGetTokenT< edm::View< reco::Muon > > token_muons
Definition: SoftLepton.cc:110
const edm::EDGetTokenT< edm::View< reco::Electron > > token_electrons
Definition: SoftLepton.cc:108
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > token_gsfElectrons
Definition: SoftLepton.cc:107
SelectionType
Selector type.
Definition: MuonSelectors.h:18
const muon::SelectionType m_muonSelection
Definition: SoftLepton.cc:127
const unsigned int m_refineJetAxis
Definition: SoftLepton.cc:122
const edm::InputTag m_leptons
Definition: SoftLepton.cc:106
const edm::EDGetTokenT< reco::VertexCollection > token_primaryVertex
Definition: SoftLepton.cc:105
const double m_chi2Cut
Definition: SoftLepton.cc:124
const edm::InputTag m_leptonId
Definition: SoftLepton.cc:114
const edm::InputTag m_leptonCands
Definition: SoftLepton.cc:112
const edm::EDGetTokenT< edm::View< reco::Jet > > token_jets
Definition: SoftLepton.cc:104
const edm::InputTag m_jets
Definition: SoftLepton.cc:102
const edm::EDGetTokenT< edm::View< reco::Track > > token_tracks
Definition: SoftLepton.cc:111
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
const edm::EDPutTokenT< reco::SoftLeptonTagInfoCollection > token_put
Definition: SoftLepton.cc:120
const edm::EDGetTokenT< reco::JetTracksAssociationCollection > token_jtas
Definition: SoftLepton.cc:103

Member Function Documentation

◆ boostedPPar()

double SoftLepton::boostedPPar ( const math::XYZVector vector,
const math::XYZVector axis 
)
staticprotected

Definition at line 499 of file SoftLepton.cc.

References metsig::jet, and trackerHitRTTI::vector.

Referenced by tag().

499  {
500  static const double lepton_mass = 0.00; // assume a massless (ultrarelativistic) lepton
501  static const double jet_mass = 5.279; // use B±/B0 mass as the jet rest mass [PDG 2007 updates]
502  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > lepton(
503  vector.Dot(axis) / axis.r(), Perp(vector, axis), 0., lepton_mass);
504  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > jet(axis.r(), 0., 0., jet_mass);
505  ROOT::Math::BoostX boost(-jet.Beta());
506  return boost(lepton).x();
507 }
Definition: CLHEP.h:16

◆ fillDescriptions()

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

Definition at line 510 of file SoftLepton.cc.

References edm::ConfigurationDescriptions::addDefault(), submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

510  {
512  desc.add<unsigned int>("muonSelection", 1);
513  desc.add<edm::InputTag>("leptons", edm::InputTag("muons"));
514  desc.add<edm::InputTag>("primaryVertex", edm::InputTag("offlinePrimaryVertices"));
515  desc.add<edm::InputTag>("leptonCands", edm::InputTag());
516  desc.add<edm::InputTag>("leptonId", edm::InputTag());
517  desc.add<unsigned int>("refineJetAxis", 0);
518  desc.add<edm::InputTag>("jets", edm::InputTag("ak4PFJetsCHS"));
519  desc.add<double>("leptonDeltaRCut", 0.4);
520  desc.add<double>("leptonChi2Cut", 9999.0);
521  descriptions.addDefault(desc);
522 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ produce()

void SoftLepton::produce ( edm::StreamID  ,
edm::Event event,
const edm::EventSetup setup 
) const
finalprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 188 of file SoftLepton.cc.

References edm::View< T >::begin(), HPSPFTauProducerPuppi_cfi::electron, edm::View< T >::end(), Exception, edm::ValueMap< T >::get(), mps_fire::i, EcalPhiSymFlatTableProducers_cfi::id, ProducerED_cfi::InputTag, muon::isGoodMuon(), edm::HandleBase::isValid(), PDWG_EXODelayedJetMET_cff::jets, HLT_2024v14_cff::leptonId, HLT_2024v14_cff::leptons, m_jets, m_leptonCands, m_leptonId, m_leptons, m_muonSelection, eostools::move(), HLT_2024v14_cff::muon, edm::errors::NotFound, valuemaptraslator_cfi::outputCollection, edm::View< T >::refAt(), mps_fire::result, s_nominalBeamSpot, singleTopDQM_cfi::setup, edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::size(), findQualityFiles::size, tag(), token_builder, token_electrons, token_gsfElectrons, token_jets, token_jtas, token_leptonCands, token_leptonId, token_muons, token_pfElectrons, token_primaryVertex, token_put, token_tracks, DiMuonV_cfg::tracks, and bphysicsOniaDQM_cfi::vertex.

188  {
189  // grab a TransientTrack helper from the Event Setup
190  auto const &transientTrackBuilder = setup.getData(token_builder);
191 
192  // input objects
193 
194  // input jets (and possibly tracks)
195  ProductID jets_id;
196  std::vector<edm::RefToBase<reco::Jet> > jets;
197  std::vector<reco::TrackRefVector> tracks;
198  do {
199  {
200  // look for a JetTracksAssociationCollection
202  if (h_jtas.isValid()) {
203  unsigned int size = h_jtas->size();
204  jets.resize(size);
205  tracks.resize(size);
206  for (unsigned int i = 0; i < size; ++i) {
207  jets[i] = (*h_jtas)[i].first;
208  tracks[i] = (*h_jtas)[i].second;
209  }
210  break;
211  }
212  }
213  { // else...
214  // look for a View<Jet>
215  edm::Handle<edm::View<reco::Jet> > h_jets = event.getHandle(token_jets);
216  if (h_jets.isValid()) {
217  unsigned int size = h_jets->size();
218  jets.resize(size);
219  tracks.resize(size);
220  for (unsigned int i = 0; i < h_jets->size(); i++)
221  jets[i] = h_jets->refAt(i);
222  break;
223  }
224  }
225  { // else...
227  << "Object " << m_jets
228  << " of type among (\"reco::JetTracksAssociationCollection\", \"edm::View<reco::Jet>\") not found";
229  }
230  } while (false);
231 
232  // input primary vetex
234  Handle<reco::VertexCollection> h_primaryVertex = event.getHandle(token_primaryVertex);
235  if (h_primaryVertex.isValid() and not h_primaryVertex->empty())
236  vertex = h_primaryVertex->front();
237  else
238  // fall back to nominal beam spot
240 
241  // input leptons (can be of different types)
243 
244  Handle<edm::ValueMap<float> > h_leptonCands;
245  bool haveLeptonCands = !(m_leptonCands == edm::InputTag());
246  if (haveLeptonCands)
247  h_leptonCands = event.getHandle(token_leptonCands);
248 
249  // try to access the input collection as a collection of GsfElectrons, Muons or Tracks
250 
252  do {
253  {
254  // look for View<GsfElectron>
255  Handle<GsfElectronView> h_electrons = event.getHandle(token_gsfElectrons);
256 
257  if (h_electrons.isValid()) {
258  leptonId = SoftLeptonProperties::Quality::egammaElectronId;
259  for (GsfElectronView::const_iterator electron = h_electrons->begin(); electron != h_electrons->end();
260  ++electron) {
261  LeptonIds &id = leptons[reco::TrackBaseRef(electron->gsfTrack())];
262  id[SoftLeptonProperties::Quality::pfElectronId] = electron->mva_e_pi();
263  if (haveLeptonCands)
264  id[SoftLeptonProperties::Quality::btagElectronCands] =
265  (*h_leptonCands)[h_electrons->refAt(electron - h_electrons->begin())];
266  }
267  break;
268  }
269  }
270  { // else
271  // look for View<Electron>
272  // FIXME: is this obsolete?
273  Handle<ElectronView> h_electrons = event.getHandle(token_electrons);
274  if (h_electrons.isValid()) {
275  leptonId = SoftLeptonProperties::Quality::egammaElectronId;
276  for (ElectronView::const_iterator electron = h_electrons->begin(); electron != h_electrons->end(); ++electron) {
277  LeptonIds &id = leptons[reco::TrackBaseRef(electron->track())];
278  if (haveLeptonCands)
279  id[SoftLeptonProperties::Quality::btagElectronCands] =
280  (*h_leptonCands)[h_electrons->refAt(electron - h_electrons->begin())];
281  }
282  break;
283  }
284  }
285  { // else
286  // look for PFElectrons
287  // FIXME: is this obsolete?
288  Handle<reco::PFCandidateCollection> h_electrons = event.getHandle(token_pfElectrons);
289  if (h_electrons.isValid()) {
290  leptonId = SoftLeptonProperties::Quality::egammaElectronId;
291  for (reco::PFCandidateCollection::const_iterator electron = h_electrons->begin();
292  electron != h_electrons->end();
293  ++electron) {
294  LeptonIds *id;
295  if (electron->gsfTrackRef().isNonnull())
296  id = &leptons[reco::TrackBaseRef(electron->gsfTrackRef())];
297  else if (electron->trackRef().isNonnull())
298  id = &leptons[reco::TrackBaseRef(electron->trackRef())];
299  else
300  continue;
301  (*id)[SoftLeptonProperties::Quality::pfElectronId] = electron->mva_e_pi();
302  if (haveLeptonCands)
303  (*id)[SoftLeptonProperties::Quality::btagElectronCands] =
304  (*h_leptonCands)[reco::PFCandidateRef(h_electrons, electron - h_electrons->begin())];
305  }
306  break;
307  }
308  }
309  { // else
310  // look for View<Muon>
311  Handle<MuonView> h_muons = event.getHandle(token_muons);
312  if (h_muons.isValid()) {
313  for (MuonView::const_iterator muon = h_muons->begin(); muon != h_muons->end(); ++muon) {
314  // FIXME -> turn this selection into a muonCands input?
316  LeptonIds *id;
317  if (muon->globalTrack().isNonnull())
318  id = &leptons[reco::TrackBaseRef(muon->globalTrack())];
319  else if (muon->innerTrack().isNonnull())
320  id = &leptons[reco::TrackBaseRef(muon->innerTrack())];
321  else if (muon->outerTrack().isNonnull())
322  // does this makes sense ?
323  id = &leptons[reco::TrackBaseRef(muon->outerTrack())];
324  else
325  continue;
326  if (haveLeptonCands)
327  (*id)[SoftLeptonProperties::Quality::btagMuonCands] =
328  (*h_leptonCands)[h_muons->refAt(muon - h_muons->begin())];
329  }
330  }
331  break;
332  }
333  }
334  { // else
335  // look for edm::View<Track>
336  Handle<edm::View<reco::Track> > h_tracks = event.getHandle(token_tracks);
337  if (h_tracks.isValid()) {
338  for (unsigned int i = 0; i < h_tracks->size(); i++) {
339  LeptonIds &id = leptons[h_tracks->refAt(i)];
340  if (haveLeptonCands)
341  id[SoftLeptonProperties::Quality::btagLeptonCands] = (*h_leptonCands)[h_tracks->refAt(i)];
342  }
343  break;
344  }
345  }
346  { // else
347  throw edm::Exception(edm::errors::NotFound) << "Object " << m_leptons
348  << " of type among (\"edm::View<reco::GsfElectron>\", "
349  "\"edm::View<reco::Muon>\", \"edm::View<reco::Track>\") !found";
350  }
351  } while (false);
352 
353  if (!(m_leptonId == edm::InputTag())) {
354  edm::ValueMap<float> const &h_leptonId = event.get(token_leptonId);
355 
356  for (Leptons::iterator lepton = leptons.begin(); lepton != leptons.end(); ++lepton)
357  lepton->second[leptonId] = h_leptonId[lepton->first];
358  }
359 
360  // output collections
362  for (unsigned int i = 0; i < jets.size(); ++i) {
363  reco::SoftLeptonTagInfo result = tag(jets[i], tracks[i], leptons, vertex, transientTrackBuilder);
364  outputCollection.push_back(result);
365  }
366  event.emplace(token_put, std::move(outputCollection));
367 }
size
Write out results.
reco::SoftLeptonTagInfo tag(const edm::RefToBase< reco::Jet > &jet, const reco::TrackRefVector &tracks, const Leptons &leptons, const reco::Vertex &primaryVertex, const TransientTrackBuilder &builder) const
Definition: SoftLepton.cc:370
const edm::EDGetTokenT< reco::PFCandidateCollection > token_pfElectrons
Definition: SoftLepton.cc:109
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > token_builder
Definition: SoftLepton.cc:118
RefToBase< value_type > refAt(size_type i) const
size_type size() const
const_reference_type get(ProductID id, size_t idx) const
Definition: ValueMap.h:138
const edm::EDGetTokenT< edm::ValueMap< float > > token_leptonCands
Definition: SoftLepton.cc:113
const edm::EDGetTokenT< edm::ValueMap< float > > token_leptonId
Definition: SoftLepton.cc:115
const edm::EDGetTokenT< edm::View< reco::Muon > > token_muons
Definition: SoftLepton.cc:110
const edm::EDGetTokenT< edm::View< reco::Electron > > token_electrons
Definition: SoftLepton.cc:108
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > token_gsfElectrons
Definition: SoftLepton.cc:107
std::map< edm::RefToBase< reco::Track >, LeptonIds, TrackCompare > Leptons
Definition: SoftLepton.cc:78
std::vector< SoftLeptonTagInfo > SoftLeptonTagInfoCollection
std::map< unsigned int, float > LeptonIds
Definition: SoftLepton.cc:77
const muon::SelectionType m_muonSelection
Definition: SoftLepton.cc:127
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
Definition: TrackFwd.h:35
const edm::InputTag m_leptons
Definition: SoftLepton.cc:106
const edm::EDGetTokenT< reco::VertexCollection > token_primaryVertex
Definition: SoftLepton.cc:105
const edm::InputTag m_leptonId
Definition: SoftLepton.cc:114
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
const edm::InputTag m_leptonCands
Definition: SoftLepton.cc:112
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
const edm::EDGetTokenT< edm::View< reco::Jet > > token_jets
Definition: SoftLepton.cc:104
bool isValid() const
Definition: HandleBase.h:70
static const reco::Vertex s_nominalBeamSpot
Definition: SoftLepton.cc:130
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:88
const edm::InputTag m_jets
Definition: SoftLepton.cc:102
const edm::EDGetTokenT< edm::View< reco::Track > > token_tracks
Definition: SoftLepton.cc:111
const_iterator begin() const
const edm::EDPutTokenT< reco::SoftLeptonTagInfoCollection > token_put
Definition: SoftLepton.cc:120
const_iterator end() const
def move(src, dest)
Definition: eostools.py:511
const edm::EDGetTokenT< reco::JetTracksAssociationCollection > token_jtas
Definition: SoftLepton.cc:103

◆ refineJetAxis()

GlobalVector SoftLepton::refineJetAxis ( const edm::RefToBase< reco::Jet > &  jet,
const reco::TrackRefVector tracks,
const edm::RefToBase< reco::Track > &  exclude = edm::RefToBase<reco::Track>() 
) const
protected

Definition at line 415 of file SoftLepton.cc.

References AXIS_CALORIMETRIC_NOLEPTON, AXIS_CHARGED_AVERAGE, AXIS_CHARGED_AVERAGE_NOLEPTON, AXIS_CHARGED_SUM, AXIS_CHARGED_SUM_NOLEPTON, edm::RefToBase< T >::isNonnull(), metsig::jet, M_PI, m_refineJetAxis, reco::TrackBase::momentum(), or, perp(), HLT_2024v14_cff::track, and DiMuonV_cfg::tracks.

Referenced by tag().

418  {
419  math::XYZVector axis = jet->momentum();
420 
422  double sum_pT = 0.;
423  double sum_eta_by_pT = 0.;
424  double sum_phi_by_pT = 0.;
425 
426  double perp;
427  double phi_rel;
428  double eta_rel;
429 
430  // refine jet eta and phi with charged tracks measurements, if available
431  for (reco::TrackRefVector::const_iterator track_it = tracks.begin(); track_it != tracks.end(); ++track_it) {
432  const reco::Track &track = **track_it;
433 
434  perp = track.pt();
435  eta_rel = (double)track.eta() - axis.eta();
436  phi_rel = (double)track.phi() - axis.phi();
437  while (phi_rel < -M_PI)
438  phi_rel += 2 * M_PI;
439  while (phi_rel > M_PI)
440  phi_rel -= 2 * M_PI;
441 
442  sum_pT += perp;
443  sum_phi_by_pT += perp * phi_rel;
444  sum_eta_by_pT += perp * eta_rel;
445  }
446 
447  // "remove" excluded track
449  const reco::Track &track = *exclude;
450 
451  perp = track.pt();
452  eta_rel = (double)track.eta() - axis.eta();
453  phi_rel = (double)track.phi() - axis.phi();
454  while (phi_rel < -M_PI)
455  phi_rel += 2 * M_PI;
456  while (phi_rel > M_PI)
457  phi_rel -= 2 * M_PI;
458 
459  sum_pT -= perp;
460  sum_phi_by_pT -= perp * phi_rel;
461  sum_eta_by_pT -= perp * eta_rel;
462  }
463 
464  if (sum_pT > 1.) // avoid the case of only the lepton-track with small rounding errors
465  axis =
466  math::RhoEtaPhiVector(axis.rho(), axis.eta() + sum_eta_by_pT / sum_pT, axis.phi() + sum_phi_by_pT / sum_pT);
467 
469  math::XYZVector sum;
470 
471  // recalculate the jet direction as the sum of charget tracks momenta
472  for (reco::TrackRefVector::const_iterator track_it = tracks.begin(); track_it != tracks.end(); ++track_it) {
473  const reco::Track &track = **track_it;
474  sum += track.momentum();
475  }
476 
477  // "remove" excluded track
478  if (m_refineJetAxis == AXIS_CHARGED_SUM_NOLEPTON and exclude.isNonnull()) {
479  const reco::Track &track = *exclude;
480  sum -= track.momentum();
481  }
482 
483  if (sum.R() > 1.) // avoid the case of only the lepton-track with small rounding errors
484  axis = sum;
486  axis -= exclude->momentum();
487  }
488 
489  return GlobalVector(axis.x(), axis.y(), axis.z());
490 }
bool isNonnull() const
Checks for non-null.
Definition: RefToBase.h:290
RhoEtaPhiVectorD RhoEtaPhiVector
spatial vector with cylindrical internal representation using pseudorapidity
Definition: Vector3D.h:33
const unsigned int m_refineJetAxis
Definition: SoftLepton.cc:122
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
T perp() const
Magnitude of transverse component.
#define M_PI
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:664
Global3DVector GlobalVector
Definition: GlobalVector.h:10

◆ relativeEta()

double SoftLepton::relativeEta ( const math::XYZVector vector,
const math::XYZVector axis 
)
staticprotected

Definition at line 492 of file SoftLepton.cc.

References dot(), CrabHelper::log, mag(), and trackerHitRTTI::vector.

Referenced by tag().

492  {
493  double mag = vector.r() * axis.r();
494  double dot = vector.Dot(axis);
495  return -log((mag - dot) / (mag + dot)) / 2;
496 }
T dot(const Basic3DVector &v) const
Scalar product, or "dot" product, with a vector of same type.
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())

◆ tag()

reco::SoftLeptonTagInfo SoftLepton::tag ( const edm::RefToBase< reco::Jet > &  jet,
const reco::TrackRefVector tracks,
const Leptons leptons,
const reco::Vertex primaryVertex,
const TransientTrackBuilder builder 
) const

Definition at line 370 of file SoftLepton.cc.

References boostedPPar(), TransientTrackBuilder::build(), reco::SoftLeptonProperties::deltaR, eleIsoSequence_cff::deltaR, reco::SoftLeptonProperties::etaRel, info(), electrons_cff::ip3d, metsig::jet, HLT_2024v14_cff::leptons, m_chi2Cut, m_deltaRCut, reco::SoftLeptonProperties::p0Par, BeamMonitor_cff::primaryVertex, reco::SoftLeptonProperties::ptRel, reco::SoftLeptonProperties::ratio, reco::SoftLeptonProperties::ratioRel, refineJetAxis(), relativeEta(), reco::SoftLeptonProperties::setQuality(), IPTools::signedImpactParameter3D(), IPTools::signedTransverseImpactParameter(), Measurement1D::significance(), reco::SoftLeptonProperties::sip2d, reco::SoftLeptonProperties::sip2dsig, reco::SoftLeptonProperties::sip3d, reco::SoftLeptonProperties::sip3dsig, DiMuonV_cfg::tracks, Measurement1D::value(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by produce().

374  {
376  info.setJetRef(jet);
377 
378  for (Leptons::const_iterator lepton = leptons.begin(); lepton != leptons.end(); ++lepton) {
379  const math::XYZVector &lepton_momentum = lepton->first->momentum();
380  if (m_chi2Cut > 0.0 && lepton->first->normalizedChi2() > m_chi2Cut)
381  continue;
382 
383  const GlobalVector jetAxis = refineJetAxis(jet, tracks, lepton->first);
384  const math::XYZVector axis(jetAxis.x(), jetAxis.y(), jetAxis.z());
385  float deltaR = Geom::deltaR(lepton_momentum, axis);
386  if (deltaR > m_deltaRCut)
387  continue;
388 
389  reco::SoftLeptonProperties properties;
390 
391  reco::TransientTrack transientTrack = transientTrackBuilder.build(*lepton->first);
392  Measurement1D ip2d = IPTools::signedTransverseImpactParameter(transientTrack, jetAxis, primaryVertex).second;
393  Measurement1D ip3d = IPTools::signedImpactParameter3D(transientTrack, jetAxis, primaryVertex).second;
394  properties.sip2dsig = ip2d.significance();
395  properties.sip3dsig = ip3d.significance();
396  properties.sip2d = ip2d.value();
397  properties.sip3d = ip3d.value();
398  properties.deltaR = deltaR;
399  properties.ptRel = Perp(lepton_momentum, axis);
400  properties.p0Par = boostedPPar(lepton_momentum, axis);
401  properties.etaRel = relativeEta(lepton_momentum, axis);
402  properties.ratio = lepton_momentum.R() / axis.R();
403  properties.ratioRel = lepton_momentum.Dot(axis) / axis.Mag2();
404 
405  for (LeptonIds::const_iterator iter = lepton->second.begin(); iter != lepton->second.end(); ++iter)
406  properties.setQuality(static_cast<SoftLeptonProperties::Quality::Generic>(iter->first), iter->second);
407 
408  info.insert(lepton->first, properties);
409  }
410 
411  return info;
412 }
static const TGPicture * info(bool iBackgroundIsBlack)
const double m_deltaRCut
Definition: SoftLepton.cc:123
T z() const
Definition: PV3DBase.h:61
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:57
std::pair< bool, Measurement1D > signedImpactParameter3D(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:81
GlobalVector refineJetAxis(const edm::RefToBase< reco::Jet > &jet, const reco::TrackRefVector &tracks, const edm::RefToBase< reco::Track > &exclude=edm::RefToBase< reco::Track >()) const
Definition: SoftLepton.cc:415
void setQuality(Quality::Generic qual, float value)
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
static double relativeEta(const math::XYZVector &vector, const math::XYZVector &axis)
Definition: SoftLepton.cc:492
const double m_chi2Cut
Definition: SoftLepton.cc:124
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
double value() const
Definition: Measurement1D.h:25
double significance() const
Definition: Measurement1D.h:29
primaryVertex
hltOfflineBeamSpot for HLTMON
static double boostedPPar(const math::XYZVector &vector, const math::XYZVector &axis)
Definition: SoftLepton.cc:499

Member Data Documentation

◆ m_chi2Cut

const double SoftLepton::m_chi2Cut
private

Definition at line 124 of file SoftLepton.cc.

Referenced by tag().

◆ m_deltaRCut

const double SoftLepton::m_deltaRCut
private

Definition at line 123 of file SoftLepton.cc.

Referenced by tag().

◆ m_jets

const edm::InputTag SoftLepton::m_jets
private

Definition at line 102 of file SoftLepton.cc.

Referenced by produce().

◆ m_leptonCands

const edm::InputTag SoftLepton::m_leptonCands
private

Definition at line 112 of file SoftLepton.cc.

Referenced by produce().

◆ m_leptonId

const edm::InputTag SoftLepton::m_leptonId
private

Definition at line 114 of file SoftLepton.cc.

Referenced by produce().

◆ m_leptons

const edm::InputTag SoftLepton::m_leptons
private

Definition at line 106 of file SoftLepton.cc.

Referenced by produce().

◆ m_muonSelection

const muon::SelectionType SoftLepton::m_muonSelection
private

Definition at line 127 of file SoftLepton.cc.

Referenced by produce().

◆ m_refineJetAxis

const unsigned int SoftLepton::m_refineJetAxis
private

Definition at line 122 of file SoftLepton.cc.

Referenced by refineJetAxis().

◆ s_nominalBeamSpot

const reco::Vertex SoftLepton::s_nominalBeamSpot
staticprivate

Definition at line 130 of file SoftLepton.cc.

Referenced by produce().

◆ token_builder

const edm::ESGetToken<TransientTrackBuilder, TransientTrackRecord> SoftLepton::token_builder
private

Definition at line 118 of file SoftLepton.cc.

Referenced by produce().

◆ token_electrons

const edm::EDGetTokenT<edm::View<reco::Electron> > SoftLepton::token_electrons
private

Definition at line 108 of file SoftLepton.cc.

Referenced by produce().

◆ token_gsfElectrons

const edm::EDGetTokenT<edm::View<reco::GsfElectron> > SoftLepton::token_gsfElectrons
private

Definition at line 107 of file SoftLepton.cc.

Referenced by produce().

◆ token_jets

const edm::EDGetTokenT<edm::View<reco::Jet> > SoftLepton::token_jets
private

Definition at line 104 of file SoftLepton.cc.

Referenced by produce().

◆ token_jtas

const edm::EDGetTokenT<reco::JetTracksAssociationCollection> SoftLepton::token_jtas
private

Definition at line 103 of file SoftLepton.cc.

Referenced by produce().

◆ token_leptonCands

const edm::EDGetTokenT<edm::ValueMap<float> > SoftLepton::token_leptonCands
private

Definition at line 113 of file SoftLepton.cc.

Referenced by produce().

◆ token_leptonId

const edm::EDGetTokenT<edm::ValueMap<float> > SoftLepton::token_leptonId
private

Definition at line 115 of file SoftLepton.cc.

Referenced by produce().

◆ token_muons

const edm::EDGetTokenT<edm::View<reco::Muon> > SoftLepton::token_muons
private

Definition at line 110 of file SoftLepton.cc.

Referenced by produce().

◆ token_pfElectrons

const edm::EDGetTokenT<reco::PFCandidateCollection> SoftLepton::token_pfElectrons
private

Definition at line 109 of file SoftLepton.cc.

Referenced by produce().

◆ token_primaryVertex

const edm::EDGetTokenT<reco::VertexCollection> SoftLepton::token_primaryVertex
private

Definition at line 105 of file SoftLepton.cc.

Referenced by produce().

◆ token_put

const edm::EDPutTokenT<reco::SoftLeptonTagInfoCollection> SoftLepton::token_put
private

Definition at line 120 of file SoftLepton.cc.

Referenced by produce().

◆ token_tracks

const edm::EDGetTokenT<edm::View<reco::Track> > SoftLepton::token_tracks
private

Definition at line 111 of file SoftLepton.cc.

Referenced by produce().