CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes

reco::GhostTrackVertexFinder Class Reference

#include <GhostTrackVertexFinder.h>

List of all members.

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 reco::BeamSpot &beamSpot, const std::vector< TransientTrack > &primaries, 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 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 GlobalPoint &primaryPosition, const GlobalError &primaryError, const reco::BeamSpot &beamSpot, const GhostTrack &ghostTrack) const
std::vector< TransientVertexvertices (const GlobalPoint &primaryPosition, const GlobalError &primaryError, 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
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 std::vector< TransientTrack > &tracks, const std::vector< float > &weights=std::vector< float >()) 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 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 reco::BeamSpot &beamSpot, const std::vector< TransientTrack > &tracks) 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 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 > &primaries, 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
 ~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::auto_ptr< GhostTrackFitterghostTrackFitter_
double maxFitChi2_
double mergeThreshold_
double primcut_
std::auto_ptr< VertexFitter< 5 > > primVertexFitter_
double seccut_
std::auto_ptr< VertexFitter< 5 > > secVertexFitter_

Detailed Description

Definition at line 29 of file GhostTrackVertexFinder.h.


Member Enumeration Documentation

Enumerator:
kAlwaysWithGhostTrack 
kSingleTracksWithGhostTrack 
kRefitGhostTrackWithVertices 

Definition at line 31 of file GhostTrackVertexFinder.h.


Constructor & Destructor Documentation

GhostTrackVertexFinder::GhostTrackVertexFinder ( )

Definition at line 275 of file GhostTrackVertexFinder.cc.

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

Definition at line 284 of file GhostTrackVertexFinder.cc.

                                                :
        maxFitChi2_(maxFitChi2),
        mergeThreshold_(mergeThreshold),
        primcut_(primcut),
        seccut_(seccut),
        fitType_(fitType)
{
}
GhostTrackVertexFinder::~GhostTrackVertexFinder ( )

Definition at line 295 of file GhostTrackVertexFinder.cc.

{
}

Member Function Documentation

GhostTrackFitter & GhostTrackVertexFinder::ghostTrackFitter ( ) const [private]

Definition at line 299 of file GhostTrackVertexFinder.cc.

References ghostTrackFitter_.

Referenced by vertices().

std::vector< CachingVertex< 5 > > GhostTrackVertexFinder::initialVertices ( const FinderInfo info) const [private]

Definition at line 751 of file GhostTrackVertexFinder.cc.

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

Referenced by vertices().

{
        std::vector<CachingVertex<5> > vertices;
        for(std::vector<GhostTrackState>::const_iterator iter =
                    info.states.begin(); iter != info. states.end(); ++iter) {

                if (!iter->isValid())
                        continue;

                GhostTrackState state(*iter);
                state.linearize(info.pred);

                if (!state.isValid())
                        continue;

                CachingVertex<5> vtx = vertexAtState(info.ghostTrack,
                                                     info.pred, state);

                if (vtx.isValid()) // && fitChi2(vtx) < maxFitChi2_)
                        vertices.push_back(vtx);
        }

        return vertices;
}
CachingVertex< 5 > GhostTrackVertexFinder::mergeVertices ( const CachingVertex< 5 > &  vertex1,
const CachingVertex< 5 > &  vertex2,
const FinderInfo info,
bool  isPrimary 
) const [private]

Definition at line 800 of file GhostTrackVertexFinder.cc.

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

Referenced by recursiveMerge().

{
        VertexTrackFactory<5> vertexTrackFactory;

        VertexState state = stateMean(vertex1.vertexState(),
                                      vertex2.vertexState());
        std::vector<RefCountedVertexTrack> linTracks;
        VtxTrackIs isGhostTrack(info.ghostTrack);
        RefCountedVertexTrack vtxGhostTrack;

        mergeTrackHelper(vertex1.tracks(), linTracks, state,
                         isGhostTrack, vtxGhostTrack, vertexTrackFactory);
        mergeTrackHelper(vertex2.tracks(), linTracks, state,
                         isGhostTrack, vtxGhostTrack, vertexTrackFactory);

        if (vtxGhostTrack &&
            (fitType_ == kAlwaysWithGhostTrack || linTracks.size() < 2))
                linTracks.push_back(
                        vertexTrackFactory.vertexTrack(
                                vtxGhostTrack->linearizedTrack(),
                                vtxGhostTrack->vertexState()));

        try {
                CachingVertex<5> vtx;
                if (info.hasBeamSpot && isPrimary)
                        vtx = vertexFitter(true).vertex(linTracks,
                                                info.beamSpot.position(),
                                                info.beamSpot.error());
                else
                        vtx = vertexFitter(isPrimary).vertex(linTracks);
                if (vtx.isValid())
                        return vtx;
        } catch(const VertexException &e) {
                // fit failed
        }

        return CachingVertex<5>();
}
bool GhostTrackVertexFinder::reassignTracks ( std::vector< CachingVertex< 5 > > &  vertices,
const FinderInfo info 
) const [private]

