CMS 3D CMS Logo

L1AnalysisRecoMuon2.cc
Go to the documentation of this file.
5 #include <TLorentzVector.h>
6 
7 using namespace std;
8 using namespace muon;
9 
11  muPropagator1st_(pset.getParameter<edm::ParameterSet>("muProp1st")),
12  muPropagator2nd_(pset.getParameter<edm::ParameterSet>("muProp2nd"))
13 {
14 }
15 
16 
18 {
19 }
20 
22  const edm::EventSetup& setup,
25  double METx, double METy,
26  unsigned maxMuon)
27 {
28 
29  recoMuon_.nMuons=0;
30 
31  for(reco::MuonCollection::const_iterator it=muons->begin();
32  it!=muons->end() && recoMuon_.nMuons < maxMuon;
33  ++it) {
34 
35  recoMuon_.e.push_back(it->energy());
36  recoMuon_.pt.push_back(it->pt());
37  recoMuon_.et.push_back(it->et());
38  recoMuon_.eta.push_back(it->eta());
39  recoMuon_.phi.push_back(it->phi());
40  recoMuon_.charge.push_back(it->charge());
41 
42  //check isLooseMuon
43  bool flagLoose = isLooseMuonCustom(*it);
44  recoMuon_.isLooseMuon.push_back(flagLoose);
45 
46  //check isMediumMuon
47  bool flagMedium = isMediumMuonCustom(*it);
48  recoMuon_.isMediumMuon.push_back(flagMedium);
49 
50  //check isTightMuon
51  bool flagTight = false;
52  if (vertices.isValid())
53  flagTight = isTightMuonCustom(*it, (*vertices)[0]);
54  recoMuon_.isTightMuon.push_back(flagTight);
55 
56  double iso = (it->pfIsolationR04().sumChargedHadronPt + max(0.,
57  it->pfIsolationR04().sumNeutralHadronEt +
58  it->pfIsolationR04().sumPhotonEt -
59  0.5*it->pfIsolationR04().sumPUPt)) / it->pt();
60  recoMuon_.iso.push_back(iso);
61 
62  double MET_local = TMath::Sqrt (METx*METx + METy*METy);
63  recoMuon_.met.push_back(MET_local);
64 
65  TLorentzVector METP4;
66  METP4.SetPxPyPzE(METx, METy, 0, MET_local);
67 
68  TLorentzVector Muon;
69  Muon.SetPtEtaPhiE(it->pt(),it->eta(),it->phi(),it->energy());
70 
71  double scalSum = MET_local + Muon.Pt();
72  TLorentzVector vecSum (Muon);
73  vecSum += METP4;
74  double vecSumPt = vecSum.Pt();
75 
76  recoMuon_.mt.push_back(TMath::Sqrt (scalSum*scalSum - vecSumPt*vecSumPt));
77 
78  recoMuon_.nMuons++;
79 
80  // extrapolation of track coordinates
82  if (stateAtMuSt1.isValid()) {
83  recoMuon_.etaSt1.push_back(stateAtMuSt1.globalPosition().eta());
84  recoMuon_.phiSt1.push_back(stateAtMuSt1.globalPosition().phi());
85  } else {
86  recoMuon_.etaSt1.push_back(-9999);
87  recoMuon_.phiSt1.push_back(-9999);
88  }
89 
91  if (stateAtMuSt2.isValid()) {
92  recoMuon_.etaSt2.push_back(stateAtMuSt2.globalPosition().eta());
93  recoMuon_.phiSt2.push_back(stateAtMuSt2.globalPosition().phi());
94  } else {
95  recoMuon_.etaSt2.push_back(-9999);
96  recoMuon_.phiSt2.push_back(-9999);
97  }
98  }
99 }
100 
102 {
103  muPropagator1st_.init(eventSetup);
104  muPropagator2nd_.init(eventSetup);
105 }
TrajectoryStateOnSurface extrapolate(const reco::Track &tk) const
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
GlobalPoint globalPosition() const
bool isLooseMuonCustom(const reco::Muon &recoMu)
Definition: MuonID.h:20
bool isTightMuonCustom(const reco::Muon &recoMu, const reco::Vertex recoVtx)
Definition: MuonID.h:42
bool isMediumMuonCustom(const reco::Muon &recoMu)
Definition: MuonID.h:28
bool isValid() const
Definition: HandleBase.h:74
L1AnalysisRecoMuon2(const edm::ParameterSet &pset)
void init(const edm::EventSetup &iSetup)
T eta() const
Definition: PV3DBase.h:76
HLT enums.
L1AnalysisRecoMuon2DataFormat recoMuon_
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