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 auto track = muon->trackParticle( xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle );
279 if(track==
nullptr)
continue;
281 muonTracks.push_back(track);
285 for(
auto jpsiItr=selectedJpsiCandidates.begin(); jpsiItr!=selectedJpsiCandidates.end(); ++jpsiItr) {
290 QuadletTracks[0] = jpsiTP1;
291 QuadletTracks[1] = jpsiTP2;
295 jpsiTracks.resize(2);
296 jpsiTracks[0] = jpsiTP1;
297 jpsiTracks[1] = jpsiTP2;
301 for (TrackBag::iterator trkItr1=theIDTracksAfterSelection.begin(); trkItr1<theIDTracksAfterSelection.end(); ++trkItr1) {
303 int linkedMuonTrk1 = 0;
306 if (linkedMuonTrk1)
ATH_MSG_DEBUG(
"This id track 1 is muon track!");
309 if (linkedMuonTrk1)
ATH_MSG_DEBUG(
"ID track 1 removed: id track is selected to build Jpsi!");
316 std::abs((*trkItr1)->z0() + (*trkItr1)->vz() - (*jpsiItr)->z()) >
m_trkDeltaZ )
319 for (TrackBag::iterator trkItr2=trkItr1+1; trkItr2!=theIDTracksAfterSelection.end(); ++trkItr2) {
322 return StatusCode::SUCCESS;
328 if (linkedMuonTrk2)
ATH_MSG_DEBUG(
"This id track 2 is muon track!");
330 if (linkedMuonTrk2)
ATH_MSG_DEBUG(
"ID track 2 removed: id track is selected to build Jpsi Vtx!");
341 std::abs((*trkItr2)->z0() + (*trkItr2)->vz() - (*jpsiItr)->z()) >
m_trkDeltaZ )
350 if((*trkItr2)->qOverP()>0) {
351 QuadletTracks[2] = *trkItr2;
352 QuadletTracks[3] = *trkItr1;
354 QuadletTracks[2] = *trkItr1;
355 QuadletTracks[3] = *trkItr2;
361 bool passesDiTrack(
true);
378 if (!passesDiTrack)
continue;
381 bool passes4TrackMass(
true);
399 if (!passes4TrackMass)
continue;
402 std::unique_ptr<xAOD::Vertex> bVertex (
fit(ctx, QuadletTracks, importedTrackCollection, importedGSFTrackCollection));
403 if(!bVertex)
continue;
404 double bChi2DOF = bVertex->chiSquared()/bVertex->numberDoF();
407 if(!chi2CutPassed) {
ATH_MSG_DEBUG(
"Chi Cut failed!");
continue; }
411 if(!passesCuts)
continue;
414 std::vector<const xAOD::Vertex*> theJpsiPreceding;
415 theJpsiPreceding.push_back(*jpsiItr);
423 return StatusCode::SUCCESS;
434 const std::vector<const xAOD::TrackParticle*> &inputTracks,
438 std::unique_ptr<Trk::IVKalState> state =
m_VKVFitter->makeState(ctx);
452 std::array<int,2> indices= {1, 2};
460 StatusCode
sc=
m_VKVFitter->VKalVrtFitFast(inputTracks, startingPoint, *state);
464 std::unique_ptr<xAOD::Vertex> theResult =
m_VKVFitter->fit(inputTracks, startingPoint, *state);
468 std::vector<ElementLink<DataVector<xAOD::TrackParticle> > > newLinkVector;
469 for(
unsigned int i=0; i< theResult->trackParticleLinks().
size(); i++)
473 newLinkVector.push_back( mylink );
475 theResult->clearTracks();
476 theResult->setTrackParticleLinks( newLinkVector );
489 double qOverP1=trk1->
qOverP();
490 double qOverP2=trk2->
qOverP();
491 bool opposite = (qOverP1*qOverP2<0.0);
498 TLorentzVector bMomentum = bHelper.
totalP(masses);
500 double bPt = bMomentum.Pt();
502 double bMass = bMomentum.M();
503 ATH_MSG_DEBUG(
"Candidate pt/mass under " <<
str <<
" track mass hypothesis is " << bPt <<
" / " << bMass);
506 assert(masses.size()==4);
507 TLorentzVector tr1 = bHelper.
refTrk(2,masses[2]);
508 TLorentzVector tr2 = bHelper.
refTrk(3,masses[3]);
509 double bDiTrkPt = (tr1+tr2).Pt();
510 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.
size_t size() const
Number of registered mappings.
static bool oppositeCharges(const xAOD::TrackParticle *, const xAOD::TrackParticle *)
ToolHandle< Trk::ITrackSelectorTool > m_trkSelector
std::vector< double > m_mumupkMasses
Trk::TrkVKalVrtFitter * m_VKVFitter
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
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
std::unique_ptr< xAOD::Vertex > fit(const EventContext &ctx, const std::vector< const xAOD::TrackParticle * > &, const xAOD::TrackParticleContainer *, const xAOD::TrackParticleContainer *GSL) const
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) noexcept
static double getInvariantMass(const xAOD::TrackParticle *trk1, double mass1, const xAOD::TrackParticle *trk2, double mass2)
static bool cutRangeOR(std::span< double const > values, double min, double max) noexcept
static bool isContainedIn(const xAOD::TrackParticle *, std::span< const xAOD::TrackParticle *const >) noexcept
static double getPt(std::span< const xAOD::TrackParticle *const > tracks)
static bool cutAcceptGreater(double value, double min) noexcept
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)
Set link storable to data object pointed by data (slower).
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
float qOverP() const
Returns the parameter.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
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".
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".