CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TrackVertexArbitration< VTX > Class Template Reference

#include <TrackVertexArbitration.h>

Public Member Functions

 TrackVertexArbitration (const edm::ParameterSet &params)
 
std::vector< VTX > trackVertexArbitrator (edm::Handle< reco::BeamSpot > &beamSpot, const reco::Vertex &pv, std::vector< reco::TransientTrack > &selectedTracks, std::vector< VTX > &secondaryVertices)
 

Private Member Functions

bool trackFilterArbitrator (const reco::TransientTrack &track) const
 

Private Attributes

edm::InputTag beamSpotCollection
 
double distCut
 
double dLenFraction
 
double dRCut
 
double fitterRatio
 
double fitterSigmacut
 
double fitterTini
 
double maxTimeSignificance
 
edm::InputTag primaryVertexCollection
 
edm::InputTag secondaryVertexCollection
 
double sigCut
 
edm::InputTag trackCollection
 
int trackMinLayers
 
int trackMinPixels
 
double trackMinPt
 

Detailed Description

template<class VTX>
class TrackVertexArbitration< VTX >

Definition at line 58 of file TrackVertexArbitration.h.

Constructor & Destructor Documentation

template<class VTX >
TrackVertexArbitration< VTX >::TrackVertexArbitration ( const edm::ParameterSet params)

Definition at line 93 of file TrackVertexArbitration.h.

References TrackVertexArbitration< VTX >::dRCut.

93  :
94  primaryVertexCollection (params.getParameter<edm::InputTag>("primaryVertices")),
95  secondaryVertexCollection (params.getParameter<edm::InputTag>("secondaryVertices")),
96  trackCollection (params.getParameter<edm::InputTag>("tracks")),
97  beamSpotCollection (params.getParameter<edm::InputTag>("beamSpot")),
98  dRCut (params.getParameter<double>("dRCut")),
99  distCut (params.getParameter<double>("distCut")),
100  sigCut (params.getParameter<double>("sigCut")),
101  dLenFraction (params.getParameter<double>("dLenFraction")),
102  fitterSigmacut (params.getParameter<double>("fitterSigmacut")),
103  fitterTini (params.getParameter<double>("fitterTini")),
104  fitterRatio (params.getParameter<double>("fitterRatio")),
105  trackMinLayers (params.getParameter<int32_t>("trackMinLayers")),
106  trackMinPt (params.getParameter<double>("trackMinPt")),
107  trackMinPixels (params.getParameter<int32_t>("trackMinPixels")),
108  maxTimeSignificance (params.getParameter<double>("maxTimeSignificance"))
109 {
110  dRCut*=dRCut;
111 }
T getParameter(std::string const &) const
edm::InputTag secondaryVertexCollection

Member Function Documentation

template<class VTX >
bool TrackVertexArbitration< VTX >::trackFilterArbitrator ( const reco::TransientTrack track) const
private

Definition at line 113 of file TrackVertexArbitration.h.

References reco::TrackBase::hitPattern(), reco::TransientTrack::isValid(), reco::HitPattern::numberOfValidPixelHits(), reco::TrackBase::pt(), reco::TransientTrack::track(), reco::HitPattern::trackerLayersWithMeasurement(), TrackVertexArbitration< VTX >::trackMinLayers, TrackVertexArbitration< VTX >::trackMinPixels, and TrackVertexArbitration< VTX >::trackMinPt.

Referenced by TrackVertexArbitration< VTX >::trackVertexArbitrator().

114 {
115  if(!track.isValid())
116  return false;
118  return false;
119  if (track.track().pt() < trackMinPt)
120  return false;
122  return false;
123 
124  return true;
125 }
bool isValid() const
Make the ReferenceCountingProxy method to check validity public.
int trackerLayersWithMeasurement() const
Definition: HitPattern.cc:518
double pt() const
track transverse momentum
Definition: TrackBase.h:621
const Track & track() const
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:446
int numberOfValidPixelHits() const
Definition: HitPattern.h:838
template<class VTX >
std::vector< VTX > TrackVertexArbitration< VTX >::trackVertexArbitrator ( edm::Handle< reco::BeamSpot > &  beamSpot,
const reco::Vertex pv,
std::vector< reco::TransientTrack > &  selectedTracks,
std::vector< VTX > &  secondaryVertices 
)

Definition at line 150 of file TrackVertexArbitration.h.

