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) {
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;
189 template <
class Container,
class Base,
class Helper>
191 : m_helper(iConfig, consumesCollector()) {
197 esConsumes<TransientTrackBuilder, TransientTrackRecord>(
edm::ESInputTag(
"",
"TransientTrackBuilder"));
198 token_calib2D = esConsumes<TrackProbabilityCalibration, BTagTrackProbability2DRcd>();
199 token_calib3D = esConsumes<TrackProbabilityCalibration, BTagTrackProbability3DRcd>();
215 produces<reco::TrackCollection>(
"ghostTracks");
219 template <
class Container,
class Base,
class Helper>
226 template <
class Container,
class Base,
class Helper>
229 if (m_computeProbabilities)
230 checkEventSetup(iSetup);
239 auto result = std::make_unique<Product>();
241 std::unique_ptr<reco::TrackCollection> ghostTracks;
243 if (m_computeGhostTrack) {
244 ghostTracks = std::make_unique<reco::TrackCollection>();
258 e(0, 0) = 0.0015 * 0.0015;
259 e(1, 1) = 0.0015 * 0.0015;
265 std::vector<Base> baseTagInfos = m_helper.makeBaseVector(
iEvent);
266 for (
typename std::vector<Base>::const_iterator
it = baseTagInfos.begin();
it != baseTagInfos.end();
it++) {
270 if (m_directionWithTracks) {
272 for (
typename Container::const_iterator itTrack =
tracks.begin(); itTrack !=
tracks.end(); ++itTrack)
274 jetMomentum += (*itTrack)->momentum();
278 std::vector<reco::TransientTrack> transientTracks;
280 for (
typename Container::const_iterator itTrack =
tracks.begin(); itTrack !=
tracks.end(); ++itTrack) {
290 if (
track.pt() > m_cutMinPt &&
291 track.hitPattern().numberOfValidHits() >= m_cutTotalHits &&
292 track.hitPattern().numberOfValidPixelHits() >= m_cutPixelHits &&
293 track.normalizedChi2() < m_cutMaxChiSquared &&
std::abs(
track.dxy(
pv->position())) < m_cutMaxTIP &&
297 transientTracks.push_back(transientTrack);
301 GlobalVector direction(jetMomentum.x(), jetMomentum.y(), jetMomentum.z());
303 std::unique_ptr<reco::GhostTrack> ghostTrack;
305 if (m_computeGhostTrack) {
309 ghostTrack = std::make_unique<reco::GhostTrack>(
310 fitter.
fit(origin,
error, direction, m_ghostTrackPriorDeltaR, transientTracks));
328 ghostTrackRef =
reco::TrackRef(ghostTrackRefProd, ghostTracks->size());
329 ghostTracks->push_back(*ghostTrack);
331 if (m_directionWithGhostTrack) {
333 double lambda = pred.
lambda(origin);
344 std::vector<float> prob2D, prob3D;
345 std::vector<reco::btag::TrackIPData> ipData;
347 for (
unsigned int ind = 0; ind < transientTracks.size(); ind++) {
363 if (ghostTrack.get()) {
364 const std::vector<reco::GhostTrackState>& states = ghostTrack->states();
365 std::vector<reco::GhostTrackState>::const_iterator
pos =
366 std::find_if(states.begin(), states.end(), [&](
auto&
arg) {
return arg.track() == transientTrack; });
368 if (
pos != states.end() &&
pos->isValid()) {
387 ipData.push_back(trackIP);
389 if (m_computeProbabilities) {
391 std::pair<bool, double> probability = m_probabilityEstimator->probability(
392 m_useTrackQuality, 0, ipData.back().ip3d.significance(),
track, *(
it->jet()), *
pv);
393 prob3D.push_back(probability.first ? probability.second : -1.);
396 probability = m_probabilityEstimator->probability(
397 m_useTrackQuality, 1, ipData.back().ip2d.significance(),
track, *(
it->jet()), *
pv);
398 prob2D.push_back(probability.first ? probability.second : -1.);
406 if (m_computeGhostTrack)
418 template <
class Container,
class Base,
class Helper>
423 unsigned long long cacheId3D = re3D.cacheIdentifier();
425 if (cacheId2D != m_calibrationCacheId2D || cacheId3D != m_calibrationCacheId3D)
434 m_probabilityEstimator = std::make_unique<HistogramProbabilityEstimator>(ca3D, ca2D);
436 m_calibrationCacheId3D = cacheId3D;
437 m_calibrationCacheId2D = cacheId2D;
446 desc.add<
double>(
"maximumTransverseImpactParameter", 0.2);
447 desc.add<
int>(
"minimumNumberOfHits", 8);
448 desc.add<
double>(
"minimumTransverseMomentum", 1.0);
450 desc.add<
double>(
"maximumLongitudinalImpactParameter", 17.0);
451 desc.add<
bool>(
"computeGhostTrack",
true);
452 desc.add<
double>(
"ghostTrackPriorDeltaR", 0.03);
454 desc.add<
bool>(
"jetDirectionUsingGhostTrack",
false);
455 desc.add<
int>(
"minimumNumberOfPixelHits", 2);
456 desc.add<
bool>(
"jetDirectionUsingTracks",
false);
457 desc.add<
bool>(
"computeProbabilities",
true);
458 desc.add<
bool>(
"useTrackQuality",
false);
459 desc.add<
double>(
"maximumChiSquared", 5.0);
468 desc.add<
double>(
"maximumTransverseImpactParameter", 0.2);
469 desc.add<
int>(
"minimumNumberOfHits", 8);
470 desc.add<
double>(
"minimumTransverseMomentum", 1.0);
472 desc.add<
double>(
"maximumLongitudinalImpactParameter", 17.0);
473 desc.add<
bool>(
"computeGhostTrack",
true);
474 desc.add<
double>(
"maxDeltaR", 0.4);
476 desc.add<
bool>(
"jetDirectionUsingGhostTrack",
false);
477 desc.add<
int>(
"minimumNumberOfPixelHits", 2);
478 desc.add<
bool>(
"jetDirectionUsingTracks",
false);
479 desc.add<
bool>(
"computeProbabilities",
true);
480 desc.add<
bool>(
"useTrackQuality",
false);
482 desc.add<
double>(
"ghostTrackPriorDeltaR", 0.03);
483 desc.add<
double>(
"maximumChiSquared", 5.0);
484 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
int closest(std::vector< int > const &vec, int value)
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
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)
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
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