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
26 auto ctx = getContext() ;
27
29 const xAOD::TrackParticleContainer* inputTracks = inputTracks_handle.cptr();
30 if (not inputTracks) {
31 ATH_MSG_FATAL("Unable to retrieve input ID tacks");
32 return StatusCode::FAILURE;
33 }
34
35
36 ATH_MSG_DEBUG ("Found "<<inputTracks->size()<< " input tracks");
37 // trakc particles
38 for ( const auto* trk : *inputTracks )
39 {
40 // get Cov matrix of input track
41 xAOD::ParametersCovMatrix_t trkcov = trk->definingParametersCovMatrix();
42 auto trkcovvec = trk->definingParametersCovMatrixVec();
43 if (trk->pt() == 0.) continue;
44 ATH_MSG_DEBUG ("Track: "
45 <<" curv=" << 1./trk->pt()
46 <<" phi=" << trk->phi()
47 <<" eta=" << trk->eta()
48 <<" d0=" << trk->d0()
49 <<" z0=" << trk->z0()
50 <<" pT=" << trk->pt()
51 <<" cov_d0=" << trkcov(Trk::d0,Trk::d0)
52 <<" cov_z0=" << trkcov(Trk::z0,Trk::z0)
53 <<" sigma_d0=" << std::sqrt(std::abs(trkcov(Trk::d0,Trk::d0)))
54 <<" sigma_z0=" << std::sqrt(std::abs(trkcov(Trk::z0,Trk::z0))) );
55 }
56
59 const xAOD::TrackParticleContainer* smearedTracks = smearedTracks_handle.cptr();
60 if (not smearedTracks) {
61 ATH_MSG_FATAL("Unable to retrieve smeared ID tacks");
62 return StatusCode::FAILURE;
63 }
64
65
66 ATH_MSG_DEBUG ("Found "<<smearedTracks->size()<< " smeared tracks");
67 // trakc particles
68 for ( const auto* trk : *smearedTracks )
69 {
70 // get Cov matrix of input track
71 xAOD::ParametersCovMatrix_t trkcov = trk->definingParametersCovMatrix();
72 auto trkcovvec = trk->definingParametersCovMatrixVec();
73 if (trk->pt() == 0.) continue;
74 ATH_MSG_DEBUG ("Smeared Track: "
75 <<" curv=" << 1./trk->pt()
76 <<" phi=" << trk->phi()
77 <<" eta=" << trk->eta()
78 <<" d0=" << trk->d0()
79 <<" z0=" << trk->z0()
80 <<" pT=" << trk->pt()
81 <<" cov_d0=" << trkcov(Trk::d0,Trk::d0)
82 <<" cov_z0=" << trkcov(Trk::z0,Trk::z0)
83 <<" sigma_d0=" << std::sqrt(std::abs(trkcov(Trk::d0,Trk::d0)))
84 <<" sigma_z0=" << std::sqrt(std::abs(trkcov(Trk::z0,Trk::z0))) );
85 }
86
88 //truth
90 const xAOD::TruthParticleContainer* inputTruth = inputTruth_handle.cptr();
91 if (not inputTruth) {
92 ATH_MSG_FATAL("Unable to retrieve input truth particle");
93 return StatusCode::FAILURE;
94 }
95
96 static const SG::ConstAccessor<float> ptAcc("pt");
97 static const SG::ConstAccessor<float> d0Acc("d0");
98 static const SG::ConstAccessor<float> z0Acc("z0");
99
100 ATH_MSG_DEBUG ("Found "<<inputTruth->size()<< " input truth particles");
101 for ( const auto* part : *inputTruth )
102 {
103 if (part->pt() == 0.) continue;
104 ATH_MSG_DEBUG ("===> Truth : "
105 <<" curv=" << 1./part->pt()
106 <<" phi=" << part->phi()
107 <<" eta=" << part->eta()
108 <<" d0=" << d0Acc(*part)
109 <<" z0=" << z0Acc(*part)
110 <<" pT=" << part->pt()
111 <<" PDGID=" << part->pdgId()
112 <<" status=" << part->status()
113 );
114 if (part->parent(0)) ATH_MSG_DEBUG (" parent pdgId=" << part->parent(0)->pdgId());
115 }
116
118
120 const xAOD::TruthParticleContainer* smearedTruth = smearedTruth_handle.cptr();
121 if (not smearedTruth) {
122 ATH_MSG_FATAL("Unable to retrieve input truth particle");
123 return StatusCode::FAILURE;
124 }
125
126 ATH_MSG_DEBUG ("Found "<<smearedTruth->size()<< " smeared truth particles");
127 for ( const auto* part : *smearedTruth )
128 {
129 if (part->pt() == 0.) continue;
130 ATH_MSG_DEBUG ("===> Truth : "
131 <<" curv=" << 1./ptAcc(*part)
132 <<" phi=" << part->phi()
133 <<" eta=" << part->eta()
134 <<" d0=" << d0Acc(*part)
135 <<" z0=" << z0Acc(*part)
136 <<" pT=" << ptAcc(*part)
137 <<" PDGID=" << part->pdgId()
138 <<" status=" << part->status()
139 );
140 if (part->parent(0)) ATH_MSG_DEBUG (" parent pdgId=" << part->parent(0)->pdgId());
141 }
142
143 return StatusCode::SUCCESS;
144}
#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() override
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.