CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
reco::GhostTrackVertexFinder Class Reference

#include <GhostTrackVertexFinder.h>

Classes

struct  FinderInfo
 

Public Types

enum  FitType { kAlwaysWithGhostTrack, kSingleTracksWithGhostTrack, kRefitGhostTrackWithVertices }
 

Public Member Functions

 GhostTrackVertexFinder ()
 
 GhostTrackVertexFinder (double maxFitChi2, double mergeThreshold, double primcut, double seccut, FitType fitType)
 
std::vector< TransientVertexvertices (const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
 
std::vector< TransientVertexvertices (const GlobalPoint &primaryPosition, const GlobalError &primaryError, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
 
std::vector< TransientVertexvertices (const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const reco::BeamSpot &beamSpot, const std::vector< TransientTrack > &tracks) const
 
std::vector< TransientVertexvertices (const GlobalPoint &primaryPosition, const GlobalError &primaryError, const GlobalVector &direction, double coneRadius, const reco::BeamSpot &beamSpot, const std::vector< TransientTrack > &tracks) const
 
std::vector< TransientVertexvertices (const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const reco::BeamSpot &beamSpot, const std::vector< TransientTrack > &primaries, const std::vector< TransientTrack > &tracks) const
 
std::vector< TransientVertexvertices (const GlobalPoint &primaryPosition, const GlobalError &primaryError, const GlobalVector &direction, double coneRadius, const reco::BeamSpot &beamSpot, const std::vector< TransientTrack > &primaries, const std::vector< TransientTrack > &tracks) const
 
std::vector< TransientVertexvertices (const reco::Vertex &primaryVertex, const reco::Track &ghostTrack, const std::vector< TransientTrack > &tracks, const std::vector< float > &weights=std::vector< float >()) const
 
std::vector< TransientVertexvertices (const reco::Vertex &primaryVertex, const reco::Track &ghostTrack, const reco::BeamSpot &beamSpot, const std::vector< TransientTrack > &tracks, const std::vector< float > &weights=std::vector< float >()) const
 
std::vector< TransientVertexvertices (const reco::Vertex &primaryVertex, const reco::Track &ghostTrack, const reco::BeamSpot &beamSpot, const std::vector< TransientTrack > &primaries, const std::vector< TransientTrack > &tracks, const std::vector< float > &weights=std::vector< float >()) const
 
std::vector< TransientVertexvertices (const GlobalPoint &primaryPosition, const GlobalError &primaryError, const GhostTrack &ghostTrack) const
 
std::vector< TransientVertexvertices (const GlobalPoint &primaryPosition, const GlobalError &primaryError, const reco::BeamSpot &beamSpot, const GhostTrack &ghostTrack) const
 
std::vector< TransientVertexvertices (const GlobalPoint &primaryPosition, const GlobalError &primaryError, const reco::BeamSpot &beamSpot, const std::vector< TransientTrack > &primaries, const GhostTrack &ghostTrack) const
 
std::vector< TransientVertexvertices (const reco::Vertex &primaryVertex, const GhostTrack &ghostTrack) const
 
std::vector< TransientVertexvertices (const reco::Vertex &primaryVertex, const reco::BeamSpot &beamSpot, const GhostTrack &ghostTrack) const
 
std::vector< TransientVertexvertices (const reco::Vertex &primaryVertex, const reco::BeamSpot &beamSpot, const std::vector< TransientTrack > &primaries, const GhostTrack &ghostTrack) const
 
std::vector< TransientVertexvertices (const GhostTrack &ghostTrack, const CachingVertex< 5 > &primary=CachingVertex< 5 >(), const reco::BeamSpot &beamSpot=reco::BeamSpot(), bool hasBeamSpot=false, bool hasPrimaries=false) const
 
 ~GhostTrackVertexFinder ()
 

Private Member Functions

GhostTrackFitterghostTrackFitter () const
 
std::vector< CachingVertex< 5 > > initialVertices (const FinderInfo &info) const
 
CachingVertex< 5 > mergeVertices (const CachingVertex< 5 > &vertex1, const CachingVertex< 5 > &vertex2, const FinderInfo &info, bool isPrimary) const
 
bool reassignTracks (std::vector< CachingVertex< 5 > > &vertices, const FinderInfo &info) const
 
bool recursiveMerge (std::vector< CachingVertex< 5 > > &vertices, const FinderInfo &info) const
 
void refitGhostTrack (std::vector< CachingVertex< 5 > > &vertices, FinderInfo &info) const
 
VertexFitter< 5 > & vertexFitter (bool primary) const
 

Static Private Member Functions

static double vertexCompat (const CachingVertex< 5 > &vtx1, const CachingVertex< 5 > &vtx2, const FinderInfo &info, double scale1=1.0, double scale2=1.0)
 

Private Attributes

FitType fitType_
 
std::unique_ptr< GhostTrackFitterghostTrackFitter_
 
double maxFitChi2_
 
double mergeThreshold_
 
double primcut_
 
std::unique_ptr< VertexFitter< 5 > > primVertexFitter_
 
double seccut_
 
std::unique_ptr< VertexFitter< 5 > > secVertexFitter_
 

Detailed Description

Definition at line 29 of file GhostTrackVertexFinder.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

GhostTrackVertexFinder::GhostTrackVertexFinder ( )
GhostTrackVertexFinder::GhostTrackVertexFinder ( double  maxFitChi2,
double  mergeThreshold,
double  primcut,
double  seccut,
FitType  fitType 
)
GhostTrackVertexFinder::~GhostTrackVertexFinder ( )

Definition at line 266 of file GhostTrackVertexFinder.cc.

266 {}

Member Function Documentation

GhostTrackFitter & GhostTrackVertexFinder::ghostTrackFitter ( ) const
private

Definition at line 268 of file GhostTrackVertexFinder.cc.

References ghostTrackFitter_.

Referenced by vertices().

268  {
269  if (!ghostTrackFitter_.get())
271 
272  return *ghostTrackFitter_;
273 }
std::unique_ptr< GhostTrackFitter > ghostTrackFitter_
std::vector< CachingVertex< 5 > > GhostTrackVertexFinder::initialVertices ( const FinderInfo info) const
private

Definition at line 638 of file GhostTrackVertexFinder.cc.

References reco::GhostTrackVertexFinder::FinderInfo::ghostTrack, reco::GhostTrackState::isValid(), CachingVertex< N >::isValid(), reco::GhostTrackState::linearize(), reco::GhostTrackVertexFinder::FinderInfo::pred, reco::GhostTrackVertexFinder::FinderInfo::states, vertexAtState(), and vertices().

Referenced by vertices().

638  {
639  std::vector<CachingVertex<5> > vertices;
640  for (std::vector<GhostTrackState>::const_iterator iter = info.states.begin(); iter != info.states.end(); ++iter) {
641  if (!iter->isValid())
642  continue;
643 
644  GhostTrackState state(*iter);
645  state.linearize(info.pred);
646 
647  if (!state.isValid())
648  continue;
649 
650  CachingVertex<5> vtx = vertexAtState(info.ghostTrack, info.pred, state);
651 
652  if (vtx.isValid()) // && fitChi2(vtx) < maxFitChi2_)
653  vertices.push_back(vtx);
654  }
655 
656  return vertices;
657 }
static const TGPicture * info(bool iBackgroundIsBlack)
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
bool isValid() const
static CachingVertex< 5 > vertexAtState(const TransientTrack &ghostTrack, const GhostTrackPrediction &pred, const GhostTrackState &state)
CachingVertex< 5 > GhostTrackVertexFinder::mergeVertices ( const CachingVertex< 5 > &  vertex1,
const CachingVertex< 5 > &  vertex2,
const FinderInfo info,
bool  isPrimary 
) const
private

Definition at line 679 of file GhostTrackVertexFinder.cc.

References reco::GhostTrackVertexFinder::FinderInfo::beamSpot, MillePedeFileConverter_cfg::e, VertexState::error(), fitType_, reco::GhostTrackVertexFinder::FinderInfo::ghostTrack, reco::GhostTrackVertexFinder::FinderInfo::hasBeamSpot, CachingVertex< N >::isValid(), kAlwaysWithGhostTrack, mergeTrackHelper(), VertexState::position(), stateMean(), CachingVertex< N >::tracks(), VertexFitter< N >::vertex(), vertexFitter(), CachingVertex< N >::vertexState(), VertexTrackFactory< N >::vertexTrack(), and badGlobalMuonTaggersAOD_cff::vtx.

Referenced by recursiveMerge().

682  {
683  VertexTrackFactory<5> vertexTrackFactory;
684 
685  VertexState state = stateMean(vertex1.vertexState(), vertex2.vertexState());
686  std::vector<RefCountedVertexTrack> linTracks;
687  VtxTrackIs isGhostTrack(info.ghostTrack);
688  RefCountedVertexTrack vtxGhostTrack;
689 
690  mergeTrackHelper(vertex1.tracks(), linTracks, state, isGhostTrack, vtxGhostTrack, vertexTrackFactory);
691  mergeTrackHelper(vertex2.tracks(), linTracks, state, isGhostTrack, vtxGhostTrack, vertexTrackFactory);
692 
693  if (vtxGhostTrack && (fitType_ == kAlwaysWithGhostTrack || linTracks.size() < 2))
694  linTracks.push_back(vertexTrackFactory.vertexTrack(vtxGhostTrack->linearizedTrack(), vtxGhostTrack->vertexState()));
695 
696  try {
698  if (info.hasBeamSpot && isPrimary)
699  vtx = vertexFitter(true).vertex(linTracks, info.beamSpot.position(), info.beamSpot.error());
700  else
701  vtx = vertexFitter(isPrimary).vertex(linTracks);
702  if (vtx.isValid())
703  return vtx;
704  } catch (const VertexException &e) {
705  // fit failed
706  }
707 
708  return CachingVertex<5>();
709 }
std::vector< RefCountedVertexTrack > tracks() const
static const TGPicture * info(bool iBackgroundIsBlack)
RefCountedVertexTrack vertexTrack(const RefCountedLinearizedTrackState lt, const VertexState vs, float weight=1.0) const
Common base class.
VertexState const & vertexState() const
static VertexState stateMean(const VertexState &v1, const VertexState &v2)
virtual CachingVertex< N > vertex(const std::vector< reco::TransientTrack > &tracks) const =0
VertexFitter< 5 > & vertexFitter(bool primary) const
bool isValid() const
static void mergeTrackHelper(const std::vector< RefCountedVertexTrack > &tracks, std::vector< RefCountedVertexTrack > &newTracks, const VertexState &state, const VtxTrackIs &ghostTrackFinder, RefCountedVertexTrack &ghostTrack, const VertexTrackFactory< 5 > &factory)
bool GhostTrackVertexFinder::reassignTracks ( std::vector< CachingVertex< 5 > > &  vertices,
const FinderInfo info 
) const
private

Definition at line 783 of file GhostTrackVertexFinder.cc.

References reco::GhostTrackVertexFinder::FinderInfo::beamSpot, MillePedeFileConverter_cfg::e, VertexState::error(), fitType_, reco::GhostTrackVertexFinder::FinderInfo::ghostTrack, reco::GhostTrackVertexFinder::FinderInfo::hasBeamSpot, training_settings::idx, CachingVertex< N >::isValid(), kAlwaysWithGhostTrack, reco::GhostTrackPrediction::lambda(), LinearizedTrackStateFactory::linearizedTrackState(), VertexState::position(), TransientVertex::position(), reco::GhostTrackVertexFinder::FinderInfo::pred, primcut_, relinearizeTrack(), relinearizeTracks(), seccut_, funct::sqr(), reco::GhostTrackVertexFinder::FinderInfo::states, std::swap(), reco::TransientTrack::track(), HLT_2018_cff::track, trackVertexCompat(), VertexFitter< N >::vertex(), vertexAtState(), vertexFitter(), VertexTrackFactory< N >::vertexTrack(), vertices(), and badGlobalMuonTaggersAOD_cff::vtx.

Referenced by vertices().

783  {
784  std::vector<std::pair<RefCountedVertexTrack, std::vector<RefCountedVertexTrack> > > trackBundles(vertices_.size());
785 
786  VtxTrackIs isGhostTrack(info.ghostTrack);
787 
788  bool assignmentChanged = false;
789  for (std::vector<CachingVertex<5> >::const_iterator iter = vertices_.begin(); iter != vertices_.end(); ++iter) {
790  std::vector<RefCountedVertexTrack> vtxTracks = iter->tracks();
791 
792  if (vtxTracks.empty()) {
793  LinearizedTrackStateFactory linTrackFactory;
794  VertexTrackFactory<5> vertexTrackFactory;
795 
796  RefCountedLinearizedTrackState linState = linTrackFactory.linearizedTrackState(iter->position(), info.ghostTrack);
797 
798  trackBundles[iter - vertices_.begin()].first = vertexTrackFactory.vertexTrack(linState, iter->vertexState());
799  }
800 
801  for (std::vector<RefCountedVertexTrack>::const_iterator track = vtxTracks.begin(); track != vtxTracks.end();
802  ++track) {
803  if (isGhostTrack(*track)) {
804  trackBundles[iter - vertices_.begin()].first = *track;
805  continue;
806  }
807 
808  if ((*track)->weight() < 1e-3) {
809  trackBundles[iter - vertices_.begin()].second.push_back(*track);
810  continue;
811  }
812 
813  unsigned int idx = iter - vertices_.begin();
814  double best = 1.0e9;
815  for (std::vector<CachingVertex<5> >::const_iterator vtx = vertices_.begin(); vtx != vertices_.end(); ++vtx) {
816  if (info.pred.lambda(vtx->position()) < info.pred.lambda(vertices_[0].position()))
817  continue;
818 
819  double compat = sqr(trackVertexCompat(*vtx, *track));
820 
821  compat /= (vtx == vertices_.begin()) ? primcut_ : seccut_;
822 
823  if (compat < best) {
824  best = compat;
825  idx = vtx - vertices_.begin();
826  }
827  }
828 
829  if ((int)idx != iter - vertices_.begin())
830  assignmentChanged = true;
831 
832  trackBundles[idx].second.push_back(*track);
833  }
834  }
835 
836  if (!assignmentChanged)
837  return false;
838 
839  VertexTrackFactory<5> vertexTrackFactory;
840  std::vector<CachingVertex<5> > vertices;
841  vertices.reserve(vertices_.size());
842 
843  for (std::vector<CachingVertex<5> >::const_iterator iter = vertices_.begin(); iter != vertices_.end(); ++iter) {
844  const std::vector<RefCountedVertexTrack> &tracks = trackBundles[iter - vertices_.begin()].second;
845  if (tracks.empty())
846  continue;
847 
849 
850  if (tracks.size() == 1) {
851  const TransientTrack &track = tracks[0]->linearizedTrack()->track();
852 
853  int idx = -1;
854  for (std::vector<GhostTrackState>::const_iterator iter = info.states.begin(); iter != info.states.end(); ++iter) {
855  if (iter->isTrack() && iter->track() == track) {
856  idx = iter - info.states.begin();
857  break;
858  }
859  }
860  if (idx < 0)
861  continue;
862 
863  vtx = vertexAtState(info.ghostTrack, info.pred, info.states[idx]);
864  if (!vtx.isValid())
865  continue;
866  } else {
867  std::vector<RefCountedVertexTrack> linTracks = relinearizeTracks(tracks, iter->vertexState());
868 
870  linTracks.push_back(
871  relinearizeTrack(trackBundles[iter - vertices_.begin()].first, iter->vertexState(), vertexTrackFactory));
872 
873  bool primary = iter == vertices_.begin();
874  try {
875  if (primary && info.hasBeamSpot)
876  vtx = vertexFitter(true).vertex(linTracks, info.beamSpot.position(), info.beamSpot.error());
877  else
878  vtx = vertexFitter(primary).vertex(linTracks);
879  } catch (const VertexException &e) {
880  // fit failed;
881  }
882  if (!vtx.isValid())
883  return false;
884  }
885 
886  vertices.push_back(vtx);
887  };
888 
889  std::swap(vertices_, vertices);
890  return true;
891 }
static const TGPicture * info(bool iBackgroundIsBlack)
RefCountedVertexTrack vertexTrack(const RefCountedLinearizedTrackState lt, const VertexState vs, float weight=1.0) const
Common base class.
static RefCountedVertexTrack relinearizeTrack(const RefCountedVertexTrack &track, const VertexState &state, const VertexTrackFactory< 5 > factory)
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
static std::vector< RefCountedVertexTrack > relinearizeTracks(const std::vector< RefCountedVertexTrack > &tracks, const VertexState &state)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
virtual CachingVertex< N > vertex(const std::vector< reco::TransientTrack > &tracks) const =0
RefCountedLinearizedTrackState linearizedTrackState(const GlobalPoint &linP, const reco::TransientTrack &track) const override
VertexFitter< 5 > & vertexFitter(bool primary) const
static double trackVertexCompat(const CachingVertex< 5 > &vtx, const RefCountedVertexTrack &vertexTrack)
Square< F >::type sqr(const F &f)
Definition: Square.h:14
bool isValid() const
static CachingVertex< 5 > vertexAtState(const TransientTrack &ghostTrack, const GhostTrackPrediction &pred, const GhostTrackState &state)
bool GhostTrackVertexFinder::recursiveMerge ( std::vector< CachingVertex< 5 > > &  vertices,
const FinderInfo info 
) const
private

Definition at line 711 of file GhostTrackVertexFinder.cc.

References fitChi2(), mps_fire::i, bTagCombinedSVVariables_cff::indices, CachingVertex< N >::isValid(), dqmiolumiharvest::j, SiStripPI::max, maxFitChi2_, mergeThreshold_, mergeVertices(), min(), dqmiodumpmetadata::n, BeamSpotFilterParameters_cfi::newVtx, trackingPlots::other, primcut_, seccut_, std::swap(), vertexCompat(), and vertices().

Referenced by vertices().

711  {
712  typedef std::pair<unsigned int, unsigned int> Indices;
713 
714  std::multimap<float, Indices> compatMap;
715  unsigned int n = vertices.size();
716  for (unsigned int i = 0; i < n; i++) {
717  const CachingVertex<5> &v1 = vertices[i];
718  for (unsigned int j = i + 1; j < n; j++) {
719  const CachingVertex<5> &v2 = vertices[j];
720 
721  float compat = vertexCompat(v1, v2, info, i == 0 ? primcut_ : seccut_, seccut_);
722 
723  if (compat > mergeThreshold_)
724  continue;
725 
726  compatMap.insert(std::make_pair(compat, Indices(i, j)));
727  }
728  }
729 
730  bool changesMade = false;
731  bool repeat = true;
732  while (repeat) {
733  repeat = false;
734  for (std::multimap<float, Indices>::const_iterator iter = compatMap.begin(); iter != compatMap.end(); ++iter) {
735  unsigned int v1 = iter->second.first;
736  unsigned int v2 = iter->second.second;
737 
739  if (!newVtx.isValid() || (v1 != 0 && fitChi2(newVtx) > maxFitChi2_))
740  continue;
741 
742  std::swap(vertices[v1], newVtx);
743  vertices.erase(vertices.begin() + v2);
744  n--;
745 
746  std::multimap<float, Indices> newCompatMap;
747  for (++iter; iter != compatMap.end(); ++iter) {
748  if (iter->second.first == v1 || iter->second.first == v2 || iter->second.second == v1 ||
749  iter->second.second == v2)
750  continue;
751 
752  Indices indices = iter->second;
753  indices.first -= indices.first > v2;
754  indices.second -= indices.second > v2;
755 
756  newCompatMap.insert(std::make_pair(iter->first, indices));
757  }
758  std::swap(compatMap, newCompatMap);
759 
760  for (unsigned int i = 0; i < n; i++) {
761  if (i == v1)
762  continue;
763 
764  const CachingVertex<5> &other = vertices[i];
765  float compat =
766  vertexCompat(vertices[v1], other, info, v1 == 0 ? primcut_ : seccut_, i == 0 ? primcut_ : seccut_);
767 
768  if (compat > mergeThreshold_)
769  continue;
770 
771  compatMap.insert(std::make_pair(compat, Indices(std::min(i, v1), std::max(i, v1))));
772  }
773 
774  changesMade = true;
775  repeat = true;
776  break;
777  }
778  }
779 
780  return changesMade;
781 }
static const TGPicture * info(bool iBackgroundIsBlack)
static double vertexCompat(const CachingVertex< 5 > &vtx1, const CachingVertex< 5 > &vtx2, const FinderInfo &info, double scale1=1.0, double scale2=1.0)
static double fitChi2(const CachingVertex< 5 > &vtx)
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
Indices
Definition: EdmEventSize.cc:29
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T min(T a, T b)
Definition: MathUtil.h:58
CachingVertex< 5 > mergeVertices(const CachingVertex< 5 > &vertex1, const CachingVertex< 5 > &vertex2, const FinderInfo &info, bool isPrimary) const
bool isValid() const
void GhostTrackVertexFinder::refitGhostTrack ( std::vector< CachingVertex< 5 > > &  vertices,
FinderInfo info 
) const
private

Definition at line 893 of file GhostTrackVertexFinder.cc.

References reco::GhostTrackVertexFinder::FinderInfo::beamSpot, hltPixelTracks_cff::chi2, MillePedeFileConverter_cfg::e, VertexState::error(), reco::GhostTrackVertexFinder::FinderInfo::field, reco::SequentialGhostTrackFitter::fit(), reco::GhostTrackVertexFinder::FinderInfo::ghostTrack, reco::GhostTrackVertexFinder::FinderInfo::hasBeamSpot, training_settings::idx, CachingVertex< N >::isValid(), LinearizedTrackStateFactory::linearizedTrackState(), ndof, VertexState::position(), reco::GhostTrackVertexFinder::FinderInfo::pred, reco::GhostTrackVertexFinder::FinderInfo::prior, reco::GhostTrackVertexFinder::FinderInfo::states, std::swap(), HLT_2018_cff::track, transientGhostTrack(), groupFilesInBlocks::tt, VertexFitter< N >::vertex(), vertexAtState(), vertexFitter(), VertexTrackFactory< N >::vertexTrack(), vertices(), and badGlobalMuonTaggersAOD_cff::vtx.

Referenced by vertices().

893  {
894  VtxTrackIs isGhostTrack(info.ghostTrack);
895 
896  std::vector<GhostTrackState> states;
897  std::vector<unsigned int> oldStates;
898  oldStates.reserve(info.states.size());
899 
900  for (std::vector<CachingVertex<5> >::const_iterator iter = vertices.begin(); iter != vertices.end(); ++iter) {
901  std::vector<RefCountedVertexTrack> vtxTracks = iter->tracks();
902 
903  oldStates.clear();
904  for (std::vector<RefCountedVertexTrack>::const_iterator track = vtxTracks.begin(); track != vtxTracks.end();
905  ++track) {
906  if (isGhostTrack(*track) || (*track)->weight() < 1e-3)
907  continue;
908 
909  const TransientTrack &tt = (*track)->linearizedTrack()->track();
910 
911  int idx = -1;
912  for (std::vector<GhostTrackState>::const_iterator iter = info.states.begin(); iter != info.states.end(); ++iter) {
913  if (iter->isTrack() && iter->track() == tt) {
914  idx = iter - info.states.begin();
915  break;
916  }
917  }
918 
919  if (idx >= 0)
920  oldStates.push_back(idx);
921  }
922 
923  if (oldStates.size() == 1)
924  states.push_back(info.states[oldStates[0]]);
925  else
926  states.push_back(GhostTrackState(iter->vertexState()));
927  }
928 
929  KalmanGhostTrackUpdater updater;
931  double ndof, chi2;
932  info.pred = fitter.fit(updater, info.prior, states, ndof, chi2);
933  TransientTrack ghostTrack = transientGhostTrack(info.pred, info.field);
934 
935  std::swap(info.states, states);
936  states.clear();
937 
938  std::vector<CachingVertex<5> > newVertices;
939  for (std::vector<CachingVertex<5> >::const_iterator iter = vertices.begin(); iter != vertices.end(); ++iter) {
940  std::vector<RefCountedVertexTrack> vtxTracks = iter->tracks();
941 
942  int idx = -1;
943  bool redo = false;
944  for (std::vector<RefCountedVertexTrack>::iterator track = vtxTracks.begin(); track != vtxTracks.end(); ++track) {
945  if (isGhostTrack(*track)) {
946  LinearizedTrackStateFactory linTrackFactory;
947  VertexTrackFactory<5> vertexTrackFactory;
948 
949  *track = vertexTrackFactory.vertexTrack(linTrackFactory.linearizedTrackState(iter->position(), ghostTrack),
950  iter->vertexState());
951  redo = true;
952  continue;
953  }
954 
955  const TransientTrack &tt = (*track)->linearizedTrack()->track();
956 
957  if (idx >= 0) {
958  idx = -1;
959  break;
960  }
961 
962  for (std::vector<GhostTrackState>::const_iterator it = info.states.begin(); it != info.states.end(); ++it) {
963  if (!it->isTrack())
964  continue;
965 
966  if (it->track() == tt) {
967  idx = it - info.states.begin();
968  break;
969  }
970  }
971  }
972 
973  if (idx >= 0) {
974  CachingVertex<5> vtx = vertexAtState(ghostTrack, info.pred, info.states[idx]);
975  if (vtx.isValid())
976  newVertices.push_back(vtx);
977  } else if (redo) {
978  bool primary = iter == vertices.begin();
980  if (primary && info.hasBeamSpot)
981  vtx = vertexFitter(true).vertex(vtxTracks, info.beamSpot.position(), info.beamSpot.error());
982  else
983  vtx = vertexFitter(primary).vertex(vtxTracks);
984  if (vtx.isValid())
985  newVertices.push_back(vtx);
986  } else
987  newVertices.push_back(*iter);
988  }
989 
990  std::swap(newVertices, vertices);
991  info.ghostTrack = ghostTrack;
992 }
static const TGPicture * info(bool iBackgroundIsBlack)
RefCountedVertexTrack vertexTrack(const RefCountedLinearizedTrackState lt, const VertexState vs, float weight=1.0) const
static TransientTrack transientGhostTrack(const GhostTrackPrediction &pred, const MagneticField *field)
GhostTrackPrediction fit(const GhostTrackFitter::PredictionUpdater &updater, const GhostTrackPrediction &prior, std::vector< GhostTrackState > &states, double &ndof, double &chi2) override
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
virtual CachingVertex< N > vertex(const std::vector< reco::TransientTrack > &tracks) const =0
RefCountedLinearizedTrackState linearizedTrackState(const GlobalPoint &linP, const reco::TransientTrack &track) const override
const Track & track() const
VertexFitter< 5 > & vertexFitter(bool primary) const
bool isValid() const
static CachingVertex< 5 > vertexAtState(const TransientTrack &ghostTrack, const GhostTrackPrediction &pred, const GhostTrackState &state)
double GhostTrackVertexFinder::vertexCompat ( const CachingVertex< 5 > &  vtx1,
const CachingVertex< 5 > &  vtx2,
const FinderInfo info,
double  scale1 = 1.0,
double  scale2 = 1.0 
)
staticprivate

Definition at line 230 of file GhostTrackVertexFinder.cc.

References conv, change_name::diff, CachingVertex< N >::error(), GlobalErrorBase< T, ErrorWeightType >::matrix(), CachingVertex< N >::position(), and funct::sqr().

Referenced by recursiveMerge().

231  {
232  Vector3 diff = conv(vtx2.position() - vtx1.position());
233  Matrix3S cov = scale1 * vtx1.error().matrix() + scale2 * vtx2.error().matrix();
234 
235  return sqr(ROOT::Math::Dot(diff, diff)) / ROOT::Math::Similarity(cov, diff);
236 }
static HepMC::IO_HEPEVT conv
const AlgebraicSymMatrix33 matrix() const
GlobalPoint position() const
Square< F >::type sqr(const F &f)
Definition: Square.h:14
GlobalError error() const
VertexFitter< 5 > & GhostTrackVertexFinder::vertexFitter ( bool  primary) const
private

Definition at line 275 of file GhostTrackVertexFinder.cc.

References reco::TrackKinematics::add(), FreeTrajectoryState::charge(), gather_cfg::cout, TransientVertex::degreesOfFreedom(), reco::GhostTrackPrediction::direction(), MillePedeFileConverter_cfg::e, runTheMatrix::err, cppFunctionSkipper::exception, reco::TransientTrack::initialFreeState(), reco::GhostTrackPrediction::lambda(), FreeTrajectoryState::momentum(), TransientVertex::originalTracks(), TransientVertex::position(), TransientVertex::positionError(), primcut_, primVertexFitter_, reco::GhostTrackPrediction::rho(), reco::GhostTrackPrediction::rho2(), seccut_, secVertexFitter_, mathSSE::sqrt(), TransientVertex::totalChiSquared(), HLT_2018_cff::track, reco::TransientTrack::trackBaseRef(), PDWG_EXOHSCP_cff::tracks, reco::TrackKinematics::vectorSum(), badGlobalMuonTaggersAOD_cff::vtx, and vtxErrorLong().

Referenced by mergeVertices(), reassignTracks(), and refitGhostTrack().

275  {
276  std::unique_ptr<VertexFitter<5> > *ptr = primary ? &primVertexFitter_ : &secVertexFitter_;
277  if (!ptr->get())
278  ptr->reset(new AdaptiveVertexFitter(GeometricAnnealing(primary ? primcut_ : seccut_)));
279 
280  return **ptr;
281 }
std::unique_ptr< VertexFitter< 5 > > primVertexFitter_
std::unique_ptr< VertexFitter< 5 > > secVertexFitter_
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const reco::Vertex primaryVertex,
const GlobalVector direction,
double  coneRadius,
const std::vector< TransientTrack > &  tracks 
) const

Definition at line 332 of file GhostTrackVertexFinder.cc.

References RecoVertex::convertError(), RecoVertex::convertPos(), reco::Vertex::error(), and reco::Vertex::position().

Referenced by initialVertices(), reassignTracks(), recursiveMerge(), refitGhostTrack(), and vertices().

335  {
336  return vertices(RecoVertex::convertPos(primaryVertex.position()),
337  RecoVertex::convertError(primaryVertex.error()),
338  direction,
339  coneRadius,
340  tracks);
341 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
const Point & position() const
position
Definition: Vertex.h:113
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
Error error() const
return SMatrix
Definition: Vertex.h:149
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const GlobalPoint primaryPosition,
const GlobalError primaryError,
const GlobalVector direction,
double  coneRadius,
const std::vector< TransientTrack > &  tracks 
) const

Definition at line 371 of file GhostTrackVertexFinder.cc.

References reco::GhostTrackFitter::fit(), ghostTrackFitter(), reco::GhostTrack::prediction(), mps_fire::result, and vertices().

375  {
376  GhostTrack ghostTrack = ghostTrackFitter().fit(primaryPosition, primaryError, direction, coneRadius, tracks);
377 
378  CachingVertex<5> primary(primaryPosition, primaryError, std::vector<RefCountedVertexTrack>(), 0.);
379 
380  std::vector<TransientVertex> result = vertices(ghostTrack, primary);
381 
382 #ifdef DEBUG
383  for (std::vector<TransientVertex>::const_iterator iter = result.begin(); iter != result.end(); ++iter)
384  debugVertex(*iter, ghostTrack.prediction());
385 #endif
386 
387  return result;
388 }
GhostTrack fit(const GlobalPoint &priorPosition, const GlobalError &priorError, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
GhostTrackFitter & ghostTrackFitter() const
const GhostTrackPrediction & prediction() const
Definition: GhostTrack.h:41
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const reco::Vertex primaryVertex,
const GlobalVector direction,
double  coneRadius,
const reco::BeamSpot beamSpot,
const std::vector< TransientTrack > &  tracks 
) const

Definition at line 343 of file GhostTrackVertexFinder.cc.

References RecoVertex::convertError(), RecoVertex::convertPos(), reco::Vertex::error(), reco::Vertex::position(), and vertices().

347  {
348  return vertices(RecoVertex::convertPos(primaryVertex.position()),
349  RecoVertex::convertError(primaryVertex.error()),
350  direction,
351  coneRadius,
352  beamSpot,
353  tracks);
354 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
const Point & position() const
position
Definition: Vertex.h:113
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
Error error() const
return SMatrix
Definition: Vertex.h:149
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const GlobalPoint primaryPosition,
const GlobalError primaryError,
const GlobalVector direction,
double  coneRadius,
const reco::BeamSpot beamSpot,
const std::vector< TransientTrack > &  tracks 
) const

Definition at line 390 of file GhostTrackVertexFinder.cc.

References reco::GhostTrackFitter::fit(), ghostTrackFitter(), reco::GhostTrack::prediction(), mps_fire::result, and vertices().

395  {
396  GhostTrack ghostTrack = ghostTrackFitter().fit(primaryPosition, primaryError, direction, coneRadius, tracks);
397 
398  CachingVertex<5> primary(primaryPosition, primaryError, std::vector<RefCountedVertexTrack>(), 0.);
399 
400  std::vector<TransientVertex> result = vertices(ghostTrack, primary, beamSpot, true);
401 
402 #ifdef DEBUG
403  for (std::vector<TransientVertex>::const_iterator iter = result.begin(); iter != result.end(); ++iter)
404  debugVertex(*iter, ghostTrack.prediction());
405 #endif
406 
407  return result;
408 }
GhostTrack fit(const GlobalPoint &priorPosition, const GlobalError &priorError, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
GhostTrackFitter & ghostTrackFitter() const
const GhostTrackPrediction & prediction() const
Definition: GhostTrack.h:41
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const reco::Vertex primaryVertex,
const GlobalVector direction,
double  coneRadius,
const reco::BeamSpot beamSpot,
const std::vector< TransientTrack > &  primaries,
const std::vector< TransientTrack > &  tracks 
) const

Definition at line 356 of file GhostTrackVertexFinder.cc.

References RecoVertex::convertError(), RecoVertex::convertPos(), reco::Vertex::error(), reco::Vertex::position(), and vertices().

361  {
362  return vertices(RecoVertex::convertPos(primaryVertex.position()),
363  RecoVertex::convertError(primaryVertex.error()),
364  direction,
365  coneRadius,
366  beamSpot,
367  primaries,
368  tracks);
369 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
const Point & position() const
position
Definition: Vertex.h:113
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
Error error() const
return SMatrix
Definition: Vertex.h:149
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const GlobalPoint primaryPosition,
const GlobalError primaryError,
const GlobalVector direction,
double  coneRadius,
const reco::BeamSpot beamSpot,
const std::vector< TransientTrack > &  primaries,
const std::vector< TransientTrack > &  tracks 
) const

Definition at line 410 of file GhostTrackVertexFinder.cc.

References reco::GhostTrackFitter::fit(), ghostTrackFitter(), LinearizedTrackStateFactory::linearizedTrackState(), reco::GhostTrack::prediction(), mps_fire::result, VertexTrackFactory< N >::vertexTrack(), and vertices().

416  {
417  GhostTrack ghostTrack = ghostTrackFitter().fit(primaryPosition, primaryError, direction, coneRadius, tracks);
418 
419  std::vector<RefCountedVertexTrack> primaryVertexTracks;
420  if (!primaries.empty()) {
421  LinearizedTrackStateFactory linTrackFactory;
422  VertexTrackFactory<5> vertexTrackFactory;
423 
424  VertexState state(primaryPosition, primaryError);
425 
426  for (std::vector<TransientTrack>::const_iterator iter = primaries.begin(); iter != primaries.end(); ++iter) {
427  RefCountedLinearizedTrackState linState = linTrackFactory.linearizedTrackState(primaryPosition, *iter);
428 
429  primaryVertexTracks.push_back(vertexTrackFactory.vertexTrack(linState, state));
430  }
431  }
432 
433  CachingVertex<5> primary(primaryPosition, primaryError, primaryVertexTracks, 0.);
434 
435  std::vector<TransientVertex> result = vertices(ghostTrack, primary, beamSpot, true, true);
436 
437 #ifdef DEBUG
438  for (std::vector<TransientVertex>::const_iterator iter = result.begin(); iter != result.end(); ++iter)
439  debugVertex(*iter, ghostTrack.prediction());
440 #endif
441 
442  return result;
443 }
RefCountedVertexTrack vertexTrack(const RefCountedLinearizedTrackState lt, const VertexState vs, float weight=1.0) const
GhostTrack fit(const GlobalPoint &priorPosition, const GlobalError &priorError, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
RefCountedLinearizedTrackState linearizedTrackState(const GlobalPoint &linP, const reco::TransientTrack &track) const override
GhostTrackFitter & ghostTrackFitter() const
const GhostTrackPrediction & prediction() const
Definition: GhostTrack.h:41
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const reco::Vertex primaryVertex,
const reco::Track ghostTrack,
const std::vector< TransientTrack > &  tracks,
const std::vector< float > &  weights = std::vector<float>() 
) const

Definition at line 540 of file GhostTrackVertexFinder.cc.

References RecoVertex::convertError(), RecoVertex::convertPos(), dummyPrediction(), reco::Vertex::error(), reco::Vertex::position(), reco::GhostTrack::prediction(), mps_fire::result, and vertices().

543  {
544  GhostTrack ghostTrack_(ghostTrack,
545  tracks,
546  weights,
547  dummyPrediction(primaryVertex, ghostTrack),
548  RecoVertex::convertPos(primaryVertex.position()),
549  true);
550 
551  CachingVertex<5> primary(RecoVertex::convertPos(primaryVertex.position()),
552  RecoVertex::convertError(primaryVertex.error()),
553  std::vector<RefCountedVertexTrack>(),
554  0.);
555 
556  std::vector<TransientVertex> result = vertices(ghostTrack_, primary);
557 
558 #ifdef DEBUG
559  for (std::vector<TransientVertex>::const_iterator iter = result.begin(); iter != result.end(); ++iter)
560  debugVertex(*iter, ghostTrack_.prediction());
561 #endif
562 
563  return result;
564 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
const Point & position() const
position
Definition: Vertex.h:113
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
static GhostTrackPrediction dummyPrediction(const Vertex &primaryVertex, const Track &ghostTrack)
Error error() const
return SMatrix
Definition: Vertex.h:149
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const reco::Vertex primaryVertex,
const reco::Track ghostTrack,
const reco::BeamSpot beamSpot,
const std::vector< TransientTrack > &  tracks,
const std::vector< float > &  weights = std::vector<float>() 
) const

Definition at line 566 of file GhostTrackVertexFinder.cc.

References RecoVertex::convertError(), RecoVertex::convertPos(), dummyPrediction(), reco::Vertex::error(), reco::Vertex::position(), reco::GhostTrack::prediction(), mps_fire::result, and vertices().

570  {
571  GhostTrack ghostTrack_(ghostTrack,
572  tracks,
573  weights,
574  dummyPrediction(primaryVertex, ghostTrack),
575  RecoVertex::convertPos(primaryVertex.position()),
576  true);
577 
578  CachingVertex<5> primary(RecoVertex::convertPos(primaryVertex.position()),
579  RecoVertex::convertError(primaryVertex.error()),
580  std::vector<RefCountedVertexTrack>(),
581  0.);
582 
583  std::vector<TransientVertex> result = vertices(ghostTrack_, primary, beamSpot, true);
584 
585 #ifdef DEBUG
586  for (std::vector<TransientVertex>::const_iterator iter = result.begin(); iter != result.end(); ++iter)
587  debugVertex(*iter, ghostTrack_.prediction());
588 #endif
589 
590  return result;
591 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
const Point & position() const
position
Definition: Vertex.h:113
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
static GhostTrackPrediction dummyPrediction(const Vertex &primaryVertex, const Track &ghostTrack)
Error error() const
return SMatrix
Definition: Vertex.h:149
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const reco::Vertex primaryVertex,
const reco::Track ghostTrack,
const reco::BeamSpot beamSpot,
const std::vector< TransientTrack > &  primaries,
const std::vector< TransientTrack > &  tracks,
const std::vector< float > &  weights = std::vector<float>() 
) const

Definition at line 593 of file GhostTrackVertexFinder.cc.

References RecoVertex::convertError(), RecoVertex::convertPos(), dummyPrediction(), reco::Vertex::error(), LinearizedTrackStateFactory::linearizedTrackState(), VertexState::position(), reco::Vertex::position(), reco::GhostTrack::prediction(), mps_fire::result, VertexTrackFactory< N >::vertexTrack(), and vertices().

598  {
599  GhostTrack ghostTrack_(ghostTrack,
600  tracks,
601  weights,
602  dummyPrediction(primaryVertex, ghostTrack),
603  RecoVertex::convertPos(primaryVertex.position()),
604  true);
605 
606  std::vector<RefCountedVertexTrack> primaryVertexTracks;
607  if (!primaries.empty()) {
608  LinearizedTrackStateFactory linTrackFactory;
609  VertexTrackFactory<5> vertexTrackFactory;
610 
611  VertexState state(RecoVertex::convertPos(primaryVertex.position()),
612  RecoVertex::convertError(primaryVertex.error()));
613 
614  for (std::vector<TransientTrack>::const_iterator iter = primaries.begin(); iter != primaries.end(); ++iter) {
615  RefCountedLinearizedTrackState linState = linTrackFactory.linearizedTrackState(state.position(), *iter);
616 
617  primaryVertexTracks.push_back(vertexTrackFactory.vertexTrack(linState, state));
618  }
619  }
620 
621  CachingVertex<5> primary(RecoVertex::convertPos(primaryVertex.position()),
622  RecoVertex::convertError(primaryVertex.error()),
623  primaryVertexTracks,
624  0.);
625 
626  std::vector<TransientVertex> result = vertices(ghostTrack_, primary, beamSpot, true, true);
627 
628 #ifdef DEBUG
629  for (std::vector<TransientVertex>::const_iterator iter = result.begin(); iter != result.end(); ++iter)
630  debugVertex(*iter, ghostTrack_.prediction());
631 #endif
632 
633  return result;
634 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
RefCountedVertexTrack vertexTrack(const RefCountedLinearizedTrackState lt, const VertexState vs, float weight=1.0) const
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
const Point & position() const
position
Definition: Vertex.h:113
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
static GhostTrackPrediction dummyPrediction(const Vertex &primaryVertex, const Track &ghostTrack)
RefCountedLinearizedTrackState linearizedTrackState(const GlobalPoint &linP, const reco::TransientTrack &track) const override
Error error() const
return SMatrix
Definition: Vertex.h:149
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const GlobalPoint primaryPosition,
const GlobalError primaryError,
const GhostTrack ghostTrack 
) const

Definition at line 445 of file GhostTrackVertexFinder.cc.

References reco::GhostTrack::prediction(), mps_fire::result, and vertices().

447  {
448  CachingVertex<5> primary(primaryPosition, primaryError, std::vector<RefCountedVertexTrack>(), 0.);
449 
450  std::vector<TransientVertex> result = vertices(ghostTrack, primary);
451 
452 #ifdef DEBUG
453  for (std::vector<TransientVertex>::const_iterator iter = result.begin(); iter != result.end(); ++iter)
454  debugVertex(*iter, ghostTrack.prediction());
455 #endif
456 
457  return result;
458 }
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
const GhostTrackPrediction & prediction() const
Definition: GhostTrack.h:41
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const GlobalPoint primaryPosition,
const GlobalError primaryError,
const reco::BeamSpot beamSpot,
const GhostTrack ghostTrack 
) const

