Skip to content

Commit 071a141

Browse files
committed
expanded dimuon content
1 parent 003d1c6 commit 071a141

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

PhysicsTools/BPHNano/plugins/DiLeptonBuilder.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "CommonTools/Statistics/interface/ChiSquaredProbability.h"
1010
#include "CommonTools/Utils/interface/StringCutObjectSelector.h"
11+
#include "DataFormats/BeamSpot/interface/BeamSpot.h"
1112
#include "DataFormats/Math/interface/deltaR.h"
1213
#include "DataFormats/PatCandidates/interface/CompositeCandidate.h"
1314
#include "FWCore/Framework/interface/Event.h"
@@ -33,6 +34,7 @@ class DiLeptonBuilder : public edm::global::EDProducer<> {
3334
pre_vtx_selection_{cfg.getParameter<std::string>("preVtxSelection")},
3435
post_vtx_selection_{cfg.getParameter<std::string>("postVtxSelection")},
3536
src_{consumes<LeptonCollection>(cfg.getParameter<edm::InputTag>("src"))},
37+
beamspot_{consumes<reco::BeamSpot>(cfg.getParameter<edm::InputTag>("beamSpot"))},
3638
ttracks_src_{consumes<TransientTrackCollection>(cfg.getParameter<edm::InputTag>("transientTracksSrc"))} {
3739
produces<pat::CompositeCandidateCollection>("SelectedDiLeptons");
3840
}
@@ -47,6 +49,7 @@ class DiLeptonBuilder : public edm::global::EDProducer<> {
4749
const StringCutObjectSelector<pat::CompositeCandidate> pre_vtx_selection_; // cut on the di-lepton before the SV fit
4850
const StringCutObjectSelector<pat::CompositeCandidate> post_vtx_selection_; // cut on the di-lepton after the SV fit
4951
const edm::EDGetTokenT<LeptonCollection> src_;
52+
const edm::EDGetTokenT<reco::BeamSpot> beamspot_;
5053
const edm::EDGetTokenT<TransientTrackCollection> ttracks_src_;
5154
};
5255

@@ -56,6 +59,9 @@ void DiLeptonBuilder<Lepton>::produce(edm::StreamID, edm::Event &evt, edm::Event
5659
edm::Handle<LeptonCollection> leptons;
5760
evt.getByToken(src_, leptons);
5861

62+
edm::Handle<reco::BeamSpot> beamspot;
63+
evt.getByToken(beamspot_, beamspot);
64+
5965
edm::Handle<TransientTrackCollection> ttracks;
6066
evt.getByToken(ttracks_src_, ttracks);
6167

@@ -103,11 +109,16 @@ void DiLeptonBuilder<Lepton>::produce(edm::StreamID, edm::Event &evt, edm::Event
103109
lepton_pair.addUserFloat(
104110
"fitted_massErr",
105111
fitter.success() ? sqrt(fitter.fitted_candidate().kinematicParametersError().matrix()(6, 6)) : -1);
112+
auto fit_p4 = fitter.fitted_p4();
106113
lepton_pair.addUserFloat("vtx_x", lepton_pair.vx());
107114
lepton_pair.addUserFloat("vtx_y", lepton_pair.vy());
108115
lepton_pair.addUserFloat("vtx_z", lepton_pair.vz());
116+
lepton_pair.addUserFloat("cos_theta_2D", bph::cos_theta_2D(fitter, *beamspot, lepton_pair.p4()));
117+
lepton_pair.addUserFloat("fitted_cos_theta_2D", bph::cos_theta_2D(fitter, *beamspot, fit_p4));
109118

110-
// if needed, add here more stuff
119+
auto lxy = bph::l_xy(fitter, *beamspot);
120+
lepton_pair.addUserFloat("l_xy", lxy.value());
121+
lepton_pair.addUserFloat("l_xy_unc", lxy.error());
111122

112123
// cut on the SV info
113124
if (!post_vtx_selection_(lepton_pair))

PhysicsTools/BPHNano/python/MuMu_cff.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
transientTracksSrc = cms.InputTag('muonBPH', 'SelectedTransientMuons'),
1010
lep1Selection = cms.string('pt > 4.0 && abs(eta) < 2.4 && isLooseMuon && isGlobalMuon'),
1111
lep2Selection = cms.string('pt > 3.0 && abs(eta) < 2.4 && isLooseMuon && isGlobalMuon'),
12+
beamSpot = cms.InputTag("offlineBeamSpot"),
1213
preVtxSelection = cms.string('abs(userCand("l1").vz - userCand("l2").vz) <= 1.'
1314
'&& 0 < mass() && mass() < 15.0 '
1415
'&& charge() == 0'
@@ -33,11 +34,18 @@
3334
singleton = cms.bool(False), # the number of entries is variable
3435
extension = cms.bool(False), # this is the main table for the muons
3536
variables = cms.PSet(CandVars,
36-
fitted_mass = Var("userFloat('fitted_mass')", float, doc="Fitted dilepton mass", precision=10),
37-
svprob = Var("userFloat('sv_prob')", float, doc="Vtx fit probability", precision=10),
38-
vtx_x =Var("userFloat('vtx_x')", float, doc="Vtx position in x", precision=10),
39-
vtx_y = Var("userFloat('vtx_y')", float, doc="Vtx position in y", precision=10),
40-
vtx_z = Var("userFloat('vtx_z')", float, doc="Vtx position in y", precision=10),
37+
l1_idx = Var("userInt('l1_idx')", int, doc = "leading muon index to the BPH muon collection"),
38+
l2_idx = Var("userInt('l2_idx')", int, doc = "subleading muon index to the BPH muon collection"),
39+
fit_mass = Var("userFloat('fitted_mass')", float, doc="Fitted dilepton mass", precision=10),
40+
fit_massErr = Var("userFloat('fitted_massErr')", float, doc = "post-fit uncertainty of the mass of the B candidate", precision=10),
41+
svprob = Var("userFloat('sv_prob')", float, doc="Vtx fit probability", precision=10),
42+
l_xy = Var("userFloat('l_xy')", float, doc = "post-fit vertex displacement on transverse plane wrt beamspot", precision=10),
43+
l_xy_unc = Var("userFloat('l_xy_unc')", float, doc = "post-fit vertex uncertainty of displacement on transverse plane wrt beamspot", precision=10),
44+
vtx_x =Var("userFloat('vtx_x')", float, doc="Vtx position in x", precision=10),
45+
vtx_y = Var("userFloat('vtx_y')", float, doc="Vtx position in y", precision=10),
46+
vtx_z = Var("userFloat('vtx_z')", float, doc="Vtx position in y", precision=10),
47+
cos2D = Var("userFloat('cos_theta_2D')", float, doc = "cos 2D of pre-fit candidate wrt beamspot", precision=10),
48+
fit_cos2D = Var("userFloat('fitted_cos_theta_2D')", float, doc = "cos 2D of fitted vertex wrt beamspot", precision=10),
4149

4250
)
4351
)

0 commit comments

Comments
 (0)