Skip to content

Commit d5ea2ab

Browse files
authored
backport to CMSSW_15_0_X
Backport to CMSSW_15_0_X
2 parents 8118289 + 245381b commit d5ea2ab

14 files changed

+328
-206
lines changed

PhysicsTools/BPHNano/plugins/BToTrkLLBuilder.cc

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "TrackingTools/TransientTrack/interface/TransientTrack.h"
3030
#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
3131
#include "helper.h"
32+
#include "FWCore/MessageLogger/interface/MessageLogger.h"
3233

3334
class BToTrkLLBuilder : public edm::global::EDProducer<> {
3435
// perhaps we need better structure here (begin run etc)
@@ -131,10 +132,15 @@ void BToTrkLLBuilder::produce(edm::StreamID, edm::Event &evt, edm::EventSetup co
131132
if (!pre_vtx_selection_(cand))
132133
continue;
133134

134-
KinVtxFitter fitter({leptons_ttracks->at(l1_idx), leptons_ttracks->at(l2_idx), kaons_ttracks->at(k_idx)},
135-
{l1_ptr->mass(), l2_ptr->mass(), bph::K_MASS},
136-
{bph::LEP_SIGMA, bph::LEP_SIGMA, bph::K_SIGMA} // some small sigma for the lepton mass
137-
);
135+
KinVtxFitter fitter;
136+
try {
137+
fitter = KinVtxFitter({leptons_ttracks->at(l1_idx), leptons_ttracks->at(l2_idx), kaons_ttracks->at(k_idx)},
138+
{l1_ptr->mass(), l2_ptr->mass(), bph::K_MASS},
139+
{bph::LEP_SIGMA, bph::LEP_SIGMA, bph::K_SIGMA});
140+
} catch (const VertexException &e) {
141+
edm::LogWarning("KinematicFit") << "BToKLL: Skipping candidate due to fit failure: " << e.what();
142+
continue;
143+
}
138144

139145
if (!fitter.success())
140146
continue; // hardcoded, but do we need otherwise?
@@ -231,11 +237,18 @@ void BToTrkLLBuilder::produce(edm::StreamID, edm::Event &evt, edm::EventSetup co
231237
// Mass constraint is applied to the first two particles in the
232238
// "particles" vector Make sure that the first two particles are the
233239
// ones you want to constrain
234-
KinVtxFitter constraint_fitter(
235-
{leptons_ttracks->at(l1_idx), leptons_ttracks->at(l2_idx), kaons_ttracks->at(k_idx)},
236-
{l1_ptr->mass(), l2_ptr->mass(), bph::K_MASS},
237-
{bph::LEP_SIGMA, bph::LEP_SIGMA, bph::K_SIGMA},
238-
mass_constraint);
240+
KinVtxFitter constraint_fitter;
241+
try {
242+
constraint_fitter =
243+
KinVtxFitter({leptons_ttracks->at(l1_idx), leptons_ttracks->at(l2_idx), kaons_ttracks->at(k_idx)},
244+
{l1_ptr->mass(), l2_ptr->mass(), bph::K_MASS},
245+
{bph::LEP_SIGMA, bph::LEP_SIGMA, bph::K_SIGMA},
246+
mass_constraint);
247+
} catch (const VertexException &e) {
248+
edm::LogWarning("KinematicFit")
249+
<< "BToKLL - Constrained fit: Skipping candidate due to fit failure: " << e.what();
250+
continue;
251+
}
239252
if (constraint_fitter.success()) {
240253
auto constraint_p4 = constraint_fitter.fitted_p4();
241254
constraint_sv_prob = constraint_fitter.prob();

PhysicsTools/BPHNano/plugins/BToTrkTrkLLBuilder.cc

Lines changed: 87 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
2929
#include "TrackingTools/TransientTrack/interface/TransientTrack.h"
3030
#include "helper.h"
31+
#include "FWCore/MessageLogger/interface/MessageLogger.h"
3132

3233
class BToTrkTrkLLBuilder : public edm::global::EDProducer<> {
3334
// perhaps we need better structure here (begin run etc)
@@ -133,7 +134,10 @@ void BToTrkTrkLLBuilder::produce(edm::StreamID, edm::Event &evt, edm::EventSetup
133134
cand.addUserInt("l2_idx", l2_idx);
134135
cand.addUserInt("trk1_idx", trk1_idx);
135136
cand.addUserInt("trk2_idx", trk2_idx);
136-
cand.addUserInt("ditrack_idx", ditracks_idx);
137+
// cand.addUserInt("ditrack_idx", ditracks_idx); this index corresponds to the ditrack collection.
138+
// However, in order to refuce the event size, we do not store all the ditrack candidates but only those used to build a B candidate.
139+
// So, now, index of B candidate is the same number for index of ditrack candidate
140+
// This variable is not removed from the code in case we decide to store in the future all the ditrack candidates.
137141
cand.addUserInt("ll_idx", ll_idx);
138142

139143
auto lep1_p4 = l1_ptr->polarP4();
@@ -162,28 +166,49 @@ void BToTrkTrkLLBuilder::produce(edm::StreamID, edm::Event &evt, edm::EventSetup
162166
if (!pre_vtx_selection_(cand))
163167
continue;
164168

165-
KinVtxFitter fitter({leptons_ttracks->at(l1_idx),
166-
leptons_ttracks->at(l2_idx),
167-
ditracks_ttracks->at(trk1_idx),
168-
ditracks_ttracks->at(trk2_idx)},
169-
{l1_ptr->mass(), l2_ptr->mass(), bph::K_MASS, bph::K_MASS},
170-
{bph::LEP_SIGMA, bph::LEP_SIGMA, bph::K_SIGMA, bph::K_SIGMA});
171-
if (!fitter.success())
172-
continue;
173-
KinVtxFitter fitter_Kpi({leptons_ttracks->at(l1_idx),
169+
KinVtxFitter fitter;
170+
try {
171+
fitter = KinVtxFitter({leptons_ttracks->at(l1_idx),
174172
leptons_ttracks->at(l2_idx),
175173
ditracks_ttracks->at(trk1_idx),
176174
ditracks_ttracks->at(trk2_idx)},
177-
{l1_ptr->mass(), l2_ptr->mass(), bph::K_MASS, bph::PI_MASS},
175+
{l1_ptr->mass(), l2_ptr->mass(), bph::K_MASS, bph::K_MASS},
178176
{bph::LEP_SIGMA, bph::LEP_SIGMA, bph::K_SIGMA, bph::K_SIGMA});
177+
} catch (const VertexException &e) {
178+
edm::LogWarning("KinematicFit") << "BToTrkTrkLL - KK mass hypothesis: Skipping candidate due to fit failure: "
179+
<< e.what();
180+
continue;
181+
}
182+
if (!fitter.success())
183+
continue;
184+
KinVtxFitter fitter_Kpi;
185+
try {
186+
fitter_Kpi = KinVtxFitter({leptons_ttracks->at(l1_idx),
187+
leptons_ttracks->at(l2_idx),
188+
ditracks_ttracks->at(trk1_idx),
189+
ditracks_ttracks->at(trk2_idx)},
190+
{l1_ptr->mass(), l2_ptr->mass(), bph::K_MASS, bph::PI_MASS},
191+
{bph::LEP_SIGMA, bph::LEP_SIGMA, bph::K_SIGMA, bph::K_SIGMA});
192+
} catch (const VertexException &e) {
193+
edm::LogWarning("KinematicFit") << "BToTrkTrkLL - Kpi mass hypothesis: Skipping candidate due to fit failure: "
194+
<< e.what();
195+
continue;
196+
}
179197
if (!fitter_Kpi.success())
180198
continue;
181-
KinVtxFitter fitter_piK({leptons_ttracks->at(l1_idx),
182-
leptons_ttracks->at(l2_idx),
183-
ditracks_ttracks->at(trk1_idx),
184-
ditracks_ttracks->at(trk2_idx)},
185-
{l1_ptr->mass(), l2_ptr->mass(), bph::PI_MASS, bph::K_MASS},
186-
{bph::LEP_SIGMA, bph::LEP_SIGMA, bph::K_SIGMA, bph::K_SIGMA});
199+
KinVtxFitter fitter_piK;
200+
try {
201+
fitter_piK = KinVtxFitter({leptons_ttracks->at(l1_idx),
202+
leptons_ttracks->at(l2_idx),
203+
ditracks_ttracks->at(trk1_idx),
204+
ditracks_ttracks->at(trk2_idx)},
205+
{l1_ptr->mass(), l2_ptr->mass(), bph::PI_MASS, bph::K_MASS},
206+
{bph::LEP_SIGMA, bph::LEP_SIGMA, bph::K_SIGMA, bph::K_SIGMA});
207+
} catch (const VertexException &e) {
208+
edm::LogWarning("KinematicFit") << "BToTrkTrkLL - piK mass hypothesis: Skipping candidate due to fit failure: "
209+
<< e.what();
210+
continue;
211+
}
187212
if (!fitter_piK.success())
188213
continue;
189214

@@ -310,31 +335,55 @@ void BToTrkTrkLLBuilder::produce(edm::StreamID, edm::Event &evt, edm::EventSetup
310335
// "particles" vector Make sure that the first two particles are the
311336
// ones you want to constrain
312337

313-
KinVtxFitter constraint_fitter_KK({leptons_ttracks->at(l1_idx),
314-
leptons_ttracks->at(l2_idx),
315-
ditracks_ttracks->at(trk1_idx),
316-
ditracks_ttracks->at(trk2_idx)},
317-
{l1_ptr->mass(), l2_ptr->mass(), bph::K_MASS, bph::K_MASS},
318-
{bph::LEP_SIGMA, bph::LEP_SIGMA, bph::K_SIGMA, bph::K_SIGMA},
319-
mass_constraint);
338+
KinVtxFitter constraint_fitter_KK;
339+
try {
340+
constraint_fitter_KK = KinVtxFitter({leptons_ttracks->at(l1_idx),
341+
leptons_ttracks->at(l2_idx),
342+
ditracks_ttracks->at(trk1_idx),
343+
ditracks_ttracks->at(trk2_idx)},
344+
{l1_ptr->mass(), l2_ptr->mass(), bph::K_MASS, bph::K_MASS},
345+
{bph::LEP_SIGMA, bph::LEP_SIGMA, bph::K_SIGMA, bph::K_SIGMA},
346+
mass_constraint);
347+
} catch (const VertexException &e) {
348+
edm::LogWarning("KinematicFit")
349+
<< "BToTrkTrkLL - KK mass hypothesis constrained fit: Skipping candidate due to fit failure: "
350+
<< e.what();
351+
continue;
352+
}
320353
if (!constraint_fitter_KK.success())
321354
continue;
322-
KinVtxFitter constraint_fitter_Kpi({leptons_ttracks->at(l1_idx),
323-
leptons_ttracks->at(l2_idx),
324-
ditracks_ttracks->at(trk1_idx),
325-
ditracks_ttracks->at(trk2_idx)},
326-
{l1_ptr->mass(), l2_ptr->mass(), bph::K_MASS, bph::PI_MASS},
327-
{bph::LEP_SIGMA, bph::LEP_SIGMA, bph::K_SIGMA, bph::K_SIGMA},
328-
mass_constraint);
355+
KinVtxFitter constraint_fitter_Kpi;
356+
try {
357+
constraint_fitter_Kpi = KinVtxFitter({leptons_ttracks->at(l1_idx),
358+
leptons_ttracks->at(l2_idx),
359+
ditracks_ttracks->at(trk1_idx),
360+
ditracks_ttracks->at(trk2_idx)},
361+
{l1_ptr->mass(), l2_ptr->mass(), bph::K_MASS, bph::PI_MASS},
362+
{bph::LEP_SIGMA, bph::LEP_SIGMA, bph::K_SIGMA, bph::K_SIGMA},
363+
mass_constraint);
364+
} catch (const VertexException &e) {
365+
edm::LogWarning("KinematicFit")
366+
<< "BToTrkTrkLL - Kpi mass hypothesis constrained fit: Skipping candidate due to fit failure: "
367+
<< e.what();
368+
continue;
369+
}
329370
if (!constraint_fitter_Kpi.success())
330371
continue;
331-
KinVtxFitter constraint_fitter_piK({leptons_ttracks->at(l1_idx),
332-
leptons_ttracks->at(l2_idx),
333-
ditracks_ttracks->at(trk1_idx),
334-
ditracks_ttracks->at(trk2_idx)},
335-
{l1_ptr->mass(), l2_ptr->mass(), bph::PI_MASS, bph::K_MASS},
336-
{bph::LEP_SIGMA, bph::LEP_SIGMA, bph::K_SIGMA, bph::K_SIGMA},
337-
mass_constraint);
372+
KinVtxFitter constraint_fitter_piK;
373+
try {
374+
constraint_fitter_piK = KinVtxFitter({leptons_ttracks->at(l1_idx),
375+
leptons_ttracks->at(l2_idx),
376+
ditracks_ttracks->at(trk1_idx),
377+
ditracks_ttracks->at(trk2_idx)},
378+
{l1_ptr->mass(), l2_ptr->mass(), bph::PI_MASS, bph::K_MASS},
379+
{bph::LEP_SIGMA, bph::LEP_SIGMA, bph::K_SIGMA, bph::K_SIGMA},
380+
mass_constraint);
381+
} catch (const VertexException &e) {
382+
edm::LogWarning("KinematicFit")
383+
<< "BToTrkTrkLL - piK mass hypothesis constrained fit: Skipping candidate due to fit failure: "
384+
<< e.what();
385+
continue;
386+
}
338387
if (!constraint_fitter_piK.success())
339388
continue;
340389

PhysicsTools/BPHNano/plugins/BToV0LLBuilder.cc

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "TrackingTools/TransientTrack/interface/TransientTrack.h"
3636
#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
3737
#include "helper.h"
38+
#include "FWCore/MessageLogger/interface/MessageLogger.h"
3839

3940
class BToV0LLBuilder : public edm::global::EDProducer<> {
4041
// perhaps we need better structure here (begin run etc)
@@ -130,9 +131,15 @@ void BToV0LLBuilder::produce(edm::StreamID, edm::Event &evt, edm::EventSetup con
130131
if (!pre_vtx_selection_(cand))
131132
continue;
132133

133-
KinVtxFitter fitter({leptons_ttracks->at(l1_idx), leptons_ttracks->at(l2_idx), v0_ttracks->at(v0_idx)},
134-
{l1_ptr->mass(), l2_ptr->mass(), v0_ptr->mass()},
135-
{bph::LEP_SIGMA, bph::LEP_SIGMA, v0_ptr->userFloat("massErr")});
134+
KinVtxFitter fitter;
135+
try {
136+
fitter = KinVtxFitter({leptons_ttracks->at(l1_idx), leptons_ttracks->at(l2_idx), v0_ttracks->at(v0_idx)},
137+
{l1_ptr->mass(), l2_ptr->mass(), v0_ptr->mass()},
138+
{bph::LEP_SIGMA, bph::LEP_SIGMA, v0_ptr->userFloat("massErr")});
139+
} catch (const VertexException &e) {
140+
edm::LogWarning("KinematicFit") << "BToV0LL: Skipping candidate due to fit failure: " << e.what();
141+
continue;
142+
}
136143

137144
if (!fitter.success())
138145
continue;
@@ -246,11 +253,17 @@ void BToV0LLBuilder::produce(edm::StreamID, edm::Event &evt, edm::EventSetup con
246253
// Mass constraint is applied to the first two particles in the
247254
// "particles" vector Make sure that the first two particles are the
248255
// ones you want to constrain
249-
KinVtxFitter constraint_fitter(
250-
{leptons_ttracks->at(l1_idx), leptons_ttracks->at(l2_idx), v0_ttracks->at(v0_idx)},
251-
{l1_ptr->mass(), l2_ptr->mass(), v0_ptr->mass()},
252-
{bph::LEP_SIGMA, bph::LEP_SIGMA, v0_ptr->userFloat("massErr")},
253-
mass_constraint);
256+
KinVtxFitter constraint_fitter;
257+
try {
258+
constraint_fitter =
259+
KinVtxFitter({leptons_ttracks->at(l1_idx), leptons_ttracks->at(l2_idx), v0_ttracks->at(v0_idx)},
260+
{l1_ptr->mass(), l2_ptr->mass(), v0_ptr->mass()},
261+
{bph::LEP_SIGMA, bph::LEP_SIGMA, v0_ptr->userFloat("massErr")},
262+
mass_constraint);
263+
} catch (const VertexException &e) {
264+
edm::LogWarning("KinematicFit") << "BToV0LL: Skipping candidate due to fit failure: " << e.what();
265+
continue;
266+
}
254267
if (constraint_fitter.success()) {
255268
auto constraint_p4 = constraint_fitter.fitted_p4();
256269
cstr_vtx_x = constraint_fitter.fitted_vtx().x();

PhysicsTools/BPHNano/plugins/BToV0TrkDisplacedLLBuilder.cc

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <limits>
2727
#include <algorithm>
2828
#include "KinVtxFitter.h"
29+
#include "FWCore/MessageLogger/interface/MessageLogger.h"
2930

3031
using namespace std;
3132

@@ -171,9 +172,15 @@ void BToV0TrkDisplacedLLBuilder::produce(edm::StreamID, edm::Event &evt, edm::Ev
171172
if (!pre_vtx_selection_(cand))
172173
continue;
173174

174-
KinVtxFitter xifitter({pions_ttracks->at(pi_idx), V0s_ttracks->at(V0_idx)},
175-
{bph::PI_MASS, V0_ptr->mass()},
176-
{bph::PI_SIGMA, V0_ptr->userFloat("massErr")});
175+
KinVtxFitter xifitter;
176+
try {
177+
xifitter = KinVtxFitter({pions_ttracks->at(pi_idx), V0s_ttracks->at(V0_idx)},
178+
{bph::PI_MASS, V0_ptr->mass()},
179+
{bph::PI_SIGMA, V0_ptr->userFloat("massErr")});
180+
} catch (const VertexException &e) {
181+
edm::LogWarning("KinematicFit") << "Xi Builder: Skipping candidate due to fit failure: " << e.what();
182+
continue;
183+
}
177184
if (!xifitter.success())
178185
continue;
179186
const auto &XiTT = xifitter.fitted_candidate_ttrk();
@@ -196,9 +203,15 @@ void BToV0TrkDisplacedLLBuilder::produce(edm::StreamID, edm::Event &evt, edm::Ev
196203
cand.addUserFloat("Xi_mass", ximass);
197204
cand.addUserFloat("Xi_massErr", ximassErr);
198205

199-
KinVtxFitter fitter({leptons_ttracks->at(l1_idx), leptons_ttracks->at(l2_idx), XiTT},
200-
{l1_ptr->mass(), l2_ptr->mass(), ximass},
201-
{bph::LEP_SIGMA, bph::LEP_SIGMA, ximassErr});
206+
KinVtxFitter fitter;
207+
try {
208+
fitter = KinVtxFitter({leptons_ttracks->at(l1_idx), leptons_ttracks->at(l2_idx), XiTT},
209+
{l1_ptr->mass(), l2_ptr->mass(), ximass},
210+
{bph::LEP_SIGMA, bph::LEP_SIGMA, ximassErr});
211+
} catch (const VertexException &e) {
212+
edm::LogWarning("KinematicFit") << "BToXiLL Builder: Skipping candidate due to fit failure: " << e.what();
213+
continue;
214+
}
202215
if (!fitter.success())
203216
continue;
204217
cand.setVertex(
@@ -319,12 +332,18 @@ void BToV0TrkDisplacedLLBuilder::produce(edm::StreamID, edm::Event &evt, edm::Ev
319332
ParticleMass mass_constraint = (dilepton_mass < jpsi_bin[1]) ? JPsi_mass : Psi2S_mass;
320333
// Mass constraint is applied to the first two particles in the "particles" vector
321334
// Make sure that the first two particles are the ones you want to constrain
322-
KinVtxFitter constrained_fitter(
323335

324-
{leptons_ttracks->at(l1_idx), leptons_ttracks->at(l2_idx), XiTT},
325-
{l1_ptr->mass(), l2_ptr->mass(), ximass},
326-
{bph::LEP_SIGMA, bph::LEP_SIGMA, ximassErr},
327-
mass_constraint); //K_SIGMA==PI_SIGMA
336+
KinVtxFitter constrained_fitter;
337+
try {
338+
constrained_fitter = KinVtxFitter({leptons_ttracks->at(l1_idx), leptons_ttracks->at(l2_idx), XiTT},
339+
{l1_ptr->mass(), l2_ptr->mass(), ximass},
340+
{bph::LEP_SIGMA, bph::LEP_SIGMA, ximassErr},
341+
mass_constraint);
342+
} catch (const VertexException &e) {
343+
edm::LogWarning("KinematicFit") << "BToXiLL Builder: Skipping candidate due to fit failure: " << e.what();
344+
continue;
345+
}
346+
328347
if (!constrained_fitter.success()) {
329348
// Save default values and continue
330349
cand.addUserInt("sv_OK_withMC", sv_OK_withMC);

0 commit comments

Comments
 (0)