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
112 if( !infotrk->hasExtrapolatedTrack() ) {
113 ATH_MSG_DEBUG("TrigMuonEFInfo track has no extrapolated track");
114 if(muon->muonSpectrometerTrackParticleLink().isValid() ) {
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->muonSpectrometerTrackParticleLink().isValid()) ) {
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 StatusCode sc = compareTracks( infotrk->ExtrapolatedTrack(), *(muon->muonSpectrometerTrackParticleLink()) );
132 if(sc.isFailure()) return sc;
133 else ATH_MSG_DEBUG("Passed check on extrapolated track");
134
135 return StatusCode::SUCCESS;
136}
137
142
143 if( !infotrk->hasCombinedTrack() ) {
144 ATH_MSG_DEBUG("TrigMuonEFInfo track has no combined track");
145 if(muon->combinedTrackParticleLink().isValid() ) {
146 ATH_MSG_ERROR("Mismatch: TrigMuonEFInfoTrack has no combined track, xAOD::Muon does");
147 return StatusCode::RECOVERABLE;
148 }
149
150 return StatusCode::SUCCESS; // ok both new and old don't have the track
151 }
152
153 if( infotrk->hasCombinedTrack() ) {
154 ATH_MSG_DEBUG("TrigMuonEFInfo track has combined track");
155 if( !(muon->combinedTrackParticleLink().isValid()) ) {
156 ATH_MSG_ERROR("Mismatch: TrigMuonEFInfoTrack has combined track, xAOD::Muon does not");
157 return StatusCode::RECOVERABLE;
158 }
159 }
160
161 // now compare the actual tracks
162 StatusCode sc = compareTracks( infotrk->CombinedTrack(), *(muon->combinedTrackParticleLink()) );
163 if(sc.isFailure()) return sc;
164 else ATH_MSG_DEBUG("Passed check on combined track");
165
166 return StatusCode::SUCCESS;
167}
168
173
174 const TrigMuonEFTrack* primtrk=nullptr;
175 if( infotrk->hasExtrapolatedTrack() ) {
176 primtrk = infotrk->ExtrapolatedTrack();
177 }
178 if( infotrk->hasCombinedTrack() ) {
179 primtrk = infotrk->CombinedTrack();
180 }
181 if(primtrk!=nullptr && muon->primaryTrackParticleLink().isValid()) {
182 StatusCode sc = compareTracks(primtrk, *(muon->primaryTrackParticleLink()));
183 if(sc.isFailure()) return sc;
184 } else {
185 if(primtrk!=nullptr || muon->primaryTrackParticleLink().isValid()) {
186 ATH_MSG_ERROR("One of the primary tracks is not good, old = " << (primtrk!=nullptr) << ", new = " << muon->primaryTrackParticleLink().isValid() );
187 return StatusCode::RECOVERABLE;
188 } else return StatusCode::SUCCESS; // this means both are 0, which is ok
189 }
190
191 ATH_MSG_DEBUG("Passed check on primary track");
192
193 return StatusCode::SUCCESS;
194
195}//comparePrimaryTracks
196
198
199 if(msgLvl(MSG::VERBOSE)) {
200 msg() << MSG::VERBOSE << "Compare Track:" << endmsg;
201 msg() << MSG::VERBOSE << "old track pt = " << eftrack->pt() << ", new track pt = " << xaodtrack->pt() << endmsg;
202 msg() << MSG::VERBOSE << "old track eta = " << eftrack->eta() << ", new track eta = " << xaodtrack->eta() << endmsg;
203 msg() << MSG::VERBOSE << "old track phi = " << eftrack->phi() << ", new track phi = " << xaodtrack->phi() << endmsg;
204 }
205 const double dpt = std::abs(eftrack->pt() - xaodtrack->pt());
206 if( dpt > ptcheckthres*eftrack->pt() ) { // pT check is relative - we accept 0.1% changes
207
208 ATH_MSG_ERROR("pT of two tracks is different, old = " << std::fixed << std::setprecision(8) << eftrack->pt() << ", new = " << xaodtrack->pt() << ", dpt = " << dpt);
209 return StatusCode::RECOVERABLE;
210
211 }
212 if( std::abs(eftrack->eta() - xaodtrack->eta()) > etaphicheckthres ) {
213 ATH_MSG_ERROR("eta of two tracks is different, old = " << eftrack->eta() << ", new = " << xaodtrack->eta());
214 return StatusCode::RECOVERABLE;
215 }
216 const double dphi = P4Helpers::deltaPhi( eftrack->phi(), xaodtrack->phi() );
217 if( std::abs(dphi) > etaphicheckthres) {
218 ATH_MSG_ERROR("phi of two tracks is different, old = " << eftrack->phi() << ", new = " << xaodtrack->phi());
219 return StatusCode::RECOVERABLE;
220 }
221
222 return StatusCode::SUCCESS;
223}
#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 Double_t sc
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".