References funct::abs(), IPTools::absoluteImpactParameter3D(), RecoVertex::convertError(), RecoVertex::convertPos(), gather_cfg::cout, svhelper::cov33(), deltaR(), reco::deltaR2(), VertexDistance3D::distance(), TrackVertexArbitration< VTX >::distCut, TrackVertexArbitration< VTX >::dLenFraction, PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, TrackVertexArbitration< VTX >::dRCut, reco::TransientTrack::dtErrorExt(), reco::TransientTrack::field(), TrackVertexArbitration< VTX >::fitterRatio, TrackVertexArbitration< VTX >::fitterSigmacut, TrackVertexArbitration< VTX >::fitterTini, reco::TransientTrack::impactPointState(), edm::isFinite(), TransientVertex::isValid(), TrackVertexArbitration< VTX >::maxTimeSignificance, reco::Vertex::position(), funct::pow(), trackingPlots::selectedTracks, reco::TransientTrack::setBeamSpot(), TrackVertexArbitration< VTX >::sigCut, Measurement1D::significance(), mathSSE::sqrt(), reco::TransientTrack::timeExt(), reco::TransientTrack::track(), TrackVertexArbitration< VTX >::trackFilterArbitrator(), trackWeight(), groupFilesInBlocks::tt, svhelper::updateVertexTime(), Measurement1D::value(), AdaptiveVertexFitter::vertex(), and w.

