54 if (transTrk.size() < 2)
58 transVtx = kvf.
vertex(transTrk);
61 edm::LogWarning(
"PATLeptonTimeLifeInfoProducer") <<
" fitVertex failed: " <<
e.what();
84 pvChoice_(
cfg.getParameter<
int>(
"pvChoice")) {
85 produces<TrackTimeLifeInfoMap>();
101 std::vector<TrackTimeLifeInfo>
infos;
104 for (
const auto& lepton : *
leptons) {
108 if (!selector_(lepton)) {
113 if (pvChoice_ == useClosestInDz &&
getTrack(lepton) !=
nullptr) {
118 if (dz_tmp < dz_min) {
128 produceAndFillIPInfo(lepton, transTrackBuilder,
pv,
info);
131 produceAndFillSVInfo(lepton, transTrackBuilder,
pv,
info);
136 auto infoMap = std::make_unique<TrackTimeLifeInfoMap>();
147 return electron.gsfTrack().isNonnull() ?
electron.gsfTrack().get() :
nullptr;
152 return muon.innerTrack().isNonnull() ?
muon.innerTrack().get() :
nullptr;
158 if (
tau.leadChargedHadrCand().isNonnull())
159 track =
tau.leadChargedHadrCand()->bestTrack();
163 template <
typename T>
169 if (
track !=
nullptr) {
175 if (!closestState.isValid()) {
177 <<
"closestState not valid! From:\n" 178 <<
"transTrack.impactPointState():\n" 179 << transTrack.
impactPointState() <<
"RecoVertex::convertPos(pv.position()):\n" 184 GlobalError pca_cov = closestState.cartesianError().position();
189 if (ip_vec.
dot(
GlobalVector(lepton.px(), lepton.py(), lepton.pz())) < 0)
195 info.setPCA(pca, pca_cov);
196 info.setIP(ip_vec, ip_cov);
197 info.setIPLength(ip_mes);
201 template <
typename T>
214 if (
tau.signalChargedHadrCands().size() +
tau.signalLostTracks().size() > 1) {
216 std::vector<reco::TransientTrack> transTrks;
218 for (
const auto&
cand :
tau.signalChargedHadrCands()) {
222 if (
track !=
nullptr)
223 transTrks.push_back(transTrackBuilder.
build(
track));
225 for (
const auto&
cand :
tau.signalLostTracks()) {
229 if (
track !=
nullptr)
230 transTrks.push_back(transTrackBuilder.
build(
track));
233 fitOK = fitVertex(transTrks, transVtx) ? 1 : -1;
248 info.setFlightVector(flight_vec, flight_cov);
249 info.setFlightLength(flightLength_mes);
254 template <
typename T>
261 lepCollName =
"slimmedElectrons";
263 lepCollName =
"slimmedMuons";
265 lepCollName =
"slimmedTaus";
268 desc.add<
std::string>(
"selection",
"")->setComment(
"Selection required to produce and store time-life information");
269 desc.add<
int>(
"pvChoice", useFront)
271 "Define PV to compute IP: 0: first PV, 1: PV with the smallest dz of the tau leading track (default: " +
reco::Vertex::Point convertPos(const GlobalPoint &p)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
GlobalError positionError() const
void produce(edm::Event &, const edm::EventSetup &) override
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
PATLeptonTimeLifeInfoProducer(const edm::ParameterSet &)
void produceAndFillSVInfo(const T &, const TransientTrackBuilder &, const reco::Vertex &, TrackTimeLifeInfo &)
Global3DPoint GlobalPoint
GlobalVector inInverseGeV(const GlobalPoint &gp) const
Field value ad specified global point, in 1/Gev.
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
bool getByToken(EDGetToken token, Handle< PROD > &result) const
~PATLeptonTimeLifeInfoProducer() override
Log< level::Error, false > LogError
edm::EDGetTokenT< reco::VertexCollection > pvToken_
std::vector< Vertex > VertexCollection
edm::EDGetTokenT< std::vector< T > > leptonsToken_
PATLeptonTimeLifeInfoProducer< pat::Electron > PATElectronTimeLifeInfoProducer
static std::string to_string(const XMLCh *ch)
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const override
reco::TransientTrack build(const reco::Track *p) const
PATLeptonTimeLifeInfoProducer< pat::Muon > PATMuonTimeLifeInfoProducer
static bool fitVertex(const std::vector< reco::TransientTrack > &transTrk, TransientVertex &transVtx)
const MagneticField * field() const
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
Analysis-level tau class.
static const TrackGhostTrackState * getTrack(const BasicGhostTrackState *basic)
const MagneticField * field() const
const StringCutObjectSelector< T > selector_
bool hasRefittedTracks() const
void produceAndFillIPInfo(const T &, const TransientTrackBuilder &, const reco::Vertex &, TrackTimeLifeInfo &)
Analysis-level electron class.
const reco::Track * getTrack(const T &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Log< level::Warning, false > LogWarning
Analysis-level muon class.
Structure to hold time-life information.
PATLeptonTimeLifeInfoProducer< pat::Tau > PATTauTimeLifeInfoProducer
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > transTrackBuilderToken_
TrajectoryStateOnSurface impactPointState() const
Global3DVector GlobalVector
std::vector< reco::TransientTrack > const & refittedTracks() const
Produces lepton life-time information.