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")){}
91 return m_map[it.
jet().
key()];
96 std::vector<reco::JetTagInfo> bases;
101 m_map.resize(jets->size());
104 it != jets->end(); it++, i++) {
106 bases.push_back(jRef);
108 for(
size_t j=0;
j<cands->size();
j++) {
109 if((*cands)[
j].bestTrack()!=0 && ROOT::Math::VectorUtil::DeltaR((*cands)[
j].
p4(),(*jets)[i].
p4()) < maxDeltaR && (*cands)[
j].charge() !=0 ){
110 m_map[
i].push_back(cands->ptrAt(
j));
116 std::vector<std::vector<reco::CandidatePtr> >
m_map;
122 template <
class Container,
class Base,
class Helper>
125 typedef std::vector<reco::IPTagInfo<Container,Base> >
Product;
184 m_config(iConfig),m_helper(iConfig,consumesCollector())
204 if (m_computeGhostTrack)
205 produces<reco::TrackCollection>(
"ghostTracks");
217 template <
class Container,
class Base,
class Helper>
void
221 if (m_computeProbabilities)
222 checkEventSetup(iSetup);
226 iEvent.
getByToken(token_primaryVertex, primaryVertex);
235 auto_ptr<reco::TrackCollection> ghostTracks;
237 if (m_computeGhostTrack) {
244 const Vertex *pv = &dummy;
246 if (primaryVertex->size() != 0) {
247 pv = &*primaryVertex->begin();
252 e(0, 0) = 0.0015 * 0.0015;
253 e(1, 1) = 0.0015 * 0.0015;
256 dummy =
Vertex(p, e, 0, 0, 0);
259 std::vector<Base> baseTagInfos = m_helper.makeBaseVector(iEvent);
260 for(
typename std::vector<Base>::const_iterator it = baseTagInfos.begin(); it != baseTagInfos.end(); it++) {
264 if (m_directionWithTracks) {
266 for(
typename Container::const_iterator itTrack = tracks.begin();
267 itTrack != tracks.end(); ++itTrack)
269 jetMomentum += (*itTrack)->momentum();
273 vector<TransientTrack> transientTracks;
275 for(
typename Container::const_iterator itTrack = tracks.begin();
276 itTrack != tracks.end(); ++itTrack) {
286 if (track.
pt() > m_cutMinPt &&
293 selectedTracks.push_back(*itTrack);
294 transientTracks.push_back(transientTrack);
298 GlobalVector direction(jetMomentum.x(), jetMomentum.y(), jetMomentum.z());
302 if (m_computeGhostTrack) {
306 ghostTrack.reset(
new GhostTrack(fitter.
fit(origin, error, direction,
307 m_ghostTrackPriorDeltaR,
326 ghostTrackRef =
TrackRef(ghostTrackRefProd, ghostTracks->size());
327 ghostTracks->push_back(*ghostTrack);
329 if (m_directionWithGhostTrack) {
331 double lambda = pred.
lambda(origin);
340 vector<float> prob2D, prob3D;
341 vector<reco::btag::TrackIPData> ipData;
343 for(
unsigned int ind = 0; ind < transientTracks.size(); ind++) {
354 transientTrack.
field());
361 if (ghostTrack.get()) {
362 const std::vector<GhostTrackState> &
states = ghostTrack->states();
363 std::vector<GhostTrackState>::const_iterator pos =
364 std::find_if(states.begin(), states.end(),
365 bind(equal_to<TransientTrack>(),
366 bind(&GhostTrackState::track, _1),
369 if (pos != states.end() && pos->isValid()) {
373 GlobalError e1 = pos->tsos().cartesianError().position();
389 ipData.push_back(trackIP);
391 if (m_computeProbabilities) {
393 pair<bool,double> probability = m_probabilityEstimator->probability(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(m_useTrackQuality,1,ipData.back().ip2d.significance(),track,*(it->jet()),*pv);
398 prob2D.push_back(probability.first ? probability.second : -1.);
403 *it, pvRef, direction, ghostTrackRef));
406 if (m_computeGhostTrack)
407 iEvent.
put(ghostTracks,
"ghostTracks");
422 using namespace edm::eventsetup;
427 unsigned long long cacheId3D= re3D.cacheIdentifier();
429 if(cacheId2D!=m_calibrationCacheId2D || cacheId3D!=m_calibrationCacheId3D )
443 m_calibrationCacheId3D=cacheId3D;
444 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
const reco::Track * toTrack(const reco::TrackRef &t)
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
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
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
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