CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Private Types | Private Attributes
hltriggeroffline::L1MuonMatcherAlgo Class Reference

#include <L1MuonMatcherAlgo.h>

Public Types

using ESTokens = PropagateToMuon::ESTokens
 

Public Member Functions

TrajectoryStateOnSurface extrapolate (const reco::Track &tk) const
 
TrajectoryStateOnSurface extrapolate (const reco::Candidate &tk) const
 
TrajectoryStateOnSurface extrapolate (const FreeTrajectoryState &state) const
 
void init (const edm::EventSetup &iSetup)
 
 L1MuonMatcherAlgo (const edm::ParameterSet &iConfig, const ESTokens &iTokens)
 
bool match (const reco::Track &tk, const l1extra::L1MuonParticle &l1, float &deltaR, float &deltaPhi, TrajectoryStateOnSurface &propagated) const
 
bool match (const reco::Candidate &c, const l1extra::L1MuonParticle &l1, float &deltaR, float &deltaPhi, TrajectoryStateOnSurface &propagated) const
 
bool match (TrajectoryStateOnSurface &propagated, const l1extra::L1MuonParticle &l1, float &deltaR, float &deltaPhi) const
 
int match (const reco::Track &tk, const std::vector< l1extra::L1MuonParticle > &l1, float &deltaR, float &deltaPhi, TrajectoryStateOnSurface &propagated) const
 
int match (const reco::Candidate &c, const std::vector< l1extra::L1MuonParticle > &l1, float &deltaR, float &deltaPhi, TrajectoryStateOnSurface &propagated) const
 
int match (TrajectoryStateOnSurface &propagated, const std::vector< l1extra::L1MuonParticle > &l1, float &deltaR, float &deltaPhi) const
 
template<typename Collection , typename Selector >
int matchGeneric (const reco::Track &tk, const Collection &l1, const Selector &sel, float &deltaR, float &deltaPhi, TrajectoryStateOnSurface &propagated) const
 
template<typename Collection , typename Selector >
int matchGeneric (const reco::Candidate &c, const Collection &l1, const Selector &sel, float &deltaR, float &deltaPhi, TrajectoryStateOnSurface &propagated) const
 
template<typename Collection , typename Selector >
int matchGeneric (TrajectoryStateOnSurface &propagated, const Collection &l1, const Selector &sel, float &deltaR, float &deltaPhi) const
 