Definition at line 933 of file GhostTrackVertexFinder.cc.

References reco::GhostTrackVertexFinder::FinderInfo::beamSpot, alignCSCRings::e, VertexState::error(), fitType_, reco::GhostTrackVertexFinder::FinderInfo::ghostTrack, reco::GhostTrackVertexFinder::FinderInfo::hasBeamSpot, UserOptions_cff::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, reco::swap(), trackVertexCompat(), VertexFitter< N >::vertex(), vertexAtState(), vertexFitter(), VertexTrackFactory< N >::vertexTrack(), and vertices().

Referenced by vertices().

{
        std::vector<std::pair<RefCountedVertexTrack,
                              std::vector<RefCountedVertexTrack> > >
                                        trackBundles(vertices_.size());

        VtxTrackIs isGhostTrack(info.ghostTrack);

        bool assignmentChanged = false;
        for(std::vector<CachingVertex<5> >::const_iterator iter =
                        vertices_.begin(); iter != vertices_.end(); ++iter) {
                std::vector<RefCountedVertexTrack> vtxTracks = iter->tracks();

                if (vtxTracks.empty()) {
                        LinearizedTrackStateFactory linTrackFactory;
                        VertexTrackFactory<5> vertexTrackFactory;

                        RefCountedLinearizedTrackState linState =
                                linTrackFactory.linearizedTrackState(
                                        iter->position(), info.ghostTrack);

                        trackBundles[iter - vertices_.begin()].first =
                                        vertexTrackFactory.vertexTrack(
                                                linState, iter->vertexState());
                }

                for(std::vector<RefCountedVertexTrack>::const_iterator track =
                        vtxTracks.begin(); track != vtxTracks.end(); ++track) {

                        if (isGhostTrack(*track)) {
                                trackBundles[iter - vertices_.begin()]
                                                        .first = *track;
                                continue;
                        }

                        if ((*track)->weight() < 1e-3) {
                                trackBundles[iter - vertices_.begin()]
                                                .second.push_back(*track);
                                continue;
                        }

                        unsigned int idx = iter - vertices_.begin();
                        double best = 1.0e9;
                        for(std::vector<CachingVertex<5> >::const_iterator
                                                vtx = vertices_.begin();
                            vtx != vertices_.end(); ++vtx) {
                                if (info.pred.lambda(vtx->position()) <
                                    info.pred.lambda(vertices_[0].position()))
                                        continue;

                                double compat =
                                        sqr(trackVertexCompat(*vtx, *track));

                                compat /= (vtx == vertices_.begin()) ?
                                                        primcut_ : seccut_;

                                if (compat < best) {
                                        best = compat;
                                        idx = vtx - vertices_.begin();
                                }
                        }

                        if ((int)idx != iter - vertices_.begin())
                                assignmentChanged = true;

                        trackBundles[idx].second.push_back(*track);
                }
        }

        if (!assignmentChanged)
                return false;

        VertexTrackFactory<5> vertexTrackFactory;
        std::vector<CachingVertex<5> > vertices;
        vertices.reserve(vertices_.size());

        for(std::vector<CachingVertex<5> >::const_iterator iter =
                        vertices_.begin(); iter != vertices_.end(); ++iter) {
                const std::vector<RefCountedVertexTrack> &tracks =
                                trackBundles[iter - vertices_.begin()].second;
                if (tracks.empty())
                        continue;

                CachingVertex<5> vtx;

                if (tracks.size() == 1) {
                        const TransientTrack &track =
                                tracks[0]->linearizedTrack()->track();

                        int idx = -1;
                        for(std::vector<GhostTrackState>::const_iterator iter =
                                                        info.states.begin();
                            iter != info.states.end(); ++iter) {
                                if (iter->isTrack() && iter->track() == track) {
                                        idx = iter - info.states.begin();
                                        break;
                                }
                        }
                        if (idx < 0)
                                continue;

                        vtx = vertexAtState(info.ghostTrack, info.pred,
                                            info.states[idx]);
                        if (!vtx.isValid())
                                continue;
                } else {
                        std::vector<RefCountedVertexTrack> linTracks =
                                relinearizeTracks(tracks, iter->vertexState());

                        if (fitType_ == kAlwaysWithGhostTrack)
                                linTracks.push_back(relinearizeTrack(
                                        trackBundles[iter - vertices_.begin()].first,
                                        iter->vertexState(), vertexTrackFactory));

                        bool primary = iter == vertices_.begin();
                        try {
                                if (primary && info.hasBeamSpot)
                                        vtx = vertexFitter(true).vertex(
                                                linTracks,
                                                info.beamSpot.position(),
                                                info.beamSpot.error());
                                else
                                        vtx = vertexFitter(primary).vertex(
                                                                linTracks);
                        } catch(const VertexException &e) {
                                // fit failed;
                        }
                        if (!vtx.isValid())
                                return false;
                }

                vertices.push_back(vtx);
        };

        std::swap(vertices_, vertices);
        return true;
}
bool GhostTrackVertexFinder::recursiveMerge ( std::vector< CachingVertex< 5 > > &  vertices,
const FinderInfo info 
) const [private]

