CMS 3D CMS Logo

ME0MuonSelector.cc
Go to the documentation of this file.
1 
8 
13 
14 namespace muon {
16  const static SelectionTypeStringToEnum selectionTypeStringToEnumMap[] = {
17  {"All", All}, {"VeryLoose", VeryLoose}, {"Loose", Loose}, {"Tight", Tight}, {nullptr, (SelectionType)-1}};
18 
20  bool found = false;
21  for (int i = 0; selectionTypeStringToEnumMap[i].label && (!found); ++i)
22  if (!strcmp(label.c_str(), selectionTypeStringToEnumMap[i].label)) {
23  found = true;
24  value = selectionTypeStringToEnumMap[i].value;
25  }
26 
27  // in case of unrecognized selection type
28  if (!found)
29  throw cms::Exception("MuonSelectorError") << label << " is not a recognized SelectionType";
30  return value;
31  }
32 } // namespace muon
33 
35  switch (type) {
36  case muon::All:
37  return true;
38  break;
39  case muon::VeryLoose:
40  return isGoodMuon(me0muon, 3, 4, 20, 20, 3.14);
41  break;
42  case muon::Loose:
43  return isGoodMuon(me0muon, 3, 2, 3, 2, 0.5);
44  break;
45  case muon::Tight:
46  return isGoodMuon(me0muon, 3, 2, 3, 2, 0.15);
47  break;
48  default:
49  return false;
50  }
51 }
52 
53 bool muon::isGoodMuon(const reco::ME0Muon& me0muon,
54  double MaxPullX,
55  double MaxDiffX,
56  double MaxPullY,
57  double MaxDiffY,
58  double MaxDiffPhiDir) {
59  using namespace reco;
60 
61  const ME0Segment& thisSegment = me0muon.me0segment();
62 
63  const LocalPoint& r3FinalReco = me0muon.localTrackPosAtSurface();
64 
66  LocalPoint thisPosition(thisSegment.localPosition());
67 
68  double sigmax = sqrt(C[3][3] + thisSegment.localPositionError().xx());
69  double sigmay = sqrt(C[4][4] + thisSegment.localPositionError().yy());
70 
71  bool X_MatchFound = false, Y_MatchFound = false, Dir_MatchFound = false;
72 
73  if (((std::abs(thisPosition.x() - r3FinalReco.x()) / sigmax) < MaxPullX) ||
74  (std::abs(thisPosition.x() - r3FinalReco.x()) < MaxDiffX))
75  X_MatchFound = true;
76  if (((std::abs(thisPosition.y() - r3FinalReco.y()) / sigmay) < MaxPullY) ||
77  (std::abs(thisPosition.y() - r3FinalReco.y()) < MaxDiffY))
78  Y_MatchFound = true;
79  if (std::abs(reco::deltaPhi(me0muon.localTrackMomAtSurface().barePhi(), thisSegment.localDirection().barePhi())) <
80  MaxDiffPhiDir)
81  Dir_MatchFound = true;
82 
83  return (X_MatchFound && Y_MatchFound && Dir_MatchFound);
84 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
type
Definition: HCALResponse.h:21
float xx() const
Definition: LocalError.h:22
const LocalPoint & localTrackPosAtSurface() const
Definition: ME0Muon.h:50
T y() const
Definition: PV3DBase.h:60
SelectionType
Selector type.
Definition: MuonSelectors.h:19
const ME0Segment & me0segment() const
Definition: ME0Muon.h:42
T barePhi() const
Definition: PV3DBase.h:65
char const * label
float yy() const
Definition: LocalError.h:24
T sqrt(T t)
Definition: SSEVec.h:19
const AlgebraicSymMatrix55 & localTrackCov() const
Definition: ME0Muon.h:55
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Definition: value.py:1
LocalVector localDirection() const override
Local direction.
Definition: ME0Segment.h:50
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
LocalPoint localPosition() const override
Definition: ME0Segment.h:47
SelectionType selectionTypeFromString(const std::string &label)
Definition: MuonSelectors.cc:9
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
const LocalVector & localTrackMomAtSurface() const
Definition: ME0Muon.h:51
LocalError localPositionError() const override
Definition: ME0Segment.cc:83
fixed size matrix
T x() const
Definition: PV3DBase.h:59