Execute method.
107{
108
109
110
112
113
115
116
117
118
119 SG::ReadHandle<xAOD::TrackParticleContainer> h_inDetTracks(
m_inDetTracksKey, ctx);
120 if (!h_inDetTracks.isValid()){
121 ATH_MSG_FATAL(
"execute - failed to find the InDetTrackParticles");
122 return StatusCode::FAILURE;
123 }
124
126
127
128
129
130 std::set< xAOD::Vertex* > svSet;
131
134 std::make_unique< xAOD::VertexContainer>(), std::make_unique< xAOD::VertexAuxContainer>()
135 ));
137
138
139
140
144
145 ATH_MSG_DEBUG (
"NonPromptLeptonVertexingAlg::execute - Read " << vertices->size() <<
" primary vertices");
146 ATH_MSG_DEBUG (
"NonPromptLeptonVertexingAlg::execute - Read " << refittedVertices->size() <<
" refitted primary vertices");
147
148
149
150
151 Prompt::FittingInput fittingInput(&inDetTracks, 0, 0);
152
155 fittingInput.priVtx =
vertex;
156 break;
157 }
158 }
159
160 if(!fittingInput.priVtx) {
161 ATH_MSG_INFO(
"Failed to find primary vertex - skip this event");
162
163 return StatusCode::SUCCESS;
164 }
165
166
167
168
170 short refittedVertexType = 0;
171
173 fittingInput.refittedPriVtx =
vertex;
174 }
175
176 if(fittingInput.refittedPriVtx) {
177 break;
178 }
179 }
180
181
182
183
184 ATH_MSG_DEBUG(
"\n\t\t\t Size of lepton container: " << leptonContainer ->
size());
185
187
188 using VecElemVtx_t = std::vector<ElementLink<xAOD::VertexContainer> >;
189 SG::WriteDecorHandle<xAOD::IParticleContainer, std::vector<int> >
191 SG::WriteDecorHandle<xAOD::IParticleContainer, std::vector<int> >
193 SG::WriteDecorHandle<xAOD::IParticleContainer, VecElemVtx_t>
195 SG::WriteDecorHandle<xAOD::IParticleContainer, VecElemVtx_t>
197
198 for(const xAOD::IParticle *lepton: *leptonContainer) {
202
203 if(elec) {
204
205
206
208
209
210
211
214 }
215 }
216 else if(muon) {
218 tracklep =
muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle);
219 }
220 }
221 else {
222 ATH_MSG_WARNING(
"NonPromptLeptonVertexingAlg::execute - failed to find electron or muon: should never happen!");
223 }
224
225 if(!tracklep) {
226 lepSVElementLinksDec (*lepton).clear();
227 lepDeepMergedSVElementLinksDec(*lepton).clear();
228 indexVectorDec (*lepton).clear();
229 indexVectorDecDeepMerge (*lepton).clear();
230
231 ATH_MSG_DEBUG(
"NonPromptLeptonVertexingAlg::execute - cannot find muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle) nor electron->trackParticle()");
232 continue;
233 }
234
235 ATH_MSG_DEBUG(
"NonPromptLeptonVertexingAlg::execute - process new lepton track " << tracklep);
236
237
238
239
240 fittingInput.refittedPriVtxWithoutLep = 0;
241
242 if(priVtxWithoutLepAcc.isAvailable(*lepton)) {
243 ElementLink<xAOD::VertexContainer> vtxLink = priVtxWithoutLepAcc(*lepton);
244
246 fittingInput.refittedPriVtxWithoutLep = *vtxLink;
247
248 ATH_MSG_DEBUG(
"DecorateSecondaryVertex - found refitted primary vertex without lepton: "
250 }
251 }
252
253
254
255
256 std::vector<const xAOD::TrackParticle* > ifitTracks =
findNearbyTracks(*tracklep, inDetTracks, *fittingInput.priVtx);
257
258
259
260
262 ctx, fittingInput, tracklep, ifitTracks
263 );
264
265
266
267 std::vector<std::unique_ptr<xAOD::Vertex>> twoTrkVerticesCopy;
268 for (std::unique_ptr<xAOD::Vertex> &vtx : twoTrkVertices) {
269 std::unique_ptr<xAOD::Vertex> newVtx = std::make_unique<xAOD::Vertex>(*vtx);
270 twoTrkVerticesCopy.push_back(std::move(newVtx));
271 }
272
273
275 ATH_MSG_DEBUG(
"Starting with " << twoTrkVertices.size() <<
" 2-track vertices");
276 Prompt::MergeResultNotOwner deep_merged_result =
m_vertexMerger->mergeInitVertices(
277 ctx, fittingInput, tracklep, twoTrkVertices, ifitTracks);
278
279
280
281
282 std::vector<ElementLink<xAOD::VertexContainer> > svLinks;
283 std::vector<ElementLink<xAOD::VertexContainer> > deepmergeSVLinks;
284
285 std::vector<int> indexVectorTwoTrk;
286 std::vector<int> indexVectorDeepMerged;
287
288
289
290
291 ATH_MSG_DEBUG(
"NonPromptLeptonVertexingAlg::execute --- recording " << twoTrkVerticesCopy.size() <<
" 2-track and simple merged vertices");
293
294
295
296
297 ATH_MSG_DEBUG(
"NonPromptLeptonVertexingAlg::execute --- recording " << deep_merged_result.
vtxsNewMerged.size() <<
" merged multi-track vertices");
299
302
303 ATH_MSG_DEBUG (
"NonPromptLeptonVertexingAlg::execute -- number of two-track SV = " << twoTrkVertices.size());
304 ATH_MSG_DEBUG (
"NonPromptLeptonVertexingAlg::execute -- number of deep merged SV = " << deep_merged_result.
vtxsNewMerged.size());
305
306 lepSVElementLinksDec (*lepton) = std::move(svLinks);
307 lepDeepMergedSVElementLinksDec(*lepton) = std::move(deepmergeSVLinks);
308 indexVectorDec (*lepton) = std::move(indexVectorTwoTrk);
309 indexVectorDecDeepMerge (*lepton) = std::move(indexVectorDeepMerged);
310
311 ATH_MSG_DEBUG(
"NonPromptLeptonVertexingAlg - done with lepton pT=" << tracklep->
pt() <<
", " <<
truthAsStr(*lepton) << endl
312 << "___________________________________________________________________________");
313 }
314
316
317 ATH_MSG_DEBUG(
" NonPromptLeptonVertexingAlg::execute - done with this event" << endl
318 << "___________________________________________________________________________");
319
320 return StatusCode::SUCCESS;
321}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
size_t size() const
Number of registered mappings.
bool isValid() const
Check if the element can be found.
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
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
std::vector< std::unique_ptr< xAOD::Vertex > > prepLepWithTwoTrkSVVec(const EventContext &ctx, const FittingInput &input, const xAOD::TrackParticle *tracklep, const std::vector< const xAOD::TrackParticle * > &tracks)
SG::ReadHandleKey< xAOD::VertexContainer > m_refittedPriVtxContainerName
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