Definition at line 843 of file GhostTrackVertexFinder.cc.

References fitChi2(), i, CachingVertex< N >::isValid(), j, max(), maxFitChi2_, mergeThreshold_, mergeVertices(), min, n, BeamSpotFilterParameters_cfi::newVtx, primcut_, seccut_, reco::swap(), vertexCompat(), and vertices().

Referenced by vertices().

{
        typedef std::pair<unsigned int, unsigned int> Indices;

        std::multimap<float, Indices> compatMap;
        unsigned int n = vertices.size();
        for(unsigned int i = 0; i < n; i++) {
                const CachingVertex<5> &v1 = vertices[i];
                for(unsigned int j = i + 1; j < n; j++) {
                        const CachingVertex<5> &v2 = vertices[j];

                        float compat = vertexCompat(v1, v2, info,
                                        i == 0 ? primcut_ : seccut_, seccut_);

                        if (compat > mergeThreshold_)
                                continue;

                        compatMap.insert(
                                std::make_pair(compat, Indices(i, j)));
                }
        }

        bool changesMade = false;
        bool repeat = true;
        while(repeat) {
                repeat = false;
                for(std::multimap<float, Indices>::const_iterator iter =
                        compatMap.begin(); iter != compatMap.end(); ++iter) {
                        unsigned int v1 = iter->second.first;
                        unsigned int v2 = iter->second.second;

                        CachingVertex<5> newVtx =
                                mergeVertices(vertices[v1], vertices[v2],
                                              info, v1 == 0);
                        if (!newVtx.isValid() ||
                            (v1 != 0 && fitChi2(newVtx) > maxFitChi2_))
                                continue;

                        std::swap(vertices[v1], newVtx);
                        vertices.erase(vertices.begin() + v2);
                        n--;

                        std::multimap<float, Indices> newCompatMap;
                        for(++iter; iter != compatMap.end(); ++iter) {
                                if (iter->second.first == v1 ||
                                    iter->second.first == v2 ||
                                    iter->second.second == v1 ||
                                    iter->second.second == v2)
                                        continue;

                                Indices indices = iter->second;
                                indices.first -= indices.first > v2;
                                indices.second -= indices.second > v2;

                                newCompatMap.insert(std::make_pair(
                                                        iter->first, indices));
                        }
                        std::swap(compatMap, newCompatMap);

                        for(unsigned int i = 0; i < n; i++) {
                                if (i == v1)
                                        continue;

                                const CachingVertex<5> &other = vertices[i];
                                float compat = vertexCompat(
                                                vertices[v1], other, info,
                                                v1 == 0 ? primcut_ : seccut_,
                                                i == 0 ? primcut_ : seccut_);

                                if (compat > mergeThreshold_)
                                        continue;

                                compatMap.insert(
                                        std::make_pair(
                                                compat,
                                                Indices(std::min(i, v1),
                                                        std::max(i, v1))));
                        }

                        changesMade = true;
                        repeat = true;
                        break;
                }
        }

        return changesMade;
}
void GhostTrackVertexFinder::refitGhostTrack ( std::vector< CachingVertex< 5 > > &  vertices,
FinderInfo info 
) const [private]

