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/plugin/SoftLepton.h>

Inheritance diagram for SoftLepton:
edm::stream::EDProducer<>

Classes

struct  TrackCompare
 

Public Types

typedef std::map< unsigned int, float > LeptonIds
 
typedef std::map< edm::RefToBase< reco::Track >, LeptonIds, TrackCompareLeptons
 
- 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
 

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
 
 ~SoftLepton () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::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
 

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::Event &event, const edm::EventSetup &setup) override
 

Private Attributes

double m_chi2Cut
 
double m_deltaRCut
 
const edm::InputTag m_jets
 
const edm::InputTag m_leptonCands
 
const edm::InputTag m_leptonId
 
const edm::InputTag m_leptons
 
muon::SelectionType m_muonSelection
 
unsigned int m_refineJetAxis
 
const TransientTrackBuilderm_transientTrackBuilder
 
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::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:

Description: CMSSW EDProducer wrapper for sot lepton b tagging.

Implementation: The actual tagging is performed by SoftLeptonAlgorithm.

Definition at line 50 of file SoftLepton.h.

Member Typedef Documentation

typedef std::map<unsigned int, float> SoftLepton::LeptonIds

Definition at line 62 of file SoftLepton.h.

Definition at line 63 of file SoftLepton.h.

Constructor & Destructor Documentation

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

Definition at line 70 of file SoftLepton.cc.

