ATLAS Offline Software
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 
14 ParameterErrDecoratorAlg::ParameterErrDecoratorAlg(const std::string& name, ISvcLocator* pSvcLocator) :
15 AthReentrantAlgorithm(name, pSvcLocator) {
16 }
17 
19 // nop
20 }
21 
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  }
37 
39  assert( m_decor.size() == kNDecorators);
40 
41  return StatusCode::SUCCESS;
42 }
43 
46  return StatusCode::SUCCESS;
47 }
48 
50 ParameterErrDecoratorAlg::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 
69 bool
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 }
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
EventPrimitivesHelpers.h
IDPVM::createDecoratorKeysAndAccessor
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)
Definition: safeDecorator.h:52
ParameterErrDecoratorAlg::decorateTrack
virtual bool decorateTrack(const xAOD::TrackParticle &particle, std::vector< IDPVM::OptionalDecoration< xAOD::TrackParticleContainer, float > > &floatDecoration) const
Definition: ParameterErrDecoratorAlg.cxx:70
Trk::z0
@ z0
Definition: ParamDefs.h:70
AthCommonMsg< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
ReweightUtils.message
message
Definition: ReweightUtils.py:15
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition: EventPrimitives.h:52
ParameterErrDecoratorAlg::finalize
virtual StatusCode finalize()
Definition: ParameterErrDecoratorAlg.cxx:45
ParameterErrDecoratorAlg::m_decor
std::vector< std::pair< SG::WriteDecorHandleKey< xAOD::TrackParticleContainer >, SG::AuxElement::ConstAccessor< float > > > m_decor
Definition: ParameterErrDecoratorAlg.h:53
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
ParameterErrDecoratorAlg::kDecorZ0err
@ kDecorZ0err
Definition: ParameterErrDecoratorAlg.h:46
ParameterErrDecoratorAlg::execute
virtual StatusCode execute(const EventContext &ctx) const
Definition: ParameterErrDecoratorAlg.cxx:50
ParameterErrDecoratorAlg.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ParameterErrDecoratorAlg::~ParameterErrDecoratorAlg
virtual ~ParameterErrDecoratorAlg()
Definition: ParameterErrDecoratorAlg.cxx:18
IDPVM::OptionalDecoration
std::pair< SG::WriteDecorHandle< ContainerType, VariableType >, bool > OptionalDecoration
Definition: safeDecorator.h:48
Trk::theta
@ theta
Definition: ParamDefs.h:72
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
IDPVM::decorateOrRejectQuietly
void decorateOrRejectQuietly(const T_Cont_Elm &particle, OptionalDecoration< T_Cont, T > &decorator, const T &value)
Definition: safeDecorator.h:175
ParameterErrDecoratorAlg::kDecorD0err
@ kDecorD0err
Definition: ParameterErrDecoratorAlg.h:45
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
JacobianThetaPToCotThetaPt.h
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
ParameterErrDecoratorAlg::m_prefix
Gaudi::Property< std::string > m_prefix
Definition: ParameterErrDecoratorAlg.h:38
ParameterErrDecoratorAlg::m_trkParticleKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trkParticleKey
Definition: ParameterErrDecoratorAlg.h:42
IDPVM::createDecoratorsIfNeeded
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)
Definition: safeDecorator.h:70
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
Trk::d0
@ d0
Definition: ParamDefs.h:69
ParameterErrDecoratorAlg::initialize
virtual StatusCode initialize()
Definition: ParameterErrDecoratorAlg.cxx:23
Amg::error
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 ...
Definition: EventPrimitivesHelpers.h:40
ParameterErrDecoratorAlg::kDecorPhierr
@ kDecorPhierr
Definition: ParameterErrDecoratorAlg.h:47
ParameterErrDecoratorAlg::kDecorThetaerr
@ kDecorThetaerr
Definition: ParameterErrDecoratorAlg.h:48
GeoPrimitivesHelpers.h
DEBUG
#define DEBUG
Definition: page_access.h:11
ParameterErrDecoratorAlg::kDecorQoperr
@ kDecorQoperr
Definition: ParameterErrDecoratorAlg.h:49
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:73
Trk::phi
@ phi
Definition: ParamDefs.h:81
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
Trk::JacobianThetaPToCotThetaPt
Definition: JacobianThetaPToCotThetaPt.h:41
ParameterErrDecoratorAlg::ParameterErrDecoratorAlg
ParameterErrDecoratorAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: ParameterErrDecoratorAlg.cxx:14
ParameterErrDecoratorAlg::kNDecorators
@ kNDecorators
Definition: ParameterErrDecoratorAlg.h:50