Definition at line 460 of file GhostTrackVertexFinder.cc.

References reco::GhostTrack::prediction(), mps_fire::result, and vertices().

463  {
464  CachingVertex<5> primary(primaryPosition, primaryError, std::vector<RefCountedVertexTrack>(), 0.);
465 
466  std::vector<TransientVertex> result = vertices(ghostTrack, primary, beamSpot, true);
467 
468 #ifdef DEBUG
469  for (std::vector<TransientVertex>::const_iterator iter = result.begin(); iter != result.end(); ++iter)
470  debugVertex(*iter, ghostTrack.prediction());
471 #endif
472 
473  return result;
474 }
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
const GhostTrackPrediction & prediction() const
Definition: GhostTrack.h:41
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const GlobalPoint primaryPosition,
const GlobalError primaryError,
const reco::BeamSpot beamSpot,
const std::vector< TransientTrack > &  primaries,
const GhostTrack ghostTrack 
) const

Definition at line 476 of file GhostTrackVertexFinder.cc.

References LinearizedTrackStateFactory::linearizedTrackState(), reco::GhostTrack::prediction(), mps_fire::result, VertexTrackFactory< N >::vertexTrack(), and vertices().

480  {
481  std::vector<RefCountedVertexTrack> primaryVertexTracks;
482  if (!primaries.empty()) {
483  LinearizedTrackStateFactory linTrackFactory;
484  VertexTrackFactory<5> vertexTrackFactory;
485 
486  VertexState state(primaryPosition, primaryError);
487 
488  for (std::vector<TransientTrack>::const_iterator iter = primaries.begin(); iter != primaries.end(); ++iter) {
489  RefCountedLinearizedTrackState linState = linTrackFactory.linearizedTrackState(primaryPosition, *iter);
490 
491  primaryVertexTracks.push_back(vertexTrackFactory.vertexTrack(linState, state));
492  }
493  }
494 
495  CachingVertex<5> primary(primaryPosition, primaryError, primaryVertexTracks, 0.);
496 
497  std::vector<TransientVertex> result = vertices(ghostTrack, primary, beamSpot, true, true);
498 
499 #ifdef DEBUG
500  for (std::vector<TransientVertex>::const_iterator iter = result.begin(); iter != result.end(); ++iter)
501  debugVertex(*iter, ghostTrack.prediction());
502 #endif
503 
504  return result;
505 }
RefCountedVertexTrack vertexTrack(const RefCountedLinearizedTrackState lt, const VertexState vs, float weight=1.0) const
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
RefCountedLinearizedTrackState linearizedTrackState(const GlobalPoint &linP, const reco::TransientTrack &track) const override
const GhostTrackPrediction & prediction() const
Definition: GhostTrack.h:41
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const reco::Vertex primaryVertex,
const GhostTrack ghostTrack 
) const

