92{
93 const EventContext& ctx = Gaudi::Hive::currentContext();
94
95
96
97
99
100
101
102
103 SG::ReadHandle<xAOD::TrackParticleContainer> h_inDetTracks(
m_inDetTracksKey, ctx);
104 if (!h_inDetTracks.isValid()){
105 ATH_MSG_FATAL(
"execute - failed to find the InDetTrackParticles");
106 return StatusCode::FAILURE;
107 }
108
110
111
112
113
114
115 std::unique_ptr<xAOD::VertexContainer> refitVtxContainer = std::make_unique< xAOD::VertexContainer>();
116 std::unique_ptr<xAOD::VertexAuxContainer> refitVtxContainerAux = std::make_unique< xAOD::VertexAuxContainer>();
117
118 refitVtxContainer->setStore(refitVtxContainerAux.get());
119
122 std::move(refitVtxContainer), std::move(refitVtxContainerAux)
123 ));
125
126
127
128
130 if (!h_leptonContainer.isValid()){
131 ATH_MSG_FATAL(
"execute - failed to find the lepton container");
132 return StatusCode::FAILURE;
133 }
134
136 if (!h_vertices.isValid()){
138 return StatusCode::FAILURE;
139 }
140
143
144 Prompt::FittingInput fittingInput(&inDetTracks, 0, 0);
145
147 if(
vertex->vertexType() == 1) {
149 break;
150 }
151 }
152
153 if(!fittingInput.priVtx) {
154 ATH_MSG_INFO(
"Failed to find primary vertices - save empty containers");
155 return StatusCode::SUCCESS;
156 }
157
158
159
160
161 std::vector<const xAOD::TrackParticle *> priVtx_tracks;
162 priVtx_tracks.reserve(fittingInput.priVtx->nTrackParticles());
163
164 for(
unsigned k = 0;
k < fittingInput.priVtx->nTrackParticles(); ++
k) {
166
167 if(track) {
168 priVtx_tracks.push_back(track);
169 }
170 }
171
172
174 fittingInput, priVtx_tracks,
175 fittingInput.priVtx->position(),
177 );
178
179 if(!refittedPriVtx) {
180 ATH_MSG_WARNING(
"Failed to refit primary vertex - save empty containers");
181 return StatusCode::SUCCESS;
182 }
183
184
185
186
187 fittingInput.refittedPriVtx = refittedPriVtx.get();
188
189 ATH_MSG_DEBUG(
"execute -- primary vertex NTrack = " << fittingInput.priVtx ->nTrackParticles());
190 ATH_MSG_DEBUG(
"execute -- refitted primary vertex NTrack = " << fittingInput.refittedPriVtx->nTrackParticles());
191
192
193
194
196 <<
"\n\t\t\t Size of lepton container: " << leptonContainer.
size()
197 << "\n-----------------------------------------------------------------");
198
199 SG::WriteDecorHandle<xAOD::IParticleContainer, ElementLink<xAOD::VertexContainer> >
201
202 DataLink<xAOD::VertexContainer> refitVtxContainerLink (refitVtxContainerRef, ctx);
203 for(const xAOD::IParticle *lepton: leptonContainer) {
207
208 if(elec) {
209
210
211
213
214
215
216
218 }
219 else if(muon) {
220 if(
muon->inDetTrackParticleLink().isValid()) {
221 tracklep = *(
muon->inDetTrackParticleLink());
222 }
223 else {
224 ATH_MSG_DEBUG(
"PrimaryVertexReFitter::execute - skip muon without valid inDetTrackParticleLink()");
225 continue;
226 }
227 }
228
229 if(!tracklep) {
230 ATH_MSG_WARNING(
"PrimaryVertexReFitter::execute - cannot find muon->inDetTrackParticleLink() nor electron->trackParticle()");
231 continue;
232 }
233
235 {
236 lepRefittedRMVtxLinkDec(*lepton) = ElementLink<xAOD::VertexContainer>(refitVtxContainerLink, refitVtxContainerRef.
size()-1);
237 }
238 }
239
240 h_refitVtxContainer->push_back(std::move(refittedPriVtx));
241
243
246
247 return StatusCode::SUCCESS;
248}
#define ATH_CHECK
Evaluate an expression and check for errors.
size_type size() const noexcept
Returns the number of elements in the collection.
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_lepRefittedVtxWithoutLeptonLinkName
SG::ReadHandleKey< xAOD::VertexContainer > m_primaryVertexContainerKey
SG::ReadHandleKey< xAOD::IParticleContainer > m_leptonContainerKey
SG::WriteHandleKey< xAOD::VertexContainer > m_reFitPrimaryVertexKey
bool decorateLepWithReFitPrimaryVertex(const FittingInput &input, const xAOD::TrackParticle *tracklep, const std::vector< const xAOD::TrackParticle * > &tracks, xAOD::VertexContainer &refitVtxContainer)
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inDetTracksKey
const xAOD::TrackParticle * trackParticle(size_t index=0) const
Pointer to the xAOD::TrackParticle/s that match the electron candidate.
timer(name, disabled=False)
const xAOD::TrackParticle * getOriginalTrackParticleFromGSF(const xAOD::TrackParticle *trkPar)
Helper function for getting the "Original" Track Particle (i.e before GSF) via the GSF Track Particle...
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
Muon_v1 Muon
Reference the current persistent version:
Electron_v1 Electron
Definition of the current "egamma version".
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.