CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
TrackIPProducer Class Reference

#include <RecoBTau/TrackIPProducer/src/TrackIPProducer.cc>

Inheritance diagram for TrackIPProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)
 
 TrackIPProducer (const edm::ParameterSet &)
 
 ~TrackIPProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

void checkEventSetup (const edm::EventSetup &iSetup)
 

Private Attributes

edm::InputTag m_associator
 
unsigned long long m_calibrationCacheId2D
 
unsigned long long m_calibrationCacheId3D
 
bool m_computeGhostTrack
 
bool m_computeProbabilities
 
const edm::ParameterSetm_config
 
double m_cutMaxChiSquared
 
double m_cutMaxLIP
 
double m_cutMaxTIP
 
double m_cutMinPt
 
int m_cutPixelHits
 
int m_cutTotalHits
 
bool m_directionWithGhostTrack
 
bool m_directionWithTracks
 
double m_ghostTrackPriorDeltaR
 
edm::InputTag m_primaryVertexProducer
 
std::auto_ptr
< HistogramProbabilityEstimator
m_probabilityEstimator
 
bool m_useDB
 
bool m_useTrackQuality
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 14 of file TrackIPProducer.h.

Constructor & Destructor Documentation

TrackIPProducer::TrackIPProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 64 of file TrackIPProducer.cc.

References edm::ParameterSet::getParameter(), m_associator, m_calibrationCacheId2D, m_calibrationCacheId3D, m_computeGhostTrack, m_computeProbabilities, m_config, m_cutMaxChiSquared, m_cutMaxLIP, m_cutMaxTIP, m_cutMinPt, m_cutPixelHits, m_cutTotalHits, m_directionWithGhostTrack, m_directionWithTracks, m_ghostTrackPriorDeltaR, m_primaryVertexProducer, and m_useTrackQuality.

64  :
65  m_config(iConfig)
66 {
69 
72  m_computeProbabilities = m_config.getParameter<bool>("computeProbabilities");
73  m_computeGhostTrack = m_config.getParameter<bool>("computeGhostTrack");
74  m_ghostTrackPriorDeltaR = m_config.getParameter<double>("ghostTrackPriorDeltaR");
75  m_cutPixelHits = m_config.getParameter<int>("minimumNumberOfPixelHits");
76  m_cutTotalHits = m_config.getParameter<int>("minimumNumberOfHits");
77  m_cutMaxTIP = m_config.getParameter<double>("maximumTransverseImpactParameter");
78  m_cutMinPt = m_config.getParameter<double>("minimumTransverseMomentum");
79  m_cutMaxChiSquared = m_config.getParameter<double>("maximumChiSquared");
80  m_cutMaxLIP = m_config.getParameter<double>("maximumLongitudinalImpactParameter");
81  m_directionWithTracks = m_config.getParameter<bool>("jetDirectionUsingTracks");
82  m_directionWithGhostTrack = m_config.getParameter<bool>("jetDirectionUsingGhostTrack");
83  m_useTrackQuality = m_config.getParameter<bool>("useTrackQuality");
84 
85  if (m_computeGhostTrack)
86  produces<reco::TrackCollection>("ghostTracks");
87  produces<reco::TrackIPTagInfoCollection>();
88 }
T getParameter(std::string const &) const
double m_ghostTrackPriorDeltaR
double m_cutMaxChiSquared
unsigned long long m_calibrationCacheId2D
edm::InputTag m_associator
const edm::ParameterSet & m_config
bool m_directionWithGhostTrack
unsigned long long m_calibrationCacheId3D
edm::InputTag m_primaryVertexProducer
TrackIPProducer::~TrackIPProducer ( )

Definition at line 90 of file TrackIPProducer.cc.

91 {
92 }

Member Function Documentation

void TrackIPProducer::checkEventSetup ( const edm::EventSetup iSetup)
private

Definition at line 291 of file TrackIPProducer.cc.

References edm::eventsetup::EventSetupRecord::cacheIdentifier(), edm::EventSetup::get(), m_calibrationCacheId2D, m_calibrationCacheId3D, m_probabilityEstimator, and edm::ESHandle< class >::product().

Referenced by produce().