Definition at line 507 of file GhostTrackVertexFinder.cc.

References RecoVertex::convertError(), RecoVertex::convertPos(), reco::Vertex::error(), reco::Vertex::position(), and vertices().

508  {
509  return vertices(
510  RecoVertex::convertPos(primaryVertex.position()), RecoVertex::convertError(primaryVertex.error()), ghostTrack);
511 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
const Point & position() const
position
Definition: Vertex.h:113
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
Error error() const
return SMatrix
Definition: Vertex.h:149
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const reco::Vertex primaryVertex,
const reco::BeamSpot beamSpot,
const GhostTrack ghostTrack 
) const

Definition at line 513 of file GhostTrackVertexFinder.cc.

References RecoVertex::convertError(), RecoVertex::convertPos(), reco::Vertex::error(), reco::Vertex::position(), and vertices().

515  {
516  return vertices(RecoVertex::convertPos(primaryVertex.position()),
517  RecoVertex::convertError(primaryVertex.error()),
518  beamSpot,
519  ghostTrack);
520 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
const Point & position() const
position
Definition: Vertex.h:113
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
Error error() const
return SMatrix
Definition: Vertex.h:149
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const reco::Vertex primaryVertex,
const reco::BeamSpot beamSpot,
const std::vector< TransientTrack > &  primaries,
const GhostTrack ghostTrack 
) const

