Skip to content

Commit 341edfe

Browse files
authored
Merge pull request #48033 from drkovalskyi/bphnano_for_run2025
BPHNano size reduction
2 parents 65bb3e8 + 1236efc commit 341edfe

File tree

13 files changed

+299
-277
lines changed

13 files changed

+299
-277
lines changed

PhysicsTools/BPHNano/plugins/BToTrkTrkLLBuilder.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class BToTrkTrkLLBuilder : public edm::global::EDProducer<> {
4848
beamspot_{consumes<reco::BeamSpot>(cfg.getParameter<edm::InputTag>("beamSpot"))},
4949
dilepton_constraint_{cfg.getParameter<bool>("dileptonMassContraint")} {
5050
// output
51-
produces<pat::CompositeCandidateCollection>();
51+
produces<pat::CompositeCandidateCollection>("SelectedBToTrkTrkMuMu");
52+
produces<pat::CompositeCandidateCollection>("SelectedTrkTrk");
5253
}
5354

5455
~BToTrkTrkLLBuilder() override {}
@@ -96,6 +97,7 @@ void BToTrkTrkLLBuilder::produce(edm::StreamID, edm::Event &evt, edm::EventSetup
9697

9798
// output
9899
std::unique_ptr<pat::CompositeCandidateCollection> ret_val(new pat::CompositeCandidateCollection());
100+
std::unique_ptr<pat::CompositeCandidateCollection> ditrack_out(new pat::CompositeCandidateCollection());
99101

100102
for (size_t ditracks_idx = 0; ditracks_idx < ditracks->size(); ++ditracks_idx) {
101103
// both k*,phi and lep pair already passed cuts; no need for more
@@ -352,13 +354,15 @@ void BToTrkTrkLLBuilder::produce(edm::StreamID, edm::Event &evt, edm::EventSetup
352354
cand.addUserFloat("constraint_massErr_piK", constraint_massErr_piK);
353355
cand.addUserFloat("constraint_mll", constraint_mll);
354356

355-
ret_val->push_back(cand);
357+
ret_val->emplace_back(cand);
358+
ditrack_out->emplace_back(*ditracks_ptr);
356359

357360
} // for(size_t ll_idx = 0; ll_idx < dileptons->size(); ++ll_idx) {
358361

359362
} // for(size_t k_idx = 0; k_idx < ditracks->size(); ++k_idx)
360363

361-
evt.put(std::move(ret_val));
364+
evt.put(std::move(ret_val), "SelectedBToTrkTrkMuMu");
365+
evt.put(std::move(ditrack_out), "SelectedTrkTrk");
362366
}
363367

364368
#include "FWCore/Framework/interface/MakerMacros.h"

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/BToKLL_cff.py

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -38,54 +38,54 @@
3838
l1_idx = Var("userInt('l1_idx')", int, doc = "leading muon index to the BPH muon collection"),
3939
l2_idx = Var("userInt('l2_idx')", int, doc = "subleading muon index to the BPH muon collection"),
4040
k_idx = Var("userInt('trk_idx')", int, doc = "track index to the BPH track collection"),
41-
minDR = Var("userFloat('min_dr')", float, doc = "minimum DeltaR between the kaon and the two muons"),
42-
maxDR = Var("userFloat('max_dr')", float, doc = "maximum DeltaR between the kaon and the two muons"),
41+
minDR = Var("userFloat('min_dr')", float, doc = "minimum DeltaR between the kaon and the two muons", precision=10),
42+
maxDR = Var("userFloat('max_dr')", float, doc = "maximum DeltaR between the kaon and the two muons", precision=10),
4343
# fit and vtx info
44-
svprob = Var("userFloat('sv_prob')", float, doc = "vertex probability of the B candidate"),
45-
l_xy = Var("userFloat('l_xy')", float, doc = "post-fit vertex displacement on transverse plane wrt beamspot"),
46-
l_xy_unc = Var("userFloat('l_xy_unc')", float, doc = "post-fit vertex uncertainty of displacement on transverse plane wrt beamspot"),
44+
svprob = Var("userFloat('sv_prob')", float, doc = "vertex probability of the B candidate", precision=10),
45+
l_xy = Var("userFloat('l_xy')", float, doc = "post-fit vertex displacement on transverse plane wrt beamspot", precision=10),
46+
l_xy_unc = Var("userFloat('l_xy_unc')", float, doc = "post-fit vertex uncertainty of displacement on transverse plane wrt beamspot", precision=10),
4747

48-
vtx_x = Var("userFloat('vtx_x')", float, doc = "position x of fitted vertex"),
49-
vtx_y = Var("userFloat('vtx_y')", float, doc = "position y of fitted vertex"),
50-
vtx_z = Var("userFloat('vtx_z')", float, doc = "position z of fitted vertex"),
51-
vtx_cxx = Var("userFloat('vtx_cxx')", float, doc = "error x of fitted vertex"),
52-
vtx_cyy = Var("userFloat('vtx_cyy')", float, doc = "error y of fitted vertex"),
53-
vtx_czz = Var("userFloat('vtx_czz')", float, doc = "error z of fitted vertex"),
54-
vtx_cyx = Var("userFloat('vtx_cyx')", float, doc = "error yx of fitted vertex"),
55-
vtx_czx = Var("userFloat('vtx_czx')", float, doc = "error zx of fitted vertex"),
56-
vtx_czy = Var("userFloat('vtx_czy')", float, doc = "error zy of fitted vertex"),
48+
vtx_x = Var("userFloat('vtx_x')", float, doc = "position x of fitted vertex", precision=10),
49+
vtx_y = Var("userFloat('vtx_y')", float, doc = "position y of fitted vertex", precision=10),
50+
vtx_z = Var("userFloat('vtx_z')", float, doc = "position z of fitted vertex", precision=10),
51+
vtx_cxx = Var("userFloat('vtx_cxx')", float, doc = "error x of fitted vertex", precision=10),
52+
vtx_cyy = Var("userFloat('vtx_cyy')", float, doc = "error y of fitted vertex", precision=10),
53+
vtx_czz = Var("userFloat('vtx_czz')", float, doc = "error z of fitted vertex", precision=10),
54+
vtx_cyx = Var("userFloat('vtx_cyx')", float, doc = "error yx of fitted vertex", precision=10),
55+
vtx_czx = Var("userFloat('vtx_czx')", float, doc = "error zx of fitted vertex", precision=10),
56+
vtx_czy = Var("userFloat('vtx_czy')", float, doc = "error zy of fitted vertex", precision=10),
5757
# Mll
58-
mll_fullfit = Var("userFloat('fitted_mll')", float, doc = "post-fit mass of the two muons"),
58+
mll_fullfit = Var("userFloat('fitted_mll')", float, doc = "post-fit mass of the two muons", precision=10),
5959
# Cos(theta)
60-
cos2D = Var("userFloat('cos_theta_2D')", float, doc = "cos 2D of pre-fit candidate wrt beamspot"),
61-
fit_cos2D = Var("userFloat('fitted_cos_theta_2D')", float, doc = "cos 2D of fitted vertex wrt beamspot"),
60+
cos2D = Var("userFloat('cos_theta_2D')", float, doc = "cos 2D of pre-fit candidate wrt beamspot", precision=10),
61+
fit_cos2D = Var("userFloat('fitted_cos_theta_2D')", float, doc = "cos 2D of fitted vertex wrt beamspot", precision=10),
6262
# post-fit momentum
63-
fit_mass = Var("userFloat('fitted_mass')", float, doc = "post-fit mass of the B candidate"),
64-
fit_massErr = Var("userFloat('fitted_massErr')", float, doc = "post-fit uncertainty of the mass of the B candidate"),
65-
fit_pt = Var("userFloat('fitted_pt')", float, doc = "post-fit B pT"),
66-
fit_eta = Var("userFloat('fitted_eta')", float, doc = "post-fit B eta"),
67-
fit_phi = Var("userFloat('fitted_phi')", float, doc = "post-fit B phi"),
68-
fit_l1_pt = Var("userFloat('fitted_l1_pt')", float, doc = "post-fit leading mu pT"),
69-
fit_l1_eta = Var("userFloat('fitted_l1_eta')", float, doc = "post-fit leading mu eta"),
70-
fit_l1_phi = Var("userFloat('fitted_l1_phi')", float, doc = "post-fit leading mu phi"),
71-
fit_l2_pt = Var("userFloat('fitted_l2_pt')", float, doc = "post-fit subleading mu pT"),
72-
fit_l2_eta = Var("userFloat('fitted_l2_eta')", float, doc = "post-fit subleading mu eta"),
73-
fit_l2_phi = Var("userFloat('fitted_l2_phi')", float, doc = "post-fit subleading mu phi"),
74-
fit_k_pt = Var("userFloat('fitted_trk_pt')", float, doc = "post-fit track pT"),
75-
fit_k_eta = Var("userFloat('fitted_trk_eta')", float, doc = "post-fit track eta"),
76-
fit_k_phi = Var("userFloat('fitted_trk_phi')", float, doc = "post-fit track phi"),
77-
k_svip2d = Var("userFloat('k_svip2d')", float, doc = "2D IP of the track wrt the dimuon vertex"),
78-
k_svip2d_err = Var("userFloat('k_svip2d_err')", float, doc = "uncertainty of 2D IP of the track wrt the dimuon vertex"),
79-
l1_iso04 = Var("userFloat('l1_iso04')", float, doc = "leading mu isolation DR<0.4"),
80-
l2_iso04 = Var("userFloat('l2_iso04')", float, doc = "subleading mu isolation DR<0.4"),
81-
k_iso04 = Var("userFloat('trk_iso04')", float, doc = "track isolation DR<0.4"),
82-
constraint_sv_prob = Var("userFloat('constraint_sv_prob')", float, doc = "B vertex probability after the dimuon mass constraint"),
83-
constraint_pt = Var("userFloat('constraint_pt')", float, doc = "B pt after the dimuon mass constraint"),
84-
constraint_eta = Var("userFloat('constraint_eta')", float, doc = "B eta after the dimuon mass constraint"),
85-
constraint_phi = Var("userFloat('constraint_phi')", float, doc = "B phi after the dimuon mass constraint"),
86-
constraint_mass = Var("userFloat('constraint_mass')", float, doc = "B mass after the dimuon mass constraint"),
87-
constraint_massErr = Var("userFloat('constraint_massErr')", float, doc = "mass uncertainty of the dimuon mass constraint"),
88-
constraint_mll = Var("userFloat('constraint_mll')", float, doc = "dimuon mass after the dimuon mass constraint"),
63+
fit_mass = Var("userFloat('fitted_mass')", float, doc = "post-fit mass of the B candidate", precision=10),
64+
fit_massErr = Var("userFloat('fitted_massErr')", float, doc = "post-fit uncertainty of the mass of the B candidate", precision=10),
65+
fit_pt = Var("userFloat('fitted_pt')", float, doc = "post-fit B pT", precision=10),
66+
fit_eta = Var("userFloat('fitted_eta')", float, doc = "post-fit B eta", precision=10),
67+
fit_phi = Var("userFloat('fitted_phi')", float, doc = "post-fit B phi", precision=10),
68+
fit_l1_pt = Var("userFloat('fitted_l1_pt')", float, doc = "post-fit leading mu pT", precision=10),
69+
fit_l1_eta = Var("userFloat('fitted_l1_eta')", float, doc = "post-fit leading mu eta", precision=10),
70+
fit_l1_phi = Var("userFloat('fitted_l1_phi')", float, doc = "post-fit leading mu phi", precision=10),
71+
fit_l2_pt = Var("userFloat('fitted_l2_pt')", float, doc = "post-fit subleading mu pT", precision=10),
72+
fit_l2_eta = Var("userFloat('fitted_l2_eta')", float, doc = "post-fit subleading mu eta", precision=10),
73+
fit_l2_phi = Var("userFloat('fitted_l2_phi')", float, doc = "post-fit subleading mu phi", precision=10),
74+
fit_k_pt = Var("userFloat('fitted_trk_pt')", float, doc = "post-fit track pT", precision=10),
75+
fit_k_eta = Var("userFloat('fitted_trk_eta')", float, doc = "post-fit track eta", precision=10),
76+
fit_k_phi = Var("userFloat('fitted_trk_phi')", float, doc = "post-fit track phi", precision=10),
77+
k_svip2d = Var("userFloat('k_svip2d')", float, doc = "2D IP of the track wrt the dimuon vertex", precision=10),
78+
k_svip2d_err = Var("userFloat('k_svip2d_err')", float, doc = "uncertainty of 2D IP of the track wrt the dimuon vertex", precision=10),
79+
l1_iso04 = Var("userFloat('l1_iso04')", float, doc = "leading mu isolation DR<0.4", precision=10),
80+
l2_iso04 = Var("userFloat('l2_iso04')", float, doc = "subleading mu isolation DR<0.4", precision=10),
81+
k_iso04 = Var("userFloat('trk_iso04')", float, doc = "track isolation DR<0.4", precision=10),
82+
constraint_sv_prob = Var("userFloat('constraint_sv_prob')", float, doc = "B vertex probability after the dimuon mass constraint", precision=10),
83+
constraint_pt = Var("userFloat('constraint_pt')", float, doc = "B pt after the dimuon mass constraint", precision=10),
84+
constraint_eta = Var("userFloat('constraint_eta')", float, doc = "B eta after the dimuon mass constraint", precision=10),
85+
constraint_phi = Var("userFloat('constraint_phi')", float, doc = "B phi after the dimuon mass constraint", precision=10),
86+
constraint_mass = Var("userFloat('constraint_mass')", float, doc = "B mass after the dimuon mass constraint", precision=10),
87+
constraint_massErr = Var("userFloat('constraint_massErr')", float, doc = "mass uncertainty of the dimuon mass constraint", precision=10),
88+
constraint_mll = Var("userFloat('constraint_mll')", float, doc = "dimuon mass after the dimuon mass constraint", precision=10),
8989
)
9090
)
9191

0 commit comments

Comments
 (0)