292  {
293  using namespace edm;
294  using namespace edm::eventsetup;
295 
296  const EventSetupRecord & re2D= iSetup.get<BTagTrackProbability2DRcd>();
297  const EventSetupRecord & re3D= iSetup.get<BTagTrackProbability3DRcd>();
298  unsigned long long cacheId2D= re2D.cacheIdentifier();
299  unsigned long long cacheId3D= re3D.cacheIdentifier();
300 
301  if(cacheId2D!=m_calibrationCacheId2D || cacheId3D!=m_calibrationCacheId3D ) //Calibration changed
302  {
303  //iSetup.get<BTagTrackProbabilityRcd>().get(calib);
305  iSetup.get<BTagTrackProbability2DRcd>().get(calib2DHandle);
307  iSetup.get<BTagTrackProbability3DRcd>().get(calib3DHandle);
308 
309  const TrackProbabilityCalibration * ca2D= calib2DHandle.product();
310  const TrackProbabilityCalibration * ca3D= calib3DHandle.product();
311 
313 
314  }
315  m_calibrationCacheId3D=cacheId3D;
316  m_calibrationCacheId2D=cacheId2D;
317 }
unsigned long long cacheIdentifier() const
std::auto_ptr< HistogramProbabilityEstimator > m_probabilityEstimator
unsigned long long m_calibrationCacheId2D
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
unsigned long long m_calibrationCacheId3D
void TrackIPProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 99 of file TrackIPProducer.cc.

References abs, edm::RefVector< C, T, F >::begin(), checkEventSetup(), IPTools::closestApproachToJet(), reco::TrackIPTagInfo::TrackIPData::closestToGhostTrack, reco::TrackIPTagInfo::TrackIPData::closestToJetAxis, RecoVertex::convertError(), RecoVertex::convertPos(), reco::GhostTrackPrediction::direction(), VertexDistance3D::distance(), reco::TrackIPTagInfo::TrackIPData::distanceToGhostTrack, reco::TrackIPTagInfo::TrackIPData::distanceToJetAxis, reco::TrackBase::dxy(), reco::TrackBase::dz(), edm::RefVector< C, T, F >::end(), error, reco::Vertex::error(), reco::TransientTrack::field(), reco::GhostTrackFitter::fit(), edm::EventSetup::get(), edm::Event::getByLabel(), edm::Event::getRefBeforePut(), ghostTrackES_cfi::ghostTrack, reco::TrackIPTagInfo::TrackIPData::ghostTrackWeight, TrajectoryStateOnSurface::globalPosition(), reco::TrackBase::hitPattern(), i, reco::TransientTrack::impactPointState(), reco::TrackIPTagInfo::TrackIPData::ip2d, reco::TrackIPTagInfo::TrackIPData::ip3d, TrajectoryStateOnSurface::isValid(), IPTools::jetTrackDistance(), reco::GhostTrackPrediction::lambda(), m_associator, m_computeGhostTrack, m_computeProbabilities, m_cutMaxChiSquared, m_cutMaxLIP, m_cutMaxTIP, m_cutMinPt, m_cutPixelHits, m_cutTotalHits, m_directionWithGhostTrack, m_directionWithTracks, m_ghostTrackPriorDeltaR, m_primaryVertexProducer, m_probabilityEstimator, m_useTrackQuality, reco::TrackBase::normalizedChi2(), reco::HitPattern::numberOfValidHits(), reco::HitPattern::numberOfValidPixelHits(), L1TEmulatorMonitor_cff::p, p1, p2, pos, reco::GhostTrackPrediction::position(), reco::Vertex::position(), reco::GhostTrackPrediction::positionError(), reco::GhostTrackPrediction::prediction(), reco::TrackBase::pt(), edm::RefVector< C, T, F >::push_back(), edm::Event::put(), query::result, IPTools::signedImpactParameter3D(), IPTools::signedTransverseImpactParameter(), and testEve_cfg::tracks.