Definition at line 1073 of file GhostTrackVertexFinder.cc.

References reco::GhostTrackVertexFinder::FinderInfo::beamSpot, alignCSCRings::e, VertexState::error(), reco::GhostTrackVertexFinder::FinderInfo::field, reco::SequentialGhostTrackFitter::fit(), reco::GhostTrackVertexFinder::FinderInfo::ghostTrack, ghostTrackES_cfi::ghostTrack, reco::GhostTrackVertexFinder::FinderInfo::hasBeamSpot, UserOptions_cff::idx, CachingVertex< N >::isValid(), LinearizedTrackStateFactory::linearizedTrackState(), VertexState::position(), reco::GhostTrackVertexFinder::FinderInfo::pred, reco::GhostTrackVertexFinder::FinderInfo::prior, reco::GhostTrackVertexFinder::FinderInfo::states, reco::swap(), transientGhostTrack(), groupFilesInBlocks::tt, VertexFitter< N >::vertex(), vertexAtState(), vertexFitter(), VertexTrackFactory< N >::vertexTrack(), and vertices().

Referenced by vertices().

{
        VtxTrackIs isGhostTrack(info.ghostTrack);

        std::vector<GhostTrackState> states;
        std::vector<unsigned int> oldStates;
        oldStates.reserve(info.states.size());

        for(std::vector<CachingVertex<5> >::const_iterator iter =
                        vertices.begin(); iter != vertices.end(); ++iter) {
                std::vector<RefCountedVertexTrack> vtxTracks = iter->tracks();

                oldStates.clear();
                for(std::vector<RefCountedVertexTrack>::const_iterator track =
                        vtxTracks.begin(); track != vtxTracks.end(); ++track) {

                        if (isGhostTrack(*track) || (*track)->weight() < 1e-3)
                                continue;

                        const TransientTrack &tt =
                                        (*track)->linearizedTrack()->track();

                        int idx = -1;
                        for(std::vector<GhostTrackState>::const_iterator iter =
                                                        info.states.begin();
                            iter != info.states.end(); ++iter) {
                                if (iter->isTrack() && iter->track() == tt) {
                                        idx = iter - info.states.begin();
                                        break;
                                }
                        }

                        if (idx >= 0)
                                oldStates.push_back(idx);
                }

                if (oldStates.size() == 1)
                        states.push_back(info.states[oldStates[0]]);
                else
                        states.push_back(GhostTrackState(iter->vertexState()));
        }

        KalmanGhostTrackUpdater updater;
        SequentialGhostTrackFitter fitter;
        double ndof, chi2;
        info.pred = fitter.fit(updater, info.prior, states, ndof, chi2);
        TransientTrack ghostTrack = transientGhostTrack(info.pred, info.field);

        std::swap(info.states, states);
        states.clear();

        std::vector<CachingVertex<5> > newVertices;
        for(std::vector<CachingVertex<5> >::const_iterator iter =
                        vertices.begin(); iter != vertices.end(); ++iter) {
                std::vector<RefCountedVertexTrack> vtxTracks = iter->tracks();

                int idx = -1;
                bool redo = false;
                for(std::vector<RefCountedVertexTrack>::iterator track =
                        vtxTracks.begin(); track != vtxTracks.end(); ++track) {

                        if (isGhostTrack(*track)) {
                                LinearizedTrackStateFactory linTrackFactory;
                                VertexTrackFactory<5> vertexTrackFactory;

                                *track = vertexTrackFactory.vertexTrack(
                                        linTrackFactory.linearizedTrackState(
                                                iter->position(), ghostTrack),
                                                iter->vertexState());
                                redo = true;
                                continue;
                        }

                        const TransientTrack &tt =
                                        (*track)->linearizedTrack()->track();

                        if (idx >= 0) {
                                idx = -1;
                                break;
                        }

                        for(std::vector<GhostTrackState>::const_iterator it =
                                                        info.states.begin();
                            it != info.states.end(); ++it) {
                                if (!it->isTrack())
                                        continue;

                                if (it->track() == tt) {
                                        idx = it - info.states.begin();
                                        break;
                                }
                        }
                }

                if (idx >= 0) {
                        CachingVertex<5> vtx =
                                vertexAtState(ghostTrack, info.pred,
                                              info.states[idx]);
                        if (vtx.isValid())
                                newVertices.push_back(vtx);
                } else if (redo) {
                        bool primary = iter == vertices.begin();
                        CachingVertex<5> vtx;
                        if (primary && info.hasBeamSpot)
                                vtx = vertexFitter(true).vertex(
                                                vtxTracks,
                                                info.beamSpot.position(),
                                                info.beamSpot.error());
                        else
                                vtx = vertexFitter(primary).vertex(vtxTracks);
                        if (vtx.isValid())
                                newVertices.push_back(vtx);
                } else
                        newVertices.push_back(*iter);
        }

        std::swap(newVertices, vertices);
        info.ghostTrack = ghostTrack;
}
double GhostTrackVertexFinder::vertexCompat ( const CachingVertex< 5 > &  vtx1,
const CachingVertex< 5 > &  vtx2,
const FinderInfo info,
double  scale1 = 1.0,
double  scale2 = 1.0 
) [static, private]

