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) {
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)
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);
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);