CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
L1AnalysisRecoMuon2.cc
Go to the documentation of this file.
5 #include <TLorentzVector.h>
6 
7 using namespace std;
8 using namespace muon;
9 
11  : muPropagatorSetup1st_(pset.getParameter<edm::ParameterSet>("muProp1st"), iC),
12  muPropagatorSetup2nd_(pset.getParameter<edm::ParameterSet>("muProp2nd"), iC) {}
13 
15 
17  const edm::EventSetup& setup,
20  double METx,
21  double METy,
22  unsigned maxMuon) {
23  recoMuon_.nMuons = 0;
24 
25  for (reco::MuonCollection::const_iterator it = muons->begin(); it != muons->end() && recoMuon_.nMuons < maxMuon;
26  ++it) {
27  recoMuon_.e.push_back(it->energy());
28  recoMuon_.pt.push_back(it->pt());
29  recoMuon_.et.push_back(it->et());
30  recoMuon_.eta.push_back(it->eta());
31  recoMuon_.phi.push_back(it->phi());
32  recoMuon_.charge.push_back(it->charge());
33 
34  //check isLooseMuon
35  bool flagLoose = isLooseMuonCustom(*it);
36  recoMuon_.isLooseMuon.push_back(flagLoose);
37 
38  //check isMediumMuon
39  bool flagMedium = isMediumMuonCustom(*it);
40  recoMuon_.isMediumMuon.push_back(flagMedium);
41 
42  //check isTightMuon
43  bool flagTight = false;
44  if (vertices.isValid())
45  flagTight = isTightMuonCustom(*it, (*vertices)[0]);
46  recoMuon_.isTightMuon.push_back(flagTight);
47 
48  double iso = (it->pfIsolationR04().sumChargedHadronPt +
49  max(0.,
50  it->pfIsolationR04().sumNeutralHadronEt + it->pfIsolationR04().sumPhotonEt -
51  0.5 * it->pfIsolationR04().sumPUPt)) /
52  it->pt();
53  recoMuon_.iso.push_back(iso);
54 
55  double MET_local = TMath::Sqrt(METx * METx + METy * METy);
56  recoMuon_.met.push_back(MET_local);
57 
58  TLorentzVector METP4;
59  METP4.SetPxPyPzE(METx, METy, 0, MET_local);
60 
61  TLorentzVector Muon;
62  Muon.SetPtEtaPhiE(it->pt(), it->eta(), it->phi(), it->energy());
63 
64  double scalSum = MET_local + Muon.Pt();
65  TLorentzVector vecSum(Muon);
66  vecSum += METP4;
67  double vecSumPt = vecSum.Pt();
68 
69  recoMuon_.mt.push_back(TMath::Sqrt(scalSum * scalSum - vecSumPt * vecSumPt));
70 
71  recoMuon_.nMuons++;
72 
73  // extrapolation of track coordinates
74  TrajectoryStateOnSurface stateAtMuSt1 = muPropagator1st_.extrapolate(*it);
75  if (stateAtMuSt1.isValid()) {
76  recoMuon_.etaSt1.push_back(stateAtMuSt1.globalPosition().eta());
77  recoMuon_.phiSt1.push_back(stateAtMuSt1.globalPosition().phi());
78  } else {
79  recoMuon_.etaSt1.push_back(-9999);
80  recoMuon_.phiSt1.push_back(-9999);
81  }
82 
83  TrajectoryStateOnSurface stateAtMuSt2 = muPropagator2nd_.extrapolate(*it);
84  if (stateAtMuSt2.isValid()) {
85  recoMuon_.etaSt2.push_back(stateAtMuSt2.globalPosition().eta());
86  recoMuon_.phiSt2.push_back(stateAtMuSt2.globalPosition().phi());
87  } else {
88  recoMuon_.etaSt2.push_back(-9999);
89  recoMuon_.phiSt2.push_back(-9999);
90  }
91  }
92 }
93 
95  muPropagator1st_ = muPropagatorSetup1st_.init(eventSetup);
96  muPropagator2nd_ = muPropagatorSetup2nd_.init(eventSetup);
97 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T eta() const
Definition: PV3DBase.h:73
bool isLooseMuonCustom(const reco::Muon &recoMu)
Definition: MuonID.h:19
GlobalPoint globalPosition() const
Definition: Muon.py:1
bool isTightMuonCustom(const reco::Muon &recoMu, const reco::Vertex recoVtx)
Definition: MuonID.h:36
bool isMediumMuonCustom(const reco::Muon &recoMu)
Definition: MuonID.h:27
L1AnalysisRecoMuon2(const edm::ParameterSet &pset, edm::ConsumesCollector)
HLT enums.
void init(const edm::EventSetup &eventSetup)
void SetMuon(const edm::Event &event, const edm::EventSetup &setup, const edm::Handle< reco::MuonCollection > muons, const edm::Handle< reco::VertexCollection > vertices, double METx, double METy, unsigned maxMuon)
Definition: event.py:1