ATLAS Offline Software
Loading...
Searching...
No Matches
TrigMuonEFInfoCnvTestAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6
14
16
17#include <vector>
18#include <iomanip>
19
20static const double ptcheckthres=0.001;
21static const double etaphicheckthres=0.0001;
22
23TrigMuonEFInfoCnvTestAlg::TrigMuonEFInfoCnvTestAlg( const std::string& name, ISvcLocator* svcLoc ) :
24 AthAlgorithm(name, svcLoc)
25{
26 declareProperty( "AODContainerName", m_aodContainerName = "HLT_MuonEFInfo" );
27 declareProperty( "xAODMuonContainerName", m_xaodMuonContainerName = "HLT_Muons" );
28}
29
31
32 ATH_MSG_INFO( "AODContainerName = " << m_aodContainerName << ", xAODMuonContainerName = " << m_xaodMuonContainerName );
33
34 // Return gracefully:
35 return StatusCode::SUCCESS;
36}
37
39
40 // Retrieve the TrigMuonEFInfoContainer
41 const TrigMuonEFInfoContainer* infocont = evtStore()->tryConstRetrieve<TrigMuonEFInfoContainer>(m_aodContainerName);
42 if (!infocont) {
43 ATH_MSG_ERROR("No TrigMuonEFInfoContainer with key " << m_aodContainerName << " found.");
44 return StatusCode::RECOVERABLE;
45 }
46 ATH_MSG_DEBUG("Retrieved " << m_aodContainerName);
47
48 // Retrieve the xAOD::MuonContainer
49 const xAOD::MuonContainer* muoncont = evtStore()->tryConstRetrieve<xAOD::MuonContainer>(m_xaodMuonContainerName);
50 if(!muoncont) {
51 ATH_MSG_ERROR("No xAOD::MuonContainer with key " << m_xaodMuonContainerName << " found.");
52 return StatusCode::RECOVERABLE;
53 }
55
56 // put all TrigMuonEF tracks into a single vector
57 std::vector<const TrigMuonEFInfoTrack*> efinfotracks;
58 for(const auto *infoit : *infocont) {
59 const TrigMuonEFInfoTrackContainer* trkcont = infoit->TrackContainer();
60 for(const auto *trk : *trkcont) {
61
62 if(trk->hasCombinedTrack() || trk->hasExtrapolatedTrack()) {
63 // for now ignore MS only tracks
64 efinfotracks.push_back(trk);
65 }
66
67 }//loop on Info track objects
68 }//loop on TrigMuonEFInfo objects
69
70 ATH_MSG_DEBUG("N(TrigMuonEFInfoTrack) = " << efinfotracks.size());
71 ATH_MSG_DEBUG("N(muons) = " << muoncont->size());
72
73 if(efinfotracks.size() != muoncont->size()) {
74 ATH_MSG_ERROR("Inconsistency in number of muons from " << m_xaodMuonContainerName << " and " << m_aodContainerName);
75 ATH_MSG_ERROR("Converter code is likely faulty");
76 return StatusCode::RECOVERABLE;
77 }
78 ATH_MSG_DEBUG("Size of old & new vectors matches ok");
79
80 // same number of muons, now loop over them
81 for( unsigned int i=0; i<muoncont->size(); ++i) {
82
83 const TrigMuonEFInfoTrack* infotrk = efinfotracks[i];
84 const xAOD::Muon* muon = (*muoncont)[i];
85
86 if(!infotrk) {
87 ATH_MSG_ERROR("Zero pointer for TrigMuonEFInfoTrack");
88 return StatusCode::RECOVERABLE;
89 }
90 if(!muon) {
91 ATH_MSG_ERROR("Zero pointer for xAOD::Muon");
92 return StatusCode::RECOVERABLE;
93 }
94
95 ATH_MSG_DEBUG("Check muon " << i);
96
98 ATH_CHECK(compareCombinedTracks(infotrk, muon));
99 ATH_CHECK(comparePrimaryTracks(infotrk, muon));
100
101 }//loop on muons
102
103 return StatusCode::SUCCESS;
104}//execute
105
111 using enum xAOD::Muon::TrackParticleType;
112 if( !infotrk->hasExtrapolatedTrack() ) {
113 ATH_MSG_DEBUG("TrigMuonEFInfo track has no extrapolated track");
114 if(muon->trackParticle(MuonSpectrometerTrackParticle) ) {
115 ATH_MSG_ERROR("Mismatch: TrigMuonEFInfoTrack has no ME track, xAOD::Muon does");
116 return StatusCode::RECOVERABLE;
117 }
118
119 return StatusCode::SUCCESS; // ok both new and old don't have the track
120 }
121
122 if( infotrk->hasExtrapolatedTrack() ) {
123 ATH_MSG_DEBUG("TrigMuonEFInfo track has extrapolated track");
124 if( !(muon->trackParticle(MuonSpectrometerTrackParticle)) ) {
125 ATH_MSG_ERROR("Mismatch: TrigMuonEFInfoTrack has ME track, xAOD::Muon does not");
126 return StatusCode::RECOVERABLE;
127 }
128 }
129
130 // now compare the actual tracks
131 ATH_CHECK(compareTracks( infotrk->ExtrapolatedTrack(), muon->trackParticle(MuonSpectrometerTrackParticle)));
132 return StatusCode::SUCCESS;
133}
134
139 using enum xAOD::Muon::TrackParticleType;
140 if( !infotrk->hasCombinedTrack() ) {
141 ATH_MSG_DEBUG("TrigMuonEFInfo track has no combined track");
142
143 if(muon->trackParticle(CombinedTrackParticle)) {
144 ATH_MSG_ERROR("Mismatch: TrigMuonEFInfoTrack has no combined track, xAOD::Muon does");
145 return StatusCode::RECOVERABLE;
146 }
147
148 return StatusCode::SUCCESS; // ok both new and old don't have the track
149 }
150
151 if( infotrk->hasCombinedTrack() ) {
152 ATH_MSG_DEBUG("TrigMuonEFInfo track has combined track");
153 if( !muon->trackParticle(CombinedTrackParticle) ) {
154 ATH_MSG_ERROR("Mismatch: TrigMuonEFInfoTrack has combined track, xAOD::Muon does not");
155 return StatusCode::RECOVERABLE;
156 }
157 }
158
159 // now compare the actual tracks
160 ATH_CHECK(compareTracks( infotrk->CombinedTrack(), muon->trackParticle(CombinedTrackParticle)));
161
162 return StatusCode::SUCCESS;
163}
164
169
170 const TrigMuonEFTrack* primtrk=nullptr;
171 if( infotrk->hasExtrapolatedTrack() ) {
172 primtrk = infotrk->ExtrapolatedTrack();
173 }
174 if( infotrk->hasCombinedTrack() ) {
175 primtrk = infotrk->CombinedTrack();
176 }
177 ATH_CHECK(compareTracks(primtrk, muon->primaryTrackParticle()));
178
179 ATH_MSG_DEBUG("Passed check on primary track");
180
181 return StatusCode::SUCCESS;
182
183}//comparePrimaryTracks
184
186
187 if(msgLvl(MSG::VERBOSE)) {
188 msg() << MSG::VERBOSE << "Compare Track:" << endmsg;
189 msg() << MSG::VERBOSE << "old track pt = " << eftrack->pt() << ", new track pt = " << xaodtrack->pt() << endmsg;
190 msg() << MSG::VERBOSE << "old track eta = " << eftrack->eta() << ", new track eta = " << xaodtrack->eta() << endmsg;
191 msg() << MSG::VERBOSE << "old track phi = " << eftrack->phi() << ", new track phi = " << xaodtrack->phi() << endmsg;
192 }
193 const double dpt = std::abs(eftrack->pt() - xaodtrack->pt());
194 if( dpt > ptcheckthres*eftrack->pt() ) { // pT check is relative - we accept 0.1% changes
195
196 ATH_MSG_ERROR("pT of two tracks is different, old = " << std::fixed << std::setprecision(8) << eftrack->pt() << ", new = " << xaodtrack->pt() << ", dpt = " << dpt);
197 return StatusCode::RECOVERABLE;
198
199 }
200 if( std::abs(eftrack->eta() - xaodtrack->eta()) > etaphicheckthres ) {
201 ATH_MSG_ERROR("eta of two tracks is different, old = " << eftrack->eta() << ", new = " << xaodtrack->eta());
202 return StatusCode::RECOVERABLE;
203 }
204 const double dphi = P4Helpers::deltaPhi( eftrack->phi(), xaodtrack->phi() );
205 if( std::abs(dphi) > etaphicheckthres) {
206 ATH_MSG_ERROR("phi of two tracks is different, old = " << eftrack->phi() << ", new = " << xaodtrack->phi());
207 return StatusCode::RECOVERABLE;
208 }
209
210 return StatusCode::SUCCESS;
211}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
static const double etaphicheckthres
static const double ptcheckthres
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() const
size_type size() const noexcept
Returns the number of elements in the collection.
virtual double eta() const
pseudo rapidity
virtual double pt() const
transverse momentum
virtual double phi() const
get phi data member
StatusCode compareTracks(const TrigMuonEFTrack *eftrack, const xAOD::TrackParticle *xaodtrack)
compare tracks
std::string m_xaodMuonContainerName
The key for the xAOD::MuonContainer.
std::string m_aodContainerName
The key of the TrigMuonEFInfoContainer.
StatusCode comparePrimaryTracks(const TrigMuonEFInfoTrack *infotrk, const xAOD::Muon *muon)
compare primary tracks
virtual StatusCode initialize()
Function initialising the algorithm.
StatusCode compareExtrapolatedTracks(const TrigMuonEFInfoTrack *infotrk, const xAOD::Muon *muon)
compare extrapolated tracks
virtual StatusCode execute()
Function executing the algorithm.
TrigMuonEFInfoCnvTestAlg(const std::string &name, ISvcLocator *svcLoc)
Regular algorithm constructor.
StatusCode compareCombinedTracks(const TrigMuonEFInfoTrack *infotrk, const xAOD::Muon *muon)
compare combined tracks
TrigMuonEFCbTrack * CombinedTrack()
TrigMuonEFTrack * ExtrapolatedTrack()
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .).
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
Definition P4Helpers.h:34
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Muon_v1 Muon
Reference the current persistent version:
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".