CMS 3D CMS Logo

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