16#include "CLHEP/Vector/LorentzVector.h"
17#include "CLHEP/Matrix/Vector.h"
18#include "CLHEP/Matrix/Matrix.h"
19#include "CLHEP/Matrix/SymMatrix.h"
23#include "TLorentzVector.h"
122 return StatusCode::SUCCESS;
136 jpsiContainer = handle.
cptr();
138 if (!jpsiContainer) {
140 return StatusCode::RECOVERABLE;
155 for (
const xAOD::Vertex* jpsiCandidate : *jpsiContainer) {
170 m_vx->push_back(jpsiCandidate->x());
171 m_vy->push_back(jpsiCandidate->y());
172 m_vz->push_back(jpsiCandidate->z());
187 double orig_mass = (origTrk1+origTrk2).M();
188 double mass = (refTrk1+refTrk2).M();
193 m_jpsiChi2->push_back(jpsiCandidate->chiSquared());
204 return StatusCode::SUCCESS;
213 std::cout <<
"===================" << std::endl;
214 std::cout <<
"SUMMARY OF ANALYSIS" << std::endl;
215 std::cout <<
"===================" << std::endl;
216 std::cout <<
" " << std::endl;
217 std::cout <<
"Total number of events analysed: " <<
m_eventCntr << std::endl;
218 std::cout <<
"Total number of jpsi candidates: " <<
m_jpsiCntr << std::endl;
225 return StatusCode::SUCCESS;
290 m_vx =
new std::vector<double>;
291 m_vy =
new std::vector<double>;
292 m_vz =
new std::vector<double>;
316 float px = 0., py = 0., pz = 0.;
331 const std::vector<float>& refTrackPx = hx(*vxCandidate);
332 const std::vector<float>& refTrackPy = hy(*vxCandidate);
333 const std::vector<float>& refTrackPz = hz(*vxCandidate);
335 if(trkIndex < refTrackPx.size() && refTrackPx.size() == refTrackPy.size() && refTrackPz.size()) {
336 px = refTrackPx[trkIndex];
337 py = refTrackPy[trkIndex];
338 pz = refTrackPz[trkIndex];
341 TVector3 mom(px,py,pz);
352 TLorentzVector lorentz;
353 lorentz.SetVectM(mom, mass);
366 if(origTrack==NULL) {
370 mom.SetPtEtaPhi(origTrack->
pt(), origTrack->
eta(), origTrack->
phi());
381 TLorentzVector lorentz;
382 lorentz.SetVectM(mom, mass);
393 if (masses.size() != NTrk) {
394 ATH_MSG_WARNING(
"The provided number of masses does not match the number of tracks in the vertex");
399 uint ndimExp = (3*NTrk+3)*(3*NTrk+3+1)/2;
400 if (ndim == ndimExp) {
403 ATH_MSG_WARNING(
"Unknown covariance matrix dimension: " << ndim <<
", expected: " << ndimExp);
419 std::vector<CLHEP::HepLorentzVector> particleMom(NTrk);
420 std::vector<CLHEP::HepMatrix> particleDeriv(NTrk);
421 CLHEP::HepLorentzVector totalMom;
422 CLHEP::HepMatrix tmpDeriv(3,3);
425 for(
unsigned int it=0; it<NTrk; it++){
430 CLHEP::HepLorentzVector tmp( cos(
phi)*sin(
theta)/fabs(invP),
432 cos(
theta)/fabs(invP) );
433 double esq = tmp.px()*tmp.px() + tmp.py()*tmp.py() + tmp.pz()*tmp.pz() + masses[it]*masses[it];
434 double e = (esq>0.) ? sqrt(esq) : 0.;
436 particleMom[it] = tmp;
440 tmpDeriv(1,1) = - tmp.py();
441 tmpDeriv(2,1) = tmp.px();
443 tmpDeriv(1,2) = cos(
phi) * tmp.pz();
444 tmpDeriv(2,2) = sin(
phi) * tmp.pz();
445 tmpDeriv(3,2) = - sin(
theta)/fabs(invP);
446 tmpDeriv(1,3) = - tmp.px()/invP;
447 tmpDeriv(2,3) = - tmp.py()/invP;
448 tmpDeriv(3,3) = - tmp.pz()/invP;
449 particleDeriv[it] = tmpDeriv;
452 double dMdPx=0., dMdPy=0., dMdPz=0., dMdPhi=0., dMdTheta=0., dMdInvP=0.;
453 std::vector<double> Deriv(3*NTrk+3, 0.);
454 for(
unsigned int it=0; it<NTrk; it++){
455 dMdPx = ( totalMom.e() * particleMom[it].px()/particleMom[it].e() - totalMom.px() ) / totalMom.m();
456 dMdPy = ( totalMom.e() * particleMom[it].py()/particleMom[it].e() - totalMom.py() ) / totalMom.m();
457 dMdPz = ( totalMom.e() * particleMom[it].pz()/particleMom[it].e() - totalMom.pz() ) / totalMom.m();
459 dMdPhi = dMdPx*particleDeriv[it](1,1) + dMdPy*particleDeriv[it](2,1) + dMdPz*particleDeriv[it](3,1);
460 dMdTheta = dMdPx*particleDeriv[it](1,2) + dMdPy*particleDeriv[it](2,2) + dMdPz*particleDeriv[it](3,2);
461 dMdInvP = dMdPx*particleDeriv[it](1,3) + dMdPy*particleDeriv[it](2,3) + dMdPz*particleDeriv[it](3,3);
463 Deriv[3*it + 3 + 0] = dMdPhi; Deriv[3*it + 3 + 1] = dMdTheta; Deriv[3*it + 3 + 2] = dMdInvP;
467 for(
unsigned int i=0; i<3*NTrk+3; i++){
468 for(
unsigned int j=0; j<3*NTrk+3; j++){
469 err += Deriv[i]*( (*fullCov)(i,j))*Deriv[j];
476 return (err>0.) ? sqrt(err) : 0.;
485 if(vxCandidate!=NULL && vxCandidate->
trackParticle(i)!=NULL) {
502 for(
int i=1; i<=(3+3*NTrk); i++){
503 for(
int j=1; j<=i; j++){
505 (*mtx)(i-1,j-1)=
Matrix[ij];
507 (*mtx).fillSymmetric(i-1,j-1,
Matrix[ij]);
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
A number of constexpr particle constants to avoid hardcoding them directly in various places.
Handle class for reading a decoration on an object.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
size_type size() const noexcept
Returns the number of elements in the collection.
std::vector< double > * m_trkOrigPz1
StatusCode finalize() override
StatusCode execute() override
double invariantMassError(const xAOD::Vertex *vxCandidate, const std::vector< double > &masses) const
Amg::MatrixX * convertVKalCovMatrix(int NTrk, const std::vector< float > &Matrix) const
TLorentzVector track4Momentum(const xAOD::Vertex *vxCandidate, int trkIndex, double mass) const
TVector3 trackMomentum(const xAOD::Vertex *vxCandidate, uint trkIndex) const
std::vector< double > * m_trkOrigCharge2
std::vector< double > * m_jpsiMassPullMC
std::vector< double > * m_trkRefitPx1
TLorentzVector origTrack4Momentum(const xAOD::Vertex *vxCandidate, int trkIndex, double mass) const
std::vector< double > * m_vx
std::vector< double > * m_jpsiMass
std::vector< double > * m_jpsiChi2
std::vector< double > * m_vy
StatusCode initialize() override
std::vector< double > * m_trkOrigPx1
std::vector< double > * m_trkOrigCharge1
std::vector< double > * m_jpsiMassPullRec
SG::ReadDecorHandleKey< xAOD::VertexContainer > m_refPY
SG::ReadHandleKey< xAOD::VertexContainer > m_JpsiCandidatesKey
Name of J/psi container.
double trackCharge(const xAOD::Vertex *vxCandidate, int i) const
std::vector< double > * m_trkOrigPy2
std::vector< double > * m_trkRefitPz1
std::vector< double > * m_trkOrigPy1
std::vector< double > * m_trkRefitPx2
TVector3 origTrackMomentum(const xAOD::Vertex *vxCandidate, int trkIndex) const
SG::ReadDecorHandleKey< xAOD::VertexContainer > m_refPX
std::vector< double > * m_trkOrigPz2
void initializeBranches(void)
std::vector< double > * m_trkOrigPx2
std::vector< double > * m_trkRefitPy2
std::vector< double > * m_vz
std::vector< double > * m_trkRefitPz2
JpsiExample(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< double > * m_jpsiMassError
std::vector< double > * m_trkRefitPy1
double massErrorVKalVrt(const xAOD::Vertex *vxCandidate, const std::vector< double > &masses) const
std::vector< double > * m_jpsiMassRec
SG::ReadDecorHandleKey< xAOD::VertexContainer > m_refPZ
Handle class for reading a decoration on an object.
const_pointer_type cptr()
Dereference the pointer.
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .)
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
float charge() const
Returns the charge.
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.
std::vector< Trk::VxTrackAtVertex > & vxTrackAtVertex()
Non-const access to the VxTrackAtVertex vector.
const std::vector< float > & covariance() const
Returns the covariance matrix as a simple vector of values.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
constexpr double JpsiMassInMeV
ParametersBase< TrackParametersDim, Charged > TrackParameters
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.