Skip to content

Commit

Permalink
Merge pull request #44869 from francescobrivio/alca-closestState_chec…
Browse files Browse the repository at this point in the history
…k_14_0_X

[14_0_X] Add check on PATLeptonTimeLifeInfoProducer closestState valid state
  • Loading branch information
cmsbuild authored Apr 30, 2024
2 parents 691d708 + e2dd018 commit 167dd40
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions PhysicsTools/PatAlgos/plugins/PATLeptonTimeLifeInfoProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "DataFormats/Common/interface/ValueMap.h"
#include "DataFormats/PatCandidates/interface/Electron.h"
Expand Down Expand Up @@ -161,14 +162,19 @@ void PATLeptonTimeLifeInfoProducer<T>::produceAndFillIPInfo(const T& lepton,
TrackTimeLifeInfo& info) {
const reco::Track* track = getTrack(lepton);
if (track != nullptr) {
info.setTrack(track);
info.setBField_z(transTrackBuilder.field()->inInverseGeV(GlobalPoint(track->vx(), track->vy(), track->vz())).z());

// Extrapolate track to the point closest to PV
reco::TransientTrack transTrack = transTrackBuilder.build(track);
AnalyticalImpactPointExtrapolator extrapolator(transTrack.field());
TrajectoryStateOnSurface closestState =
extrapolator.extrapolate(transTrack.impactPointState(), RecoVertex::convertPos(pv.position()));
if (!closestState.isValid()) {
edm::LogError("PATLeptonTimeLifeInfoProducer")
<< "closestState not valid! From:\n"
<< "transTrack.impactPointState():\n"
<< transTrack.impactPointState() << "RecoVertex::convertPos(pv.position()):\n"
<< RecoVertex::convertPos(pv.position());
return;
}
GlobalPoint pca = closestState.globalPosition();
GlobalError pca_cov = closestState.cartesianError().position();
GlobalVector ip_vec = GlobalVector(pca.x() - pv.x(), pca.y() - pv.y(), pca.z() - pv.z());
Expand All @@ -178,7 +184,9 @@ void PATLeptonTimeLifeInfoProducer<T>::produceAndFillIPInfo(const T& lepton,
if (ip_vec.dot(GlobalVector(lepton.px(), lepton.py(), lepton.pz())) < 0)
ip_mes = Measurement1D(-1. * ip_mes.value(), ip_mes.error());

// Store PCA info
// Store Track and PCA info
info.setTrack(track);
info.setBField_z(transTrackBuilder.field()->inInverseGeV(GlobalPoint(track->vx(), track->vy(), track->vz())).z());
info.setPCA(pca, pca_cov);
info.setIP(ip_vec, ip_cov);
info.setIPLength(ip_mes);
Expand Down

0 comments on commit 167dd40

Please sign in to comment.