Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow user to select vtx or beamspot covariance #12097

Merged
merged 1 commit into from Nov 3, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 8 additions & 10 deletions RecoVertex/V0Producer/src/V0Fitter.cc
Expand Up @@ -98,12 +98,13 @@ void V0Fitter::fitAll(const edm::Event& iEvent, const edm::EventSetup& iSetup,
iEvent.getByToken(token_beamSpot, theBeamSpotHandle);
const reco::BeamSpot* theBeamSpot = theBeamSpotHandle.product();
math::XYZPoint referencePos(theBeamSpot->position());


reco::Vertex referenceVtx;
if (useVertex_) {
edm::Handle<std::vector<reco::Vertex>> vertices;
iEvent.getByToken(token_vertices, vertices);
const reco::Vertex & vertex = (*vertices)[0];
referencePos = vertex.position();
referenceVtx = vertices->at(0);
referencePos = referenceVtx.position();
}

edm::ESHandle<MagneticField> theMagneticFieldHandle;
Expand All @@ -116,12 +117,8 @@ void V0Fitter::fitAll(const edm::Event& iEvent, const edm::EventSetup& iSetup,
// fill vectors of TransientTracks and TrackRefs after applying preselection cuts
for (reco::TrackCollection::const_iterator iTk = theTrackCollection->begin(); iTk != theTrackCollection->end(); ++iTk) {
const reco::Track* tmpTrack = &(*iTk);
double ipsigXY;
if (useVertex_) {
ipsigXY = std::abs(tmpTrack->dxy(referencePos)/tmpTrack->dxyError());
} else {
ipsigXY = std::abs(tmpTrack->dxy(*theBeamSpot)/tmpTrack->dxyError());
}
double ipsigXY = std::abs(tmpTrack->dxy(*theBeamSpot)/tmpTrack->dxyError());
if (useVertex_) ipsigXY = std::abs(tmpTrack->dxy(referencePos)/tmpTrack->dxyError());
double ipsigZ = std::abs(tmpTrack->dz(referencePos)/tmpTrack->dzError());
if (tmpTrack->normalizedChi2() < tkChi2Cut_ && tmpTrack->numberOfValidHits() >= tkNHitsCut_ &&
tmpTrack->pt() > tkPtCut_ && ipsigXY > tkIPSigXYCut_ && ipsigZ > tkIPSigZCut_) {
Expand Down Expand Up @@ -206,7 +203,8 @@ void V0Fitter::fitAll(const edm::Event& iEvent, const edm::EventSetup& iSetup,
GlobalPoint vtxPos(theVtx.x(), theVtx.y(), theVtx.z());

// 2D decay significance
const SMatrixSym3D totalCov = theBeamSpot->rotatedCovariance3D() + theVtx.covariance();
SMatrixSym3D totalCov = theBeamSpot->rotatedCovariance3D() + theVtx.covariance();
if (useVertex_) totalCov = referenceVtx.covariance() + theVtx.covariance();
SVector3 distVecXY(vtxPos.x()-referencePos.x(), vtxPos.y()-referencePos.y(), 0.);
double distMagXY = ROOT::Math::Mag(distVecXY);
double sigmaDistMagXY = sqrt(ROOT::Math::Similarity(totalCov, distVecXY)) / distMagXY;
Expand Down