21#include "AthLinks/ElementLink.h"
53 ATH_MSG_FATAL(
"Invalid number of elements given for manualMass hypothesis - needs 4");
54 return StatusCode::FAILURE;
62 return StatusCode::FAILURE;
66 return StatusCode::FAILURE;
84 return StatusCode::SUCCESS;
126 declareInterface<JpsiPlus2Tracks>(
this);
184 return StatusCode::FAILURE;
186 importedJpsiCollection = jpsihandle.
cptr();
196 return StatusCode::FAILURE;
198 importedTrackCollection = trackshandle.
cptr();
207 importedGSFTrackCollection =
h.cptr();
216 return StatusCode::FAILURE;
218 importedMuonCollection =
h.cptr();
225 typedef std::vector<const xAOD::TrackParticle*> TrackBag;
228 TrackBag theIDTracksAfterSelection;
229 for (
auto trkPBItr=importedTrackCollection->
cbegin(); trkPBItr!=importedTrackCollection->
cend(); ++trkPBItr) {
236 if (
m_trkSelector->decision(*tp, NULL) ) theIDTracksAfterSelection.push_back(tp);
238 if (theIDTracksAfterSelection.size() == 0)
return StatusCode::SUCCESS;
239 ATH_MSG_DEBUG(
"Number of tracks after ID trkSelector: " << theIDTracksAfterSelection.size());
242 std::vector<const xAOD::Vertex*> selectedJpsiCandidates;
243 std::vector<const xAOD::TrackParticle*> jpsiTracks;
244 for(
auto vxcItr=importedJpsiCollection->
cbegin(); vxcItr!=importedJpsiCollection->
cend(); ++vxcItr) {
253 selectedJpsiCandidates.push_back(*vxcItr);
260 jpsiTracks.push_back(jpsiTP1);
261 jpsiTracks.push_back(jpsiTP2);
264 ATH_MSG_DEBUG(
"selectedJpsiCandidates: " << selectedJpsiCandidates.size());
271 std::vector<const xAOD::TrackParticle*> QuadletTracks(4,
nullptr);
273 std::vector<double> massCuts;
277 for(
auto muon : *importedMuonCollection){
278 if(!muon->inDetTrackParticleLink().isValid())
continue;
279 auto track = muon->trackParticle( xAOD::Muon::InnerDetectorTrackParticle );
280 if(track==
nullptr)
continue;
282 muonTracks.push_back(track);
286 for(
auto jpsiItr=selectedJpsiCandidates.begin(); jpsiItr!=selectedJpsiCandidates.end(); ++jpsiItr) {
291 QuadletTracks[0] = jpsiTP1;
292 QuadletTracks[1] = jpsiTP2;
296 jpsiTracks.resize(2);
297 jpsiTracks[0] = jpsiTP1;
298 jpsiTracks[1] = jpsiTP2;
302 for (TrackBag::iterator trkItr1=theIDTracksAfterSelection.begin(); trkItr1<theIDTracksAfterSelection.end(); ++trkItr1) {
304 int linkedMuonTrk1 = 0;
307 if (linkedMuonTrk1)
ATH_MSG_DEBUG(
"This id track 1 is muon track!");
310 if (linkedMuonTrk1)
ATH_MSG_DEBUG(
"ID track 1 removed: id track is selected to build Jpsi!");
317 std::abs((*trkItr1)->z0() + (*trkItr1)->vz() - (*jpsiItr)->z()) >
m_trkDeltaZ )
320 for (TrackBag::iterator trkItr2=trkItr1+1; trkItr2!=theIDTracksAfterSelection.end(); ++trkItr2) {
323 return StatusCode::SUCCESS;
329 if (linkedMuonTrk2)
ATH_MSG_DEBUG(
"This id track 2 is muon track!");
331 if (linkedMuonTrk2)
ATH_MSG_DEBUG(
"ID track 2 removed: id track is selected to build Jpsi Vtx!");
342 std::abs((*trkItr2)->z0() + (*trkItr2)->vz() - (*jpsiItr)->z()) >
m_trkDeltaZ )
351 if((*trkItr2)->qOverP()>0) {
352 QuadletTracks[2] = *trkItr2;
353 QuadletTracks[3] = *trkItr1;
355 QuadletTracks[2] = *trkItr1;
356 QuadletTracks[3] = *trkItr2;
362 bool passesDiTrack(
true);
379 if (!passesDiTrack)
continue;
382 bool passes4TrackMass(
true);
400 if (!passes4TrackMass)
continue;
403 std::unique_ptr<xAOD::Vertex> bVertex (
fit(QuadletTracks, importedTrackCollection, importedGSFTrackCollection));
404 if(!bVertex)
continue;
405 double bChi2DOF = bVertex->chiSquared()/bVertex->numberDoF();
408 if(!chi2CutPassed) {
ATH_MSG_DEBUG(
"Chi Cut failed!");
continue; }
412 if(!passesCuts)
continue;
415 std::vector<const xAOD::Vertex*> theJpsiPreceding;
416 theJpsiPreceding.push_back(*jpsiItr);
424 return StatusCode::SUCCESS;
438 std::unique_ptr<Trk::IVKalState> state =
m_VKVFitter->makeState();
452 std::array<int,2> indices= {1, 2};
460 StatusCode
sc=
m_VKVFitter->VKalVrtFitFast(inputTracks, startingPoint, *state);
468 std::vector<ElementLink<DataVector<xAOD::TrackParticle> > > newLinkVector;
473 newLinkVector.push_back( mylink );
489 double qOverP1=trk1->
qOverP();
490 double qOverP2=trk2->
qOverP();
491 bool opposite = (qOverP1*qOverP2<0.0);
505 const auto trk1V = trk1->
p4();
506 double px1 = trk1V.Px();
507 double py1 = trk1V.Py();
508 double pz1 = trk1V.Pz();
509 double e1 = sqrt(px1*px1+py1*py1+pz1*pz1+mass1*mass1);
510 const auto trk2V = trk2->
p4();
511 double px2 = trk2V.Px();
512 double py2 = trk2V.Py();
513 double pz2 = trk2V.Pz();
514 double e2 = sqrt(px2*px2+py2*py2+pz2*pz2+mass2*mass2);
515 double pxSum=px1+px2;
516 double pySum=py1+py2;
517 double pzSum=pz1+pz2;
519 double M=sqrt((eSum*eSum)-(pxSum*pxSum)-(pySum*pySum)-(pzSum*pzSum));
526 const std::vector<double> &masses)
528 assert(trk.size() == masses.size() && trk.size()==4);
529 const auto trk1V = trk[0]->p4();
530 double px1 = trk1V.Px();
531 double py1 = trk1V.Py();
532 double pz1 = trk1V.Pz();
533 double e1 = sqrt(px1*px1+py1*py1+pz1*pz1+masses[0]*masses[0]);
535 const auto trk2V = trk[1]->p4();
536 double px2 = trk2V.Px();
537 double py2 = trk2V.Py();
538 double pz2 = trk2V.Pz();
539 double e2 = sqrt(px2*px2+py2*py2+pz2*pz2+masses[1]*masses[1]);
541 const auto trk3V = trk[2]->p4();
542 double px3 = trk3V.Px();
543 double py3 = trk3V.Py();
544 double pz3 = trk3V.Pz();
545 double e3 = sqrt(px3*px3+py3*py3+pz3*pz3+masses[2]*masses[2]);
547 const auto trk4V = trk[3]->p4();
548 double px4 = trk4V.Px();
549 double py4 = trk4V.Py();
550 double pz4 = trk4V.Pz();
551 double e4 = sqrt(px4*px4+py4*py4+pz4*pz4+masses[3]*masses[3]);
553 double pxSum=px1+px2+px3+px4;
554 double pySum=py1+py2+py3+py4;
555 double pzSum=pz1+pz2+pz3+pz4;
556 double eSum=e1+e2+e3+e4;
558 double M=sqrt((eSum*eSum)-(pxSum*pxSum)-(pySum*pySum)-(pzSum*pzSum));
566 TLorentzVector bMomentum = bHelper.
totalP(masses);
568 double bPt = bMomentum.Pt();
570 double bMass = bMomentum.M();
571 ATH_MSG_DEBUG(
"Candidate pt/mass under " <<
str <<
" track mass hypothesis is " << bPt <<
" / " << bMass);
574 assert(masses.size()==4);
575 TLorentzVector tr1 = bHelper.
refTrk(2,masses[2]);
576 TLorentzVector tr2 = bHelper.
refTrk(3,masses[3]);
577 double bDiTrkPt = (tr1+tr2).Pt();
578 double bDiTrkMass = (tr1+tr2).M();
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
: B-physics xAOD helpers.
A number of constexpr particle constants to avoid hardcoding them directly in various places.
static bool oppositeCharges(const xAOD::TrackParticle *, const xAOD::TrackParticle *)
ToolHandle< Trk::ITrackSelectorTool > m_trkSelector
std::vector< double > m_mumupkMasses
Trk::TrkVKalVrtFitter * m_VKVFitter
xAOD::Vertex * fit(const std::vector< const xAOD::TrackParticle * > &, const xAOD::TrackParticleContainer *, const xAOD::TrackParticleContainer *GSL) const
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_TrkParticleGSFCollection
bool m_excludeCrossJpsiTracks
std::vector< int > m_useGSFTrackIndices
double m_finalDiTrackMassUpper
virtual StatusCode initialize() override
std::vector< double > m_mumukpMasses
virtual StatusCode performSearch(const EventContext &ctx, xAOD::VertexContainer &) const override
JpsiPlus2Tracks(const std::string &t, const std::string &n, const IInterface *p)
std::vector< double > m_manualMassHypo
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_TrkParticleCollection
bool vertexCuts(xAOD::BPhysHelper &bHelper) const
static double getInvariantMass(const xAOD::TrackParticle *, double, const xAOD::TrackParticle *, double)
bool passCuts(xAOD::BPhysHelper &bHelper, std::span< const double > masses, std::string_view str) const
std::vector< double > m_mumupipiMasses
double m_diTrackMassLower
ToolHandle< Trk::IVertexFitter > m_iVertexFitter
SG::ReadHandleKey< xAOD::VertexContainer > m_jpsiCollectionKey
SG::ReadHandleKey< xAOD::MuonContainer > m_MuonsUsedInJpsi
std::vector< double > m_altMassMuonTracks
std::vector< double > m_mumukkMasses
double m_diTrackMassUpper
double m_trkQuadrupletMassUpper
double m_trkQuadrupletMassLower
std::vector< double > m_mumukpiMasses
std::vector< double > m_mumupikMasses
std::bitset< 4 > m_useGSFTrack
double m_finalDiTrackMassLower
bool m_excludeJpsiMuonsOnly
static bool cutRange(double value, double min, double max)
static bool isContainedIn(const xAOD::TrackParticle *, const std::vector< const xAOD::TrackParticle * > &)
static bool cutRangeOR(const std::vector< double > &values, double min, double max)
static double getPt(const xAOD::TrackParticle *, const xAOD::TrackParticle *)
static bool cutAcceptGreater(double value, double min)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Header file for AthHistogramAlgorithm.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator cbegin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
const_iterator cend() const noexcept
Return a const_iterator pointing past the end of the collection.
ElementLink implementation for ROOT usage.
bool setStorableObject(BaseConstReference data, bool replace=false, IProxyDict *sg=0)
Set link to point to a new container (storable).
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
bool setPrecedingVertices(const std::vector< const xAOD::Vertex * > &vertices, const xAOD::VertexContainer *vertexContainer)
Sets links to preceding vertices.
TVector3 refTrk(const size_t index)
Returns i-th refitted track 3-momentum.
bool setRefTrks(std::vector< float > px, std::vector< float > py, std::vector< float > pz)
Sets refitted track momenta.
TVector3 totalP()
: Returns total 3-momentum calculated from the refitted tracks
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
float qOverP() const
Returns the parameter.
void setTrackParticleLinks(const TrackParticleLinks_t &trackParticles)
Set all track particle links at once.
void clearTracks()
Remove all tracks from the vertex.
const TrackParticleLinks_t & trackParticleLinks() const
Get all the particles associated with the vertex.
Eigen::Matrix< double, 3, 1 > Vector3D
The namespace of all packages in PhysicsAnalysis/JetTagging.
constexpr double muonMassInMeV
the mass of the muon (in MeV)
constexpr double chargedKaonMassInMeV
the mass of the charged kaon (in MeV)
constexpr double JpsiMassInMeV
constexpr double protonMassInMeV
the mass of the proton (in MeV)
constexpr double chargedPionMassInMeV
the mass of the charged pion (in MeV)
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".