155 {
156  using namespace reco;
157 
158  //std::cout << "PV: " << pv.position() << std::endl;
159  VertexDistance3D dist;
160  AdaptiveVertexFitter theAdaptiveFitter(
166 
167 
168 
169  std::vector<VTX> recoVertices;
170  VertexDistance3D vdist;
171  GlobalPoint ppv(pv.position().x(),pv.position().y(),pv.position().z());
172 
173  std::unordered_map<unsigned int, Measurement1D> cachedIP;
174  for(typename std::vector<VTX>::const_iterator sv = secondaryVertices.begin();
175  sv != secondaryVertices.end(); ++sv) {
176 
177  const double svTime(sv->t()), svTimeCov(svhelper::cov33(*sv));
178  const bool svHasTime = svTimeCov > 0.;
179 
180  GlobalPoint ssv(sv->position().x(),sv->position().y(),sv->position().z());
181  GlobalVector flightDir = ssv-ppv;
182 // std::cout << "Vertex : " << sv-secondaryVertices->begin() << " " << sv->position() << std::endl;
183  Measurement1D dlen= vdist.distance(pv,VertexState(RecoVertex::convertPos(sv->position()),RecoVertex::convertError(sv->error())));
184  std::vector<reco::TransientTrack> selTracks;
185  for(unsigned int itrack = 0; itrack < selectedTracks.size(); itrack++){
186  TransientTrack & tt = (selectedTracks)[itrack];
187  if (!trackFilterArbitrator(tt)) continue;
188  tt.setBeamSpot(*beamSpot);
189  float w = trackWeight(*sv,tt);
190  Measurement1D ipv;
191  if( cachedIP.count(itrack) ) {
192  ipv=cachedIP[itrack];
193  } else {
194  std::pair<bool,Measurement1D> ipvp = IPTools::absoluteImpactParameter3D(tt,pv);
195  cachedIP[itrack]=ipvp.second;
196  ipv=ipvp.second;
197  }
198 
199  AnalyticalImpactPointExtrapolator extrapolator(tt.field());
200  TrajectoryStateOnSurface tsos = extrapolator.extrapolate(tt.impactPointState(), RecoVertex::convertPos(sv->position()));
201  if(! tsos.isValid()) continue;
202  GlobalPoint refPoint = tsos.globalPosition();
203  GlobalError refPointErr = tsos.cartesianError().position();
204  Measurement1D isv = dist.distance(VertexState(RecoVertex::convertPos(sv->position()),RecoVertex::convertError(sv->error())),VertexState(refPoint, refPointErr));
205 
206  float dR = Geom::deltaR2(flightDir,tt.track()); //.eta(), flightDir.phi(), tt.track().eta(), tt.track().phi());
207 
208  double timeSig = 0.;
209  if( svHasTime && edm::isFinite(tt.timeExt()) ) {
210  double tError = std::sqrt( std::pow( tt.dtErrorExt(), 2 ) + svTimeCov );
211  timeSig = std::abs(tt.timeExt() - svTime)/tError;
212  }
213 
214  if( w > 0 || ( isv.significance() < sigCut && isv.value() < distCut && isv.value() < dlen.value()*dLenFraction && timeSig < maxTimeSignificance) )
215  {
216 
217  if(( isv.value() < ipv.value() ) && isv.value() < distCut && isv.value() < dlen.value()*dLenFraction
218  && dR < dRCut && timeSig < maxTimeSignificance )
219  {
220 #ifdef VTXDEBUG
221  if(w > 0.5) std::cout << " = ";
222  else std::cout << " + ";
223 #endif
224  selTracks.push_back(tt);
225  } else
226  {
227 #ifdef VTXDEBUG
228  if(w > 0.5 && isv.value() > ipv.value() ) std::cout << " - ";
229  else std::cout << " ";
230 #endif
231  //add also the tracks used in previous fitting that are still closer to Sv than Pv
232  if(w > 0.5 && isv.value() <= ipv.value() && dR < dRCut && timeSig < maxTimeSignificance) {
233  selTracks.push_back(tt);
234 #ifdef VTXDEBUG
235  std::cout << " = ";
236 #endif
237  }
238  if(w > 0.5 && isv.value() <= ipv.value() && dR >= dRCut) {
239 #ifdef VTXDEBUG
240  std::cout << " - ";
241 #endif
242 
243  }
244 
245 
246  }
247 #ifdef VTXDEBUG
248 
249  std::cout << "t : " << itrack << " ref " << ref.key() << " w: " << w
250  << " svip: " << isv.significance() << " " << isv.value()
251  << " pvip: " << ipv.significance() << " " << ipv.value() << " res " << tt.track().residualX(0) << "," << tt.track().residualY(0)
252 // << " tpvip: " << itpv.second.significance() << " " << itpv.second.value() << " dr: " << dR << std::endl;
253 #endif
254 
255  }
256  else
257  {
258 #ifdef VTXDEBUG
259 
260  std::cout << " . t : " << itrack << " ref " << ref.key()<< " w: " << w
261  << " svip: " << isv.second.significance() << " " << isv.second.value()
262  << " pvip: " << ipv.significance() << " " << ipv.value() << " dr: " << dR << std::endl;
263 #endif
264 
265  }
266  }
267 
268  if(selTracks.size() >= 2)
269  {
270  TransientVertex singleFitVertex;
271  singleFitVertex = theAdaptiveFitter.vertex(selTracks,ssv);
272 
273  if(singleFitVertex.isValid()) {
274  svhelper::updateVertexTime(singleFitVertex);
275  recoVertices.push_back(VTX(singleFitVertex));
276 
277 
278 #ifdef VTXDEBUG
279  const VTX & extVertex = recoVertices.back();
280  GlobalVector vtxDir = GlobalVector(extVertex.p4().X(),extVertex.p4().Y(),extVertex.p4().Z());
281 
282 
283  std::cout << " pointing : " << Geom::deltaR(extVertex.position() - pv.position(), vtxDir) << std::endl;
284 #endif
285  }
286  }
287  }
288  return recoVertices;
289 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
const double w
Definition: UKUtility.cc:23
void setBeamSpot(const reco::BeamSpot &beamSpot)
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
std::pair< bool, Measurement1D > absoluteImpactParameter3D(const reco::TransientTrack &transientTrack, const reco::Vertex &vertex)
Definition: IPTools.cc:37
bool trackFilterArbitrator(const reco::TransientTrack &track) const
double timeExt() const
const MagneticField * field() const
const Point & position() const
position
Definition: Vertex.h:109
bool isFinite(T x)
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
T sqrt(T t)
Definition: SSEVec.h:18
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
double significance() const
Definition: Measurement1D.h:32
const Track & track() const
double dtErrorExt() const
double value() const
Definition: Measurement1D.h:28
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
void updateVertexTime(TransientVertex &vtx)
Definition: SVTimeHelpers.h:11
fixed size matrix
double cov33(const reco::Vertex &sv)
TrajectoryStateOnSurface impactPointState() const
bool isValid() const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
float trackWeight(const reco::Vertex &sv, const reco::TransientTrack &track)
Global3DVector GlobalVector
Definition: GlobalVector.h:10

Member Data Documentation

template<class VTX >
edm::InputTag TrackVertexArbitration< VTX >::beamSpotCollection
private

Definition at line 77 of file TrackVertexArbitration.h.

template<class VTX >
double TrackVertexArbitration< VTX >::distCut
private
template<class VTX >
double TrackVertexArbitration< VTX >::dLenFraction
private
template<class VTX >
double TrackVertexArbitration< VTX >::dRCut
private
template<class VTX >
double TrackVertexArbitration< VTX >::fitterRatio
private
template<class VTX >
double TrackVertexArbitration< VTX >::fitterSigmacut
private
template<class VTX >
double TrackVertexArbitration< VTX >::fitterTini
private
template<class VTX >
double TrackVertexArbitration< VTX >::maxTimeSignificance
private
template<class VTX >
edm::InputTag TrackVertexArbitration< VTX >::primaryVertexCollection
private

Definition at line 74 of file TrackVertexArbitration.h.

template<class VTX >
edm::InputTag TrackVertexArbitration< VTX >::secondaryVertexCollection
private

Definition at line 75 of file TrackVertexArbitration.h.

template<class VTX >
double TrackVertexArbitration< VTX >::sigCut
private
template<class VTX >
edm::InputTag TrackVertexArbitration< VTX >::trackCollection
private

Definition at line 76 of file TrackVertexArbitration.h.

template<class VTX >
int TrackVertexArbitration< VTX >::trackMinLayers
private
template<class VTX >
int TrackVertexArbitration< VTX >::trackMinPixels
private
template<class VTX >
double TrackVertexArbitration< VTX >::trackMinPt
private