71  : m_jets(iConfig.getParameter<edm::InputTag>("jets")),
72  token_jtas(mayConsume<reco::JetTracksAssociationCollection>(iConfig.getParameter<edm::InputTag>("jets"))),
73  token_jets(mayConsume<edm::View<reco::Jet> >(iConfig.getParameter<edm::InputTag>("jets"))),
74  token_primaryVertex(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("primaryVertex"))),
75  m_leptons(iConfig.getParameter<edm::InputTag>("leptons")),
76  token_gsfElectrons(mayConsume<GsfElectronView>(iConfig.getParameter<edm::InputTag>("leptons"))),
77  token_electrons(mayConsume<ElectronView>(iConfig.getParameter<edm::InputTag>("leptons"))),
78  token_pfElectrons(mayConsume<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("leptons"))),
79  token_muons(mayConsume<MuonView>(iConfig.getParameter<edm::InputTag>("leptons"))),
80  token_tracks(mayConsume<edm::View<reco::Track> >(iConfig.getParameter<edm::InputTag>("leptons"))),
81  m_leptonCands(iConfig.exists("leptonCands") ? iConfig.getParameter<edm::InputTag>("leptonCands")
82  : edm::InputTag()),
84  iConfig.exists("leptonCands") ? iConfig.getParameter<edm::InputTag>("leptonCands") : edm::InputTag())),
85  m_leptonId(iConfig.exists("leptonId") ? iConfig.getParameter<edm::InputTag>("leptonId") : edm::InputTag()),
87  iConfig.exists("leptonId") ? iConfig.getParameter<edm::InputTag>("leptonId") : edm::InputTag())),
88  m_transientTrackBuilder(nullptr),
89  m_refineJetAxis(iConfig.getParameter<unsigned int>("refineJetAxis")),
90  m_deltaRCut(iConfig.getParameter<double>("leptonDeltaRCut")),
91  m_chi2Cut(iConfig.getParameter<double>("leptonChi2Cut")),
92  m_muonSelection((muon::SelectionType)iConfig.getParameter<unsigned int>("muonSelection")) {
93  produces<reco::SoftLeptonTagInfoCollection>();
94 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< reco::PFCandidateCollection > token_pfElectrons
Definition: SoftLepton.h:93
const edm::EDGetTokenT< edm::ValueMap< float > > token_leptonCands
Definition: SoftLepton.h:97
bool exists(std::string const &parameterName) const
checks if a parameter exists
const edm::EDGetTokenT< edm::ValueMap< float > > token_leptonId
Definition: SoftLepton.h:99
const edm::EDGetTokenT< edm::View< reco::Muon > > token_muons
Definition: SoftLepton.h:94
const edm::EDGetTokenT< edm::View< reco::Electron > > token_electrons
Definition: SoftLepton.h:92
double m_chi2Cut
Definition: SoftLepton.h:107
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > token_gsfElectrons
Definition: SoftLepton.h:91
SelectionType
Selector type.
Definition: MuonSelectors.h:19
const edm::InputTag m_leptons
Definition: SoftLepton.h:90
const edm::EDGetTokenT< reco::VertexCollection > token_primaryVertex
Definition: SoftLepton.h:89
const edm::InputTag m_leptonId
Definition: SoftLepton.h:98
double m_deltaRCut
Definition: SoftLepton.h:106
const edm::InputTag m_leptonCands
Definition: SoftLepton.h:96
unsigned int m_refineJetAxis
Definition: SoftLepton.h:105
const edm::EDGetTokenT< edm::View< reco::Jet > > token_jets
Definition: SoftLepton.h:88
muon::SelectionType m_muonSelection
Definition: SoftLepton.h:110
const edm::InputTag m_jets
Definition: SoftLepton.h:86
const TransientTrackBuilder * m_transientTrackBuilder
Definition: SoftLepton.h:102
const edm::EDGetTokenT< edm::View< reco::Track > > token_tracks
Definition: SoftLepton.h:95
const edm::EDGetTokenT< reco::JetTracksAssociationCollection > token_jtas
Definition: SoftLepton.h:87
SoftLepton::~SoftLepton ( void  )
override

Definition at line 97 of file SoftLepton.cc.

97 {}

Member Function Documentation

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

Definition at line 421 of file SoftLepton.cc.

References metsig::jet.

Referenced by tag().

421  {
422  static const double lepton_mass = 0.00; // assume a massless (ultrarelativistic) lepton
423  static const double jet_mass = 5.279; // use B±/B0 mass as the jet rest mass [PDG 2007 updates]
424  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > lepton(
425  vector.Dot(axis) / axis.r(), Perp(vector, axis), 0., lepton_mass);
426  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > jet(axis.r(), 0., 0., jet_mass);
427  ROOT::Math::BoostX boost(-jet.Beta());
428  return boost(lepton).x();
429 }
Definition: CLHEP.h:16
void SoftLepton::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 432 of file SoftLepton.cc.

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::addDefault(), and HLT_2018_cff::InputTag.

432  {
434  desc.add<unsigned int>("muonSelection", 1);
435  desc.add<edm::InputTag>("leptons", edm::InputTag("muons"));
436  desc.add<edm::InputTag>("primaryVertex", edm::InputTag("offlinePrimaryVertices"));
437  desc.add<edm::InputTag>("leptonCands", edm::InputTag(""));
438  desc.add<edm::InputTag>("leptonId", edm::InputTag(""));
439  desc.add<unsigned int>("refineJetAxis", 0);
440  desc.add<edm::InputTag>("jets", edm::InputTag("ak4PFJetsCHS"));
441  desc.add<double>("leptonDeltaRCut", 0.4);
442  desc.add<double>("leptonChi2Cut", 9999.0);
443  descriptions.addDefault(desc);
444 }
void addDefault(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void SoftLepton::produce ( edm::Event event,
const edm::EventSetup setup 
)
overrideprivate

Definition at line 100 of file SoftLepton.cc.

References edm::View< T >::begin(), metsig::electron, edm::View< T >::end(), Exception, edm::EventSetup::get(), mps_fire::i, triggerObjects_cff::id, HLT_2018_cff::InputTag, muon::isGoodMuon(), edm::HandleBase::isValid(), singleTopDQM_cfi::jets, HLT_2018_cff::leptonId, HLT_2018_cff::leptons, m_jets, m_leptonCands, m_leptonId, m_leptons, m_muonSelection, m_transientTrackBuilder, eostools::move(), HLT_2018_cff::muon, edm::errors::NotFound, edm::ESHandle< T >::product(), edm::View< T >::refAt(), mps_fire::result, s_nominalBeamSpot, edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::size(), findQualityFiles::size, tag(), token_electrons, token_gsfElectrons, token_jets, token_jtas, token_leptonCands, token_leptonId, token_muons, token_pfElectrons, token_primaryVertex, token_tracks, PDWG_EXOHSCP_cff::tracks, and bphysicsOniaDQM_cfi::vertex.

100  {
101  // grab a TransientTrack helper from the Event Setup
103  setup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
104  m_transientTrackBuilder = builder.product();
105 
106  // input objects
107 
108  // input jets (and possibly tracks)
109  ProductID jets_id;
110  std::vector<edm::RefToBase<reco::Jet> > jets;
111  std::vector<reco::TrackRefVector> tracks;
112  do {
113  {
114  // look for a JetTracksAssociationCollection
116  event.getByToken(token_jtas, h_jtas);
117  if (h_jtas.isValid()) {
118  unsigned int size = h_jtas->size();
119  jets.resize(size);
120  tracks.resize(size);
121  for (unsigned int i = 0; i < size; ++i) {
122  jets[i] = (*h_jtas)[i].first;
123  tracks[i] = (*h_jtas)[i].second;
124  }
125  break;
126  }
127  }
128  { // else...
129  // look for a View<Jet>
131  event.getByToken(token_jets, h_jets);
132  if (h_jets.isValid()) {
133  unsigned int size = h_jets->size();
134  jets.resize(size);
135  tracks.resize(size);
136  for (unsigned int i = 0; i < h_jets->size(); i++)
137  jets[i] = h_jets->refAt(i);
138  break;
139  }
140  }
141  { // else...
143  << "Object " << m_jets
144  << " of type among (\"reco::JetTracksAssociationCollection\", \"edm::View<reco::Jet>\") not found";
145  }
146  } while (false);
147 
148  // input primary vetex
150  Handle<reco::VertexCollection> h_primaryVertex;
151  event.getByToken(token_primaryVertex, h_primaryVertex);
152  if (h_primaryVertex.isValid() and not h_primaryVertex->empty())
153  vertex = h_primaryVertex->front();
154  else
155  // fall back to nominal beam spot
156  vertex = s_nominalBeamSpot;
157 
158  // input leptons (can be of different types)
160 
161  Handle<edm::ValueMap<float> > h_leptonCands;
162  bool haveLeptonCands = !(m_leptonCands == edm::InputTag());
163  if (haveLeptonCands)
164  event.getByToken(token_leptonCands, h_leptonCands);
165 
166  // try to access the input collection as a collection of GsfElectrons, Muons or Tracks
167 
169  do {
170  {
171  // look for View<GsfElectron>
172  Handle<GsfElectronView> h_electrons;
173  event.getByToken(token_gsfElectrons, h_electrons);
174 
175  if (h_electrons.isValid()) {
176  leptonId = SoftLeptonProperties::Quality::egammaElectronId;
177  for (GsfElectronView::const_iterator electron = h_electrons->begin(); electron != h_electrons->end();
178  ++electron) {
179  LeptonIds &id = leptons[reco::TrackBaseRef(electron->gsfTrack())];
180  id[SoftLeptonProperties::Quality::pfElectronId] = electron->mva_e_pi();
181  if (haveLeptonCands)
182  id[SoftLeptonProperties::Quality::btagElectronCands] =
183  (*h_leptonCands)[h_electrons->refAt(electron - h_electrons->begin())];
184  }
185  break;
186  }
187  }
188  { // else
189  // look for View<Electron>
190  // FIXME: is this obsolete?
191  Handle<ElectronView> h_electrons;
192  event.getByToken(token_electrons, h_electrons);
193  if (h_electrons.isValid()) {
194  leptonId = SoftLeptonProperties::Quality::egammaElectronId;
195  for (ElectronView::const_iterator electron = h_electrons->begin(); electron != h_electrons->end(); ++electron) {
196  LeptonIds &id = leptons[reco::TrackBaseRef(electron->track())];
197  if (haveLeptonCands)
198  id[SoftLeptonProperties::Quality::btagElectronCands] =
199  (*h_leptonCands)[h_electrons->refAt(electron - h_electrons->begin())];
200  }
201  break;
202  }
203  }
204  { // else
205  // look for PFElectrons
206  // FIXME: is this obsolete?
208  event.getByToken(token_pfElectrons, h_electrons);
209  if (h_electrons.isValid()) {
210  leptonId = SoftLeptonProperties::Quality::egammaElectronId;
211  for (reco::PFCandidateCollection::const_iterator electron = h_electrons->begin();
212  electron != h_electrons->end();
213  ++electron) {
214  LeptonIds *id;
215  if (electron->gsfTrackRef().isNonnull())
216  id = &leptons[reco::TrackBaseRef(electron->gsfTrackRef())];
217  else if (electron->trackRef().isNonnull())
218  id = &leptons[reco::TrackBaseRef(electron->trackRef())];
219  else
220  continue;
221  (*id)[SoftLeptonProperties::Quality::pfElectronId] = electron->mva_e_pi();
222  if (haveLeptonCands)
223  (*id)[SoftLeptonProperties::Quality::btagElectronCands] =
224  (*h_leptonCands)[reco::PFCandidateRef(h_electrons, electron - h_electrons->begin())];
225  }
226  break;
227  }
228  }
229  { // else
230  // look for View<Muon>
231  Handle<MuonView> h_muons;
232  event.getByToken(token_muons, h_muons);
233  if (h_muons.isValid()) {
234  for (MuonView::const_iterator muon = h_muons->begin(); muon != h_muons->end(); ++muon) {
235  // FIXME -> turn this selection into a muonCands input?
237  LeptonIds *id;
238  if (muon->globalTrack().isNonnull())
239  id = &leptons[reco::TrackBaseRef(muon->globalTrack())];
240  else if (muon->innerTrack().isNonnull())
241  id = &leptons[reco::TrackBaseRef(muon->innerTrack())];
242  else if (muon->outerTrack().isNonnull())
243  // does this makes sense ?
244  id = &leptons[reco::TrackBaseRef(muon->outerTrack())];
245  else
246  continue;
247  if (haveLeptonCands)
248  (*id)[SoftLeptonProperties::Quality::btagMuonCands] =
249  (*h_leptonCands)[h_muons->refAt(muon - h_muons->begin())];
250  }
251  }
252  break;
253  }
254  }
255  { // else
256  // look for edm::View<Track>
258  event.getByToken(token_tracks, h_tracks);
259  if (h_tracks.isValid()) {
260  for (unsigned int i = 0; i < h_tracks->size(); i++) {
261  LeptonIds &id = leptons[h_tracks->refAt(i)];
262  if (haveLeptonCands)
263  id[SoftLeptonProperties::Quality::btagLeptonCands] = (*h_leptonCands)[h_tracks->refAt(i)];
264  }
265  break;
266  }
267  }
268  { // else
269  throw edm::Exception(edm::errors::NotFound) << "Object " << m_leptons
270  << " of type among (\"edm::View<reco::GsfElectron>\", "
271  "\"edm::View<reco::Muon>\", \"edm::View<reco::Track>\") !found";
272  }
273  } while (false);
274 
275  if (!(m_leptonId == edm::InputTag())) {
276  Handle<edm::ValueMap<float> > h_leptonId;
277  event.getByToken(token_leptonId, h_leptonId);
278 
279  for (Leptons::iterator lepton = leptons.begin(); lepton != leptons.end(); ++lepton)
280  lepton->second[leptonId] = (*h_leptonId)[lepton->first];
281  }
282 
283  // output collections
284  auto outputCollection = std::make_unique<reco::SoftLeptonTagInfoCollection>();
285  for (unsigned int i = 0; i < jets.size(); ++i) {
286  reco::SoftLeptonTagInfo result = tag(jets[i], tracks[i], leptons, vertex);
287  outputCollection->push_back(result);
288  }
289  event.put(std::move(outputCollection));
290 }
size
Write out results.
const edm::EDGetTokenT< reco::PFCandidateCollection > token_pfElectrons
Definition: SoftLepton.h:93
const edm::EDGetTokenT< edm::ValueMap< float > > token_leptonCands
Definition: SoftLepton.h:97
const edm::EDGetTokenT< edm::ValueMap< float > > token_leptonId
Definition: SoftLepton.h:99
const edm::EDGetTokenT< edm::View< reco::Muon > > token_muons
Definition: SoftLepton.h:94
const edm::EDGetTokenT< edm::View< reco::Electron > > token_electrons
Definition: SoftLepton.h:92
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > token_gsfElectrons
Definition: SoftLepton.h:91
RefToBase< value_type > refAt(size_type i) const
const_iterator begin() const
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
Definition: TrackFwd.h:35
const edm::InputTag m_leptons
Definition: SoftLepton.h:90
const edm::EDGetTokenT< reco::VertexCollection > token_primaryVertex
Definition: SoftLepton.h:89
const edm::InputTag m_leptonId
Definition: SoftLepton.h:98
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
bool isValid() const
Definition: HandleBase.h:70
const edm::InputTag m_leptonCands
Definition: SoftLepton.h:96
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
reco::SoftLeptonTagInfo tag(const edm::RefToBase< reco::Jet > &jet, const reco::TrackRefVector &tracks, const Leptons &leptons, const reco::Vertex &primaryVertex) const
Definition: SoftLepton.cc:293
const edm::EDGetTokenT< edm::View< reco::Jet > > token_jets
Definition: SoftLepton.h:88
std::map< unsigned int, float > LeptonIds
Definition: SoftLepton.h:62
static const reco::Vertex s_nominalBeamSpot
Definition: SoftLepton.h:113
muon::SelectionType m_muonSelection
Definition: SoftLepton.h:110
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
T get() const
Definition: EventSetup.h:73
std::map< edm::RefToBase< reco::Track >, LeptonIds, TrackCompare > Leptons
Definition: SoftLepton.h:63
const edm::InputTag m_jets
Definition: SoftLepton.h:86
const_iterator end() const
const TransientTrackBuilder * m_transientTrackBuilder
Definition: SoftLepton.h:102
const edm::EDGetTokenT< edm::View< reco::Track > > token_tracks
Definition: SoftLepton.h:95
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511
const edm::EDGetTokenT< reco::JetTracksAssociationCollection > token_jtas
Definition: SoftLepton.h:87
size_type size() const
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 337 of file SoftLepton.cc.

References AXIS_CALORIMETRIC_NOLEPTON, AXIS_CHARGED_AVERAGE, AXIS_CHARGED_AVERAGE_NOLEPTON, AXIS_CHARGED_SUM, AXIS_CHARGED_SUM_NOLEPTON, edm::RefVector< C, T, F >::begin(), edm::RefVector< C, T, F >::end(), reco::TrackBase::eta(), edm::RefToBase< T >::isNonnull(), M_PI, m_refineJetAxis, reco::LeafCandidate::momentum(), reco::TrackBase::momentum(), or, perp(), reco::TrackBase::phi(), reco::TrackBase::pt(), and HLT_2018_cff::track.

Referenced by tag().

340  {
341  math::XYZVector axis = jet->momentum();
342 
344  double sum_pT = 0.;
345  double sum_eta_by_pT = 0.;
346  double sum_phi_by_pT = 0.;
347 
348  double perp;
349  double phi_rel;
350  double eta_rel;
351 
352  // refine jet eta and phi with charged tracks measurements, if available
353  for (reco::TrackRefVector::const_iterator track_it = tracks.begin(); track_it != tracks.end(); ++track_it) {
354  const reco::Track &track = **track_it;
355 
356  perp = track.pt();
357  eta_rel = (double)track.eta() - axis.eta();
358  phi_rel = (double)track.phi() - axis.phi();
359  while (phi_rel < -M_PI)
360  phi_rel += 2 * M_PI;
361  while (phi_rel > M_PI)
362  phi_rel -= 2 * M_PI;
363 
364  sum_pT += perp;
365  sum_phi_by_pT += perp * phi_rel;
366  sum_eta_by_pT += perp * eta_rel;
367  }
368 
369  // "remove" excluded track
371  const reco::Track &track = *exclude;
372 
373  perp = track.pt();
374  eta_rel = (double)track.eta() - axis.eta();
375  phi_rel = (double)track.phi() - axis.phi();
376  while (phi_rel < -M_PI)
377  phi_rel += 2 * M_PI;
378  while (phi_rel > M_PI)
379  phi_rel -= 2 * M_PI;
380 
381  sum_pT -= perp;
382  sum_phi_by_pT -= perp * phi_rel;
383  sum_eta_by_pT -= perp * eta_rel;
384  }
385 
386  if (sum_pT > 1.) // avoid the case of only the lepton-track with small rounding errors
387  axis =
388  math::RhoEtaPhiVector(axis.rho(), axis.eta() + sum_eta_by_pT / sum_pT, axis.phi() + sum_phi_by_pT / sum_pT);
389 
391  math::XYZVector sum;
392 
393  // recalculate the jet direction as the sum of charget tracks momenta
394  for (reco::TrackRefVector::const_iterator track_it = tracks.begin(); track_it != tracks.end(); ++track_it) {
395  const reco::Track &track = **track_it;
396  sum += track.momentum();
397  }
398 
399  // "remove" excluded track
400  if (m_refineJetAxis == AXIS_CHARGED_SUM_NOLEPTON and exclude.isNonnull()) {
401  const reco::Track &track = *exclude;
402  sum -= track.momentum();
403  }
404 
405  if (sum.R() > 1.) // avoid the case of only the lepton-track with small rounding errors
406  axis = sum;
408  axis -= exclude->momentum();
409  }
410 
411  return GlobalVector(axis.x(), axis.y(), axis.z());
412 }
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:614
bool isNonnull() const
Checks for non-null.
Definition: RefToBase.h:301
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:629
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
RhoEtaPhiVectorD RhoEtaPhiVector
spatial vector with cylindrical internal representation using pseudorapidity
Definition: Vector3D.h:33
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
Vector momentum() const final
spatial momentum vector
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:617
double pt() const
track transverse momentum
Definition: TrackBase.h:602
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
#define M_PI
unsigned int m_refineJetAxis
Definition: SoftLepton.h:105
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
T perp() const
Magnitude of transverse component.
Global3DVector GlobalVector
Definition: GlobalVector.h:10
double SoftLepton::relativeEta ( const math::XYZVector vector,
const math::XYZVector axis 
)
staticprotected

