1 #ifndef RecoBTag_IPProducer
2 #define RecoBTag_IPProducer
10 #include "boost/bind.hpp"
58 namespace IPProducerHelpers {
70 std::vector<reco::JTATagInfo> bases;
73 jetTracksAssociation->begin();
74 it != jetTracksAssociation->end(); it++, i++) {
87 explicitJTA(iConfig.existsAs<bool>(
"explicitJTA") ? iConfig.getParameter<bool>(
"explicitJTA") :
false) {}
96 std::vector<reco::JetTagInfo> bases;
101 m_map.resize(jets->size());
105 it != jets->end(); it++, i++) {
110 for(
size_t j=0;
j<it->numberOfDaughters();++
j) {
111 if( it->daughterPtr(
j)->bestTrack()!=0 && it->daughterPtr(
j)->charge() !=0 ){
112 m_map[
i].push_back(it->daughterPtr(
j));
118 for(
size_t j=0;
j<cands->size();++
j) {
119 if( (*cands)[
j].bestTrack()!=0 && (*cands)[
j].charge() !=0 &&
Geom::deltaR2((*cands)[
j],(*jets)[i]) < maxDeltaR2 ){
120 m_map[
i].push_back(cands->ptrAt(j));
127 std::vector<std::vector<reco::CandidatePtr> >
m_map;
134 template <
class Container,
class Base,
class Helper>
137 typedef std::vector<reco::IPTagInfo<Container,Base> >
Product;
197 m_config(iConfig),m_helper(iConfig,consumesCollector())
217 if (m_computeGhostTrack)
218 produces<reco::TrackCollection>(
"ghostTracks");
230 template <
class Container,
class Base,
class Helper>
void
234 if (m_computeProbabilities)
235 checkEventSetup(iSetup);
239 iEvent.
getByToken(token_primaryVertex, primaryVertex);
248 std::auto_ptr<reco::TrackCollection> ghostTracks;
250 if (m_computeGhostTrack) {
259 if (primaryVertex->size() != 0) {
260 pv = &*primaryVertex->begin();
265 e(0, 0) = 0.0015 * 0.0015;
266 e(1, 1) = 0.0015 * 0.0015;
272 std::vector<Base> baseTagInfos = m_helper.makeBaseVector(iEvent);
273 for(
typename std::vector<Base>::const_iterator it = baseTagInfos.begin(); it != baseTagInfos.end(); it++) {
277 if (m_directionWithTracks) {
279 for(
typename Container::const_iterator itTrack = tracks.begin();
280 itTrack != tracks.end(); ++itTrack)
282 jetMomentum += (*itTrack)->momentum();
286 std::vector<reco::TransientTrack> transientTracks;
288 for(
typename Container::const_iterator itTrack = tracks.begin();
289 itTrack != tracks.end(); ++itTrack) {
299 if (track.
pt() > m_cutMinPt &&
306 selectedTracks.push_back(*itTrack);
307 transientTracks.push_back(transientTrack);
311 GlobalVector direction(jetMomentum.x(), jetMomentum.y(), jetMomentum.z());
313 std::auto_ptr<reco::GhostTrack> ghostTrack;
315 if (m_computeGhostTrack) {
320 m_ghostTrackPriorDeltaR,
339 ghostTrackRef =
reco::TrackRef(ghostTrackRefProd, ghostTracks->size());
340 ghostTracks->push_back(*ghostTrack);
342 if (m_directionWithGhostTrack) {
344 double lambda = pred.
lambda(origin);
353 std::vector<float> prob2D, prob3D;
354 std::vector<reco::btag::TrackIPData> ipData;
356 for(
unsigned int ind = 0; ind < transientTracks.size(); ind++) {
367 transientTrack.
field());
374 if (ghostTrack.get()) {
375 const std::vector<reco::GhostTrackState> &states = ghostTrack->states();
376 std::vector<reco::GhostTrackState>::const_iterator pos =
377 std::find_if(states.begin(), states.end(),
378 bind(std::equal_to<reco::TransientTrack>(),
382 if (pos != states.end() && pos->isValid()) {
402 ipData.push_back(trackIP);
404 if (m_computeProbabilities) {
406 std::pair<bool,double> probability = m_probabilityEstimator->probability(m_useTrackQuality, 0,ipData.back().ip3d.significance(),track,*(it->jet()),*pv);
407 prob3D.push_back(probability.first ? probability.second : -1.);
410 probability = m_probabilityEstimator->probability(m_useTrackQuality,1,ipData.back().ip2d.significance(),track,*(it->jet()),*pv);
411 prob2D.push_back(probability.first ? probability.second : -1.);
416 *it, pvRef, direction, ghostTrackRef));
419 if (m_computeGhostTrack)
420 iEvent.
put(ghostTracks,
"ghostTracks");
435 using namespace edm::eventsetup;
440 unsigned long long cacheId3D= re3D.cacheIdentifier();
442 if(cacheId2D!=m_calibrationCacheId2D || cacheId3D!=m_calibrationCacheId3D )
456 m_calibrationCacheId3D=cacheId3D;
457 m_calibrationCacheId2D=cacheId2D;
466 desc.
add<
double>(
"maximumTransverseImpactParameter",0.2);
467 desc.
add<
int>(
"minimumNumberOfHits",8);
468 desc.
add<
double>(
"minimumTransverseMomentum",1.0);
470 desc.
add<
double>(
"maximumLongitudinalImpactParameter",17.0);
471 desc.
add<
bool>(
"computeGhostTrack",
true);
472 desc.
add<
double>(
"ghostTrackPriorDeltaR",0.03);
474 desc.
add<
bool>(
"jetDirectionUsingGhostTrack",
false);
475 desc.
add<
int>(
"minimumNumberOfPixelHits",2);
476 desc.
add<
bool>(
"jetDirectionUsingTracks",
false);
477 desc.
add<
bool>(
"computeProbabilities",
true);
478 desc.
add<
bool>(
"useTrackQuality",
false);
479 desc.
add<
double>(
"maximumChiSquared",5.0);
487 desc.
add<
double>(
"maximumTransverseImpactParameter",0.2);
488 desc.
add<
int>(
"minimumNumberOfHits",8);
489 desc.
add<
double>(
"minimumTransverseMomentum",1.0);
491 desc.
add<
double>(
"maximumLongitudinalImpactParameter",17.0);
492 desc.
add<
bool>(
"computeGhostTrack",
true);
493 desc.
add<
double>(
"maxDeltaR",0.4);
495 desc.
add<
bool>(
"jetDirectionUsingGhostTrack",
false);
496 desc.
add<
int>(
"minimumNumberOfPixelHits",2);
497 desc.
add<
bool>(
"jetDirectionUsingTracks",
false);
498 desc.
add<
bool>(
"computeProbabilities",
true);
499 desc.
add<
bool>(
"useTrackQuality",
false);
501 desc.
add<
double>(
"ghostTrackPriorDeltaR",0.03);
502 desc.
add<
double>(
"maximumChiSquared",5.0);
virtual Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const
reco::Vertex::Point convertPos(const GlobalPoint &p)
T getParameter(std::string const &) const
unsigned long long cacheIdentifier() const
double m_cutMaxChiSquared
std::vector< reco::JTATagInfo > makeBaseVector(const edm::Event &iEvent)
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
bool m_directionWithGhostTrack
virtual edm::RefToBase< Jet > jet(void) const
returns a polymorphic reference to the tagged jet
double lambda(const GlobalPoint &point) const
transient_vector_type::const_iterator const_iterator
unsigned long long m_calibrationCacheId3D
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
const TransientTrack & track() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
int numberOfValidHits() const
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
math::Error< dimension >::type Error
covariance error matrix (3x3)
GlobalPoint globalPosition() const
const MagneticField * field() const
std::auto_ptr< HistogramProbabilityEstimator > m_probabilityEstimator
const reco::Track * toTrack(const reco::TrackBaseRef &t)
const Point & position() const
position
std::vector< reco::IPTagInfo< Container, Base > > Product
double m_ghostTrackPriorDeltaR
GhostTrack fit(const GlobalPoint &priorPosition, const GlobalError &priorError, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
std::vector< std::vector< reco::CandidatePtr > > m_map
virtual TrackRefVector tracks(void) const
returns a list of tracks associated to the jet
void checkEventSetup(const edm::EventSetup &iSetup)
const std::vector< reco::CandidatePtr > & tracks(const reco::JetTagInfo &it)
Container::value_type value_type
void addDefault(ParameterSetDescription const &psetDescription)
Measurement1D distanceToGhostTrack
FromJTA(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
double pt() const
track transverse momentum
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
unsigned short numberOfValidHits() const
number of valid hits found
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< reco::JetTracksAssociationCollection > token_associator
bool m_directionWithTracks
RefProd< PROD > getRefBeforePut()
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
const edm::ParameterSet & m_config
GlobalPoint closestToJetAxis
const Track & track() const
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
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
T const * product() const
Error error() const
return SMatrix
Measurement1D distanceToJetAxis
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
const Vector & prediction() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void produce(edm::Event &, const edm::EventSetup &)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
IPProducer(const edm::ParameterSet &)
GlobalPoint position(double lambda=0.) const
GlobalPoint closestToGhostTrack
edm::EDGetTokenT< edm::View< reco::Candidate > > token_cands
std::vector< reco::JetTagInfo > makeBaseVector(const edm::Event &iEvent)
int numberOfValidPixelHits() const
TrajectoryStateOnSurface impactPointState() const
bool m_computeProbabilities
volatile std::atomic< bool > shutdown_flag false
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
edm::AssociationVector< reco::JetRefBaseProd, Values > Container
GlobalError positionError(double lambda=0.) const
const GlobalVector direction() const