Definition at line 522 of file GhostTrackVertexFinder.cc.

References RecoVertex::convertError(), RecoVertex::convertPos(), reco::Vertex::error(), reco::Vertex::position(), and vertices().

525  {
526  return vertices(RecoVertex::convertPos(primaryVertex.position()),
527  RecoVertex::convertError(primaryVertex.error()),
528  beamSpot,
529  primaries,
530  ghostTrack);
531 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
const Point & position() const
position
Definition: Vertex.h:113
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
Error error() const
return SMatrix
Definition: Vertex.h:149
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const GhostTrack ghostTrack,
const CachingVertex< 5 > &  primary = CachingVertex<5>(),
const reco::BeamSpot beamSpot = reco::BeamSpot(),
bool  hasBeamSpot = false,
bool  hasPrimaries = false 
) const

Definition at line 996 of file GhostTrackVertexFinder.cc.

References gather_cfg::cout, MillePedeFileConverter_cfg::e, reco::GhostTrackVertexFinder::FinderInfo::field, fitType_, reco::GhostTrackVertexFinder::FinderInfo::ghostTrack, info(), initialVertices(), CachingVertex< N >::isValid(), kRefitGhostTrackWithVertices, reco::GhostTrackVertexFinder::FinderInfo::pred, reco::GhostTrack::prediction(), reassignTracks(), recursiveMerge(), refitGhostTrack(), mps_fire::result, reco::GhostTrackVertexFinder::FinderInfo::states, std::swap(), transientGhostTrack(), vertices(), and badGlobalMuonTaggersAOD_cff::vtx.

