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);
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.
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
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) 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, 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
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".