1 #ifndef RecoBTag_IPProducer 2 #define RecoBTag_IPProducer 69 std::vector<reco::JTATagInfo> bases;
72 it != jetTracksAssociation->
end();
87 maxDeltaR(iConfig.getParameter<double>(
"maxDeltaR")),
94 std::vector<reco::JetTagInfo> bases;
106 for (
size_t j = 0;
j < it->numberOfDaughters(); ++
j) {
107 if (it->daughterPtr(
j)->bestTrack() !=
nullptr && it->daughterPtr(
j)->charge() != 0) {
108 m_map[
i].push_back(it->daughterPtr(
j));
112 for (
size_t j = 0;
j <
cands->size(); ++
j) {
113 if ((*
cands)[
j].bestTrack() !=
nullptr && (*cands)[
j].charge() != 0 && (*cands)[
j].pt() > 0 &&
122 std::vector<std::vector<reco::CandidatePtr> >
m_map;
129 template <
class Container,
class Base,
class Helper>
132 typedef std::vector<reco::IPTagInfo<Container, Base> >
Product;
190 template <
class Container,
class Base,
class Helper>
192 : m_config(iConfig), m_helper(iConfig, consumesCollector()) {
198 esConsumes<TransientTrackBuilder, TransientTrackRecord>(
edm::ESInputTag(
"",
"TransientTrackBuilder"));
199 token_calib2D = esConsumes<TrackProbabilityCalibration, BTagTrackProbability2DRcd>();
200 token_calib3D = esConsumes<TrackProbabilityCalibration, BTagTrackProbability3DRcd>();
216 produces<reco::TrackCollection>(
"ghostTracks");
220 template <
class Container,
class Base,
class Helper>
227 template <
class Container,
class Base,
class Helper>
230 if (m_computeProbabilities)
231 checkEventSetup(iSetup);
240 auto result = std::make_unique<Product>();
242 std::unique_ptr<reco::TrackCollection> ghostTracks;
244 if (m_computeGhostTrack) {
245 ghostTracks = std::make_unique<reco::TrackCollection>();
259 e(0, 0) = 0.0015 * 0.0015;
260 e(1, 1) = 0.0015 * 0.0015;
266 std::vector<Base> baseTagInfos = m_helper.makeBaseVector(
iEvent);
267 for (
typename std::vector<Base>::const_iterator it = baseTagInfos.begin(); it != baseTagInfos.end(); it++) {
271 if (m_directionWithTracks) {
273 for (
typename Container::const_iterator itTrack =
tracks.begin(); itTrack !=
tracks.end(); ++itTrack)
275 jetMomentum += (*itTrack)->momentum();
279 std::vector<reco::TransientTrack> transientTracks;
281 for (
typename Container::const_iterator itTrack =
tracks.begin(); itTrack !=
tracks.end(); ++itTrack) {
291 if (
track.pt() > m_cutMinPt &&
292 track.hitPattern().numberOfValidHits() >= m_cutTotalHits &&
293 track.hitPattern().numberOfValidPixelHits() >= m_cutPixelHits &&
294 track.normalizedChi2() < m_cutMaxChiSquared &&
std::abs(
track.dxy(
pv->position())) < m_cutMaxTIP &&
298 transientTracks.push_back(transientTrack);
302 GlobalVector direction(jetMomentum.x(), jetMomentum.y(), jetMomentum.z());
304 std::unique_ptr<reco::GhostTrack> ghostTrack;
306 if (m_computeGhostTrack) {
310 ghostTrack = std::make_unique<reco::GhostTrack>(
311 fitter.
fit(origin,
error, direction, m_ghostTrackPriorDeltaR, transientTracks));
329 ghostTrackRef =
reco::TrackRef(ghostTrackRefProd, ghostTracks->size());
330 ghostTracks->push_back(*ghostTrack);
332 if (m_directionWithGhostTrack) {
334 double lambda = pred.
lambda(origin);
345 std::vector<float> prob2D, prob3D;
346 std::vector<reco::btag::TrackIPData> ipData;
348 for (
unsigned int ind = 0; ind < transientTracks.size(); ind++) {
364 if (ghostTrack.get()) {
365 const std::vector<reco::GhostTrackState>& states = ghostTrack->states();
366 std::vector<reco::GhostTrackState>::const_iterator
pos =
367 std::find_if(states.begin(), states.end(), [&](
auto&
arg) {
return arg.track() == transientTrack; });
369 if (
pos != states.end() &&
pos->isValid()) {
388 ipData.push_back(trackIP);
390 if (m_computeProbabilities) {
392 std::pair<bool, double> probability = m_probabilityEstimator->probability(
393 m_useTrackQuality, 0, ipData.back().ip3d.significance(),
track, *(it->jet()), *
pv);
394 prob3D.push_back(probability.first ? probability.second : -1.);
397 probability = m_probabilityEstimator->probability(
398 m_useTrackQuality, 1, ipData.back().ip2d.significance(),
track, *(it->jet()), *
pv);
399 prob2D.push_back(probability.first ? probability.second : -1.);
407 if (m_computeGhostTrack)
419 template <
class Container,
class Base,
class Helper>
424 unsigned long long cacheId3D = re3D.cacheIdentifier();
426 if (cacheId2D != m_calibrationCacheId2D || cacheId3D != m_calibrationCacheId3D)
435 m_probabilityEstimator = std::make_unique<HistogramProbabilityEstimator>(ca3D, ca2D);
437 m_calibrationCacheId3D = cacheId3D;
438 m_calibrationCacheId2D = cacheId2D;
447 desc.add<
double>(
"maximumTransverseImpactParameter", 0.2);
448 desc.add<
int>(
"minimumNumberOfHits", 8);
449 desc.add<
double>(
"minimumTransverseMomentum", 1.0);
451 desc.add<
double>(
"maximumLongitudinalImpactParameter", 17.0);
452 desc.add<
bool>(
"computeGhostTrack",
true);
453 desc.add<
double>(
"ghostTrackPriorDeltaR", 0.03);
455 desc.add<
bool>(
"jetDirectionUsingGhostTrack",
false);
456 desc.add<
int>(
"minimumNumberOfPixelHits", 2);
457 desc.add<
bool>(
"jetDirectionUsingTracks",
false);
458 desc.add<
bool>(
"computeProbabilities",
true);
459 desc.add<
bool>(
"useTrackQuality",
false);
460 desc.add<
double>(
"maximumChiSquared", 5.0);
469 desc.add<
double>(
"maximumTransverseImpactParameter", 0.2);
470 desc.add<
int>(
"minimumNumberOfHits", 8);
471 desc.add<
double>(
"minimumTransverseMomentum", 1.0);
473 desc.add<
double>(
"maximumLongitudinalImpactParameter", 17.0);
474 desc.add<
bool>(
"computeGhostTrack",
true);
475 desc.add<
double>(
"maxDeltaR", 0.4);
477 desc.add<
bool>(
"jetDirectionUsingGhostTrack",
false);
478 desc.add<
int>(
"minimumNumberOfPixelHits", 2);
479 desc.add<
bool>(
"jetDirectionUsingTracks",
false);
480 desc.add<
bool>(
"computeProbabilities",
true);
481 desc.add<
bool>(
"useTrackQuality",
false);
483 desc.add<
double>(
"ghostTrackPriorDeltaR", 0.03);
484 desc.add<
double>(
"maximumChiSquared", 5.0);
485 desc.addOptional<
bool>(
"explicitJTA",
false);
const Vector & prediction() const
reco::Vertex::Point convertPos(const GlobalPoint &p)
double m_cutMaxChiSquared
const Track & track() const
std::vector< reco::JTATagInfo > makeBaseVector(const edm::Event &iEvent)
T getParameter(std::string const &) const
bool m_directionWithGhostTrack
transient_vector_type::const_iterator const_iterator
unsigned short numberOfValidHits() const
number of valid hits found
unsigned long long m_calibrationCacheId3D
GlobalPoint position(double lambda=0.) const
edm::ESGetToken< TrackProbabilityCalibration, BTagTrackProbability2DRcd > token_calib2D
JetTracksAssociation::Container JetTracksAssociationCollection
typedefs for backward compatibility
FromJetAndCands(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC, const std::string &jets="jets")
unsigned long long m_calibrationCacheId2D
reco::Vertex::Error convertError(const GlobalError &ge)
std::vector< Track > TrackCollection
collection of Tracks
TrackRefVector tracks(void) const override
returns a list of tracks associated to the jet
math::Error< dimension >::type Error
covariance error matrix (3x3)
const_iterator begin() const
edm::ESGetToken< TrackProbabilityCalibration, BTagTrackProbability3DRcd > token_calib3D
const reco::Track * toTrack(const reco::TrackBaseRef &t)
unsigned long long cacheIdentifier() const
double m_ghostTrackPriorDeltaR
std::vector< std::vector< reco::CandidatePtr > > m_map
reco::TransientTrack build(const reco::Track *p) const
void checkEventSetup(const edm::EventSetup &iSetup)
std::unique_ptr< HistogramProbabilityEstimator > m_probabilityEstimator
const GlobalVector direction() const
const std::vector< reco::CandidatePtr > & tracks(const reco::JetTagInfo &it)
T const * product() const
std::vector< reco::IPTagInfo< Container, Base > > Product
Container::value_type value_type
void addDefault(ParameterSetDescription const &psetDescription)
GlobalPoint globalPosition() const
edm::RefToBase< Jet > jet(void) const override
returns a polymorphic reference to the tagged jet
GlobalError positionError(double lambda=0.) const
Measurement1D distanceToGhostTrack
FromJTA(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
const MagneticField * field() const
Abs< T >::type abs(const T &t)
edm::EDGetTokenT< reco::VertexCollection > token_primaryVertex
reco::TrackRefVector tracks(const reco::JTATagInfo &it)
math::XYZPoint Point
point in the space
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
edm::EDGetTokenT< reco::JetTracksAssociationCollection > token_associator
bool m_directionWithTracks
const_iterator end() const
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
const edm::ParameterSet & m_config
auto const & tracks
cannot be loose
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
GlobalPoint closestToJetAxis
XYZVectorD XYZVector
spatial vector with cartesian internal representation
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
edm::EDGetTokenT< edm::View< reco::Jet > > token_jets
double lambda(const GlobalPoint &point) const
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > token_trackBuilder
Measurement1D distanceToJetAxis
void produce(edm::Event &, const edm::EventSetup &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
IPProducer(const edm::ParameterSet &)
GlobalPoint closestToGhostTrack
edm::EDGetTokenT< edm::View< reco::Candidate > > token_cands
GhostTrack fit(const GlobalPoint &priorPosition, const GlobalError &priorError, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
std::vector< reco::JetTagInfo > makeBaseVector(const edm::Event &iEvent)
bool m_computeProbabilities
primaryVertex
hltOfflineBeamSpot for HLTMON
edm::AssociationVector< reco::JetRefBaseProd, Values > Container
TrajectoryStateOnSurface impactPointState() const