28 #include <Math/Functions.h>
29 #include <Math/SVector.h>
30 #include <Math/SMatrix.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())
108 referencePos = referenceVtx.position();
115 std::vector<reco::TrackRef> theTrackRefs;
116 std::vector<reco::TransientTrack> theTransTracks;
119 for (reco::TrackCollection::const_iterator iTk = theTrackCollection->begin(); iTk != theTrackCollection->end();
129 theTrackRefs.push_back(
std::move(tmpRef));
131 theTransTracks.push_back(
std::move(tmpTransient));
137 for (
unsigned int trdx1 = 0; trdx1 < theTrackRefs.size(); ++trdx1) {
138 for (
unsigned int trdx2 = trdx1 + 1; trdx2 < theTrackRefs.size(); ++trdx2) {
144 if (theTrackRefs[trdx1]->
charge() < 0. && theTrackRefs[trdx2]->charge() > 0.) {
145 negativeTrackRef = theTrackRefs[trdx1];
146 positiveTrackRef = theTrackRefs[trdx2];
147 negTransTkPtr = &theTransTracks[trdx1];
148 posTransTkPtr = &theTransTracks[trdx2];
149 }
else if (theTrackRefs[trdx1]->
charge() > 0. && theTrackRefs[trdx2]->charge() < 0.) {
150 negativeTrackRef = theTrackRefs[trdx2];
151 positiveTrackRef = theTrackRefs[trdx1];
152 negTransTkPtr = &theTransTracks[trdx2];
153 posTransTkPtr = &theTransTracks[trdx1];
164 if (!posImpact.isValid() || !negImpact.isValid())
178 if ((cxPt.
x() * cxPt.
x() + cxPt.
y() * cxPt.
y()) > 120. * 120. ||
std::abs(cxPt.
z()) > 300.)
191 double totalESq = totalE * totalE;
193 double massSquared = totalESq - totalPSq;
198 std::vector<reco::TransientTrack> transTracks;
199 transTracks.reserve(2);
200 transTracks.push_back(*posTransTkPtr);
201 transTracks.push_back(*negTransTkPtr);
207 theRecoVertex = theKalmanFitter.
vertex(transTracks);
211 theRecoVertex = theAdaptiveFitter.
vertex(transTracks);
224 totalCov = referenceVtx.covariance() + theVtx.
covariance();
225 SVector3 distVecXY(vtxPos.x() - referencePos.x(), vtxPos.y() - referencePos.y(), 0.);
226 double distMagXY = ROOT::Math::Mag(distVecXY);
227 double sigmaDistMagXY =
sqrt(ROOT::Math::Similarity(totalCov, distVecXY)) / distMagXY;
234 vtxPos.x() - referencePos.x(), vtxPos.y() - referencePos.y(), vtxPos.z() - referencePos.z());
235 double distMagXYZ = ROOT::Math::Mag(distVecXYZ);
236 double sigmaDistMagXYZ =
sqrt(ROOT::Math::Similarity(totalCov, distVecXYZ)) / distMagXYZ;
242 double tkHitPosLimitSquared =
246 double posTkHitPosD2 = (posTkHitPos.x() - referencePos.x()) * (posTkHitPos.x() - referencePos.x()) +
247 (posTkHitPos.y() - referencePos.y()) * (posTkHitPos.y() - referencePos.y());
248 if (posTkHitPosD2 < tkHitPosLimitSquared)
253 double negTkHitPosD2 = (negTkHitPos.x() - referencePos.x()) * (negTkHitPos.x() - referencePos.x()) +
254 (negTkHitPos.y() - referencePos.y()) * (negTkHitPos.y() - referencePos.y());
255 if (negTkHitPosD2 < tkHitPosLimitSquared)
259 std::unique_ptr<TrajectoryStateClosestToPoint> trajPlus;
260 std::unique_ptr<TrajectoryStateClosestToPoint> trajMins;
261 std::vector<reco::TransientTrack> theRefTracks;
269 for (std::vector<reco::TransientTrack>::iterator iTrack = theRefTracks.begin(); iTrack != theRefTracks.end();
271 if (iTrack->track().charge() > 0.) {
272 thePositiveRefTrack = &*iTrack;
273 }
else if (iTrack->track().charge() < 0.) {
274 theNegativeRefTrack = &*iTrack;
277 if (thePositiveRefTrack ==
nullptr || theNegativeRefTrack ==
nullptr)
286 if (trajPlus.get() ==
nullptr || trajMins.get() ==
nullptr || !trajPlus->isValid() || !trajMins->isValid())
294 double dx = theVtx.
x() - referencePos.x();
295 double dy = theVtx.
y() - referencePos.y();
296 double px = totalP.x();
297 double py = totalP.y();
304 double dz = theVtx.
z() - referencePos.z();
305 double pz = totalP.z();
313 double piPlusE =
sqrt(positiveP.mag2() + piMassSquared);
314 double piMinusE =
sqrt(negativeP.mag2() + piMassSquared);
315 double protonE =
sqrt(positiveP.mag2() + protonMassSquared);
316 double antiProtonE =
sqrt(negativeP.mag2() + protonMassSquared);
317 double kShortETot = piPlusE + piMinusE;
318 double lambdaEtot = protonE + piMinusE;
319 double lambdaBarEtot = antiProtonE + piPlusE;
329 double vtxNdof(theVtx.
ndof());
340 if (positiveP.mag2() > negativeP.mag2()) {
350 thePiPlusCand.
setTrack(positiveTrackRef);
354 thePiMinusCand.
setTrack(negativeTrackRef);
358 theProtonCand.
setTrack(positiveTrackRef);
362 theAntiProtonCand.
setTrack(negativeTrackRef);
367 theKshort->addDaughter(thePiPlusCand);
368 theKshort->addDaughter(thePiMinusCand);
369 theKshort->setPdgId(310);
370 addp4.
set(*theKshort);
372 theKshorts.push_back(
std::move(*theKshort));
379 addp4.
set(*theLambda);
381 theLambdas.push_back(
std::move(*theLambda));
387 addp4.
set(*theLambdaBar);
389 theLambdas.push_back(
std::move(*theLambdaBar));
396 theKshort = theLambda = theLambdaBar =
nullptr;