ATLAS Offline Software
Loading...
Searching...
No Matches
ParameterErrDecoratorAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
13
14ParameterErrDecoratorAlg::ParameterErrDecoratorAlg(const std::string& name, ISvcLocator* pSvcLocator) :
15AthReentrantAlgorithm(name, pSvcLocator) {
16}
17
21
22StatusCode
24 ATH_CHECK( m_trkParticleKey.initialize() );
25
26 std::vector<std::string> decorationNames(kNDecorators);
27 decorationNames[kDecorD0err]="d0err";
28 decorationNames[kDecorZ0err]="z0err";
29 decorationNames[kDecorPhierr]="phierr";
30 decorationNames[kDecorThetaerr]="thetaerr";
31 decorationNames[kDecorQoperr]="qoperr";
32 std::string message{"The following decorations should be added by ParameterErrDecoratorAlg:\n"};
33 for (const auto & thisName: decorationNames){
34 message += thisName+"\n";
35 }
36 ATH_MSG_INFO(message);
37
39 assert( m_decor.size() == kNDecorators);
40
41 return StatusCode::SUCCESS;
42}
43
44StatusCode
46 return StatusCode::SUCCESS;
47}
48
49StatusCode
50ParameterErrDecoratorAlg::execute(const EventContext &ctx) const {
52 if ((not ptracks.isValid())) {
53 ATH_MSG_ERROR("The track particle container '"<< m_trkParticleKey.key()<<"' could not be read.");
54 return StatusCode::FAILURE;
55 }
56 std::vector< IDPVM::OptionalDecoration<xAOD::TrackParticleContainer,float> >
57 floatDecoration( IDPVM::createDecoratorsIfNeeded(*ptracks, m_decor, ctx, msgLvl(MSG::DEBUG)) );
58 if (not floatDecoration.empty()){
59 for (const xAOD::TrackParticle *pTrkParticle : *ptracks) {
60 if (not decorateTrack(*pTrkParticle, floatDecoration) ) {
61 ATH_MSG_ERROR("Decoration failed in ParameterErrDecoratorAlg::execute.");
62 return StatusCode::FAILURE;
63 }
64 }
65 }
66 return StatusCode::SUCCESS;
67}
68
69bool
71 std::vector<IDPVM::OptionalDecoration<xAOD::TrackParticleContainer, float> > &floatDecoration) const {
72 ATH_MSG_VERBOSE("Decorate track with errors ");
73 bool success(true);
74 const AmgSymMatrix(5) errorMat = particle.definingParametersCovMatrix();
75 double mtheta = particle.theta();
76 double mqp = particle.qOverP();
77 Trk::JacobianThetaPToCotThetaPt TheJac(mtheta, mqp);
78 AmgSymMatrix(5) covVert;
79 covVert = errorMat.similarity(TheJac);
80
81 // 'safeDecorator' used to prevent a crash in case of adding something which pre-exists.
82 // behaviour chosen is to reject quietly
83 float d0err = Amg::error(covVert, Trk::d0);
84 float z0err = Amg::error(covVert, Trk::z0);
85 float phierr = Amg::error(covVert, Trk::phi);
86 float thetaerr = Amg::error(covVert, Trk::theta);
87 float qoperr = Amg::error(covVert, Trk::qOverP)*1000.;
88
89 IDPVM::decorateOrRejectQuietly(particle,floatDecoration[kDecorD0err],d0err);
90 IDPVM::decorateOrRejectQuietly(particle,floatDecoration[kDecorZ0err],z0err);
91 IDPVM::decorateOrRejectQuietly(particle,floatDecoration[kDecorPhierr],phierr);
92 IDPVM::decorateOrRejectQuietly(particle,floatDecoration[kDecorThetaerr],thetaerr);
93 IDPVM::decorateOrRejectQuietly(particle,floatDecoration[kDecorQoperr],qoperr);
94
95 return success;
96}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define AmgSymMatrix(dim)
header file for class of same name
bool msgLvl(const MSG::Level lvl) const
An algorithm that can be simultaneously executed in multiple threads.
virtual bool decorateTrack(const xAOD::TrackParticle &particle, std::vector< IDPVM::OptionalDecoration< xAOD::TrackParticleContainer, float > > &floatDecoration) const
Gaudi::Property< std::string > m_prefix
std::vector< std::pair< SG::WriteDecorHandleKey< xAOD::TrackParticleContainer >, SG::AuxElement::ConstAccessor< float > > > m_decor
virtual StatusCode execute(const EventContext &ctx) const
ParameterErrDecoratorAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trkParticleKey
virtual bool isValid() override final
Can the handle be successfully dereferenced?
This is the 5x5 jacobian for the transformation of track parameters and errors having the new standar...
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
void createDecoratorKeysAndAccessor(T_Parent &parent, const SG::ReadHandleKey< T_Cont > &container_key, const std::string &prefix, const std::vector< std::string > &decor_names, std::vector< WriteKeyAccessorPair< T_Cont, T > > &decor_out)
void decorateOrRejectQuietly(const T_Cont_Elm &particle, OptionalDecoration< T_Cont, T > &decorator, const T &value)
std::vector< OptionalDecoration< T_Cont, T > > createDecoratorsIfNeeded(const T_Cont &container, const std::vector< WriteKeyAccessorPair< T_Cont, T > > &keys, const EventContext &ctx, bool verbose=false)
std::pair< SG::WriteDecorHandle< ContainerType, VariableType >, bool > OptionalDecoration
@ theta
Definition ParamDefs.h:66
@ qOverP
perigee
Definition ParamDefs.h:67
@ phi
Definition ParamDefs.h:75
@ d0
Definition ParamDefs.h:63
@ z0
Definition ParamDefs.h:64
TrackParticle_v1 TrackParticle
Reference the current persistent version: