30 #include <Math/Functions.h>
31 #include <Math/SVector.h>
32 #include <Math/SMatrix.h>
39 const double piMass = 0.13957018;
40 const double piMassSquared = piMass*piMass;
42 const double protonMassSquared = protonMass*
protonMass;
43 const double kShortMass = 0.497614;
44 const double lambdaMass = 1.115683;
82 std::vector<std::string> qual = theParameters.
getParameter<std::vector<std::string> >(
"trackQualities");
83 for (
unsigned int ndx = 0; ndx < qual.size(); ndx++) {
114 using namespace reco;
120 std::vector<TrackRef> theTrackRefs;
121 std::vector<TransientTrack> theTransTracks;
135 if( !theTrackHandle->size() )
return;
144 for(
unsigned int indx = 0; indx < theTrackHandle->size(); indx++) {
145 TrackRef tmpRef( theTrackHandle, indx );
146 bool quality_ok =
true;
149 for (
unsigned int ndx_ = 0; ndx_ <
qualities.size(); ndx_++) {
156 if( !quality_ok )
continue;
159 if( tmpRef->normalizedChi2() <
tkChi2Cut &&
161 TransientTrack tmpTk( *tmpRef, &(*bFieldHandle), globTkGeomHandle );
169 theTrackRefs.push_back( std::move(tmpRef) );
170 theTransTracks.push_back( std::move(tmpTk) );
180 for(
unsigned int trdx1 = 0; trdx1 < theTrackRefs.size(); trdx1++) {
182 for(
unsigned int trdx2 = trdx1 + 1; trdx2 < theTrackRefs.size(); trdx2++) {
193 if(theTrackRefs[trdx1]->charge() < 0. &&
194 theTrackRefs[trdx2]->charge() > 0.) {
195 negativeTrackRef = theTrackRefs[trdx1];
196 positiveTrackRef = theTrackRefs[trdx2];
197 negTransTkPtr = &theTransTracks[trdx1];
198 posTransTkPtr = &theTransTracks[trdx2];
200 else if(theTrackRefs[trdx1]->charge() > 0. &&
201 theTrackRefs[trdx2]->charge() < 0.) {
202 negativeTrackRef = theTrackRefs[trdx2];
203 positiveTrackRef = theTrackRefs[trdx1];
204 negTransTkPtr = &theTransTracks[trdx2];
205 posTransTkPtr = &theTransTracks[trdx1];
212 std::vector<TransientTrack> transTracks; transTracks.reserve(2);
213 transTracks.push_back(*posTransTkPtr);
214 transTracks.push_back(*negTransTkPtr);
225 if( !cApp.
status() )
continue;
226 float dca = fabs( cApp.
distance() );
229 if (dca < 0. || dca >
tkDCACut)
continue;
230 if (
sqrt( cxPt.x()*cxPt.x() + cxPt.y()*cxPt.y() ) > 120.
231 ||
std::abs(cxPt.z()) > 300.)
continue;
249 double totalESq = totalE*totalE;
252 double mass =
sqrt( totalESq - totalPSq);
262 theRecoVertex = theKalmanFitter.
vertex(transTracks);
267 theRecoVertex = theAdaptiveFitter.
vertex(transTracks);
280 std::vector<TransientTrack> refittedTrax;
289 typedef ROOT::Math::SMatrix<double, 3, 3, ROOT::Math::MatRepSym<double, 3> > SMatrixSym3D;
290 typedef ROOT::Math::SVector<double, 3> SVector3;
294 GlobalPoint beamSpotPos(theBeamSpotHandle->position().x(),
295 theBeamSpotHandle->position().y(),
296 theBeamSpotHandle->position().z());
298 SMatrixSym3D totalCov = theBeamSpotHandle->rotatedCovariance3D() + theVtx.
covariance();
299 SVector3 distanceVector(vtxPos.x() - beamSpotPos.x(),
300 vtxPos.y() - beamSpotPos.y(),
304 double rVtxMag = ROOT::Math::Mag(distanceVector);
305 double sigmaRvtxMag =
sqrt(ROOT::Math::Similarity(totalCov, distanceVector)) / rVtxMag;
312 double posTkHitPosD2 =
313 (posTkHitPos.x()-beamSpotPos.x())*(posTkHitPos.x()-beamSpotPos.x()) +
314 (posTkHitPos.y()-beamSpotPos.y())*(posTkHitPos.y()-beamSpotPos.y());
322 double negTkHitPosD2 =
323 (negTkHitPos.x()-beamSpotPos.x())*(negTkHitPos.x()-beamSpotPos.x()) +
324 (negTkHitPos.y()-beamSpotPos.y())*(negTkHitPos.y()-beamSpotPos.y());
339 std::auto_ptr<TrajectoryStateClosestToPoint> trajPlus;
340 std::auto_ptr<TrajectoryStateClosestToPoint> trajMins;
344 std::vector<TransientTrack>::iterator traxIter = refittedTrax.begin(),
345 traxEnd = refittedTrax.end();
352 for( ; traxIter != traxEnd; ++traxIter) {
353 if( traxIter->track().charge() > 0. ) {
354 thePositiveRefTrack = &*traxIter;
356 else if (traxIter->track().charge() < 0.) {
357 theNegativeRefTrack = &*traxIter;
360 if (thePositiveRefTrack == 0 || theNegativeRefTrack == 0)
continue;
370 if( trajPlus.get() == 0 || trajMins.get() == 0 || !trajPlus->isValid() || !trajMins->isValid() )
continue;
372 posTransTkPtr = negTransTkPtr = 0;
384 double piPlusE =
sqrt( positiveP.mag2() + piMassSquared );
385 double piMinusE =
sqrt( negativeP.mag2() + piMassSquared );
386 double protonE =
sqrt( positiveP.mag2() + protonMassSquared );
387 double antiProtonE =
sqrt( negativeP.mag2() + protonMassSquared );
388 double kShortETot = piPlusE + piMinusE;
389 double lambdaEtot = protonE + piMinusE;
390 double lambdaBarEtot = antiProtonE + piPlusE;
392 using namespace reco;
396 totalP.y(), totalP.z(),
399 totalP.y(), totalP.z(),
402 totalP.y(), totalP.z(),
407 double vtxChi2(theVtx.
chi2());
408 double vtxNdof(theVtx.
ndof());
419 if( positiveP.mag2() > negativeP.mag2() ) {
432 positiveP.y(), positiveP.z(),
434 thePiPlusCand.
setTrack(positiveTrackRef);
438 negativeP.y(), negativeP.z(),
440 thePiMinusCand.
setTrack(negativeTrackRef);
445 positiveP.y(), positiveP.z(),
447 theProtonCand.
setTrack(positiveTrackRef);
451 negativeP.y(), negativeP.z(),
453 theAntiProtonCand.
setTrack(negativeTrackRef);
460 theKshort->addDaughter(thePiPlusCand);
461 theKshort->addDaughter(thePiMinusCand);
462 theKshort->setPdgId(310);
463 addp4.
set( *theKshort );
466 theKshorts.push_back( std::move(*theKshort) );
471 theLambda->addDaughter(theProtonCand);
472 theLambda->addDaughter(thePiMinusCand);
473 theLambda->setPdgId(3122);
474 addp4.set( *theLambda );
477 theLambdas.push_back( std::move(*theLambda) );
481 theLambdaBar->addDaughter(theAntiProtonCand);
482 theLambdaBar->addDaughter(thePiPlusCand);
483 theLambdaBar->setPdgId(-3122);
484 addp4.set( *theLambdaBar );
487 theLambdas.push_back( std::move(*theLambdaBar) );
494 theKshort = theLambda = theLambdaBar =
nullptr;
T getParameter(std::string const &) const
std::vector< VertexCompositeCandidate > VertexCompositeCandidateCollection
collection of Candidate objects
Measurement1D transverseImpactParameter() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TrajectoryStateClosestToPoint impactPointTSCP() const
const FreeTrajectoryState & theState() const
double y() const
y coordinate
virtual CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const
float totalChiSquared() const
const MagneticField * magField
std::vector< Track > TrackCollection
collection of Tracks
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
bool hasRefittedTracks() const
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
virtual GlobalPoint crossingPoint() const
double findV0MassError(const GlobalPoint &vtxPos, const std::vector< reco::TransientTrack > &dauTracks)
double impactParameterSigCut
edm::EDGetTokenT< reco::TrackCollection > token_tracks
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
const TrackerGeometry * trackerGeom
virtual CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &) const
math::XYZPoint Point
point in the space
Abs< T >::type abs(const T &t)
double chi2() const
chi-squares
double z() const
y coordinate
void fitAll(const edm::Event &iEvent, const edm::EventSetup &iSetup, reco::VertexCompositeCandidateCollection &k, reco::VertexCompositeCandidateCollection &l)
math::XYZPoint Point
point in the space
V0Fitter(const edm::ParameterSet &theParams, edm::ConsumesCollector &&iC)
std::vector< reco::TrackBase::TrackQuality > qualities
double x() const
x coordinate
double significance() const
static TrackQuality qualityByName(const std::string &name)
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
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.
void setTrack(const reco::TrackRef &r)
set reference to track
virtual float distance() const
math::XYZTLorentzVector LorentzVector
Lorentz vector.
virtual bool status() const
GlobalVector momentum() const