ATLAS Offline Software
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 
9 EFTrackingSmearMonAlg::EFTrackingSmearMonAlg( const std::string& name, ISvcLocator* pSvcLocator )
10 : AthHistogramAlgorithm( name, pSvcLocator ){}
11 
12 
13 
15  ATH_MSG_INFO ("Initializing " << name() << "...");
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()) ATH_MSG_DEBUG (" parent pdgId=" << part->parent()->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()) ATH_MSG_DEBUG (" parent pdgId=" << part->parent()->pdgId());
141  }
142 
143  return StatusCode::SUCCESS;
144 }
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
EFTrackingSmearMonAlg::m_smearedTruthParticleKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_smearedTruthParticleKey
Definition: EFTrackingSmearMonAlg.h:38
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
Trk::z0
@ z0
Definition: ParamDefs.h:70
SG::ConstAccessor< float >
EFTrackingSmearMonAlg::m_inputTruthParticleKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_inputTruthParticleKey
Definition: EFTrackingSmearMonAlg.h:31
EFTrackingSmearMonAlg::execute
virtual StatusCode execute() override
Definition: EFTrackingSmearMonAlg.cxx:25
EFTrackingSmearMonAlg::m_smearedTrackParticleKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_smearedTrackParticleKey
Definition: EFTrackingSmearMonAlg.h:34
python.TrigInDetConfig.inputTracks
inputTracks
Definition: TrigInDetConfig.py:168
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
EFTrackingSmearMonAlg::EFTrackingSmearMonAlg
EFTrackingSmearMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: EFTrackingSmearMonAlg.cxx:9
EFTrackingSmearMonAlg::m_inputTrackParticleKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputTrackParticleKey
Definition: EFTrackingSmearMonAlg.h:27
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
AthHistogramAlgorithm
Definition: AthHistogramAlgorithm.h:32
DataVector< xAOD::TrackParticle_v1 >
EFTrackingSmearMonAlg.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
Trk::d0
@ d0
Definition: ParamDefs.h:69
EFTrackingSmearMonAlg::initialize
virtual StatusCode initialize() override
Definition: EFTrackingSmearMonAlg.cxx:14
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.