100 {
101  // Update probability estimator if event setup is changed
103  checkEventSetup(iSetup);
104 
105  //input objects
107  iEvent.getByLabel(m_associator, jetTracksAssociation);
108 
109  Handle<reco::VertexCollection> primaryVertex;
110  iEvent.getByLabel(m_primaryVertexProducer, primaryVertex);
111 
113  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
114  // m_algo.setTransientTrackBuilder(builder.product());
115 
116  // output collections
117  auto_ptr<reco::TrackIPTagInfoCollection> result(new reco::TrackIPTagInfoCollection);
118 
119  auto_ptr<reco::TrackCollection> ghostTracks;
120  TrackRefProd ghostTrackRefProd;
121  if (m_computeGhostTrack) {
122  ghostTracks.reset(new reco::TrackCollection);
123  ghostTrackRefProd = iEvent.getRefBeforePut<TrackCollection>("ghostTracks");
124  }
125 
126  // use first pv of the collection
127  Vertex dummy;
128  const Vertex *pv = &dummy;
130  if (primaryVertex->size() != 0) {
131  pv = &*primaryVertex->begin();
132  // we always use the first vertex (at the moment)
133  pvRef = edm::Ref<VertexCollection>(primaryVertex, 0);
134  } else { // create a dummy PV
135  Vertex::Error e;
136  e(0, 0) = 0.0015 * 0.0015;
137  e(1, 1) = 0.0015 * 0.0015;
138  e(2, 2) = 15. * 15.;
139  Vertex::Point p(0, 0, 0);
140  dummy = Vertex(p, e, 0, 0, 0);
141  }
142 
143  int i = 0;
145  jetTracksAssociation->begin();
146  it != jetTracksAssociation->end(); it++, i++) {
147  TrackRefVector tracks = it->second;
148  math::XYZVector jetMomentum = it->first->momentum();
149 
150  if (m_directionWithTracks) {
151  jetMomentum *= 0.5;
152  for(TrackRefVector::const_iterator itTrack = tracks.begin();
153  itTrack != tracks.end(); ++itTrack)
154  if ((**itTrack).numberOfValidHits() >= m_cutTotalHits)
155  //minimal quality cuts
156  jetMomentum += (*itTrack)->momentum();
157  }
158 
159  TrackRefVector selectedTracks;
160  vector<TransientTrack> transientTracks;
161 
162  for(TrackRefVector::const_iterator itTrack = tracks.begin();
163  itTrack != tracks.end(); ++itTrack) {
164  const Track & track = **itTrack;
165  TransientTrack transientTrack = builder->build(*itTrack);
166 /* cout << " pt " << track.pt() <<
167  " d0 " << fabs(track.d0()) <<
168  " #hit " << track.hitPattern().numberOfValidHits()<<
169  " ipZ " << fabs(track.dz()-pvZ)<<
170  " chi2 " << track.normalizedChi2()<<
171  " #pixel " << track.hitPattern().numberOfValidPixelHits()<< endl;
172 */
173  if (track.pt() > m_cutMinPt &&
174  track.hitPattern().numberOfValidHits() >= m_cutTotalHits && // min num tracker hits
177  std::abs(track.dxy(pv->position())) < m_cutMaxTIP &&
178  std::abs(track.dz(pv->position())) < m_cutMaxLIP) {
179  selectedTracks.push_back(*itTrack);
180  transientTracks.push_back(transientTrack);
181  }
182  }
183 
184  GlobalVector direction(jetMomentum.x(), jetMomentum.y(), jetMomentum.z());
185 
186  auto_ptr<GhostTrack> ghostTrack;
187  TrackRef ghostTrackRef;
188  if (m_computeGhostTrack) {
189  GhostTrackFitter fitter;
192  ghostTrack.reset(new GhostTrack(fitter.fit(origin, error, direction,
194  transientTracks)));
195 
196  ghostTrackRef = TrackRef(ghostTrackRefProd, ghostTracks->size());
197  ghostTracks->push_back(*ghostTrack);
198 
200  const GhostTrackPrediction &pred = ghostTrack->prediction();
201  double lambda = pred.lambda(origin);
202  dummy = Vertex(RecoVertex::convertPos(pred.position(lambda)),
204  0, 0, 0);
205  pv = &dummy;
206  direction = pred.direction();
207  }
208  }
209 
210  vector<float> prob2D, prob3D;
211  vector<TrackIPTagInfo::TrackIPData> ipData;
212 
213  for(unsigned int ind = 0; ind < transientTracks.size(); ind++) {
214  const Track & track = *selectedTracks[ind];
215  const TransientTrack &transientTrack = transientTracks[ind];
216 
218  trackIP.ip3d = IPTools::signedImpactParameter3D(transientTrack, direction, *pv).second;
219  trackIP.ip2d = IPTools::signedTransverseImpactParameter(transientTrack, direction, *pv).second;
220 
221  TrajectoryStateOnSurface closest =
223  *pv, direction,
224  transientTrack.field());
225  if (closest.isValid())
226  trackIP.closestToJetAxis = closest.globalPosition();
227 
228  // TODO: cross check if it is the same using other methods
229  trackIP.distanceToJetAxis = IPTools::jetTrackDistance(transientTrack, direction, *pv).second;
230 
231  if (ghostTrack.get()) {
232  const std::vector<GhostTrackState> &states = ghostTrack->states();
233  std::vector<GhostTrackState>::const_iterator pos =
234  std::find_if(states.begin(), states.end(),
235  bind(equal_to<TransientTrack>(),
236  bind(&GhostTrackState::track, _1),
237  transientTrack));
238 
239  if (pos != states.end() && pos->isValid()) {
240  VertexDistance3D dist;
241  const GhostTrackPrediction &pred = ghostTrack->prediction();
242  GlobalPoint p1 = pos->tsos().globalPosition();
243  GlobalError e1 = pos->tsos().cartesianError().position();
244  GlobalPoint p2 = pred.position(pos->lambda());
245  GlobalError e2 = pred.positionError(pos->lambda());
246  trackIP.closestToGhostTrack = p1;
247  trackIP.distanceToGhostTrack = dist.distance(VertexState(p1, e1),
248  VertexState(p2, e2));
249  trackIP.ghostTrackWeight = pos->weight();
250  } else {
251  trackIP.distanceToGhostTrack = Measurement1D(-1. -1.);
252  trackIP.ghostTrackWeight = 0.;
253  }
254  } else {
255  trackIP.distanceToGhostTrack = Measurement1D(-1. -1.);
256  trackIP.ghostTrackWeight = 1.;
257  }
258 
259  ipData.push_back(trackIP);
260 
262  //probability with 3D ip
263  pair<bool,double> probability = m_probabilityEstimator->probability(m_useTrackQuality, 0,ipData.back().ip3d.significance(),track,*(it->first),*pv);
264  prob3D.push_back(probability.first ? probability.second : -1.);
265 
266  //probability with 2D ip
267  probability = m_probabilityEstimator->probability(m_useTrackQuality,1,ipData.back().ip2d.significance(),track,*(it->first),*pv);
268  prob2D.push_back(probability.first ? probability.second : -1.);
269  }
270  }
271 
272  Ref<JetTracksAssociationCollection> jtaRef(jetTracksAssociation, i);
273  result->push_back(
274  TrackIPTagInfo(ipData, prob2D, prob3D, selectedTracks,
275  jtaRef, pvRef, direction, ghostTrackRef));
276  }
277 
279  iEvent.put(ghostTracks, "ghostTracks");
280  iEvent.put(result);
281 }
virtual Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const
reco::Vertex::Point convertPos(const GlobalPoint &p)
void checkEventSetup(const edm::EventSetup &iSetup)
int i
Definition: DBlmapReader.cc:9
double m_ghostTrackPriorDeltaR
int numberOfValidHits() const
Definition: HitPattern.cc:321
double m_cutMaxChiSquared
double lambda(const GlobalPoint &point) const
transient_vector_type::const_iterator const_iterator
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
Definition: TrackBase.h:111
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:50
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
std::auto_ptr< HistogramProbabilityEstimator > m_probabilityEstimator
#define abs(x)
Definition: mlp_lapack.h:159
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
std::pair< bool, Measurement1D > signedImpactParameter3D(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:71
GlobalPoint globalPosition() const
TrajectoryStateOnSurface closestApproachToJet(const TrajectoryStateOnSurface &state, const reco::Vertex &vertex, const GlobalVector &aJetDirection, const MagneticField *field)
Definition: IPTools.cc:177
const MagneticField * field() const
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:243
const Point & position() const
position
Definition: Vertex.h:93
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:238
std::pair< double, Measurement1D > jetTrackDistance(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:200
GhostTrack fit(const GlobalPoint &priorPosition, const GlobalError &priorError, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
double pt() const
track transverse momentum
Definition: TrackBase.h:131
tuple result
Definition: query.py:137
int numberOfValidPixelHits() const
Definition: HitPattern.cc:359
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:223
double p2[4]
Definition: TauolaWrapper.h:90
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
RefProd< PROD > getRefBeforePut()
Definition: Event.h:96
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...
Definition: TrackBase.h:127
tuple tracks
Definition: testEve_cfg.py:39
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
const T & get() const
Definition: EventSetup.h:55
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
edm::InputTag m_associator
Error error() const
return SMatrix
Definition: Vertex.h:116
const Vector & prediction() const
bool m_directionWithGhostTrack
double p1[4]
Definition: TauolaWrapper.h:89
GlobalPoint position(double lambda=0.) const
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:60
TrajectoryStateOnSurface impactPointState() const
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:121
edm::InputTag m_primaryVertexProducer
GlobalError positionError(double lambda=0.) const
const GlobalVector direction() const

Member Data Documentation

edm::InputTag TrackIPProducer::m_associator
private

Definition at line 25 of file TrackIPProducer.h.

Referenced by produce(), and TrackIPProducer().

unsigned long long TrackIPProducer::m_calibrationCacheId2D
private

Definition at line 31 of file TrackIPProducer.h.

Referenced by checkEventSetup(), and TrackIPProducer().

unsigned long long TrackIPProducer::m_calibrationCacheId3D
private

Definition at line 32 of file TrackIPProducer.h.

Referenced by checkEventSetup(), and TrackIPProducer().

bool TrackIPProducer::m_computeGhostTrack
private

Definition at line 28 of file TrackIPProducer.h.

Referenced by produce(), and TrackIPProducer().

bool TrackIPProducer::m_computeProbabilities
private

Definition at line 27 of file TrackIPProducer.h.

Referenced by produce(), and TrackIPProducer().

const edm::ParameterSet& TrackIPProducer::m_config
private

Definition at line 24 of file TrackIPProducer.h.

Referenced by TrackIPProducer().

double TrackIPProducer::m_cutMaxChiSquared
private

Definition at line 39 of file TrackIPProducer.h.

Referenced by produce(), and TrackIPProducer().

double TrackIPProducer::m_cutMaxLIP
private

Definition at line 40 of file TrackIPProducer.h.

Referenced by produce(), and TrackIPProducer().

double TrackIPProducer::m_cutMaxTIP
private

Definition at line 37 of file TrackIPProducer.h.

Referenced by produce(), and TrackIPProducer().

double TrackIPProducer::m_cutMinPt
private

Definition at line 38 of file TrackIPProducer.h.

Referenced by produce(), and TrackIPProducer().

int TrackIPProducer::m_cutPixelHits
private

Definition at line 35 of file TrackIPProducer.h.

Referenced by produce(), and TrackIPProducer().

int TrackIPProducer::m_cutTotalHits
private

Definition at line 36 of file TrackIPProducer.h.

Referenced by produce(), and TrackIPProducer().

bool TrackIPProducer::m_directionWithGhostTrack
private

Definition at line 42 of file TrackIPProducer.h.

Referenced by produce(), and TrackIPProducer().

bool TrackIPProducer::m_directionWithTracks
private

Definition at line 41 of file TrackIPProducer.h.

Referenced by produce(), and TrackIPProducer().

double TrackIPProducer::m_ghostTrackPriorDeltaR
private

Definition at line 29 of file TrackIPProducer.h.

Referenced by produce(), and TrackIPProducer().

edm::InputTag TrackIPProducer::m_primaryVertexProducer
private

Definition at line 26 of file TrackIPProducer.h.

Referenced by produce(), and TrackIPProducer().

std::auto_ptr<HistogramProbabilityEstimator> TrackIPProducer::m_probabilityEstimator
private

Definition at line 30 of file TrackIPProducer.h.

Referenced by checkEventSetup(), and produce().

bool TrackIPProducer::m_useDB
private

Definition at line 33 of file TrackIPProducer.h.

bool TrackIPProducer::m_useTrackQuality
private

Definition at line 43 of file TrackIPProducer.h.

Referenced by produce(), and TrackIPProducer().