Definition at line 238 of file GhostTrackVertexFinder.cc.

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

Referenced by recursiveMerge().

{
        Vector3 diff = conv(vtx2.position() - vtx1.position());
        Matrix3S cov = scale1 * vtx1.error().matrix_new() +
                       scale2 * vtx2.error().matrix_new();

        return sqr(ROOT::Math::Dot(diff, diff)) / ROOT::Math::Similarity(cov, diff);
}
VertexFitter< 5 > & GhostTrackVertexFinder::vertexFitter ( bool  primary) const [private]

Definition at line 307 of file GhostTrackVertexFinder.cc.

References primcut_, primVertexFitter_, seccut_, and secVertexFitter_.

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

{
        std::auto_ptr<VertexFitter<5> > *ptr =
                        primary ? &primVertexFitter_ : &secVertexFitter_;
        if (!ptr->get())
                ptr->reset(new AdaptiveVertexFitter(
                                        GeometricAnnealing(primary
                                                ? primcut_ : seccut_)));

        return **ptr;
}
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 665 of file GhostTrackVertexFinder.cc.

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

{
        GhostTrack ghostTrack_(ghostTrack, tracks, weights,
                               dummyPrediction(primaryVertex, ghostTrack),
                               RecoVertex::convertPos(primaryVertex.position()),
                               true);

        CachingVertex<5> primary(
                        RecoVertex::convertPos(primaryVertex.position()),
                        RecoVertex::convertError(primaryVertex.error()),
                        std::vector<RefCountedVertexTrack>(), 0.);

        std::vector<TransientVertex> result =
                        vertices(ghostTrack_, primary, beamSpot, true);

#ifdef DEBUG
        for(std::vector<TransientVertex>::const_iterator iter = result.begin();
            iter != result.end(); ++iter)
                debugVertex(*iter, ghostTrack_.prediction());
#endif

        return result;
}
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 1197 of file GhostTrackVertexFinder.cc.

References gather_cfg::cout, alignCSCRings::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(), query::result, reco::GhostTrackVertexFinder::FinderInfo::states, std::swap(), transientGhostTrack(), and vertices().

