28 #include <Math/Functions.h>
29 #include <Math/SMatrix.h>
30 #include <Math/SVector.h>
38 const double piMass = 0.13957018;
39 const double piMassSquared = piMass * piMass;
40 const double protonMass = 0.938272046;
41 const double protonMassSquared = protonMass * protonMass;
42 const double kShortMass = 0.497614;
43 const double lambdaMass = 1.115683;
46 typedef ROOT::Math::SMatrix<double, 3, 3, ROOT::Math::MatRepSym<double, 3>>
SMatrixSym3D;
47 typedef ROOT::Math::SVector<double, 3>
SVector3;
94 if (theTrackHandle->empty())
107 referenceVtx = vertices->at(0);
108 referencePos = referenceVtx.position();
113 std::vector<reco::TrackRef> theTrackRefs;
114 std::vector<reco::TransientTrack> theTransTracks;
117 for (reco::TrackCollection::const_iterator iTk = theTrackCollection->begin(); iTk != theTrackCollection->end();
127 theTrackRefs.push_back(
std::move(tmpRef));
129 theTransTracks.push_back(
std::move(tmpTransient));
135 for (
unsigned int trdx1 = 0; trdx1 < theTrackRefs.size(); ++trdx1) {
136 for (
unsigned int trdx2 = trdx1 + 1; trdx2 < theTrackRefs.size(); ++trdx2) {
142 if (theTrackRefs[trdx1]->
charge() < 0. && theTrackRefs[trdx2]->charge() > 0.) {
143 negativeTrackRef = theTrackRefs[trdx1];
144 positiveTrackRef = theTrackRefs[trdx2];
145 negTransTkPtr = &theTransTracks[trdx1];
146 posTransTkPtr = &theTransTracks[trdx2];
147 }
else if (theTrackRefs[trdx1]->
charge() > 0. && theTrackRefs[trdx2]->charge() < 0.) {
148 negativeTrackRef = theTrackRefs[trdx2];
149 positiveTrackRef = theTrackRefs[trdx1];
150 negTransTkPtr = &theTransTracks[trdx2];
151 posTransTkPtr = &theTransTracks[trdx1];
162 if (!posImpact.isValid() || !negImpact.isValid())
176 if ((cxPt.
x() * cxPt.
x() + cxPt.
y() * cxPt.
y()) > 120. * 120. ||
std::abs(cxPt.
z()) > 300.)
189 double totalESq = totalE * totalE;
191 double massSquared = totalESq - totalPSq;
196 std::vector<reco::TransientTrack> transTracks;
197 transTracks.reserve(2);
198 transTracks.push_back(*posTransTkPtr);
199 transTracks.push_back(*negTransTkPtr);
205 theRecoVertex = theKalmanFitter.
vertex(transTracks);
209 theRecoVertex = theAdaptiveFitter.
vertex(transTracks);
222 totalCov = referenceVtx.covariance() + theVtx.
covariance();
223 SVector3 distVecXY(vtxPos.x() - referencePos.x(), vtxPos.y() - referencePos.y(), 0.);
224 double distMagXY = ROOT::Math::Mag(distVecXY);
225 double sigmaDistMagXY =
sqrt(ROOT::Math::Similarity(totalCov, distVecXY)) / distMagXY;
232 vtxPos.x() - referencePos.x(), vtxPos.y() - referencePos.y(), vtxPos.z() - referencePos.z());
233 double distMagXYZ = ROOT::Math::Mag(distVecXYZ);
234 double sigmaDistMagXYZ =
sqrt(ROOT::Math::Similarity(totalCov, distVecXYZ)) / distMagXYZ;
240 double tkHitPosLimitSquared =
242 if (innerHitPosCut_ > 0. && positiveTrackRef->innerOk()) {
244 double posTkHitPosD2 = (posTkHitPos.x() - referencePos.x()) * (posTkHitPos.x() - referencePos.x()) +
245 (posTkHitPos.y() - referencePos.y()) * (posTkHitPos.y() - referencePos.y());
246 if (posTkHitPosD2 < tkHitPosLimitSquared)
249 if (innerHitPosCut_ > 0. && negativeTrackRef->innerOk()) {
251 double negTkHitPosD2 = (negTkHitPos.x() - referencePos.x()) * (negTkHitPos.x() - referencePos.x()) +
252 (negTkHitPos.y() - referencePos.y()) * (negTkHitPos.y() - referencePos.y());
253 if (negTkHitPosD2 < tkHitPosLimitSquared)
257 std::unique_ptr<TrajectoryStateClosestToPoint> trajPlus;
258 std::unique_ptr<TrajectoryStateClosestToPoint> trajMins;
259 std::vector<reco::TransientTrack> theRefTracks;
267 for (std::vector<reco::TransientTrack>::iterator iTrack = theRefTracks.begin(); iTrack != theRefTracks.end();
269 if (iTrack->track().charge() > 0.) {
270 thePositiveRefTrack = &*iTrack;
271 }
else if (iTrack->track().charge() < 0.) {
272 theNegativeRefTrack = &*iTrack;
275 if (thePositiveRefTrack ==
nullptr || theNegativeRefTrack ==
nullptr)
288 if (trajPlus.get() ==
nullptr || trajMins.get() ==
nullptr || !trajPlus->isValid() || !trajMins->isValid())
296 double dx = theVtx.
x() - referencePos.x();
297 double dy = theVtx.
y() - referencePos.y();
298 double px = totalP.x();
299 double py = totalP.y();
300 double angleXY = (dx * px + dy * py) / (
sqrt(dx * dx + dy * dy) *
sqrt(px * px + py * py));
306 double dz = theVtx.
z() - referencePos.z();
307 double pz = totalP.z();
309 (dx * px + dy * py + dz * pz) / (
sqrt(dx * dx + dy * dy + dz * dz) *
sqrt(px * px + py * py + pz * pz));
315 double piPlusE =
sqrt(positiveP.mag2() + piMassSquared);
316 double piMinusE =
sqrt(negativeP.mag2() + piMassSquared);
317 double protonE =
sqrt(positiveP.mag2() + protonMassSquared);
318 double antiProtonE =
sqrt(negativeP.mag2() + protonMassSquared);
319 double kShortETot = piPlusE + piMinusE;
320 double lambdaEtot = protonE + piMinusE;
321 double lambdaBarEtot = antiProtonE + piPlusE;
330 double vtxChi2(theVtx.
chi2());
331 double vtxNdof(theVtx.
ndof());
342 if (positiveP.mag2() > negativeP.mag2()) {
352 thePiPlusCand.
setTrack(positiveTrackRef);
356 thePiMinusCand.
setTrack(negativeTrackRef);
360 theProtonCand.
setTrack(positiveTrackRef);
364 theAntiProtonCand.
setTrack(negativeTrackRef);
369 theKshort->addDaughter(thePiPlusCand);
370 theKshort->addDaughter(thePiMinusCand);
371 theKshort->setPdgId(310);
372 addp4.
set(*theKshort);
374 theKshorts.push_back(
std::move(*theKshort));
381 addp4.
set(*theLambda);
383 theLambdas.push_back(
std::move(*theLambda));
389 addp4.
set(*theLambdaBar);
391 theLambdas.push_back(
std::move(*theLambdaBar));
398 theKshort = theLambda = theLambdaBar =
nullptr;
std::vector< VertexCompositeCandidate > VertexCompositeCandidateCollection
collection of Candidate objects
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > SMatrixSym3D
float distance() const override
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TrajectoryStateClosestToPoint impactPointTSCP() const
double dxyError() const
error on dxy
edm::EDGetTokenT< std::vector< reco::Vertex > > token_vertices
double y() const
y coordinate
std::vector< Track > TrackCollection
collection of Tracks
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
bool hasRefittedTracks() const
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &) const override
double vtxDecaySigXYZCut_
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const override
bool getData(T &iHolder) const
GlobalPoint crossingPoint() const override
edm::EDGetTokenT< reco::TrackCollection > token_tracks
bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
double pt() const
track transverse momentum
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
math::XYZPoint Point
point in the space
Abs< T >::type abs(const T &t)
double chi2() const
chi-squares
double z() const
z coordinate
void fitAll(const edm::Event &iEvent, const edm::EventSetup &iSetup, reco::VertexCompositeCandidateCollection &k, reco::VertexCompositeCandidateCollection &l)
math::XYZPoint Point
point in the space
unsigned short numberOfValidHits() const
number of valid hits found
V0Fitter(const edm::ParameterSet &theParams, edm::ConsumesCollector &&iC)
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
double dzError() const
error on dz
double x() const
x coordinate
T const * product() const
XYZPointD XYZPoint
point in space with cartesian internal representation
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
T getParameter(std::string const &) const
double mass() const final
mass
const Point & position() const
position
edm::EDGetTokenT< reco::BeamSpot > token_beamSpot
std::vector< reco::TransientTrack > const & refittedTracks() const
void set(reco::Candidate &c) const
set up a candidate
double normalizedChi2() const
chi-squared divided by n.d.o.f.
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > esTokenMF_
Covariance3DMatrix rotatedCovariance3D() const
ROOT::Math::SVector< double, 3 > SVector3
void setTrack(const reco::TrackRef &r)
set reference to track
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
math::XYZTLorentzVector LorentzVector
Lorentz vector.
void setPdgId(int pdgId) final
bool status() const override
GlobalVector momentum() const