1000  {
1001  FinderInfo info(primary, ghostTrack, beamSpot, hasBeamSpot, hasPrimaries);
1002 
1003  std::vector<TransientVertex> result;
1004  if (info.states.empty())
1005  return result;
1006 
1007  info.field = info.states[0].track().field();
1008  info.ghostTrack = transientGhostTrack(info.pred, info.field);
1009 
1010  std::vector<CachingVertex<5> > vertices = initialVertices(info);
1011  if (primary.isValid()) {
1012  vertices.push_back(primary);
1013  if (vertices.size() > 1)
1014  std::swap(vertices.front(), vertices.back());
1015  }
1016 
1017  unsigned int reassigned = 0;
1018  while (reassigned < 3) {
1019  if (vertices.size() < 2)
1020  break;
1021 
1022 #ifdef DEBUG
1023  for (std::vector<CachingVertex<5> >::const_iterator iter = vertices.begin(); iter != vertices.end(); ++iter)
1024 
1025  debugVertex(*iter, ghostTrack.prediction());
1026 
1027  std::cout << "----- recursive merging: ---------" << std::endl;
1028 #endif
1029 
1030  bool changed = recursiveMerge(vertices, info);
1031  if ((!changed && !reassigned) || vertices.size() < 2)
1032  break;
1033  if (changed)
1034  reassigned = 0;
1035 
1037  refitGhostTrack(vertices, info);
1038  changed = true;
1039  }
1040 
1041  try {
1042 #ifdef DEBUG
1043  for (std::vector<CachingVertex<5> >::const_iterator iter = vertices.begin(); iter != vertices.end(); ++iter)
1044  debugVertex(*iter, ghostTrack.prediction());
1045  std::cout << "----- reassignment: ---------" << std::endl;
1046 #endif
1047  if (reassignTracks(vertices, info)) {
1048  reassigned++;
1049  changed = true;
1050  } else
1051  reassigned = 0;
1052  } catch (const VertexException &e) {
1053  // just keep vertices as they are
1054  }
1055 
1056  if (!changed)
1057  break;
1058  }
1059 
1060  for (std::vector<CachingVertex<5> >::const_iterator iter = vertices.begin(); iter != vertices.end(); ++iter) {
1061  std::vector<RefCountedVertexTrack> tracks = iter->tracks();
1062  std::vector<RefCountedVertexTrack> newTracks;
1063  newTracks.reserve(tracks.size());
1064 
1065  std::remove_copy_if(tracks.begin(), tracks.end(), std::back_inserter(newTracks), VtxTrackIs(info.ghostTrack));
1066 
1067  if (newTracks.empty())
1068  continue;
1069 
1070  CachingVertex<5> vtx(iter->vertexState(), newTracks, iter->totalChiSquared());
1071  result.push_back(vtx);
1072  }
1073 
1074  return result;
1075 }
static const TGPicture * info(bool iBackgroundIsBlack)
Common base class.
bool reassignTracks(std::vector< CachingVertex< 5 > > &vertices, const FinderInfo &info) const
bool recursiveMerge(std::vector< CachingVertex< 5 > > &vertices, const FinderInfo &info) const
static TransientTrack transientGhostTrack(const GhostTrackPrediction &pred, const MagneticField *field)
std::vector< TransientVertex > vertices(const reco::Vertex &primaryVertex, const GlobalVector &direction, double coneRadius, const std::vector< TransientTrack > &tracks) const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
std::vector< CachingVertex< 5 > > initialVertices(const FinderInfo &info) const
const GhostTrackPrediction & prediction() const
Definition: GhostTrack.h:41
void refitGhostTrack(std::vector< CachingVertex< 5 > > &vertices, FinderInfo &info) const
bool isValid() const