PropagateToMuonpropagatorToMuon ()
 Return the propagator to second muon station (in case it's needed) More...
 
const PropagateToMuonpropagatorToMuon () const
 Return the propagator to second muon station (in case it's needed) More...
 
 ~L1MuonMatcherAlgo ()
 

Private Types

typedef
StringCutObjectSelector
< l1extra::L1MuonParticle
L1Selector
 

Private Attributes

double deltaPhi_
 
double deltaR2_
 Matching cuts. More...
 
L1Selector preselectionCut_
 Preselection cut to apply to L1 candidates before matching. More...
 
PropagateToMuon prop_
 
bool sortByDeltaPhi_
 Sort by deltaPhi instead of deltaR. More...
 

Detailed Description

Definition at line 29 of file L1MuonMatcherAlgo.h.

Member Typedef Documentation

Definition at line 31 of file L1MuonMatcherAlgo.h.

Definition at line 171 of file L1MuonMatcherAlgo.h.

Constructor & Destructor Documentation

L1MuonMatcherAlgo::L1MuonMatcherAlgo ( const edm::ParameterSet iConfig,
const ESTokens iTokens 
)
explicit

Definition at line 7 of file L1MuonMatcherAlgo.cc.

8  : prop_(iConfig, tokens),
9  preselectionCut_(iConfig.existsAs<std::string>("preselection") ? iConfig.getParameter<std::string>("preselection")
10  : ""),
11  deltaR2_(std::pow(iConfig.getParameter<double>("maxDeltaR"), 2)),
12  deltaPhi_(iConfig.existsAs<double>("maxDeltaPhi") ? iConfig.getParameter<double>("maxDeltaPhi") : 10),
13  sortByDeltaPhi_(iConfig.existsAs<bool>("sortByDeltaPhi") ? iConfig.getParameter<bool>("sortByDeltaPhi") : false) {
14 }
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
bool sortByDeltaPhi_
Sort by deltaPhi instead of deltaR.
L1Selector preselectionCut_
Preselection cut to apply to L1 candidates before matching.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
L1MuonMatcherAlgo::~L1MuonMatcherAlgo ( )

Definition at line 16 of file L1MuonMatcherAlgo.cc.

16 {}

Member Function Documentation

TrajectoryStateOnSurface hltriggeroffline::L1MuonMatcherAlgo::extrapolate ( const reco::Track tk) const
inline

Extrapolate reco::Track to the muon station 2, return an invalid TSOS if it fails

Definition at line 42 of file L1MuonMatcherAlgo.h.

References hltriggeroffline::PropagateToMuon::extrapolate(), and prop_.

Referenced by match(), and matchGeneric().

42 { return prop_.extrapolate(tk); }
TrajectoryStateOnSurface extrapolate(const reco::Track &tk) const
TrajectoryStateOnSurface hltriggeroffline::L1MuonMatcherAlgo::extrapolate ( const reco::Candidate tk) const
inline

Extrapolate reco::Candidate to the muon station 2, return an invalid TSOS if it fails

Definition at line 46 of file L1MuonMatcherAlgo.h.

References hltriggeroffline::PropagateToMuon::extrapolate(), and prop_.

46 { return prop_.extrapolate(tk); }
TrajectoryStateOnSurface extrapolate(const reco::Track &tk) const
TrajectoryStateOnSurface hltriggeroffline::L1MuonMatcherAlgo::extrapolate ( const FreeTrajectoryState state) const
inline

Extrapolate a FreeTrajectoryState to the muon station 2, return an invalid TSOS if it fails

Definition at line 50 of file L1MuonMatcherAlgo.h.

References hltriggeroffline::PropagateToMuon::extrapolate(), and prop_.

50 { return prop_.extrapolate(state); }
TrajectoryStateOnSurface extrapolate(const reco::Track &tk) const
void L1MuonMatcherAlgo::init ( const edm::EventSetup iSetup)

Call this method at the beginning of each run, to initialize geometry, magnetic field and propagators

Definition at line 18 of file L1MuonMatcherAlgo.cc.

References hltriggeroffline::PropagateToMuon::init(), and prop_.

Referenced by HLTMuonPlotter::beginRun().

18 { prop_.init(iSetup); }
void init(const edm::EventSetup &iSetup)
bool hltriggeroffline::L1MuonMatcherAlgo::match ( const reco::Track tk,
const l1extra::L1MuonParticle l1,
float &  deltaR,
float &  deltaPhi,
TrajectoryStateOnSurface propagated 
) const
inline

Try to match one track to one L1. Return true if succeeded (and update deltaR, deltaPhi and propagated TSOS accordingly) The preselection cut on L1, if specified in the config, is applied before the match

Definition at line 60 of file L1MuonMatcherAlgo.h.

References extrapolate(), and TrajectoryStateOnSurface::isValid().

Referenced by match(), and matchGeneric().

64  {
65  propagated = extrapolate(tk);
66  return propagated.isValid() ? match(propagated, l1, deltaR, deltaPhi) : false;
67  }
TrajectoryStateOnSurface extrapolate(const reco::Track &tk) const
bool match(const reco::Track &tk, const l1extra::L1MuonParticle &l1, float &deltaR, float &deltaPhi, TrajectoryStateOnSurface &propagated) const
bool hltriggeroffline::L1MuonMatcherAlgo::match ( const reco::Candidate c,
const l1extra::L1MuonParticle l1,
float &  deltaR,
float &  deltaPhi,
TrajectoryStateOnSurface propagated 
) const
inline

Try to match one track to one L1. Return true if succeeded (and update deltaR, deltaPhi and propagated TSOS accordingly) The preselection cut on L1, if specified in the config, is applied before the match

Definition at line 72 of file L1MuonMatcherAlgo.h.

References extrapolate(), TrajectoryStateOnSurface::isValid(), and match().

76  {
77  propagated = extrapolate(c);
78  return propagated.isValid() ? match(propagated, l1, deltaR, deltaPhi) : false;
79  }
TrajectoryStateOnSurface extrapolate(const reco::Track &tk) const
bool match(const reco::Track &tk, const l1extra::L1MuonParticle &l1, float &deltaR, float &deltaPhi, TrajectoryStateOnSurface &propagated) const
bool L1MuonMatcherAlgo::match ( TrajectoryStateOnSurface propagated,
const l1extra::L1MuonParticle l1,
float &  deltaR,
float &  deltaPhi 
) const

Try to match one track to one L1. Return true if succeeded (and update deltaR, deltaPhi accordingly) The preselection cut on L1, if specified in the config, is applied before the match

Definition at line 20 of file L1MuonMatcherAlgo.cc.

References srCondWrite_cfg::deltaPhi, deltaPhi_, reco::deltaR2(), deltaR2_, PV3DBase< T, PVType, FrameType >::eta(), reco::LeafCandidate::eta(), TrajectoryStateOnSurface::globalPosition(), PV3DBase< T, PVType, FrameType >::phi(), reco::LeafCandidate::phi(), preselectionCut_, and mathSSE::sqrt().

23  {
24  if (preselectionCut_(l1)) {
25  GlobalPoint pos = propagated.globalPosition();
26  double thisDeltaPhi = ::deltaPhi(double(pos.phi()), l1.phi());
27  double thisDeltaR2 = ::deltaR2(double(pos.eta()), double(pos.phi()), l1.eta(), l1.phi());
28  if ((fabs(thisDeltaPhi) < deltaPhi_) && (thisDeltaR2 < deltaR2_)) {
29  deltaR = std::sqrt(thisDeltaR2);
30  deltaPhi = thisDeltaPhi;
31  return true;
32  }
33  }
34  return false;
35 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
GlobalPoint globalPosition() const
T sqrt(T t)
Definition: SSEVec.h:19
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
T eta() const
Definition: PV3DBase.h:73
L1Selector preselectionCut_
Preselection cut to apply to L1 candidates before matching.
double phi() const final
momentum azimuthal angle
double eta() const final
momentum pseudorapidity
int hltriggeroffline::L1MuonMatcherAlgo::match ( const reco::Track tk,
const std::vector< l1extra::L1MuonParticle > &  l1,
float &  deltaR,
float &  deltaPhi,
TrajectoryStateOnSurface propagated 
) const
inline

Find the best match to L1, and return its index in the vector (and update deltaR, deltaPhi and propagated TSOS accordingly) Returns -1 if the match fails The preselection cut on L1, if specified in the config, is applied before the match

Definition at line 93 of file L1MuonMatcherAlgo.h.

References extrapolate(), TrajectoryStateOnSurface::isValid(), and match().

97  {
98  propagated = extrapolate(tk);
99  return propagated.isValid() ? match(propagated, l1, deltaR, deltaPhi) : -1;
100  }
TrajectoryStateOnSurface extrapolate(const reco::Track &tk) const
bool match(const reco::Track &tk, const l1extra::L1MuonParticle &l1, float &deltaR, float &deltaPhi, TrajectoryStateOnSurface &propagated) const
int hltriggeroffline::L1MuonMatcherAlgo::match ( const reco::Candidate c,
const std::vector< l1extra::L1MuonParticle > &  l1,
float &  deltaR,
float &  deltaPhi,
TrajectoryStateOnSurface propagated 
) const
inline

Find the best match to L1, and return its index in the vector (and update deltaR, deltaPhi and propagated TSOS accordingly) Returns -1 if the match fails The preselection cut on L1, if specified in the config, is applied before the match

Definition at line 106 of file L1MuonMatcherAlgo.h.

References extrapolate(), TrajectoryStateOnSurface::isValid(), and match().

110  {
111  propagated = extrapolate(c);
112  return propagated.isValid() ? match(propagated, l1, deltaR, deltaPhi) : -1;
113  }
TrajectoryStateOnSurface extrapolate(const reco::Track &tk) const
bool match(const reco::Track &tk, const l1extra::L1MuonParticle &l1, float &deltaR, float &deltaPhi, TrajectoryStateOnSurface &propagated) const
int L1MuonMatcherAlgo::match ( TrajectoryStateOnSurface propagated,
const std::vector< l1extra::L1MuonParticle > &  l1,
float &  deltaR,
float &  deltaPhi 
) const

Find the best match to L1, and return its index in the vector (and update deltaR, deltaPhi accordingly) Returns -1 if the match fails The preselection cut on L1, if specified in the config, is applied before the match

Definition at line 37 of file L1MuonMatcherAlgo.cc.

References matchGeneric(), and preselectionCut_.

40  {
41  return matchGeneric(propagated, l1s, preselectionCut_, deltaR, deltaPhi);
42  /*
43  int match = -1;
44  double minDeltaPhi = deltaPhi_;
45  double minDeltaR2 = deltaR2_;
46  GlobalPoint pos = propagated.globalPosition();
47  for (int i = 0, n = l1s.size(); i < n; ++i) {
48  const l1extra::L1MuonParticle &l1 = l1s[i];
49  if (preselectionCut_(l1)) {
50  double thisDeltaPhi = ::deltaPhi(double(pos.phi()), l1.phi());
51  double thisDeltaR2 = ::deltaR2(double(pos.eta()),
52  double(pos.phi()), l1.eta(), l1.phi()); if ((fabs(thisDeltaPhi) <
53  deltaPhi_) && (thisDeltaR2 < deltaR2_)) { // check both if (sortByDeltaPhi_
54  ? (fabs(thisDeltaPhi) < fabs(minDeltaPhi)) : (thisDeltaR2 < minDeltaR2)) {
55  // sort on one match = i; deltaR = std::sqrt(thisDeltaR2); deltaPhi =
56  thisDeltaPhi; if (sortByDeltaPhi_) minDeltaPhi = thisDeltaPhi; else
57  minDeltaR2 = thisDeltaR2;
58  }
59  }
60  }
61  }
62  return match;
63  */
64 }
int matchGeneric(const reco::Track &tk, const Collection &l1, const Selector &sel, float &deltaR, float &deltaPhi, TrajectoryStateOnSurface &propagated) const
L1Selector preselectionCut_
Preselection cut to apply to L1 candidates before matching.
template<typename Collection , typename Selector >
int hltriggeroffline::L1MuonMatcherAlgo::matchGeneric ( const reco::Track tk,
const Collection &  l1,
const Selector sel,
float &  deltaR,
float &  deltaPhi,
TrajectoryStateOnSurface propagated 
) const
inline

Find the best match to L1, and return its index in the vector (and update deltaR, deltaPhi and propagated TSOS accordingly) Returns -1 if the match fails Only the objects passing the selector will be allowed for the match. If you don't need a selector, just use an AnySelector (CommonTools/Utils) which accepts everything

Definition at line 130 of file L1MuonMatcherAlgo.h.

References extrapolate(), and TrajectoryStateOnSurface::isValid().

Referenced by match(), and matchGeneric().

135  {
136  propagated = extrapolate(tk);
137  return propagated.isValid() ? matchGeneric(propagated, l1, sel, deltaR, deltaPhi) : -1;
138  }
int matchGeneric(const reco::Track &tk, const Collection &l1, const Selector &sel, float &deltaR, float &deltaPhi, TrajectoryStateOnSurface &propagated) const
TrajectoryStateOnSurface extrapolate(const reco::Track &tk) const
template<typename Collection , typename Selector >
int hltriggeroffline::L1MuonMatcherAlgo::matchGeneric ( const reco::Candidate c,
const Collection &  l1,
const Selector sel,
float &  deltaR,
float &  deltaPhi,
TrajectoryStateOnSurface propagated 
) const
inline

Find the best match to L1, and return its index in the vector (and update deltaR, deltaPhi and propagated TSOS accordingly) Returns -1 if the match fails Only the objects passing the selector will be allowed for the match. If you don't need a selector, just use an AnySelector (CommonTools/Utils) which accepts everything

Definition at line 146 of file L1MuonMatcherAlgo.h.

References extrapolate(), TrajectoryStateOnSurface::isValid(), and matchGeneric().

151  {
152  propagated = extrapolate(c);
153  return propagated.isValid() ? matchGeneric(propagated, l1, sel, deltaR, deltaPhi) : -1;
154  }
int matchGeneric(const reco::Track &tk, const Collection &l1, const Selector &sel, float &deltaR, float &deltaPhi, TrajectoryStateOnSurface &propagated) const
TrajectoryStateOnSurface extrapolate(const reco::Track &tk) const
template<typename Collection , typename Selector >
int L1MuonMatcherAlgo::matchGeneric ( TrajectoryStateOnSurface propagated,
const Collection &  l1,
const Selector sel,
float &  deltaR,
float &  deltaPhi 
) const

Find the best match to L1, and return its index in the vector (and update deltaR, deltaPhi accordingly) Returns -1 if the match fails Only the objects passing the selector will be allowed for the match. The selector defaults to an AnySelector (CommonTools/Utils) which just accepts everything

Definition at line 183 of file L1MuonMatcherAlgo.h.

References srCondWrite_cfg::deltaPhi, deltaPhi_, reco::deltaR2(), deltaR2_, PV3DBase< T, PVType, FrameType >::eta(), TrajectoryStateOnSurface::globalPosition(), mps_fire::i, match(), dqmiodumpmetadata::n, getGTfromDQMFile::obj, PV3DBase< T, PVType, FrameType >::phi(), EgammaValidation_Wenu_cff::sel, sortByDeltaPhi_, and mathSSE::sqrt().

187  {
188  typedef typename Collection::value_type obj;
189  int match = -1;
190  double minDeltaPhi = deltaPhi_;
191  double minDeltaR2 = deltaR2_;
192  GlobalPoint pos = propagated.globalPosition();
193  for (int i = 0, n = l1s.size(); i < n; ++i) {
194  const obj &l1 = l1s[i];
195  if (sel(l1)) {
196  double thisDeltaPhi = ::deltaPhi(double(pos.phi()), l1.phi());
197  double thisDeltaR2 = ::deltaR2(double(pos.eta()), double(pos.phi()), l1.eta(), l1.phi());
198  if ((fabs(thisDeltaPhi) < deltaPhi_) && (thisDeltaR2 < deltaR2_)) { // check both
199  if (sortByDeltaPhi_ ? (fabs(thisDeltaPhi) < fabs(minDeltaPhi)) : (thisDeltaR2 < minDeltaR2)) { // sort on one
200  match = i;
201  deltaR = std::sqrt(thisDeltaR2);
202  deltaPhi = thisDeltaPhi;
203  if (sortByDeltaPhi_)
204  minDeltaPhi = thisDeltaPhi;
205  else
206  minDeltaR2 = thisDeltaR2;
207  }
208  }
209  }
210  }
211  return match;
212  }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
GlobalPoint globalPosition() const
T sqrt(T t)
Definition: SSEVec.h:19
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
bool sortByDeltaPhi_
Sort by deltaPhi instead of deltaR.
T eta() const
Definition: PV3DBase.h:73
bool match(const reco::Track &tk, const l1extra::L1MuonParticle &l1, float &deltaR, float &deltaPhi, TrajectoryStateOnSurface &propagated) const
PropagateToMuon& hltriggeroffline::L1MuonMatcherAlgo::propagatorToMuon ( )
inline

Return the propagator to second muon station (in case it's needed)

Definition at line 53 of file L1MuonMatcherAlgo.h.

References prop_.

53 { return prop_; }
const PropagateToMuon& hltriggeroffline::L1MuonMatcherAlgo::propagatorToMuon ( ) const
inline

Return the propagator to second muon station (in case it's needed)

Definition at line 55 of file L1MuonMatcherAlgo.h.

References prop_.

55 { return prop_; }

Member Data Documentation

double hltriggeroffline::L1MuonMatcherAlgo::deltaPhi_
private

Definition at line 176 of file L1MuonMatcherAlgo.h.

Referenced by match(), and matchGeneric().

double hltriggeroffline::L1MuonMatcherAlgo::deltaR2_
private

Matching cuts.

Definition at line 176 of file L1MuonMatcherAlgo.h.

Referenced by match(), and matchGeneric().

L1Selector hltriggeroffline::L1MuonMatcherAlgo::preselectionCut_
private

Preselection cut to apply to L1 candidates before matching.

Definition at line 173 of file L1MuonMatcherAlgo.h.

Referenced by match().

PropagateToMuon hltriggeroffline::L1MuonMatcherAlgo::prop_
private

Definition at line 169 of file L1MuonMatcherAlgo.h.

Referenced by extrapolate(), init(), and propagatorToMuon().

bool hltriggeroffline::L1MuonMatcherAlgo::sortByDeltaPhi_
private

Sort by deltaPhi instead of deltaR.

Definition at line 179 of file L1MuonMatcherAlgo.h.

Referenced by matchGeneric().