ATLAS Offline Software
Loading...
Searching...
No Matches
EFTrackingSmearMonAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8
9EFTrackingSmearMonAlg::EFTrackingSmearMonAlg( const std::string& name, ISvcLocator* pSvcLocator )
10: AthHistogramAlgorithm( name, pSvcLocator ){}
11
12
13
15 ATH_MSG_INFO ("Initializing " << name() << "...");
16 ATH_CHECK( m_inputTrackParticleKey.initialize() );
17 ATH_CHECK( m_inputTruthParticleKey.initialize() );
20
21
22 return StatusCode::SUCCESS;
23}
24
25StatusCode EFTrackingSmearMonAlg::execute(const EventContext& ctx) {
26
28 const xAOD::TrackParticleContainer* inputTracks = inputTracks_handle.cptr();
29 if (not inputTracks) {
30 ATH_MSG_FATAL("Unable to retrieve input ID tacks");
31 return StatusCode::FAILURE;
32 }
33
34
35 ATH_MSG_DEBUG ("Found "<<inputTracks->size()<< " input tracks");
36 // trakc particles
37 for ( const auto* trk : *inputTracks )
38 {
39 // get Cov matrix of input track
40 xAOD::ParametersCovMatrix_t trkcov = trk->definingParametersCovMatrix();
41 auto trkcovvec = trk->definingParametersCovMatrixVec();
42 if (trk->pt() == 0.) continue;
43 ATH_MSG_DEBUG ("Track: "
44 <<" curv=" << 1./trk->pt()
45 <<" phi=" << trk->phi()
46 <<" eta=" << trk->eta()
47 <<" d0=" << trk->d0()
48 <<" z0=" << trk->z0()
49 <<" pT=" << trk->pt()
50 <<" cov_d0=" << trkcov(Trk::d0,Trk::d0)
51 <<" cov_z0=" << trkcov(Trk::z0,Trk::z0)
52 <<" sigma_d0=" << std::sqrt(std::abs(trkcov(Trk::d0,Trk::d0)))
53 <<" sigma_z0=" << std::sqrt(std::abs(trkcov(Trk::z0,Trk::z0))) );
54 }
55
58 const xAOD::TrackParticleContainer* smearedTracks = smearedTracks_handle.cptr();
59 if (not smearedTracks) {
60 ATH_MSG_FATAL("Unable to retrieve smeared ID tacks");
61 return StatusCode::FAILURE;
62 }
63
64
65 ATH_MSG_DEBUG ("Found "<<smearedTracks->size()<< " smeared tracks");
66 // trakc particles
67 for ( const auto* trk : *smearedTracks )
68 {
69 // get Cov matrix of input track
70 xAOD::ParametersCovMatrix_t trkcov = trk->definingParametersCovMatrix();
71 auto trkcovvec = trk->definingParametersCovMatrixVec();
72 if (trk->pt() == 0.) continue;
73 ATH_MSG_DEBUG ("Smeared Track: "
74 <<" curv=" << 1./trk->pt()
75 <<" phi=" << trk->phi()
76 <<" eta=" << trk->eta()
77 <<" d0=" << trk->d0()
78 <<" z0=" << trk->z0()
79 <<" pT=" << trk->pt()
80 <<" cov_d0=" << trkcov(Trk::d0,Trk::d0)
81 <<" cov_z0=" << trkcov(Trk::z0,Trk::z0)
82 <<" sigma_d0=" << std::sqrt(std::abs(trkcov(Trk::d0,Trk::d0)))
83 <<" sigma_z0=" << std::sqrt(std::abs(trkcov(Trk::z0,Trk::z0))) );
84 }
85
87 //truth
89 const xAOD::TruthParticleContainer* inputTruth = inputTruth_handle.cptr();
90 if (not inputTruth) {
91 ATH_MSG_FATAL("Unable to retrieve input truth particle");
92 return StatusCode::FAILURE;
93 }
94
95 static const SG::ConstAccessor<float> ptAcc("pt");
96 static const SG::ConstAccessor<float> d0Acc("d0");
97 static const SG::ConstAccessor<float> z0Acc("z0");
98
99 ATH_MSG_DEBUG ("Found "<<inputTruth->size()<< " input truth particles");
100 for ( const auto* part : *inputTruth )
101 {
102 if (part->pt() == 0.) continue;
103 ATH_MSG_DEBUG ("===> Truth : "
104 <<" curv=" << 1./part->pt()
105 <<" phi=" << part->phi()
106 <<" eta=" << part->eta()
107 <<" d0=" << d0Acc(*part)
108 <<" z0=" << z0Acc(*part)
109 <<" pT=" << part->pt()
110 <<" PDGID=" << part->pdgId()
111 <<" status=" << part->status()
112 );
113 if (part->parent(0)) ATH_MSG_DEBUG (" parent pdgId=" << part->parent(0)->pdgId());
114 }
115
117
119 const xAOD::TruthParticleContainer* smearedTruth = smearedTruth_handle.cptr();
120 if (not smearedTruth) {
121 ATH_MSG_FATAL("Unable to retrieve input truth particle");
122 return StatusCode::FAILURE;
123 }
124
125 ATH_MSG_DEBUG ("Found "<<smearedTruth->size()<< " smeared truth particles");
126 for ( const auto* part : *smearedTruth )
127 {
128 if (part->pt() == 0.) continue;
129 ATH_MSG_DEBUG ("===> Truth : "
130 <<" curv=" << 1./ptAcc(*part)
131 <<" phi=" << part->phi()
132 <<" eta=" << part->eta()
133 <<" d0=" << d0Acc(*part)
134 <<" z0=" << z0Acc(*part)
135 <<" pT=" << ptAcc(*part)
136 <<" PDGID=" << part->pdgId()
137 <<" status=" << part->status()
138 );
139 if (part->parent(0)) ATH_MSG_DEBUG (" parent pdgId=" << part->parent(0)->pdgId());
140 }
141
142 return StatusCode::SUCCESS;
143}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Helper class to provide constant type-safe access to aux data.
AthHistogramAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
size_type size() const noexcept
Returns the number of elements in the collection.
EFTrackingSmearMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
virtual StatusCode initialize() override
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_smearedTruthParticleKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_smearedTrackParticleKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_inputTruthParticleKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputTrackParticleKey
Helper class to provide constant type-safe access to aux data.
const_pointer_type cptr()
Dereference the pointer.
@ d0
Definition ParamDefs.h:63
@ z0
Definition ParamDefs.h:64
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.