Definition at line 414 of file SoftLepton.cc.

References dot(), dqm-mbProfile::log, and mag().

Referenced by tag().

414  {
415  double mag = vector.r() * axis.r();
416  double dot = vector.Dot(axis);
417  return -log((mag - dot) / (mag + dot)) / 2;
418 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
T dot(const Basic3DVector &v) const
Scalar product, or "dot" product, with a vector of same type.
reco::SoftLeptonTagInfo SoftLepton::tag ( const edm::RefToBase< reco::Jet > &  jet,
const reco::TrackRefVector tracks,
const Leptons leptons,
const reco::Vertex primaryVertex 
) const

Definition at line 293 of file SoftLepton.cc.

References boostedPPar(), TransientTrackBuilder::build(), reco::SoftLeptonProperties::deltaR, PbPb_ZMuSkimMuonDPG_cff::deltaR, reco::SoftLeptonProperties::etaRel, info(), reco::TemplatedSoftLeptonTagInfo< REF >::insert(), electrons_cff::ip3d, m_chi2Cut, m_deltaRCut, m_transientTrackBuilder, reco::SoftLeptonProperties::p0Par, reco::SoftLeptonProperties::ptRel, reco::SoftLeptonProperties::ratio, reco::SoftLeptonProperties::ratioRel, refineJetAxis(), relativeEta(), reco::JetTagInfo::setJetRef(), reco::SoftLeptonProperties::setQuality(), IPTools::signedImpactParameter3D(), IPTools::signedTransverseImpactParameter(), Measurement1D::significance(), reco::SoftLeptonProperties::sip2d, reco::SoftLeptonProperties::sip2dsig, reco::SoftLeptonProperties::sip3d, reco::SoftLeptonProperties::sip3dsig, Measurement1D::value(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by produce().

296  {
298  info.setJetRef(jet);
299 
300  for (Leptons::const_iterator lepton = leptons.begin(); lepton != leptons.end(); ++lepton) {
301  const math::XYZVector &lepton_momentum = lepton->first->momentum();
302  if (m_chi2Cut > 0.0 && lepton->first->normalizedChi2() > m_chi2Cut)
303  continue;
304 
305  const GlobalVector jetAxis = refineJetAxis(jet, tracks, lepton->first);
306  const math::XYZVector axis(jetAxis.x(), jetAxis.y(), jetAxis.z());
307  float deltaR = Geom::deltaR(lepton_momentum, axis);
308  if (deltaR > m_deltaRCut)
309  continue;
310 
311  reco::SoftLeptonProperties properties;
312 
313  reco::TransientTrack transientTrack = m_transientTrackBuilder->build(*lepton->first);
314  Measurement1D ip2d = IPTools::signedTransverseImpactParameter(transientTrack, jetAxis, primaryVertex).second;
315  Measurement1D ip3d = IPTools::signedImpactParameter3D(transientTrack, jetAxis, primaryVertex).second;
316  properties.sip2dsig = ip2d.significance();
317  properties.sip3dsig = ip3d.significance();
318  properties.sip2d = ip2d.value();
319  properties.sip3d = ip3d.value();
320  properties.deltaR = deltaR;
321  properties.ptRel = Perp(lepton_momentum, axis);
322  properties.p0Par = boostedPPar(lepton_momentum, axis);
323  properties.etaRel = relativeEta(lepton_momentum, axis);
324  properties.ratio = lepton_momentum.R() / axis.R();
325  properties.ratioRel = lepton_momentum.Dot(axis) / axis.Mag2();
326 
327  for (LeptonIds::const_iterator iter = lepton->second.begin(); iter != lepton->second.end(); ++iter)
328  properties.setQuality(static_cast<SoftLeptonProperties::Quality::Generic>(iter->first), iter->second);
329 
330  info.insert(lepton->first, properties);
331  }
332 
333  return info;
334 }
static const TGPicture * info(bool iBackgroundIsBlack)
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:57
reco::TransientTrack build(const reco::Track *p) const
T y() const
Definition: PV3DBase.h:60
std::pair< bool, Measurement1D > signedImpactParameter3D(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:81
void setJetRef(const edm::Ref< T > &jetRef)
Definition: JetTagInfo.h:25
double m_chi2Cut
Definition: SoftLepton.h:107
void setQuality(Quality::Generic qual, float value)
static double relativeEta(const math::XYZVector &vector, const math::XYZVector &axis)
Definition: SoftLepton.cc:414
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:337
T z() const
Definition: PV3DBase.h:61
double m_deltaRCut
Definition: SoftLepton.h:106
void insert(const REF &lepton, const SoftLeptonProperties &properties)
double significance() const
Definition: Measurement1D.h:29
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
double value() const
Definition: Measurement1D.h:25
const TransientTrackBuilder * m_transientTrackBuilder
Definition: SoftLepton.h:102
T x() const
Definition: PV3DBase.h:59
static double boostedPPar(const math::XYZVector &vector, const math::XYZVector &axis)
Definition: SoftLepton.cc:421

Member Data Documentation

double SoftLepton::m_chi2Cut
private

Definition at line 107 of file SoftLepton.h.

Referenced by tag().

double SoftLepton::m_deltaRCut
private

Definition at line 106 of file SoftLepton.h.

Referenced by tag().

const edm::InputTag SoftLepton::m_jets
private

Definition at line 86 of file SoftLepton.h.

Referenced by produce().

const edm::InputTag SoftLepton::m_leptonCands
private

Definition at line 96 of file SoftLepton.h.

Referenced by produce().

const edm::InputTag SoftLepton::m_leptonId
private

Definition at line 98 of file SoftLepton.h.

Referenced by produce().

const edm::InputTag SoftLepton::m_leptons
private

Definition at line 90 of file SoftLepton.h.

Referenced by produce().

muon::SelectionType SoftLepton::m_muonSelection
private

Definition at line 110 of file SoftLepton.h.

Referenced by produce().

unsigned int SoftLepton::m_refineJetAxis
private

Definition at line 105 of file SoftLepton.h.

Referenced by refineJetAxis().

const TransientTrackBuilder* SoftLepton::m_transientTrackBuilder
private

Definition at line 102 of file SoftLepton.h.

Referenced by produce(), and tag().

const reco::Vertex SoftLepton::s_nominalBeamSpot
staticprivate

Definition at line 113 of file SoftLepton.h.

Referenced by produce().

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

Definition at line 92 of file SoftLepton.h.

Referenced by produce().

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

Definition at line 91 of file SoftLepton.h.

Referenced by produce().

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

Definition at line 88 of file SoftLepton.h.

Referenced by produce().

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

Definition at line 87 of file SoftLepton.h.

Referenced by produce().

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

Definition at line 97 of file SoftLepton.h.

Referenced by produce().

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

Definition at line 99 of file SoftLepton.h.

Referenced by produce().

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

Definition at line 94 of file SoftLepton.h.

Referenced by produce().

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

Definition at line 93 of file SoftLepton.h.

Referenced by produce().

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

Definition at line 89 of file SoftLepton.h.

Referenced by produce().

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

Definition at line 95 of file SoftLepton.h.

Referenced by produce().