{
        FinderInfo info(primary, ghostTrack, beamSpot,
                        hasBeamSpot, hasPrimaries);

        std::vector<TransientVertex> result;
        if (info.states.empty())
                return result;

        info.field = info.states[0].track().field();
        info.ghostTrack = transientGhostTrack(info.pred, info.field);

        std::vector<CachingVertex<5> > vertices = initialVertices(info);
        if (primary.isValid()) {
                vertices.push_back(primary);
                if (vertices.size() > 1)
                        std::swap(vertices.front(), vertices.back());
        }

        unsigned int reassigned = 0;
        while(reassigned < 3) {
                if (vertices.size() < 2)
                        break;

#ifdef DEBUG
                for(std::vector<CachingVertex<5> >::const_iterator iter =
                        vertices.begin(); iter != vertices.end(); ++iter)

                        debugVertex(*iter, ghostTrack.prediction());

                std::cout << "----- recursive merging: ---------" << std::endl;
#endif

                bool changed = recursiveMerge(vertices, info);
                if ((!changed && !reassigned) || vertices.size() < 2)
                        break;
                if (changed)
                        reassigned = 0;

                if (fitType_ == kRefitGhostTrackWithVertices) {
                        refitGhostTrack(vertices, info);
                        changed = true;
                }

                try {
#ifdef DEBUG
                        for(std::vector<CachingVertex<5> >::const_iterator
                                                iter = vertices.begin();
                            iter != vertices.end(); ++iter)
                                debugVertex(*iter, ghostTrack.prediction());
                        std::cout << "----- reassignment: ---------" << std::endl;
#endif
                        if (reassignTracks(vertices, info)) {
                                reassigned++;
                                changed = true;
                        } else
                                reassigned = 0;
                } catch(const VertexException &e) {
                        // just keep vertices as they are
                }

                if (!changed)
                        break;
        }

        for(std::vector<CachingVertex<5> >::const_iterator iter =
                        vertices.begin(); iter != vertices.end(); ++iter) {
                std::vector<RefCountedVertexTrack> tracks = iter->tracks();
                std::vector<RefCountedVertexTrack> newTracks;
                newTracks.reserve(tracks.size());

                std::remove_copy_if(tracks.begin(), tracks.end(),
                                    std::back_inserter(newTracks),
                                    VtxTrackIs(info.ghostTrack));

                if (newTracks.empty())
                        continue;

                CachingVertex<5> vtx(iter->vertexState(), newTracks,
                                     iter->totalChiSquared());
                result.push_back(vtx);
        }

        return result;
}
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 616 of file GhostTrackVertexFinder.cc.

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

{
        return vertices(RecoVertex::convertPos(primaryVertex.position()),
                        RecoVertex::convertError(primaryVertex.error()),
                        beamSpot, primaries, ghostTrack);
}
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const reco::Vertex primaryVertex,
const reco::BeamSpot beamSpot,
const GhostTrack ghostTrack 
) const
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const reco::Vertex primaryVertex,
const GhostTrack ghostTrack 
) const
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 466 of file GhostTrackVertexFinder.cc.

References reco::GhostTrackFitter::fit(), ghostTrackES_cfi::ghostTrack, ghostTrackFitter(), LinearizedTrackStateFactory::linearizedTrackState(), reco::GhostTrack::prediction(), query::result, evf::utils::state, VertexTrackFactory< N >::vertexTrack(), and vertices().

{
        GhostTrack ghostTrack =
                ghostTrackFitter().fit(primaryPosition, primaryError,
                                       direction, coneRadius, tracks);

        std::vector<RefCountedVertexTrack> primaryVertexTracks;
        if (!primaries.empty()) {
                LinearizedTrackStateFactory linTrackFactory;
                VertexTrackFactory<5> vertexTrackFactory;

                VertexState state(primaryPosition, primaryError);

                for(std::vector<TransientTrack>::const_iterator iter =
                        primaries.begin(); iter != primaries.end(); ++iter) {

                        RefCountedLinearizedTrackState linState =
                                linTrackFactory.linearizedTrackState(
                                                primaryPosition, *iter);

                        primaryVertexTracks.push_back(
                                        vertexTrackFactory.vertexTrack(
                                                        linState, state));
                }
        }

        CachingVertex<5> primary(primaryPosition, primaryError,
                                 primaryVertexTracks, 0.);

        std::vector<TransientVertex> result =
                        vertices(ghostTrack, primary, beamSpot, true, true);

#ifdef DEBUG
        for(std::vector<TransientVertex>::const_iterator iter = result.begin();
            iter != result.end(); ++iter)
                debugVertex(*iter, ghostTrack.prediction());
#endif

        return result;
}
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 401 of file GhostTrackVertexFinder.cc.

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

