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 
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_.init(eventSetup);
96  muPropagator2nd_.init(eventSetup);
97 }
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
isTightMuonCustom
bool isTightMuonCustom(const reco::Muon &recoMu, const reco::Vertex recoVtx)
Definition: MuonID.h:36
isMediumMuonCustom
bool isMediumMuonCustom(const reco::Muon &recoMu)
Definition: MuonID.h:27
muon
Definition: MuonCocktails.h:17
edm
HLT enums.
Definition: AlignableModifier.h:19
Muon.h
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
edm::Handle< reco::MuonCollection >
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
Muon
Definition: Muon.py:1
l1MuonRecoTree_cfi.maxMuon
maxMuon
Definition: l1MuonRecoTree_cfi.py:4
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
L1Analysis::L1AnalysisRecoMuon2::~L1AnalysisRecoMuon2
~L1AnalysisRecoMuon2()
Definition: L1AnalysisRecoMuon2.cc:14
JetCorrector.h
L1Analysis::L1AnalysisRecoMuon2::init
void init(const edm::EventSetup &eventSetup)
Definition: L1AnalysisRecoMuon2.cc:94
edm::ParameterSet
Definition: ParameterSet.h:47
ParameterSet
Definition: Functions.h:16
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
dumpRecoGeometry_cfg.Muon
Muon
Definition: dumpRecoGeometry_cfg.py:190
isLooseMuonCustom
bool isLooseMuonCustom(const reco::Muon &recoMu)
Definition: MuonID.h:19
edm::EventSetup
Definition: EventSetup.h:57
L1Analysis::L1AnalysisRecoMuon2::SetMuon
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: L1AnalysisRecoMuon2.cc:16
std
Definition: JetResolutionObject.h:76
L1Analysis::L1AnalysisRecoMuon2::L1AnalysisRecoMuon2
L1AnalysisRecoMuon2(const edm::ParameterSet &pset)
Definition: L1AnalysisRecoMuon2.cc:10
MuonID.h
L1AnalysisRecoMuon2.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7