1 #ifndef RecoBTag_IPProducer
2 #define RecoBTag_IPProducer
10 #include "boost/bind.hpp"
59 namespace IPProducerHelpers {
70 iEvent.
getByToken(token_associator, jetTracksAssociation);
71 std::vector<reco::JTATagInfo> bases;
74 jetTracksAssociation->begin();
75 it != jetTracksAssociation->end(); it++, i++) {
87 token_cands(iC.consumes<edm::
View<
reco::
Candidate> >(iConfig.getParameter<edm::
InputTag>(
"candidates"))), maxDeltaR(iConfig.getParameter<double>(
"maxDeltaR")),
88 explicitJTA(iConfig.existsAs<bool>(
"explicitJTA") ? iConfig.getParameter<bool>(
"explicitJTA") :
false) {}
92 return m_map[it.
jet().
key()];
97 std::vector<reco::JetTagInfo> bases;
102 m_map.resize(jets->size());
103 double maxDeltaR2 = maxDeltaR*maxDeltaR;
106 it != jets->end(); it++, i++) {
111 for(
size_t j=0;
j<it->numberOfDaughters();++
j) {
112 if( it->daughterPtr(
j)->bestTrack()!=0 && it->daughterPtr(
j)->charge() !=0 ){
113 m_map[
i].push_back(it->daughterPtr(
j));
119 for(
size_t j=0;
j<cands->size();++
j) {
120 if( (*cands)[
j].bestTrack()!=0 &&
Geom::deltaR2((*cands)[
j].
p4(),(*jets)[i].
p4()) < maxDeltaR2 && (*cands)[
j].charge() !=0 ){
121 m_map[
i].push_back(cands->ptrAt(
j));
128 std::vector<std::vector<reco::CandidatePtr> >
m_map;
135 template <
class Container,
class Base,
class Helper>
138 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 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;
269 dummy =
Vertex(p, e, 0, 0, 0);
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 vector<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 auto_ptr<GhostTrack> ghostTrack;
315 if (m_computeGhostTrack) {
319 ghostTrack.reset(
new GhostTrack(fitter.
fit(origin, error, direction,
320 m_ghostTrackPriorDeltaR,
339 ghostTrackRef =
TrackRef(ghostTrackRefProd, ghostTracks->size());
340 ghostTracks->push_back(*ghostTrack);
342 if (m_directionWithGhostTrack) {
344 double lambda = pred.
lambda(origin);
353 vector<float> prob2D, prob3D;
354 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<GhostTrackState> &
states = ghostTrack->states();
376 std::vector<GhostTrackState>::const_iterator pos =
377 std::find_if(states.begin(), states.end(),
378 bind(equal_to<TransientTrack>(),
379 bind(&GhostTrackState::track, _1),
382 if (pos != states.end() && pos->isValid()) {
386 GlobalError e1 = pos->tsos().cartesianError().position();
402 ipData.push_back(trackIP);
404 if (m_computeProbabilities) {
406 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;
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
bool m_directionWithGhostTrack
virtual edm::RefToBase< Jet > jet(void) const
returns a polymorphic reference to the tagged jet
EcalChannelStatus Container
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)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
int numberOfValidHits() const
Base class for all types of 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)
std::vector< reco::CandidatePtr > tracks(edm::Event &, const reco::JetTagInfo &it)
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< reco::JetTagInfo > makeBaseVector(edm::Event &iEvent)
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)
Measurement1D distanceToGhostTrack
FromJTA(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
reco::TrackRefVector tracks(edm::Event &, const reco::JTATagInfo &it)
double pt() const
track transverse momentum
Abs< T >::type abs(const T &t)
edm::EDGetTokenT< reco::VertexCollection > token_primaryVertex
double deltaR2(const T1 &t1, const T2 &t2)
math::XYZPoint Point
point in the space
edm::EDGetTokenT< JetTracksAssociationCollection > token_associator
unsigned short numberOfValidHits() const
number of valid hits found
Container::value_type value_type
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
const Vector & prediction() const
virtual void produce(edm::Event &, const edm::EventSetup &)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
FromJetAndCands(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
IPProducer(const edm::ParameterSet &)
GlobalPoint position(double lambda=0.) const
GlobalPoint closestToGhostTrack
edm::EDGetTokenT< edm::View< reco::Candidate > > token_cands
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...
std::vector< reco::JTATagInfo > makeBaseVector(edm::Event &iEvent)
GlobalError positionError(double lambda=0.) const
const GlobalVector direction() const