{
        return vertices(RecoVertex::convertPos(primaryVertex.position()),
                        RecoVertex::convertError(primaryVertex.error()),
                        direction, coneRadius, beamSpot, primaries, tracks);
}
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 555 of file GhostTrackVertexFinder.cc.

References LinearizedTrackStateFactory::linearizedTrackState(), reco::GhostTrack::prediction(), query::result, evf::utils::state, VertexTrackFactory< N >::vertexTrack(), and vertices().

{
        std::vector<RefCountedVertexTrack> primaryVertexTracks;
        if (!primaries.empty()) {
                LinearizedTrackStateFactory linTrackFactory;
                VertexTrackFactory<5> vertexTrackFactory;

                VertexState state(primaryPosition, primaryError);

                for(std::vector<TransientTrack>::const_iterator iter =
                        primaries.begin(); iter != primaries.end(); ++iter) {

                        RefCountedLinearizedTrackState linState =
                                linTrackFactory.linearizedTrackState(
                                                primaryPosition, *iter);

                        primaryVertexTracks.push_back(
                                        vertexTrackFactory.vertexTrack(
                                                        linState, state));
                }
        }

        CachingVertex<5> primary(primaryPosition, primaryError,
                                 primaryVertexTracks, 0.);

        std::vector<TransientVertex> result =
                        vertices(ghostTrack, primary, beamSpot, true, true);

#ifdef DEBUG
        for(std::vector<TransientVertex>::const_iterator iter = result.begin();
            iter != result.end(); ++iter)
                debugVertex(*iter, ghostTrack.prediction());
#endif

        return result;
}
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const reco::Vertex primaryVertex,
const GlobalVector direction,
double  coneRadius,
const std::vector< TransientTrack > &  tracks 
) const
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 439 of file GhostTrackVertexFinder.cc.

References reco::GhostTrackFitter::fit(), ghostTrackES_cfi::ghostTrack, ghostTrackFitter(), reco::GhostTrack::prediction(), query::result, and vertices().

{
        GhostTrack ghostTrack =
                ghostTrackFitter().fit(primaryPosition, primaryError,
                                       direction, coneRadius, tracks);

        CachingVertex<5> primary(primaryPosition, primaryError,
                                 std::vector<RefCountedVertexTrack>(), 0.);

        std::vector<TransientVertex> result =
                                vertices(ghostTrack, primary, beamSpot, true);

#ifdef DEBUG
        for(std::vector<TransientVertex>::const_iterator iter = result.begin();
            iter != result.end(); ++iter)
                debugVertex(*iter, ghostTrack.prediction());
#endif

        return result;
}
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 637 of file GhostTrackVertexFinder.cc.

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

{
        GhostTrack ghostTrack_(ghostTrack, tracks, weights,
                               dummyPrediction(primaryVertex, ghostTrack),
                               RecoVertex::convertPos(
                                                primaryVertex.position()),
                               true);

        CachingVertex<5> primary(
                        RecoVertex::convertPos(primaryVertex.position()),
                        RecoVertex::convertError(primaryVertex.error()),
                        std::vector<RefCountedVertexTrack>(), 0.);

        std::vector<TransientVertex> result = vertices(ghostTrack_, primary);

#ifdef DEBUG
        for(std::vector<TransientVertex>::const_iterator iter = result.begin();
            iter != result.end(); ++iter)
                debugVertex(*iter, ghostTrack_.prediction());
#endif

        return result;
}
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 389 of file GhostTrackVertexFinder.cc.

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

{
        return vertices(RecoVertex::convertPos(primaryVertex.position()),
                        RecoVertex::convertError(primaryVertex.error()),
                        direction, coneRadius, beamSpot, tracks);
}
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const GlobalPoint primaryPosition,
const GlobalError primaryError,
const GhostTrack ghostTrack 
) const

Definition at line 514 of file GhostTrackVertexFinder.cc.

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

{
        CachingVertex<5> primary(primaryPosition, primaryError,
                                 std::vector<RefCountedVertexTrack>(), 0.);

        std::vector<TransientVertex> result = vertices(ghostTrack, primary);

#ifdef DEBUG
        for(std::vector<TransientVertex>::const_iterator iter = result.begin();
            iter != result.end(); ++iter)
                debugVertex(*iter, ghostTrack.prediction());
#endif

        return result;
}
std::vector< TransientVertex > GhostTrackVertexFinder::vertices ( const GlobalPoint primaryPosition,
const GlobalError primaryError,
const reco::BeamSpot beamSpot,
const GhostTrack ghostTrack 
) const

