108{
109
110
111
113
114 const EventContext& ctx = Gaudi::Hive::currentContext();
115
117
118
119
120
121 SG::ReadHandle<xAOD::TrackParticleContainer> h_inDetTracks(
m_inDetTracksKey, ctx);
122 if (!h_inDetTracks.isValid()){
123 ATH_MSG_FATAL(
"execute - failed to find the InDetTrackParticles");
124 return StatusCode::FAILURE;
125 }
126
128
129
130
131
132 std::set< xAOD::Vertex* > svSet;
133
136 std::make_unique< xAOD::VertexContainer>(), std::make_unique< xAOD::VertexAuxContainer>()
137 ));
139
140
141
142
146
147 ATH_MSG_DEBUG (
"NonPromptLeptonVertexingAlg::execute - Read " << vertices->size() <<
" primary vertices");
148 ATH_MSG_DEBUG (
"NonPromptLeptonVertexingAlg::execute - Read " << refittedVertices->size() <<
" refitted primary vertices");
149
150
151
152
153 Prompt::FittingInput fittingInput(&inDetTracks, 0, 0);
154
157 fittingInput.priVtx =
vertex;
158 break;
159 }
160 }
161
162 if(!fittingInput.priVtx) {
163 ATH_MSG_INFO(
"Failed to find primary vertex - skip this event");
164
165 return StatusCode::SUCCESS;
166 }
167
168
169
170
172 short refittedVertexType = 0;
173
175 fittingInput.refittedPriVtx =
vertex;
176 }
177
178 if(fittingInput.refittedPriVtx) {
179 break;
180 }
181 }
182
183
184
185
186 ATH_MSG_DEBUG(
"\n\t\t\t Size of lepton container: " << leptonContainer ->size());
187
189
190 using VecElemVtx_t = std::vector<ElementLink<xAOD::VertexContainer> >;
191 SG::WriteDecorHandle<xAOD::IParticleContainer, std::vector<int> >
193 SG::WriteDecorHandle<xAOD::IParticleContainer, std::vector<int> >
195 SG::WriteDecorHandle<xAOD::IParticleContainer, VecElemVtx_t>
197 SG::WriteDecorHandle<xAOD::IParticleContainer, VecElemVtx_t>
199
200 for(const xAOD::IParticle *lepton: *leptonContainer) {
204
205 if(elec) {
206
207
208
210
211
212
213
216 }
217 }
218 else if(muon) {
220 tracklep = *(
muon->inDetTrackParticleLink());
221 }
222 }
223 else {
224 ATH_MSG_WARNING(
"NonPromptLeptonVertexingAlg::execute - failed to find electron or muon: should never happen!");
225 }
226
227 if(!tracklep) {
228 lepSVElementLinksDec (*lepton).clear();
229 lepDeepMergedSVElementLinksDec(*lepton).clear();
230 indexVectorDec (*lepton).clear();
231 indexVectorDecDeepMerge (*lepton).clear();
232
233 ATH_MSG_DEBUG(
"NonPromptLeptonVertexingAlg::execute - cannot find muon->inDetTrackParticleLink() nor electron->trackParticle()");
234 continue;
235 }
236
237 ATH_MSG_DEBUG(
"NonPromptLeptonVertexingAlg::execute - process new lepton track " << tracklep);
238
239
240
241
242 fittingInput.refittedPriVtxWithoutLep = 0;
243
244 if(priVtxWithoutLepAcc.isAvailable(*lepton)) {
245 ElementLink<xAOD::VertexContainer> vtxLink = priVtxWithoutLepAcc(*lepton);
246
248 fittingInput.refittedPriVtxWithoutLep = *vtxLink;
249
250 ATH_MSG_DEBUG(
"DecorateSecondaryVertex - found refitted primary vertex without lepton: "
252 }
253 }
254
255
256
257
258 std::vector<const xAOD::TrackParticle* > ifitTracks =
findNearbyTracks(*tracklep, inDetTracks, *fittingInput.priVtx);
259
260
261
262
264 fittingInput, tracklep, ifitTracks
265 );
266
267
268
269 std::vector<std::unique_ptr<xAOD::Vertex>> twoTrkVerticesCopy;
270 for (std::unique_ptr<xAOD::Vertex> &vtx : twoTrkVertices) {
271 std::unique_ptr<xAOD::Vertex> newVtx = std::make_unique<xAOD::Vertex>(*vtx);
272 twoTrkVerticesCopy.push_back(std::move(newVtx));
273 }
274
275
277 ATH_MSG_DEBUG(
"Starting with " << twoTrkVertices.size() <<
" 2-track vertices");
278 Prompt::MergeResultNotOwner deep_merged_result =
m_vertexMerger->mergeInitVertices(
279 fittingInput, tracklep, twoTrkVertices, ifitTracks);
280
281
282
283
284 std::vector<ElementLink<xAOD::VertexContainer> > svLinks;
285 std::vector<ElementLink<xAOD::VertexContainer> > deepmergeSVLinks;
286
287 std::vector<int> indexVectorTwoTrk;
288 std::vector<int> indexVectorDeepMerged;
289
290
291
292
293 ATH_MSG_DEBUG(
"NonPromptLeptonVertexingAlg::execute --- recording " << twoTrkVerticesCopy.size() <<
" 2-track and simple merged vertices");
295
296
297
298
299 ATH_MSG_DEBUG(
"NonPromptLeptonVertexingAlg::execute --- recording " << deep_merged_result.
vtxsNewMerged.size() <<
" merged multi-track vertices");
301
304
305 ATH_MSG_DEBUG (
"NonPromptLeptonVertexingAlg::execute -- number of two-track SV = " << twoTrkVertices.size());
306 ATH_MSG_DEBUG (
"NonPromptLeptonVertexingAlg::execute -- number of deep merged SV = " << deep_merged_result.
vtxsNewMerged.size());
307
308 lepSVElementLinksDec (*lepton) = std::move(svLinks);
309 lepDeepMergedSVElementLinksDec(*lepton) = std::move(deepmergeSVLinks);
310 indexVectorDec (*lepton) = std::move(indexVectorTwoTrk);
311 indexVectorDecDeepMerge (*lepton) = std::move(indexVectorDeepMerged);
312
313 ATH_MSG_DEBUG(
"NonPromptLeptonVertexingAlg - done with lepton pT=" << tracklep->
pt() <<
", " <<
truthAsStr(*lepton) << endl
314 << "___________________________________________________________________________");
315 }
316
318
319 ATH_MSG_DEBUG(
" NonPromptLeptonVertexingAlg::execute - done with this event" << endl
320 << "___________________________________________________________________________");
321
322 return StatusCode::SUCCESS;
323}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
bool isValid() const
Test to see if the link can be dereferenced.
Gaudi::Property< std::string > m_linkNameRefittedPriVtxWithoutLepton
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_decoratorNameIndexVector
SG::WriteHandleKey< xAOD::VertexContainer > m_svContainerName
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_decoratorNameIndexVectorDeepMerge
void saveSecondaryVertices(std::vector< std::unique_ptr< xAOD::Vertex > > &vtxs, std::vector< int > &indexVector, std::vector< ElementLink< xAOD::VertexContainer > > &svLinks, xAOD::VertexContainer &SVContainer, std::set< xAOD::Vertex * > &svSet)
ToolHandle< Prompt::IVertexMergingTool > m_vertexMerger
std::vector< std::unique_ptr< xAOD::Vertex > > prepLepWithTwoTrkSVVec(const FittingInput &input, const xAOD::TrackParticle *tracklep, const std::vector< const xAOD::TrackParticle * > &tracks)
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_decoratorNameSecVtxLinks
SG::ReadHandleKey< xAOD::VertexContainer > m_primaryVertexContainerName
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inDetTracksKey
bool passMuonCand(const xAOD::Muon &muon) const
SG::ReadHandleKey< xAOD::IParticleContainer > m_leptonContainerKey
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_decoratorNameDeepMergedSecVtxLinks
bool passElecCand(const xAOD::Electron &elec) const
std::vector< const xAOD::TrackParticle * > findNearbyTracks(const xAOD::TrackParticle &tracklep, const xAOD::TrackParticleContainer &inDetTracks, const xAOD::Vertex &priVtx) const
Gaudi::Property< std::string > m_refittedVertexTypeName
SG::ReadHandleKey< xAOD::VertexContainer > m_refittedPriVtxContainerName
SG::ConstAccessor< T, ALLOC > ConstAccessor
const xAOD::TrackParticle * trackParticle(size_t index=0) const
Pointer to the xAOD::TrackParticle/s that match the electron candidate.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
std::string truthAsStr(const xAOD::IParticle &particle)
bool getVar(T1 &obj, T2 &value, const std::string &var_name)
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...
TrackParticle_v1 TrackParticle
Reference the current persistent version:
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".
std::vector< std::unique_ptr< xAOD::Vertex > > vtxsInitPassedNotMerged
std::vector< std::unique_ptr< xAOD::Vertex > > vtxsNewMerged