69 std::vector<Trk::VxCascadeInfo*> cascadeinfoContainer;
70 constexpr
int topoN = 3;
71 std::array<xAOD::VertexContainer*, topoN> Vtxwritehandles;
72 std::array<xAOD::VertexAuxContainer*, topoN> Vtxwritehandlesaux;
75 for(
int i =0;
i<topoN;
i++){
78 Vtxwritehandles[
i]->setStore(Vtxwritehandlesaux[
i]);
91 if (pvContainer->size()==0){
92 ATH_MSG_WARNING(
"You have no primary vertices: " << pvContainer->size());
93 return StatusCode::RECOVERABLE;
95 primaryVertex = (*pvContainer)[0];
112 refPvContainer->setStore(refPvAuxContainer);
161 ATH_MSG_DEBUG(
"cascadeinfoContainer size " << cascadeinfoContainer.size());
177 return StatusCode::FAILURE;
198 const std::vector<xAOD::Vertex*> &cascadeVertices =
x->vertices();
199 if(cascadeVertices.size()!=topoN)
201 if(cascadeVertices[0] ==
nullptr || cascadeVertices[1] ==
nullptr || cascadeVertices[2] ==
nullptr)
ATH_MSG_ERROR(
"Error null vertex");
203 for(
int i =0;
i<topoN;
i++) Vtxwritehandles[
i]->push_back(cascadeVertices[
i]);
205 x->setSVOwnership(
false);
206 const auto mainVertex = cascadeVertices[2];
207 const std::vector< std::vector<TLorentzVector> > &moms =
x->getParticleMoms();
210 std::vector<const xAOD::Vertex*> verticestoLink;
211 verticestoLink.push_back(cascadeVertices[0]);
213 if(Vtxwritehandles[2] ==
nullptr)
ATH_MSG_ERROR(
"Vtxwritehandles[2] is null");
217 verticestoLink.clear();
218 verticestoLink.push_back(cascadeVertices[1]);
223 const xAOD::Vertex* jpsipiVertex = BPhysPVCascadeTools::FindVertex<3>(jpsipiContainer, cascadeVertices[2]);
224 ATH_MSG_DEBUG(
"1 pt Jpsi+pi tracks " << cascadeVertices[2]->trackParticle(0)->
pt() <<
", " << cascadeVertices[2]->trackParticle(1)->
pt() <<
", " << cascadeVertices[2]->trackParticle(2)->
pt());
228 const xAOD::Vertex* d0Vertex = BPhysPVCascadeTools::FindVertex<2>(d0Container, cascadeVertices[1]);;
229 ATH_MSG_DEBUG(
"1 pt D0 tracks " << cascadeVertices[1]->trackParticle(0)->
pt() <<
", " << cascadeVertices[1]->trackParticle(1)->
pt());
233 const xAOD::Vertex* k0Vertex = BPhysPVCascadeTools::FindVertex<2>(k0Container, cascadeVertices[0]);;
234 ATH_MSG_DEBUG(
"1 pt K_S0 tracks " << cascadeVertices[0]->trackParticle(0)->
pt() <<
", " << cascadeVertices[0]->trackParticle(1)->
pt());
238 std::vector<const xAOD::Vertex*> jpsipiVerticestoLink;
239 if (jpsipiVertex) jpsipiVerticestoLink.push_back(jpsipiVertex);
244 std::vector<const xAOD::Vertex*> d0VerticestoLink;
245 if (d0Vertex) d0VerticestoLink.push_back(d0Vertex);
250 std::vector<const xAOD::Vertex*> k0VerticestoLink;
251 if (k0Vertex) k0VerticestoLink.push_back(k0Vertex);
264 std::vector<double> massesJpsipi;
268 std::vector<double> massesD0;
276 std::vector<double> massesK0;
279 std::vector<double> Masses;
301 PtErr_decor(*mainVertex) =
m_CascadeTools->pTError(moms[2],
x->getCovariance()[2]);
303 chi2_decor(*mainVertex) =
x->fitChi2();
304 ndof_decor(*mainVertex) =
x->nDoF();
308 TLorentzVector p4_mu1, p4_mu2;
315 massMumu = (p4_mu1 + p4_mu2).M();
317 MassMumu_decor(*mainVertex) = massMumu;
321 TLorentzVector p4_ka, p4_pi;
337 massKpi = (p4_ka + p4_pi).M();
339 MassKpi_svdecor(*mainVertex) = massKpi;
343 TLorentzVector p4_pip, p4_pim;
350 massPipi = (p4_pip + p4_pim).M();
352 MassPipi_sv2decor(*mainVertex) = massPipi;
354 MassJpsi_decor(*mainVertex) = (moms[2][0] + moms[2][1]).M();
355 MassPiD0_decor(*mainVertex) = (moms[2][2] + moms[2][4]).M();
356 MassPiD0K0_decor(*mainVertex) = (moms[2][2] + moms[2][4] + moms[2][3]).M();
363 Mass_svdecor(*mainVertex) =
m_CascadeTools->invariantMass(moms[1]);
364 MassErr_svdecor(*mainVertex) =
m_CascadeTools->invariantMassError(moms[1],
x->getCovariance()[1]);
366 PtErr_svdecor(*mainVertex) =
m_CascadeTools->pTError(moms[1],
x->getCovariance()[1]);
367 Lxy_svdecor(*mainVertex) =
m_CascadeTools->lxy(moms[1],cascadeVertices[1],cascadeVertices[2]);
368 LxyErr_svdecor(*mainVertex) =
m_CascadeTools->lxyError(moms[1],
x->getCovariance()[1],cascadeVertices[1],cascadeVertices[2]);
369 Tau_svdecor(*mainVertex) =
m_CascadeTools->tau(moms[1],cascadeVertices[1],cascadeVertices[2]);
370 TauErr_svdecor(*mainVertex) =
m_CascadeTools->tauError(moms[1],
x->getCovariance()[1],cascadeVertices[1],cascadeVertices[2]);
374 Mass_sv2decor(*mainVertex) =
m_CascadeTools->invariantMass(moms[0]);
375 MassErr_sv2decor(*mainVertex) =
m_CascadeTools->invariantMassError(moms[0],
x->getCovariance()[0]);
377 PtErr_sv2decor(*mainVertex) =
m_CascadeTools->pTError(moms[0],
x->getCovariance()[0]);
378 Lxy_sv2decor(*mainVertex) =
m_CascadeTools->lxy(moms[0],cascadeVertices[0],cascadeVertices[2]);
379 LxyErr_sv2decor(*mainVertex) =
m_CascadeTools->lxyError(moms[0],
x->getCovariance()[0],cascadeVertices[0],cascadeVertices[2]);
380 Tau_sv2decor(*mainVertex) =
m_CascadeTools->tau(moms[0],cascadeVertices[0],cascadeVertices[2]);
381 TauErr_sv2decor(*mainVertex) =
m_CascadeTools->tauError(moms[0],
x->getCovariance()[0],cascadeVertices[0],cascadeVertices[2]);
385 <<
" chi2_1 " <<
m_V0Tools->chisq(cascadeVertices[0])
386 <<
" chi2_2 " <<
m_V0Tools->chisq(cascadeVertices[1])
387 <<
" chi2_3 " <<
m_V0Tools->chisq(cascadeVertices[2])
391 <<
" error " <<
m_V0Tools->invariantMassError(cascadeVertices[0],massesK0)
392 <<
" mass_d0 " <<
m_V0Tools->invariantMass(cascadeVertices[1],massesD0)
393 <<
" error " <<
m_V0Tools->invariantMassError(cascadeVertices[1],massesD0)
394 <<
" mass_J " <<
m_V0Tools->invariantMass(cascadeVertices[2],massesJpsipi)
395 <<
" error " <<
m_V0Tools->invariantMassError(cascadeVertices[2],massesJpsipi));
400 double Mass_B_err =
m_CascadeTools->invariantMassError(moms[2],
x->getCovariance()[2]);
401 double Mass_D0_err =
m_CascadeTools->invariantMassError(moms[1],
x->getCovariance()[1]);
402 double Mass_K0_err =
m_CascadeTools->invariantMassError(moms[0],
x->getCovariance()[0]);
403 ATH_MSG_DEBUG(
"Mass_B " << Mass_B <<
" Mass_D0 " << Mass_D0 <<
" Mass_K0 " << Mass_K0);
404 ATH_MSG_DEBUG(
"Mass_B_err " << Mass_B_err <<
" Mass_D0_err " << Mass_D0_err <<
" Mass_K0_err " << Mass_K0_err);
406 double mprob_D0 =
m_CascadeTools->massProbability(mass_d0,Mass_D0,Mass_D0_err);
407 double mprob_K0 =
m_CascadeTools->massProbability(mass_k0,Mass_K0,Mass_K0_err);
408 ATH_MSG_DEBUG(
"mprob_B " << mprob_B <<
" mprob_D0 " << mprob_D0 <<
" mprob_K0 " << mprob_K0);
412 <<
" Mass_k0 " <<
m_CascadeTools->invariantMass(moms[0],massesD0));
414 <<
" Mass_d0_err " <<
m_CascadeTools->invariantMassError(moms[1],
x->getCovariance()[1],massesD0)
415 <<
" Mass_k0_err " <<
m_CascadeTools->invariantMassError(moms[0],
x->getCovariance()[0],massesK0));
418 <<
" pt_d0 " <<
m_V0Tools->pT(cascadeVertices[1])
420 <<
" pt_k0 " <<
m_V0Tools->pT(cascadeVertices[0]));
422 <<
" ptErr_d " <<
m_CascadeTools->pTError(moms[1],
x->getCovariance()[1])
423 <<
" ptErr_d0 " <<
m_V0Tools->pTError(cascadeVertices[1])
424 <<
" ptErr_k " <<
m_CascadeTools->pTError(moms[0],
x->getCovariance()[0])
425 <<
" ptErr_k0 " <<
m_V0Tools->pTError(cascadeVertices[0]));
426 ATH_MSG_DEBUG(
"lxy_B " <<
m_V0Tools->lxy(cascadeVertices[2],primaryVertex) <<
" lxy_D " <<
m_V0Tools->lxy(cascadeVertices[1],cascadeVertices[2]) <<
" lxy_K " <<
m_V0Tools->lxy(cascadeVertices[0],cascadeVertices[2]));
429 <<
" lxyErr_d " <<
m_CascadeTools->lxyError(moms[1],
x->getCovariance()[1],cascadeVertices[1],cascadeVertices[2])
430 <<
" lxyErr_d0 " <<
m_V0Tools->lxyError(cascadeVertices[1],cascadeVertices[2])
431 <<
" lxyErr_k " <<
m_CascadeTools->lxyError(moms[0],
x->getCovariance()[0],cascadeVertices[0],cascadeVertices[2])
432 <<
" lxyErr_k0 " <<
m_V0Tools->lxyError(cascadeVertices[0],cascadeVertices[2]));
434 <<
" tau_d0 " <<
m_V0Tools->tau(cascadeVertices[1],cascadeVertices[2],massesD0)
435 <<
" tau_k0 " <<
m_V0Tools->tau(cascadeVertices[0],cascadeVertices[2],massesK0));
437 <<
" tau_d " <<
m_CascadeTools->tau(moms[1],cascadeVertices[1],cascadeVertices[2])
438 <<
" tau_D " <<
m_CascadeTools->tau(moms[1],cascadeVertices[1],cascadeVertices[2],mass_d0)
439 <<
" tau_k " <<
m_CascadeTools->tau(moms[0],cascadeVertices[0],cascadeVertices[2])
440 <<
" tau_K " <<
m_CascadeTools->tau(moms[0],cascadeVertices[0],cascadeVertices[2],mass_k0));
442 <<
" tauErr_d " <<
m_CascadeTools->tauError(moms[1],
x->getCovariance()[1],cascadeVertices[1],cascadeVertices[2])
443 <<
" tauErr_d0 " <<
m_V0Tools->tauError(cascadeVertices[1],cascadeVertices[2],massesD0)
444 <<
" tauErr_k " <<
m_CascadeTools->tauError(moms[0],
x->getCovariance()[0],cascadeVertices[0],cascadeVertices[2])
445 <<
" tauErr_k0 " <<
m_V0Tools->tauError(cascadeVertices[0],cascadeVertices[2],massesK0));
447 <<
" TauErr_d " <<
m_CascadeTools->tauError(moms[1],
x->getCovariance()[1],cascadeVertices[1],cascadeVertices[2],mass_d0)
448 <<
" TauErr_d0 " <<
m_V0Tools->tauError(cascadeVertices[1],cascadeVertices[2],massesD0,mass_d0)
449 <<
" TauErr_k " <<
m_CascadeTools->tauError(moms[0],
x->getCovariance()[0],cascadeVertices[0],cascadeVertices[2],mass_k0)
450 <<
" TauErr_k0 " <<
m_V0Tools->tauError(cascadeVertices[0],cascadeVertices[2],massesD0,mass_k0));
452 ATH_MSG_DEBUG(
"CascadeTools main vert wrt PV " <<
" CascadeTools SV " <<
" V0Tools SV");
454 <<
", " <<
m_CascadeTools->a0z(moms[1],cascadeVertices[1],cascadeVertices[2])
455 <<
", " <<
m_CascadeTools->a0z(moms[0],cascadeVertices[0],cascadeVertices[2])
456 <<
", " <<
m_V0Tools->a0z(cascadeVertices[1],cascadeVertices[2])
457 <<
", " <<
m_V0Tools->a0z(cascadeVertices[0],cascadeVertices[2]));
459 <<
", " <<
m_CascadeTools->a0zError(moms[1],
x->getCovariance()[1],cascadeVertices[1],cascadeVertices[2])
460 <<
", " <<
m_CascadeTools->a0zError(moms[0],
x->getCovariance()[0],cascadeVertices[0],cascadeVertices[2])
461 <<
", " <<
m_V0Tools->a0zError(cascadeVertices[1],cascadeVertices[2])
462 <<
", " <<
m_V0Tools->a0zError(cascadeVertices[0],cascadeVertices[2]));
464 <<
", " <<
m_CascadeTools->a0xy(moms[1],cascadeVertices[1],cascadeVertices[2])
465 <<
", " <<
m_CascadeTools->a0xy(moms[0],cascadeVertices[0],cascadeVertices[2])
466 <<
", " <<
m_V0Tools->a0xy(cascadeVertices[1],cascadeVertices[2])
467 <<
", " <<
m_V0Tools->a0xy(cascadeVertices[0],cascadeVertices[2]));
469 <<
", " <<
m_CascadeTools->a0xyError(moms[1],
x->getCovariance()[1],cascadeVertices[1],cascadeVertices[2])
470 <<
", " <<
m_CascadeTools->a0xyError(moms[0],
x->getCovariance()[0],cascadeVertices[0],cascadeVertices[2])
471 <<
", " <<
m_V0Tools->a0xyError(cascadeVertices[1],cascadeVertices[2])
472 <<
", " <<
m_V0Tools->a0xyError(cascadeVertices[0],cascadeVertices[2]));
474 <<
", " <<
m_CascadeTools->a0(moms[1],cascadeVertices[1],cascadeVertices[2])
475 <<
", " <<
m_CascadeTools->a0(moms[0],cascadeVertices[0],cascadeVertices[2])
476 <<
", " <<
m_V0Tools->a0(cascadeVertices[1],cascadeVertices[2])
477 <<
", " <<
m_V0Tools->a0(cascadeVertices[0],cascadeVertices[2]));
479 <<
", " <<
m_CascadeTools->a0Error(moms[1],
x->getCovariance()[1],cascadeVertices[1],cascadeVertices[2])
480 <<
", " <<
m_CascadeTools->a0Error(moms[0],
x->getCovariance()[0],cascadeVertices[0],cascadeVertices[2])
481 <<
", " <<
m_V0Tools->a0Error(cascadeVertices[1],cascadeVertices[2])
482 <<
", " <<
m_V0Tools->a0Error(cascadeVertices[0],cascadeVertices[2]));
486 ATH_MSG_DEBUG(
"X0 " << primaryVertex->x() <<
" Y0 " << primaryVertex->y() <<
" Z0 " << primaryVertex->z());
490 ATH_MSG_DEBUG(
"Rxy0 wrt PV " <<
m_V0Tools->rxy(cascadeVertices[0],primaryVertex) <<
" RxyErr0 wrt PV " <<
m_V0Tools->rxyError(cascadeVertices[0],primaryVertex));
491 ATH_MSG_DEBUG(
"Rxy1 wrt PV " <<
m_V0Tools->rxy(cascadeVertices[1],primaryVertex) <<
" RxyErr1 wrt PV " <<
m_V0Tools->rxyError(cascadeVertices[1],primaryVertex));
492 ATH_MSG_DEBUG(
"Rxy2 wrt PV " <<
m_V0Tools->rxy(cascadeVertices[2],primaryVertex) <<
" RxyErr2 wrt PV " <<
m_V0Tools->rxyError(cascadeVertices[2],primaryVertex));
493 ATH_MSG_DEBUG(
"number of covariance matrices " << (
x->getCovariance()).size());
498 for (
auto x : cascadeinfoContainer)
delete x;
500 return StatusCode::SUCCESS;