Member Data Documentation

FitType reco::GhostTrackVertexFinder::fitType_
private

Definition at line 155 of file GhostTrackVertexFinder.h.

Referenced by mergeVertices(), reassignTracks(), and vertices().

std::unique_ptr<GhostTrackFitter> reco::GhostTrackVertexFinder::ghostTrackFitter_
mutableprivate

Definition at line 157 of file GhostTrackVertexFinder.h.

Referenced by ghostTrackFitter().

double reco::GhostTrackVertexFinder::maxFitChi2_
private

Definition at line 151 of file GhostTrackVertexFinder.h.

Referenced by recursiveMerge().

double reco::GhostTrackVertexFinder::mergeThreshold_
private

Definition at line 152 of file GhostTrackVertexFinder.h.

Referenced by recursiveMerge().

double reco::GhostTrackVertexFinder::primcut_
private

Definition at line 153 of file GhostTrackVertexFinder.h.

Referenced by reassignTracks(), recursiveMerge(), and vertexFitter().

std::unique_ptr<VertexFitter<5> > reco::GhostTrackVertexFinder::primVertexFitter_
mutableprivate

Definition at line 158 of file GhostTrackVertexFinder.h.

Referenced by vertexFitter().

double reco::GhostTrackVertexFinder::seccut_
private

Definition at line 154 of file GhostTrackVertexFinder.h.

Referenced by reassignTracks(), recursiveMerge(), and vertexFitter().

std::unique_ptr<VertexFitter<5> > reco::GhostTrackVertexFinder::secVertexFitter_
mutableprivate

Definition at line 159 of file GhostTrackVertexFinder.h.

Referenced by vertexFitter().