42 if(m_svContainerName.empty()) {
43 ATH_MSG_ERROR(
"NonPromptLeptonVertexingAlg::initialize - empty SV container name: \"" << m_svContainerName <<
"\"");
44 return StatusCode::FAILURE;
51 ATH_CHECK(m_leptonContainerKey.initialize());
52 ATH_CHECK(m_primaryVertexContainerName.initialize());
53 ATH_CHECK(m_refittedPriVtxContainerName.initialize());
55 ATH_CHECK(m_svContainerName.initialize());
57 m_indexVectorDec = std::make_unique<decoratorVecInt_t> (m_decoratorNameIndexVector);
58 m_indexVectorDecDeepMerge = std::make_unique<decoratorVecInt_t> (m_decoratorNameIndexVector+
"DeepMerge");
60 m_lepSVElementLinksDec = std::make_unique<decoratorVecElemVtx_t>(m_decoratorNameSecVtxLinks);
61 m_lepDeepMergedSVElementLinksDec = std::make_unique<decoratorVecElemVtx_t>(m_decoratorNameDeepMergedSecVtxLinks);
63 ATH_MSG_DEBUG(
"LeptonContainerName = " << m_leptonContainerKey);
64 ATH_MSG_DEBUG(
"ReFitPriVtxContainerName = " << m_refittedPriVtxContainerName);
66 ATH_MSG_DEBUG(
"IndexVectorName = " << m_decoratorNameIndexVector);
80 ATH_MSG_DEBUG(
"maxTrackSharedSiHits = " << m_maxTrackSharedSiHits);
84 return StatusCode::SUCCESS;
100 return StatusCode::SUCCESS;
118 ATH_MSG_FATAL(
"execute - failed to find the InDetTrackParticles");
119 return StatusCode::FAILURE;
127 std::set< xAOD::Vertex* > svSet;
131 std::make_unique< xAOD::VertexContainer>(), std::make_unique< xAOD::VertexAuxContainer>()
142 ATH_MSG_DEBUG (
"NonPromptLeptonVertexingAlg::execute - Read " << vertices->
size() <<
" primary vertices");
143 ATH_MSG_DEBUG (
"NonPromptLeptonVertexingAlg::execute - Read " << refittedVertices->
size() <<
" refitted primary vertices");
152 fittingInput.
priVtx = vertex;
157 if(!fittingInput.
priVtx) {
158 ATH_MSG_INFO(
"Failed to find primary vertex - skip this event");
160 return StatusCode::SUCCESS;
167 short refittedVertexType = 0;
181 ATH_MSG_DEBUG(
"\n\t\t\t Size of lepton container: " << leptonContainer ->
size());
199 if(passElecCand(*elec) && bestmatchedGSFElTrack) {
204 if(passMuonCand(*muon) && muon->inDetTrackParticleLink().isValid()) {
205 tracklep = *(muon->inDetTrackParticleLink());
209 ATH_MSG_WARNING(
"NonPromptLeptonVertexingAlg::execute - failed to find electron or muon: should never happen!");
213 (*m_lepSVElementLinksDec) (*lepton) = std::vector<ElementLink<xAOD::VertexContainer> >();
214 (*m_lepDeepMergedSVElementLinksDec)(*lepton) = std::vector<ElementLink<xAOD::VertexContainer> >();
215 (*m_indexVectorDec) (*lepton) = std::vector<int>();
216 (*m_indexVectorDecDeepMerge) (*lepton) = std::vector<int>();
218 ATH_MSG_DEBUG(
"NonPromptLeptonVertexingAlg::execute - cannot find muon->inDetTrackParticleLink() nor electron->trackParticle()");
222 ATH_MSG_DEBUG(
"NonPromptLeptonVertexingAlg::execute - process new lepton track " << tracklep);
235 ATH_MSG_DEBUG(
"DecorateSecondaryVertex - found refitted primary vertex without lepton: "
243 std::vector<const xAOD::TrackParticle* > ifitTracks = findNearbyTracks(*tracklep, inDetTracks, *fittingInput.
priVtx);
248 std::vector<std::unique_ptr<xAOD::Vertex>> twoTrkVertices = prepLepWithTwoTrkSVVec(
249 fittingInput, tracklep, ifitTracks
254 std::vector<std::unique_ptr<xAOD::Vertex>> twoTrkVerticesCopy;
255 for (std::unique_ptr<xAOD::Vertex> &vtx : twoTrkVertices) {
256 std::unique_ptr<xAOD::Vertex> newVtx = std::make_unique<xAOD::Vertex>(*vtx);
257 twoTrkVerticesCopy.push_back(std::move(newVtx));
262 ATH_MSG_DEBUG(
"Starting with " << twoTrkVertices.size() <<
" 2-track vertices");
264 fittingInput, tracklep, twoTrkVertices, ifitTracks);
269 std::vector<ElementLink<xAOD::VertexContainer> > svLinks;
270 std::vector<ElementLink<xAOD::VertexContainer> > deepmergeSVLinks;
272 std::vector<int> indexVectorTwoTrk;
273 std::vector<int> indexVectorDeepMerged;
278 ATH_MSG_DEBUG(
"NonPromptLeptonVertexingAlg::execute --- recording " << twoTrkVerticesCopy.size() <<
" 2-track and simple merged vertices");
279 saveSecondaryVertices(twoTrkVerticesCopy, indexVectorTwoTrk, svLinks, SVContainerRef, svSet);
284 ATH_MSG_DEBUG(
"NonPromptLeptonVertexingAlg::execute --- recording " << deep_merged_result.
vtxsNewMerged.size() <<
" merged multi-track vertices");
285 saveSecondaryVertices(deep_merged_result.
vtxsNewMerged, indexVectorDeepMerged, deepmergeSVLinks, SVContainerRef, svSet);
288 saveSecondaryVertices(deep_merged_result.
vtxsInitPassedNotMerged, indexVectorDeepMerged, deepmergeSVLinks, SVContainerRef, svSet);
290 ATH_MSG_DEBUG (
"NonPromptLeptonVertexingAlg::execute -- number of two-track SV = " << twoTrkVertices.size());
291 ATH_MSG_DEBUG (
"NonPromptLeptonVertexingAlg::execute -- number of deep merged SV = " << deep_merged_result.
vtxsNewMerged.size());
293 (*m_lepSVElementLinksDec) (*lepton) = svLinks;
294 (*m_lepDeepMergedSVElementLinksDec)(*lepton) = deepmergeSVLinks;
295 (*m_indexVectorDec) (*lepton) = indexVectorTwoTrk;
296 (*m_indexVectorDecDeepMerge) (*lepton) = indexVectorDeepMerged;
298 ATH_MSG_DEBUG(
"NonPromptLeptonVertexingAlg - done with lepton pT=" << tracklep->
pt() <<
", " <<
truthAsStr(*lepton) << endl
299 <<
"___________________________________________________________________________");
302 ATH_MSG_DEBUG(
"SV Vertex container " << m_svContainerName <<
" recorded in store");
304 ATH_MSG_DEBUG(
" NonPromptLeptonVertexingAlg::execute - done with this event" << endl
305 <<
"___________________________________________________________________________");
307 return StatusCode::SUCCESS;
321 <<
"pT=" << elec.
pt() <<
", eta=" << elec.
eta() <<
", phi=" << elec.
phi() << std::endl
322 <<
" DFCommonElectronsLHLoose = " <<
int(lh_loose) << std::endl
341 <<
"pT=" << muon.pt() <<
", eta=" << muon.eta() <<
", phi=" << muon.phi() << std::endl
342 <<
" Type = " << muon.muonType() << std::endl
343 <<
" Combined = " << combined << std::endl
358 std::vector<const xAOD::TrackParticle *> mytracks;
369 if(tracklep.
p4().DeltaR(track->p4()) < m_minTrackLeptonDR) {
377 if(tracklep.
p4().DeltaR(track->p4()) > m_maxTrackLeptonDR) {
381 const double delta_z0 = track->z0() + track->vz() - priVtx.
z();
382 const double Z0Sin = std::abs(delta_z0*
std::sin(track->theta()));
383 const double abs_eta = std::abs(track->eta());
407 if(track->pt() < m_minTrackpT)
continue;
408 if(abs_eta > m_maxTrackEta)
continue;
409 if(
Z0Sin > m_maxTrackZ0Sin)
continue;
414 if(NSiHits < m_minTrackSiHits)
continue;
415 if(NSiShHits > m_maxTrackSharedSiHits)
continue;
416 if(NSiHoles > m_maxTrackSiHoles )
continue;
420 mytracks.push_back(track);
430 const std::vector<const xAOD::TrackParticle*> &tracks
437 std::vector<std::unique_ptr<xAOD::Vertex>> twoTrkVertices;
438 std::vector<const xAOD::TrackParticle*> tracksForFit;
441 ATH_MSG_WARNING(
"prepLepWithTwoTrkSVVec -- invalid primary vertex: nothing to do");
442 return twoTrkVertices;
446 tracksForFit.clear();
447 tracksForFit.push_back(tracklep);
448 tracksForFit.push_back(selectedtrack);
450 std::unique_ptr<xAOD::Vertex> newSecondaryVertex = m_vertexFitterTool->fitVertexWithPrimarySeed(
454 if(!newSecondaryVertex) {
455 ATH_MSG_DEBUG(
"prepLepWithTwoTrkSVVec -- failed to fit 2-track vertex");
459 twoTrkVertices.push_back(std::move(newSecondaryVertex));
462 return twoTrkVertices;
467 std::vector<std::unique_ptr<xAOD::Vertex>> &clusterVtxs,
468 std::vector<std::unique_ptr<xAOD::Vertex>> &inputVtxs
471 ATH_MSG_DEBUG(
"makeVertexCluster - before: clusterVtxs.size()=" << clusterVtxs.size() <<
", inputVtxs.size()=" << inputVtxs.size());
473 std::vector<std::unique_ptr<xAOD::Vertex>>
::iterator vit = inputVtxs.begin();
475 while(vit != inputVtxs.end()) {
478 for(std::vector<std::unique_ptr<xAOD::Vertex>>::const_iterator cit = clusterVtxs.begin(); cit != clusterVtxs.end(); ++cit) {
479 if(vit->get() == cit->get()) {
480 ATH_MSG_DEBUG(
"makeVertexCluster - logic error - found the same vertex twice: " << ((*vit).get()));
484 const double vdist =
getDistance((*vit)->position(), (*cit)->position());
488 if(vdist < m_mergeMinVtxDist) {
495 clusterVtxs.push_back(std::move(*vit));
496 inputVtxs.erase(vit);
498 vit = inputVtxs.begin();
505 ATH_MSG_DEBUG(
"makeVertexCluster - after: clusterVtxs.size()=" << clusterVtxs.size() <<
", inputVtxs.size()=" << inputVtxs.size());
510 std::vector<std::unique_ptr<xAOD::Vertex>> &vtxs,
511 std::vector<int> &indexVector,
514 std::set< xAOD::Vertex* >& svSet
520 ATH_MSG_DEBUG(
"saveSecondaryVertices - will save " << vtxs.size() <<
" vertexes");
522 for(std::unique_ptr<xAOD::Vertex> &vtx: vtxs) {
525 indexVector.push_back(
index);
528 ATH_MSG_WARNING(
"saveSecondaryVertices - missing \"SecondaryVertexIndex\" variable");
531 if(svSet.insert(vtx.get()).second) {
537 svLinks.push_back(svLink);
539 ATH_MSG_ERROR(
"saveSecondaryVertices --- the same vertex has been encountered more than once! Is this a logic error?");