30 static std::atomic< bool > uninitCovarianceAccessPrinted =
false;
31 if( ! uninitCovarianceAccessPrinted ) {
32 std::cout <<
"xAOD::TrackParticle WARNING Uninitialised covariance matrix was "
34 " Debug it by breaking on "
35 "xAODTrackParticlePrivate::covarianceUnsetHook function calls!"
37 uninitCovarianceAccessPrinted =
true;
60 if(
this == &tp)
return *
this;
127 float thetaT =
theta();
129 float sinTheta= sin(thetaT);
130 float px = p*sinTheta*cos(phiT);
131 float py = p*sinTheta*sin(phiT);
132 float pz = p*cos(thetaT);
133 float e = pow (
m(),2) +
134 pow( px,2) + pow(
py,2) + pow( pz,2);
135 p4.SetPxPyPzE( px,
py, pz, sqrt(
e) );
140 return Type::TrackParticle;
163 if( !
acc.isAvailable( *
this) || !
static_cast<bool>(
hasValidTime()) )
throw std::runtime_error(
"Unavailable TrackParticle time requested" );
165 return accTime( *
this );
170 if( !
acc.isAvailable( *
this) || !
static_cast<bool>(
hasValidTime()) )
throw std::runtime_error(
"Unavailable TrackParticle timeResolution requested" );
172 return accTimeRes( *
this );
176 DefiningParameters_t tmp;
195 acc3( *
this ) =
phi0;
198 acc4( *
this ) =
theta;
219 acc( *
this ) = timeRes;
237 std::vector< float > diagVec;
238 diagVec.reserve( cov.rows() );
239 for(
int i = 0; i < cov.rows(); ++i ) {
240 diagVec.push_back( cov( i, i ) );
246 std::vector< float > offDiagVec;
247 offDiagVec.reserve( ( ( cov.rows() - 1 ) * cov.rows() ) / 2 );
248 for(
int i = 1; i < cov.rows(); ++i ) {
249 for(
int j = 0; j < i; ++j ) {
250 float offDiagCoeff = (cov( i, i )>0 && cov( j, j )>0) ? cov( i, j )/sqrt(cov( i, i )*cov( j, j )) : 0;
251 offDiagVec.push_back( offDiagCoeff );
262 std::span<const float> covMatrixDiag;
265 std::span<const float> covMatrixOffDiag;
282 (
static_cast< int >(
accCovMatrixDiag( *this ).size() ) == result.rows() ) ) {
284 result.setIdentity();
294 ( ( result.rows() * ( result.rows() - 1 ) ) / 2 ) ) ) {
296 for(
int i = 1; i < result.rows(); ++i ) {
297 for(
int j = 0; j < i; ++j ) {
298 result.fillSymmetric( i, j,
true );
312 for(
const auto& pairIndex : vecPairIndex){
315 result.fillSymmetric( i, j,
true );
338 std::vector< float >
vec;
347 if (
vec.size() != ParametersCovMatrix_t::RowsAtCompileTime) {
348 throw std::runtime_error(
349 "Setting track definingParametersCovMatrixDiag with vector of size " +
350 std::to_string(
vec.size()) +
" instead of expected " +
351 std::to_string(ParametersCovMatrix_t::RowsAtCompileTime) +
352 " is not supported");
363 unsigned int uncompr_size = ( ( ( ParametersCovMatrix_t::RowsAtCompileTime - 1 ) *
364 ParametersCovMatrix_t::RowsAtCompileTime ) / 2 );
367 if( !(
vec.size() == size ||
vec.size() == uncompr_size) ){
368 throw std::runtime_error(
369 "Setting track definingParametersCovMatrixOffDiag with vector of "
371 std::to_string(
vec.size()) +
" instead of expected " +
372 std::to_string(size) +
" or " + std::to_string(uncompr_size) +
373 " is not supported");
382 std::span<const float> covMatrixOffDiag;
391 std::vector< float > offDiagVecCompr;
397 std::pair<covMatrixIndex,covMatrixIndex> pairIndex = vecPairIndex[k];
400 float offDiagElement = cov(i,i)>0 && cov(j,j)>0 ? cov(i,j)/sqrt(cov(i,i)*cov(j,j)) : 0;
401 offDiagVecCompr[k] = offDiagElement;
453 if(!acc7.isAvailable( *
this ) || !acc8.
isAvailable( *
this )){
467 Amg::Transform3D pAmgTransf = amgtranslation * Amg::RotationMatrix3D::Identity();
508 if(!
acc.isAvailable( *
this ))
return 0;
509 return acc(*this).size();
513 CurvilinearParameters_t tmp;
528 acc1(*this).resize(parameters.size());
529 acc2(*this).resize(parameters.size());
530 acc3(*this).resize(parameters.size());
531 acc4(*this).resize(parameters.size());
532 acc5(*this).resize(parameters.size());
533 acc6(*this).resize(parameters.size());
534 acc7(*this).resize(parameters.size());
536 unsigned int index=0;
537 std::vector<std::vector<float> >
::const_iterator it=parameters.begin(), itEnd=parameters.end();
538 for (;it!=itEnd;++it,++
index){
539 assert((*it).size()==6);
540 acc1(*this).at(
index)=(*it).at(0);
541 acc2(*this).at(
index)=(*it).at(1);
542 acc3(*this).at(
index)=(*it).at(2);
543 acc4(*this).at(
index)=(*it).at(3);
544 acc5(*this).at(
index)=(*it).at(4);
545 acc6(*this).at(
index)=(*it).at(5);
582 unsigned int offset =
index*15;
584 xAOD::ParametersCovMatrix_t tmp;
585 std::vector<float>::const_iterator it =
acc(*this).begin()+offset;
591 assert(cov.size()==15);
592 unsigned int offset =
index*15;
594 std::vector<float>& v =
acc(*
this);
596 std::copy(cov.begin(),cov.end(),v.begin()+offset );
608 bool foundParameters=
false;
609 for (
size_t i=0; i<maxParameters; ++i){
611 foundParameters=
true;
616 return foundParameters;
628 unsigned int offset =
index*15;
630 ParametersCovMatrix_t cov;
631 auto it =
acc(*this).begin()+offset;
652 if (!
acc.isAvailable(*
this)) {
661 std::bitset<xAOD::NumberOfTrackRecoInfo> tmp(
acc(*
this));
667 acc( *
this ) = patternReco;
672 acc( *
this ) = patternReco.to_ullong();
682 if (!
acc.isAvailable(*
this)) {
690 if( ( !
acc ) || ( !
acc->isAvailable( *
this ) ) )
return false;
692 value = ( *acc )( *this );
698 if( ( !
acc ) || ( !
acc->isAvailable( *
this ) ) )
return false;
700 value = ( *acc )( *this );
707 ( *acc )( *this ) = value;
713 ( *acc )( *this ) = value;
736 if(
acc.isAvailable( *
this ) ) {
761 if( !
acc.isAvailable( *
this ) ) {
764 if( !
acc( *this ).isValid() ) {
768 return *(
acc( *
this ) );
Scalar theta() const
theta method
#define AUXSTORE_PRIMITIVE_GETTER_WITH_CAST(CL, PERSTYPE, TRANSTYPE, NAME)
Macro creating a getter function with a type conversion.
#define AUXSTORE_PRIMITIVE_SETTER_WITH_CAST(CL, PERSTYPE, TRANSTYPE, NAME, SETTER)
Macro creating a setter function with a type conversion.
#define AUXSTORE_PRIMITIVE_GETTER(CL, TYPE, NAME)
Macro creating the reader function for a primitive auxiliary property.
#define AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of primitive auxiliary properties.
std::vector< size_t > vec
#define AmgSymMatrix(dim)
A number of constexpr particle constants to avoid hardcoding them directly in various places.
Helper functions for TrackingDetails accessors.
void makePrivateStore()
Create a new (empty) private store for this object.
SG::ConstAccessor< T, ALLOC > ConstAccessor
bool hasStore() const
Return true if this object has an associated store.
SG::Accessor< T, ALLOC > Accessor
const SG::AuxVectorData * container() const
Return the container holding this element.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
Class describing the Line to which the Perigee refers to.
IParticle & operator=(const IParticle &)=default
SG::Accessor< T, ALLOC > Accessor
Class describing a TrackParticle.
void setTrackParameterCovarianceMatrix(unsigned int index, std::vector< float > &cov)
Set the cov matrix of the parameter at 'index', using a vector of floats.
void setDefiningParametersCovMatrix(const ParametersCovMatrix_t &cov)
Set the defining parameters covariance matrix.
float z0() const
Returns the parameter.
void setTrackParameters(std::vector< std::vector< float > > ¶meters)
Set the parameters via the passed vector of vectors.
float timeResolution() const
Returns the time resolution.
const std::vector< float > & definingParametersCovMatrixDiagVec() const
Returns the diagonal elements of the defining parameters covariance matrix.
TrackingDetails::covMatrixIndex covMatrixIndex
~TrackParticle_v1()
Destructor.
float vx() const
The x origin for the parameters.
void setTrackLink(const ElementLink< TrackCollection > &track)
Set the link to the original track.
const ElementLink< TrackCollection > & trackLink() const
Returns a link (which can be invalid) to the Trk::Track which was used to make this TrackParticle.
float theta() const
Returns the parameter, which has range 0 to .
float numberDoF() const
Returns the number of degrees of freedom of the overall track or vertex fit as float.
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzM4D< double > > GenVecFourMom_t
Base 4 Momentum type for TrackParticle.
DefiningParameters_t definingParameters() const
Returns a SVector of the Perigee track parameters.
void setDefiningParametersCovMatrixOffDiagVec(const std::vector< float > &vec)
Set the off-diagonal elements of the defining parameters covariance matrix.
bool definingParametersCovMatrixOffDiagCompr() const
float time() const
Returns the time.
void resetCache()
Reset the internal cache of the object.
virtual double m() const override final
The invariant mass of the particle..
TrackParticle_v1 & operator=(const TrackParticle_v1 &tp)
Assignment operator. This can involve creating and copying an Auxilary store, and so should be used s...
void setTimeResolution(float timeResolution)
bool indexOfParameterAtPosition(unsigned int &index, ParameterPosition position) const
Function to determine if this TrackParticle contains track parameters at a certain position,...
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
void compressDefiningParametersCovMatrixOffDiag()
Delete some off-diagonal elements for compression.
const Trk::Perigee & perigeeParameters() const
Returns the Trk::MeasuredPerigee track parameters.
static const covMatrixIndexPairVec & covMatrixComprIndexPairs()
const Trk::Track * track() const
Returns a pointer (which can be NULL) to the Trk::Track which was used to make this TrackParticle.
void setParameterPosition(unsigned int index, ParameterPosition pos)
Set the 'position' (i.e. where it is in ATLAS) of the parameter at 'index', using the ParameterPositi...
float parameterPX(unsigned int index) const
Returns the parameter x momentum component, for 'index'.
IParticle::FourMom_t FourMom_t
Definition of the 4-momentum type.
float parameterX(unsigned int index) const
Returns the parameter x position, for 'index'.
const Trk::CurvilinearParameters curvilinearParameters(unsigned int index) const
Returns a curvilinear representation of the parameters at 'index'.
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .)
const ParametersCovMatrix_t definingParametersCovMatrix() const
Returns the 5x5 symmetric matrix containing the defining parameters covariance matrix.
float parameterPY(unsigned int index) const
Returns the parameter y momentum component, for 'index'.
const CurvilinearParameters_t trackParameters(unsigned int index) const
Returns the track parameter vector at 'index'.
float vz() const
The z origin for the parameters.
void setFitQuality(float chiSquared, float numberDoF)
Set the 'Fit Quality' information.
uint8_t hasValidTime() const
Returns whether or not the track has a valid time.
std::bitset< NumberOfTrackRecoInfo > patternRecoInfo() const
Access method for pattern recognition algorithm.
virtual double rapidity() const override final
The true rapidity (y) of the particle.
ParametersCovMatrix_t trackParameterCovarianceMatrix(unsigned int index) const
Returns the TrackParticleCovMatrix_t (covariance matrix) at 'index', which corresponds to the paramet...
void setParametersOrigin(float x, float y, float z)
Set the origin for the parameters.
float parameterZ(unsigned int index) const
Returns the parameter z position, for 'index'.
CxxUtils::CachedValue< Trk::Perigee > m_perigeeParameters
Cached MeasuredPerigee, built from this object.
float vy() const
The y origin for the parameters.
xAOD::ParameterPosition parameterPosition(unsigned int index) const
Return the ParameterPosition of the parameters at 'index'.
float d0() const
Returns the parameter.
void setDefiningParameters(float d0, float z0, float phi0, float theta, float qOverP)
Set the defining parameters.
bool summaryValue(uint8_t &value, const SummaryType &information) const
Accessor for TrackSummary values.
void setDefiningParametersCovMatrixDiagVec(const std::vector< float > &vec)
Set the defining parameters covariance matrix using a length 15 vector.
void setParticleHypothesis(const ParticleHypothesis hypo)
Method for setting the particle type, using the ParticleHypothesis enum.
size_t numberOfParameters() const
Returns the number of additional parameters stored in the TrackParticle.
float qOverP() const
Returns the parameter.
std::vector< float > definingParametersCovMatrixVec() const
Returns the length 6 vector containing the elements of defining parameters covariance matrix.
virtual Type::ObjectType type() const override final
The type of the object as a simple enumeration.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
float parameterY(unsigned int index) const
Returns the parameter y position, for 'index'.
GenVecFourMom_t genvecP4() const
The full 4-momentum of the particle : GenVector form.
float chiSquared() const
Returns the of the overall track fit.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
void setSummaryValue(uint8_t &value, const SummaryType &information)
Set method for TrackSummary values.
static const std::size_t COVMATRIX_OFFDIAG_VEC_COMPR_SIZE
ParametersCovMatrixFilled_t definingParametersCovMatrixFilled() const
Returns a 5x5 matrix describing which elements of the covariance matrix are known.
void setTrackFitter(const TrackFitter fitter)
Method for setting the fitter, using the TrackFitter enum.
void setPatternRecognitionInfo(const std::bitset< xAOD::NumberOfTrackRecoInfo > &patternReco)
Method setting the pattern recognition algorithm, using a bitset.
float charge() const
Returns the charge.
TrackParticle_v1()
Default constructor.
TrackFitter trackFitter() const
Returns the fitter.
const std::vector< float > & definingParametersCovMatrixOffDiagVec() const
Returns the correlation coefficient associated with the off-diagonal elements of the covariance matri...
std::vector< std::pair< covMatrixIndex, covMatrixIndex > > covMatrixIndexPairVec
ParticleHypothesis particleHypothesis() const
Returns the particle hypothesis used for Track fitting.
float phi0() const
Returns the parameter, which has range to .
void setDefiningParametersCovMatrixVec(const std::vector< float > &cov)
float parameterPZ(unsigned int index) const
Returns the parameter z momentum component, for 'index'.
virtual double e() const override final
The total energy of the particle.
Eigen::AngleAxisd AngleAxis3D
void compress(const AmgSymMatrix(N) &covMatrix, std::vector< float > &vec)
void expand(std::vector< float >::const_iterator it, std::vector< float >::const_iterator, AmgSymMatrix(N) &covMatrix)
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Translation< double, 3 > Translation3D
constexpr double muonMassInMeV
the mass of the muon (in MeV)
constexpr double chargedPionMassInMeV
the mass of the charged pion (in MeV)
constexpr double electronMassInMeV
the mass of the electron (in MeV)
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
CurvilinearParametersT< TrackParametersDim, Charged, PlaneSurface > CurvilinearParameters
void covarianceUnsetHook()
Function that would be possible to use to debug what client is trying to access covariance matrix fro...
GenVecFourMom_t genvecP4(float qOverP, float thetaT, float phiT, double m)
bool definingParametersCovMatrixOffDiagCompr(std::span< const float > covMatrixOffDiag)
xAOD::ParametersCovMatrix_t definingParametersCovMatrix(std::span< const float > covMatrixDiag, std::span< const float > covMatrixOffDiag, bool &valid)
float charge(float qOverP)
constexpr std::array< std::pair< covMatrixIndex, covMatrixIndex >, COVMATRIX_OFFDIAG_VEC_COMPR_SIZE > covMatrixComprIndexPairs
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
static const SG::AuxElement::Accessor< std::vector< float > > accCovMatrixOffDiag("definingParametersCovMatrixOffDiag")
Eigen::Matrix< bool, 5, 5, 0, 5, 5 > ParametersCovMatrixFilled_t
const SG::AuxElement::Accessor< float > * trackSummaryAccessorV1< float >(xAOD::SummaryType type)
const SG::AuxElement::Accessor< uint8_t > * trackSummaryAccessorV1< uint8_t >(xAOD::SummaryType type)
TrackFitter
Enums to identify who created this track and which properties does it have.
@ NumberOfTrackFitters
maximum number of enums
@ GaussianSumFilter
Tracks from Gaussian Sum Filter.
static const SG::AuxElement::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.
SummaryType
Enumerates the different types of information stored in Summary.
ParameterPosition
Enum allowing us to know where in ATLAS the parameters are defined.
static const SG::AuxElement::Accessor< std::vector< float > > accCovMatrixDiag("definingParametersCovMatrixDiag")