30 #include <Math/Functions.h>
31 #include <Math/SVector.h>
32 #include <Math/SMatrix.h>
38 const double piMass = 0.13957018;
39 const double piMassSquared = piMass*piMass;
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;
92 if (!theTrackHandle->size())
return;
98 const GlobalPoint beamSpotPos(theBeamSpot->position().x(), theBeamSpot->position().y(), theBeamSpot->position().z());
102 const MagneticField* theMagneticField = theMagneticFieldHandle.product();
104 std::vector<TrackRef> theTrackRefs;
105 std::vector<TransientTrack> theTransTracks;
108 for (reco::TrackCollection::const_iterator iTk = theTrackCollection->begin(); iTk != theTrackCollection->end(); ++iTk) {
114 theTrackRefs.push_back(std::move(tmpRef));
116 theTransTracks.push_back(std::move(tmpTransient));
122 for (
unsigned int trdx1 = 0; trdx1 < theTrackRefs.size(); ++trdx1) {
123 for (
unsigned int trdx2 = trdx1 + 1; trdx2 < theTrackRefs.size(); ++trdx2) {
130 if (theTrackRefs[trdx1]->charge() < 0. && theTrackRefs[trdx2]->charge() > 0.) {
131 negativeTrackRef = theTrackRefs[trdx1];
132 positiveTrackRef = theTrackRefs[trdx2];
133 negTransTkPtr = &theTransTracks[trdx1];
134 posTransTkPtr = &theTransTracks[trdx2];
135 }
else if (theTrackRefs[trdx1]->charge() > 0. && theTrackRefs[trdx2]->charge() < 0.) {
136 negativeTrackRef = theTrackRefs[trdx2];
137 positiveTrackRef = theTrackRefs[trdx1];
138 negTransTkPtr = &theTransTracks[trdx2];
139 posTransTkPtr = &theTransTracks[trdx1];
150 if (!cApp.
status())
continue;
156 if (
sqrt(cxPt.
x()*cxPt.
x() + cxPt.
y()*cxPt.
y()) > 120. ||
std::abs(cxPt.
z()) > 300.)
continue;
166 double totalESq = totalE*totalE;
168 double mass =
sqrt(totalESq - totalPSq);
172 std::vector<TransientTrack> transTracks;
173 transTracks.reserve(2);
174 transTracks.push_back(*posTransTkPtr);
175 transTracks.push_back(*negTransTkPtr);
181 theRecoVertex = theKalmanFitter.
vertex(transTracks);
185 theRecoVertex = theAdaptiveFitter.
vertex(transTracks);
187 if (!theRecoVertex.
isValid())
continue;
194 SVector3 distanceVector(vtxPos.x() - beamSpotPos.x(), vtxPos.y() - beamSpotPos.y(), 0.);
195 double rVtxMag = ROOT::Math::Mag(distanceVector);
196 double sigmaRvtxMag =
sqrt(ROOT::Math::Similarity(totalCov, distanceVector)) / rVtxMag;
201 double posTkHitPosD2 = (posTkHitPos.x()-beamSpotPos.x())*(posTkHitPos.x()-beamSpotPos.x()) +
202 (posTkHitPos.y()-beamSpotPos.y())*(posTkHitPos.y()-beamSpotPos.y());
207 double negTkHitPosD2 = (negTkHitPos.x()-beamSpotPos.x())*(negTkHitPos.x()-beamSpotPos.x()) +
208 (negTkHitPos.y()-beamSpotPos.y())*(negTkHitPos.y()-beamSpotPos.y());
212 std::auto_ptr<TrajectoryStateClosestToPoint> trajPlus;
213 std::auto_ptr<TrajectoryStateClosestToPoint> trajMins;
214 std::vector<TransientTrack> theRefTracks;
222 for (std::vector<TransientTrack>::iterator iTrack = theRefTracks.begin(); iTrack != theRefTracks.end(); ++iTrack) {
223 if (iTrack->track().charge() > 0.) {
224 thePositiveRefTrack = &*iTrack;
225 }
else if (iTrack->track().charge() < 0.) {
226 theNegativeRefTrack = &*iTrack;
229 if (thePositiveRefTrack == 0 || theNegativeRefTrack == 0)
continue;
237 if (trajPlus.get() == 0 || trajMins.get() == 0 || !trajPlus->isValid() || !trajMins->isValid())
continue;
244 double posx = theVtx.
x() - beamSpotPos.x();
245 double posy = theVtx.
y() - beamSpotPos.y();
246 double momx = totalP.x();
247 double momy = totalP.y();
248 double pointangle = (posx*momx+posy*momy)/(
sqrt(posx*posx+posy*posy)*
sqrt(momx*momx+momy*momy));
252 double piPlusE =
sqrt(positiveP.mag2() + piMassSquared);
253 double piMinusE =
sqrt(negativeP.mag2() + piMassSquared);
254 double protonE =
sqrt(positiveP.mag2() + protonMassSquared);
255 double antiProtonE =
sqrt(negativeP.mag2() + protonMassSquared);
256 double kShortETot = piPlusE + piMinusE;
257 double lambdaEtot = protonE + piMinusE;
258 double lambdaBarEtot = antiProtonE + piPlusE;
267 double vtxChi2(theVtx.
chi2());
268 double vtxNdof(theVtx.
ndof());
279 if (positiveP.mag2() > negativeP.mag2()) {
289 thePiPlusCand.
setTrack(positiveTrackRef);
293 thePiMinusCand.
setTrack(negativeTrackRef);
297 theProtonCand.
setTrack(positiveTrackRef);
301 theAntiProtonCand.
setTrack(negativeTrackRef);
306 theKshort->addDaughter(thePiPlusCand);
307 theKshort->addDaughter(thePiMinusCand);
308 theKshort->setPdgId(310);
309 addp4.
set(*theKshort);
311 theKshorts.push_back(std::move(*theKshort));
318 addp4.
set( *theLambda );
320 theLambdas.push_back(std::move(*theLambda));
326 addp4.
set(*theLambdaBar);
328 theLambdas.push_back(std::move(*theLambdaBar));
335 theKshort = theLambda = theLambdaBar =
nullptr;
T getParameter(std::string const &) const
std::vector< VertexCompositeCandidate > VertexCompositeCandidateCollection
collection of Candidate objects
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > SMatrixSym3D
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
const FreeTrajectoryState & theState() const
double dxyError() const
error on dxy
double y() const
y coordinate
virtual CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const
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
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
virtual GlobalPoint crossingPoint() const
virtual double mass() const
mass
edm::EDGetTokenT< reco::TrackCollection > token_tracks
double pt() const
track transverse momentum
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
virtual CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &) const
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
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 x() const
x coordinate
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
virtual void setPdgId(int pdgId)
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.
ROOT::Math::SVector< double, 3 > SVector3
void setTrack(const reco::TrackRef &r)
set reference to track
virtual float distance() const
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
virtual bool status() const
GlobalVector momentum() const
math::PtEtaPhiELorentzVectorF LorentzVector