Definition at line 534 of file GhostTrackVertexFinder.cc.

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

{
        CachingVertex<5> primary(primaryPosition, primaryError,
                                 std::vector<RefCountedVertexTrack>(), 0.);

        std::vector<TransientVertex> result =
                                vertices(ghostTrack, primary, beamSpot, true);

#ifdef DEBUG
        for(std::vector<TransientVertex>::const_iterator iter = result.begin();
            iter != result.end(); ++iter)
                debugVertex(*iter, ghostTrack.prediction());
#endif

        return result;
}
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 414 of file GhostTrackVertexFinder.cc.

References reco::GhostTrackFitter::fit(), ghostTrackES_cfi::ghostTrack, ghostTrackFitter(), reco::GhostTrack::prediction(), query::result, and vertices().

{
        GhostTrack ghostTrack =
                ghostTrackFitter().fit(primaryPosition, primaryError,
                                       direction, coneRadius, tracks);

        CachingVertex<5> primary(primaryPosition, primaryError,
                                 std::vector<RefCountedVertexTrack>(), 0.);

        std::vector<TransientVertex> result = vertices(ghostTrack, primary);

#ifdef DEBUG
        for(std::vector<TransientVertex>::const_iterator iter = result.begin();
            iter != result.end(); ++iter)
                debugVertex(*iter, ghostTrack.prediction());
#endif

        return result;
}
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 694 of file GhostTrackVertexFinder.cc.

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

{
        GhostTrack ghostTrack_(ghostTrack, tracks, weights,
                               dummyPrediction(primaryVertex, ghostTrack),
                               RecoVertex::convertPos(primaryVertex.position()),
                               true);

        std::vector<RefCountedVertexTrack> primaryVertexTracks;
        if (!primaries.empty()) {
                LinearizedTrackStateFactory linTrackFactory;
                VertexTrackFactory<5> vertexTrackFactory;

                VertexState state(
                        RecoVertex::convertPos(primaryVertex.position()),
                        RecoVertex::convertError(primaryVertex.error()));

                for(std::vector<TransientTrack>::const_iterator iter =
                        primaries.begin(); iter != primaries.end(); ++iter) {

                        RefCountedLinearizedTrackState linState =
                                linTrackFactory.linearizedTrackState(
                                                state.position(), *iter);

                        primaryVertexTracks.push_back(
                                        vertexTrackFactory.vertexTrack(
                                                        linState, state));
                }
        }

        CachingVertex<5> primary(
                        RecoVertex::convertPos(primaryVertex.position()),
                        RecoVertex::convertError(primaryVertex.error()),
                        primaryVertexTracks, 0.);

        std::vector<TransientVertex> result =
                        vertices(ghostTrack_, primary, beamSpot, true, true);

#ifdef DEBUG
        for(std::vector<TransientVertex>::const_iterator iter = result.begin();
            iter != result.end(); ++iter)
                debugVertex(*iter, ghostTrack_.prediction());
#endif

        return result;
}

Member Data Documentation

Definition at line 180 of file GhostTrackVertexFinder.h.

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

Definition at line 182 of file GhostTrackVertexFinder.h.

Referenced by ghostTrackFitter().

Definition at line 176 of file GhostTrackVertexFinder.h.

Referenced by recursiveMerge().

Definition at line 177 of file GhostTrackVertexFinder.h.

Referenced by recursiveMerge().

Definition at line 178 of file GhostTrackVertexFinder.h.

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

std::auto_ptr<VertexFitter<5> > reco::GhostTrackVertexFinder::primVertexFitter_ [mutable, private]

Definition at line 183 of file GhostTrackVertexFinder.h.

Referenced by vertexFitter().

Definition at line 179 of file GhostTrackVertexFinder.h.

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

std::auto_ptr<VertexFitter<5> > reco::GhostTrackVertexFinder::secVertexFitter_ [mutable, private]

Definition at line 184 of file GhostTrackVertexFinder.h.

Referenced by vertexFitter().